• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 MimeVersion 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 public class MimeVersionParser extends HeaderParser {
43 
44     /**
45      * Creates a new instance of MimeVersionParser
46      * @param mimeVersion the header to parse
47      */
MimeVersionParser(String mimeVersion)48     public MimeVersionParser(String mimeVersion) {
49         super(mimeVersion);
50     }
51 
52     /**
53      * Cosntructor
54      * @param lexer the lexer to use to parse the header
55      */
MimeVersionParser(Lexer lexer)56     protected MimeVersionParser(Lexer lexer) {
57         super(lexer);
58     }
59 
60     /**
61      * parse the String message
62      * @return SIPHeader (MimeVersion object)
63      * @throws SIPParseException if the message does not respect the spec.
64      */
parse()65     public SIPHeader parse() throws ParseException {
66 
67         if (debug)
68             dbg_enter("MimeVersionParser.parse");
69         MimeVersion mimeVersion = new MimeVersion();
70         try {
71             headerName(TokenTypes.MIME_VERSION);
72 
73             mimeVersion.setHeaderName(SIPHeaderNames.MIME_VERSION);
74 
75             try {
76                 String majorVersion = this.lexer.number();
77                 mimeVersion.setMajorVersion(Integer.parseInt(majorVersion));
78                 this.lexer.match('.');
79                 String minorVersion = this.lexer.number();
80                 mimeVersion.setMinorVersion(Integer.parseInt(minorVersion));
81 
82             } catch (InvalidArgumentException ex) {
83                 throw createParseException(ex.getMessage());
84             }
85             this.lexer.SPorHT();
86 
87             this.lexer.match('\n');
88 
89             return mimeVersion;
90         } finally {
91             if (debug)
92                 dbg_leave("MimeVersionParser.parse");
93         }
94     }
95 
96 
97 }
98 /*
99  * $Log: MimeVersionParser.java,v $
100  * Revision 1.8  2009/07/17 18:58:01  emcho
101  * Converts indentation tabs to spaces so that we have a uniform indentation policy in the whole project.
102  *
103  * Revision 1.7  2006/07/13 09:02:16  mranga
104  * Issue number:
105  * Obtained from:
106  * Submitted by:  jeroen van bemmel
107  * Reviewed by:   mranga
108  * Moved some changes from jain-sip-1.2 to java.net
109  *
110  * CVS: ----------------------------------------------------------------------
111  * CVS: Issue number:
112  * CVS:   If this change addresses one or more issues,
113  * CVS:   then enter the issue number(s) here.
114  * CVS: Obtained from:
115  * CVS:   If this change has been taken from another system,
116  * CVS:   then name the system in this line, otherwise delete it.
117  * CVS: Submitted by:
118  * CVS:   If this code has been contributed to the project by someone else; i.e.,
119  * CVS:   they sent us a patch or a set of diffs, then include their name/email
120  * CVS:   address here. If this is your work then delete this line.
121  * CVS: Reviewed by:
122  * CVS:   If we are doing pre-commit code reviews and someone else has
123  * CVS:   reviewed your changes, include their name(s) here.
124  * CVS:   If you have not had it reviewed then delete this line.
125  *
126  * Revision 1.3  2006/06/19 06:47:27  mranga
127  * javadoc fixups
128  *
129  * Revision 1.2  2006/06/16 15:26:28  mranga
130  * Added NIST disclaimer to all public domain files. Clean up some javadoc. Fixed a leak
131  *
132  * Revision 1.1.1.1  2005/10/04 17:12:35  mranga
133  *
134  * Import
135  *
136  *
137  * Revision 1.5  2004/08/10 21:35:44  mranga
138  * Reviewed by:   mranga
139  * move test cases out to another package
140  *
141  * Revision 1.4  2004/01/22 13:26:31  sverker
142  * Issue number:
143  * Obtained from:
144  * Submitted by:  sverker
145  * Reviewed by:   mranga
146  *
147  * Major reformat of code to conform with style guide. Resolved compiler and javadoc warnings. Added CVS tags.
148  *
149  * CVS: ----------------------------------------------------------------------
150  * CVS: Issue number:
151  * CVS:   If this change addresses one or more issues,
152  * CVS:   then enter the issue number(s) here.
153  * CVS: Obtained from:
154  * CVS:   If this change has been taken from another system,
155  * CVS:   then name the system in this line, otherwise delete it.
156  * CVS: Submitted by:
157  * CVS:   If this code has been contributed to the project by someone else; i.e.,
158  * CVS:   they sent us a patch or a set of diffs, then include their name/email
159  * CVS:   address here. If this is your work then delete this line.
160  * CVS: Reviewed by:
161  * CVS:   If we are doing pre-commit code reviews and someone else has
162  * CVS:   reviewed your changes, include their name(s) here.
163  * CVS:   If you have not had it reviewed then delete this line.
164  *
165  */
166