1 /*
2 * Conditions Of Use
3 *
4 * This software was developed by employees of the National Institute of
5 * Standards and Technology (NIST), an agency of the Federal Government.
6 * Pursuant to title 15 Untied States Code Section 105, works of NIST
7 * employees are not subject to copyright protection in the United States
8 * and are considered to be in the public domain.  As a result, a formal
9 * license is not needed to use the software.
10 *
11 * This software is provided by NIST as a service and is expressly
12 * provided "AS IS."  NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED
13 * OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF
14 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT
15 * AND DATA ACCURACY.  NIST does not warrant or make any representations
16 * regarding the use of the software or the results thereof, including but
17 * not limited to the correctness, accuracy, reliability or usefulness of
18 * the software.
19 *
20 * Permission to use this software is contingent upon your acceptance
21 * of the terms of this agreement
22 *
23 * .
24 *
25 */
26 package gov.nist.javax.sip.parser;
27 
28 import gov.nist.javax.sip.header.*;
29 import java.text.ParseException;
30 import javax.sip.*;
31 
32 /**
33  * Parser for MinExpires header.
34  *
35  * @version 1.2 $Revision: 1.8 $ $Date: 2009/07/17 18:58:01 $
36  *
37  * @author Olivier Deruelle   <br/>
38  * @author M. Ranganathan   <br/>
39  *
40  *
41  *
42  * @version 1.0
43  */
44 public class MinExpiresParser extends HeaderParser {
45 
46     /**
47      * Creates a new instance of MinExpiresParser
48      * @param minExpires the header to parse
49      */
MinExpiresParser(String minExpires)50     public MinExpiresParser(String minExpires) {
51         super(minExpires);
52     }
53 
54     /**
55      * Cosntructor
56      * @param lexer the lexer to use to parse the header
57      */
MinExpiresParser(Lexer lexer)58     protected MinExpiresParser(Lexer lexer) {
59         super(lexer);
60     }
61 
62     /**
63      * parse the String message
64      * @return SIPHeader (MinExpiresParser)
65      * @throws SIPParseException if the message does not respect the spec.
66      */
parse()67     public SIPHeader parse() throws ParseException {
68         if (debug)
69             dbg_enter("MinExpiresParser.parse");
70         MinExpires minExpires = new MinExpires();
71         try {
72             headerName(TokenTypes.MIN_EXPIRES);
73 
74             minExpires.setHeaderName(SIPHeaderNames.MIN_EXPIRES);
75 
76             String number = this.lexer.number();
77             try {
78                 minExpires.setExpires(Integer.parseInt(number));
79             } catch (InvalidArgumentException ex) {
80                 throw createParseException(ex.getMessage());
81             }
82             this.lexer.SPorHT();
83 
84             this.lexer.match('\n');
85 
86             return minExpires;
87         } finally {
88             if (debug)
89                 dbg_leave("MinExpiresParser.parse");
90         }
91     }
92 
93 
94 }
95 /*
96  * $Log: MinExpiresParser.java,v $
97  * Revision 1.8  2009/07/17 18:58:01  emcho
98  * Converts indentation tabs to spaces so that we have a uniform indentation policy in the whole project.
99  *
100  * Revision 1.7  2006/07/13 09:02:03  mranga
101  * Issue number:
102  * Obtained from:
103  * Submitted by:  jeroen van bemmel
104  * Reviewed by:   mranga
105  * Moved some changes from jain-sip-1.2 to java.net
106  *
107  * CVS: ----------------------------------------------------------------------
108  * CVS: Issue number:
109  * CVS:   If this change addresses one or more issues,
110  * CVS:   then enter the issue number(s) here.
111  * CVS: Obtained from:
112  * CVS:   If this change has been taken from another system,
113  * CVS:   then name the system in this line, otherwise delete it.
114  * CVS: Submitted by:
115  * CVS:   If this code has been contributed to the project by someone else; i.e.,
116  * CVS:   they sent us a patch or a set of diffs, then include their name/email
117  * CVS:   address here. If this is your work then delete this line.
118  * CVS: Reviewed by:
119  * CVS:   If we are doing pre-commit code reviews and someone else has
120  * CVS:   reviewed your changes, include their name(s) here.
121  * CVS:   If you have not had it reviewed then delete this line.
122  *
123  * Revision 1.3  2006/06/19 06:47:27  mranga
124  * javadoc fixups
125  *
126  * Revision 1.2  2006/06/16 15:26:28  mranga
127  * Added NIST disclaimer to all public domain files. Clean up some javadoc. Fixed a leak
128  *
129  * Revision 1.1.1.1  2005/10/04 17:12:35  mranga
130  *
131  * Import
132  *
133  *
134  * Revision 1.5  2004/08/10 21:35:44  mranga
135  * Reviewed by:   mranga
136  * move test cases out to another package
137  *
138  * Revision 1.4  2004/01/22 13:26:31  sverker
139  * Issue number:
140  * Obtained from:
141  * Submitted by:  sverker
142  * Reviewed by:   mranga
143  *
144  * Major reformat of code to conform with style guide. Resolved compiler and javadoc warnings. Added CVS tags.
145  *
146  * CVS: ----------------------------------------------------------------------
147  * CVS: Issue number:
148  * CVS:   If this change addresses one or more issues,
149  * CVS:   then enter the issue number(s) here.
150  * CVS: Obtained from:
151  * CVS:   If this change has been taken from another system,
152  * CVS:   then name the system in this line, otherwise delete it.
153  * CVS: Submitted by:
154  * CVS:   If this code has been contributed to the project by someone else; i.e.,
155  * CVS:   they sent us a patch or a set of diffs, then include their name/email
156  * CVS:   address here. If this is your work then delete this line.
157  * CVS: Reviewed by:
158  * CVS:   If we are doing pre-commit code reviews and someone else has
159  * CVS:   reviewed your changes, include their name(s) here.
160  * CVS:   If you have not had it reviewed then delete this line.
161  *
162  */
163