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