Debian Codegraph @

java/gov/nist/javax/sip/parser/ToParser.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 import java.text.ParseException;
28 import gov.nist.javax.sip.address.*;
29 import gov.nist.javax.sip.header.*;
30 import gov.nist.core.*;
31
32 /**
33 * To Header parser.
34 *
35 * @version 1.2 $Revision: 1.11 $ $Date: 2009/10/22 10:27:38 $
36 *
37 * @author Olivier Deruelle <br/>
38 *
39 *
40 */
41 public class ToParser extends AddressParametersParser {
42
43 /**
44 * Creates new ToParser
45 * @param to String to set
46 */
47 public ToParser(String to) {
48 super(to);
49 }
50
51 protected ToParser(Lexer lexer) {
52 super(lexer);
53 }
54
55 public SIPHeader parse() throws ParseException {
56
57 headerName(TokenTypes.TO);
58 To to = new To();
59 super.parse(to);
60 this.lexer.match('\n');
61 return to;
62 }
63
64 /**
65
66 public static void main(String args[]) throws ParseException {
67 String to[] = {
68 "To: <sip:[email protected];user=phone>;tag=5617\n",
69 "To: T. A. Watson <sip:[email protected];param=something>\n",
70 "To: LittleGuy <sip:[email protected];tag=foo>;tag=bar\n",
71 "To: sip:[email protected]\n",
72 "To: sip:[email protected];tag=696928473514.129.6.55.9\n",
73 "To: sip:[email protected]; tag=696928473514.129.6.55.9\n",
74 "To: sip:[email protected] ;tag=696928473514.129.6.55.9\n",
75 "To: sip:[email protected] ; tag=696928473514.129.6.55.9\n"
76 };
77
78 for (int i = 0; i < to.length; i++ ) {
79 System.out.println("toParse = " + to[i]);
80 ToParser tp =
81 new ToParser(to[i]);
82 To t = (To) tp.parse();
83 System.out.println("encoded = " + t.encode());
84 }
85
86 }
87 **/
88 }
89 /*
90 * $Log: ToParser.java,v $
91 * Revision 1.11 2009/10/22 10:27:38 jbemmel
92 * Fix for issue #230, restructured the code such that parsing for any address appearing without '<' '>'
93 * stops at ';', then parameters are assigned to the header as expected
94 *
95 * Revision 1.10 2009/07/17 18:58:06 emcho
96 * Converts indentation tabs to spaces so that we have a uniform indentation policy in the whole project.
97 *
98 * Revision 1.9 2007/10/23 17:34:55 mranga
99 * Issue number:
100 * Obtained from:
101 * Submitted by: mranga
102 * Reviewed by: mranga
103 *
104 * Refactored header collections.
105 *
106 * Revision 1.8 2006/07/13 09:02:00 mranga
107 * Issue number:
108 * Obtained from:
109 * Submitted by: jeroen van bemmel
110 * Reviewed by: mranga
111 * Moved some changes from jain-sip-1.2 to java.net
112 *
113 * CVS: ----------------------------------------------------------------------
114 * CVS: Issue number:
115 * CVS: If this change addresses one or more issues,
116 * CVS: then enter the issue number(s) here.
117 * CVS: Obtained from:
118 * CVS: If this change has been taken from another system,
119 * CVS: then name the system in this line, otherwise delete it.
120 * CVS: Submitted by:
121 * CVS: If this code has been contributed to the project by someone else; i.e.,
122 * CVS: they sent us a patch or a set of diffs, then include their name/email
123 * CVS: address here. If this is your work then delete this line.
124 * CVS: Reviewed by:
125 * CVS: If we are doing pre-commit code reviews and someone else has
126 * CVS: reviewed your changes, include their name(s) here.
127 * CVS: If you have not had it reviewed then delete this line.
128 *
129 * Revision 1.3 2006/06/19 06:47:27 mranga
130 * javadoc fixups
131 *
132 * Revision 1.2 2006/06/16 15:26:28 mranga
133 * Added NIST disclaimer to all public domain files. Clean up some javadoc. Fixed a leak
134 *
135 * Revision 1.1.1.1 2005/10/04 17:12:36 mranga
136 *
137 * Import
138 *
139 *
140 * Revision 1.6 2004/04/22 22:51:18 mranga
141 * Submitted by: Thomas Froment
142 * Reviewed by: mranga
143 *
144 * Fixed corner cases.
145 *
146 * Revision 1.5 2004/01/22 13:26:32 sverker
147 * Issue number:
148 * Obtained from:
149 * Submitted by: sverker
150 * Reviewed by: mranga
151 *
152 * Major reformat of code to conform with style guide. Resolved compiler and javadoc warnings. Added CVS tags.
153 *
154 * CVS: ----------------------------------------------------------------------
155 * CVS: Issue number:
156 * CVS: If this change addresses one or more issues,
157 * CVS: then enter the issue number(s) here.
158 * CVS: Obtained from:
159 * CVS: If this change has been taken from another system,
160 * CVS: then name the system in this line, otherwise delete it.
161 * CVS: Submitted by:
162 * CVS: If this code has been contributed to the project by someone else; i.e.,
163 * CVS: they sent us a patch or a set of diffs, then include their name/email
164 * CVS: address here. If this is your work then delete this line.
165 * CVS: Reviewed by:
166 * CVS: If we are doing pre-commit code reviews and someone else has
167 * CVS: reviewed your changes, include their name(s) here.
168 * CVS: If you have not had it reviewed then delete this line.
169 *
170 */