• 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 gov.nist.javax.sip.address.*;
30 import java.text.ParseException;
31 
32 /**
33  * Parser for ErrorInfo header.
34  *
35  * @version 1.2 $Revision: 1.9 $ $Date: 2009/10/22 10:27:37 $
36  *
37  * @author Olivier Deruelle   <br/>
38  * @author M. Ranganathan   <br/>
39  *
40  *
41  */
42 public class ErrorInfoParser extends ParametersParser {
43 
44     /**
45      * Creates a new instance of ErrorInfoParser
46      * @param errorInfo the header to parse
47      */
ErrorInfoParser(String errorInfo)48     public ErrorInfoParser(String errorInfo) {
49         super(errorInfo);
50     }
51 
52     /**
53      * Constructor
54      * @param lexer the lexer to use to parse the header
55      */
ErrorInfoParser(Lexer lexer)56     protected ErrorInfoParser(Lexer lexer) {
57         super(lexer);
58     }
59 
60     /**
61      * parse the ErrorInfo String header
62      * @return SIPHeader (ErrorInfoList 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("ErrorInfoParser.parse");
69         ErrorInfoList list = new ErrorInfoList();
70 
71         try {
72             headerName(TokenTypes.ERROR_INFO);
73 
74             while (lexer.lookAhead(0) != '\n') {
75             	do {
76 	                ErrorInfo errorInfo = new ErrorInfo();
77 	                errorInfo.setHeaderName(SIPHeaderNames.ERROR_INFO);
78 
79 	                this.lexer.SPorHT();
80 	                this.lexer.match('<');
81 	                URLParser urlParser = new URLParser((Lexer) this.lexer);
82 	                GenericURI uri = urlParser.uriReference( true );
83 	                errorInfo.setErrorInfo(uri);
84 	                this.lexer.match('>');
85 	                this.lexer.SPorHT();
86 
87 	                super.parse(errorInfo);
88 	                list.add(errorInfo);
89 
90 	                if ( lexer.lookAhead(0) == ',' ) {
91 	                	this.lexer.match(',');
92 	                } else break;
93             	} while (true);
94             }
95 
96             return list;
97         } finally {
98             if (debug)
99                 dbg_leave("ErrorInfoParser.parse");
100         }
101     }
102 
103 
104 }
105 /*
106  * $Log: ErrorInfoParser.java,v $
107  * Revision 1.9  2009/10/22 10:27:37  jbemmel
108  * Fix for issue #230, restructured the code such that parsing for any address appearing without '<' '>'
109  * stops at ';', then parameters are assigned to the header as expected
110  *
111  * Revision 1.8  2009/07/17 18:57:59  emcho
112  * Converts indentation tabs to spaces so that we have a uniform indentation policy in the whole project.
113  *
114  * Revision 1.7  2006/07/13 09:02:17  mranga
115  * Issue number:
116  * Obtained from:
117  * Submitted by:  jeroen van bemmel
118  * Reviewed by:   mranga
119  * Moved some changes from jain-sip-1.2 to java.net
120  *
121  * CVS: ----------------------------------------------------------------------
122  * CVS: Issue number:
123  * CVS:   If this change addresses one or more issues,
124  * CVS:   then enter the issue number(s) here.
125  * CVS: Obtained from:
126  * CVS:   If this change has been taken from another system,
127  * CVS:   then name the system in this line, otherwise delete it.
128  * CVS: Submitted by:
129  * CVS:   If this code has been contributed to the project by someone else; i.e.,
130  * CVS:   they sent us a patch or a set of diffs, then include their name/email
131  * CVS:   address here. If this is your work then delete this line.
132  * CVS: Reviewed by:
133  * CVS:   If we are doing pre-commit code reviews and someone else has
134  * CVS:   reviewed your changes, include their name(s) here.
135  * CVS:   If you have not had it reviewed then delete this line.
136  *
137  * Revision 1.3  2006/06/19 06:47:27  mranga
138  * javadoc fixups
139  *
140  * Revision 1.2  2006/06/16 15:26:28  mranga
141  * Added NIST disclaimer to all public domain files. Clean up some javadoc. Fixed a leak
142  *
143  * Revision 1.1.1.1  2005/10/04 17:12:35  mranga
144  *
145  * Import
146  *
147  *
148  * Revision 1.5  2004/08/10 21:35:43  mranga
149  * Reviewed by:   mranga
150  * move test cases out to another package
151  *
152  * Revision 1.4  2004/01/22 13:26:31  sverker
153  * Issue number:
154  * Obtained from:
155  * Submitted by:  sverker
156  * Reviewed by:   mranga
157  *
158  * Major reformat of code to conform with style guide. Resolved compiler and javadoc warnings. Added CVS tags.
159  *
160  * CVS: ----------------------------------------------------------------------
161  * CVS: Issue number:
162  * CVS:   If this change addresses one or more issues,
163  * CVS:   then enter the issue number(s) here.
164  * CVS: Obtained from:
165  * CVS:   If this change has been taken from another system,
166  * CVS:   then name the system in this line, otherwise delete it.
167  * CVS: Submitted by:
168  * CVS:   If this code has been contributed to the project by someone else; i.e.,
169  * CVS:   they sent us a patch or a set of diffs, then include their name/email
170  * CVS:   address here. If this is your work then delete this line.
171  * CVS: Reviewed by:
172  * CVS:   If we are doing pre-commit code reviews and someone else has
173  * CVS:   reviewed your changes, include their name(s) here.
174  * CVS:   If you have not had it reviewed then delete this line.
175  *
176  */
177