Debian Codegraph @

java/gov/nist/javax/sip/parser/ContentLengthParser.java

raw
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 javax.sip.*;
29 import gov.nist.javax.sip.header.*;
30 import java.text.ParseException;
31
32 /**
33 * Parser for Content-Length Header.
34 * @version 1.2 $Revision: 1.8 $ $Date: 2009/07/17 18:57:58 $
35 *
36 * @author Olivier Deruelle <br/>
37 * @author M. Ranganathan <br/>
38 *
39 *
40 *
41 */
42 public class ContentLengthParser extends HeaderParser {
43
44 public ContentLengthParser(String contentLength) {
45 super(contentLength);
46 }
47
48 protected ContentLengthParser(Lexer lexer) {
49 super(lexer);
50 }
51
52 public SIPHeader parse() throws ParseException {
53 if (debug)
54 dbg_enter("ContentLengthParser.enter");
55 try {
56 ContentLength contentLength = new ContentLength();
57 headerName(TokenTypes.CONTENT_LENGTH);
58 String number = this.lexer.number();
59 contentLength.setContentLength(Integer.parseInt(number));
60 this.lexer.SPorHT();
61 this.lexer.match('\n');
62 return contentLength;
63 } catch (InvalidArgumentException ex) {
64 throw createParseException(ex.getMessage());
65 } catch (NumberFormatException ex) {
66 throw createParseException(ex.getMessage());
67 } finally {
68 if (debug)
69 dbg_leave("ContentLengthParser.leave");
70 }
71 }
72
73
74 }
75 /*
76 * $Log: ContentLengthParser.java,v $
77 * Revision 1.8 2009/07/17 18:57:58 emcho
78 * Converts indentation tabs to spaces so that we have a uniform indentation policy in the whole project.
79 *
80 * Revision 1.7 2006/07/13 09:02:14 mranga
81 * Issue number:
82 * Obtained from:
83 * Submitted by: jeroen van bemmel
84 * Reviewed by: mranga
85 * Moved some changes from jain-sip-1.2 to java.net
86 *
87 * CVS: ----------------------------------------------------------------------
88 * CVS: Issue number:
89 * CVS: If this change addresses one or more issues,
90 * CVS: then enter the issue number(s) here.
91 * CVS: Obtained from:
92 * CVS: If this change has been taken from another system,
93 * CVS: then name the system in this line, otherwise delete it.
94 * CVS: Submitted by:
95 * CVS: If this code has been contributed to the project by someone else; i.e.,
96 * CVS: they sent us a patch or a set of diffs, then include their name/email
97 * CVS: address here. If this is your work then delete this line.
98 * CVS: Reviewed by:
99 * CVS: If we are doing pre-commit code reviews and someone else has
100 * CVS: reviewed your changes, include their name(s) here.
101 * CVS: If you have not had it reviewed then delete this line.
102 *
103 * Revision 1.3 2006/06/19 06:47:27 mranga
104 * javadoc fixups
105 *
106 * Revision 1.2 2006/06/16 15:26:28 mranga
107 * Added NIST disclaimer to all public domain files. Clean up some javadoc. Fixed a leak
108 *
109 * Revision 1.1.1.1 2005/10/04 17:12:35 mranga
110 *
111 * Import
112 *
113 *
114 * Revision 1.5 2004/07/28 14:13:55 mranga
115 * Submitted by: mranga
116 *
117 * Move out the test code to a separate test/unit class.
118 * Fixed some encode methods.
119 *
120 * Revision 1.4 2004/01/22 13:26:31 sverker
121 * Issue number:
122 * Obtained from:
123 * Submitted by: sverker
124 * Reviewed by: mranga
125 *
126 * Major reformat of code to conform with style guide. Resolved compiler and javadoc warnings. Added CVS tags.
127 *
128 * CVS: ----------------------------------------------------------------------
129 * CVS: Issue number:
130 * CVS: If this change addresses one or more issues,
131 * CVS: then enter the issue number(s) here.
132 * CVS: Obtained from:
133 * CVS: If this change has been taken from another system,
134 * CVS: then name the system in this line, otherwise delete it.
135 * CVS: Submitted by:
136 * CVS: If this code has been contributed to the project by someone else; i.e.,
137 * CVS: they sent us a patch or a set of diffs, then include their name/email
138 * CVS: address here. If this is your work then delete this line.
139 * CVS: Reviewed by:
140 * CVS: If we are doing pre-commit code reviews and someone else has
141 * CVS: reviewed your changes, include their name(s) here.
142 * CVS: If you have not had it reviewed then delete this line.
143 *
144 */