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