SIPETagParser.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 SIP-ETag header.
34 *
35 *
36 * @author Jeroen van Bemmel <br/>
37 *
38 *
39 *
40 * @version 1.2
41 * @since 1.2
42 */
43public class SIPETagParser extends HeaderParser {
44
45    /**
46     * Creates a new instance of PriorityParser
47     * @param etag the header to parse
48     */
49    public SIPETagParser(String etag) {
50        super(etag);
51    }
52
53    /**
54     * Constructor
55     * @param lexer the lexer to use to parse the header
56     */
57    protected SIPETagParser(Lexer lexer) {
58        super(lexer);
59    }
60
61    /**
62     * parse the String header
63     * @return SIPHeader (Priority object)
64     * @throws SIPParseException if the message does not respect the spec.
65     */
66    public SIPHeader parse() throws ParseException {
67
68        if (debug)
69            dbg_enter("SIPEtag.parse");
70
71        SIPETag sipEtag = new SIPETag();
72        try {
73            headerName(TokenTypes.SIP_ETAG);
74
75            this.lexer.SPorHT();
76            this.lexer.match(TokenTypes.ID);
77            Token token = lexer.getNextToken();
78
79            sipEtag.setETag(token.getTokenValue());
80
81            this.lexer.SPorHT();
82            this.lexer.match('\n');
83
84            return sipEtag;
85        } finally {
86            if (debug)
87                dbg_leave("SIPEtag.parse");
88        }
89    }
90}
91/*
92 * $Log: SIPETagParser.java,v $
93 * Revision 1.3  2009/07/17 18:58:04  emcho
94 * Converts indentation tabs to spaces so that we have a uniform indentation policy in the whole project.
95 *
96 * Revision 1.2  2006/07/13 09:01:58  mranga
97 * Issue number:
98 * Obtained from:
99 * Submitted by:  jeroen van bemmel
100 * Reviewed by:   mranga
101 * Moved some changes from jain-sip-1.2 to java.net
102 *
103 * CVS: ----------------------------------------------------------------------
104 * CVS: Issue number:
105 * CVS:   If this change addresses one or more issues,
106 * CVS:   then enter the issue number(s) here.
107 * CVS: Obtained from:
108 * CVS:   If this change has been taken from another system,
109 * CVS:   then name the system in this line, otherwise delete it.
110 * CVS: Submitted by:
111 * CVS:   If this code has been contributed to the project by someone else; i.e.,
112 * CVS:   they sent us a patch or a set of diffs, then include their name/email
113 * CVS:   address here. If this is your work then delete this line.
114 * CVS: Reviewed by:
115 * CVS:   If we are doing pre-commit code reviews and someone else has
116 * CVS:   reviewed your changes, include their name(s) here.
117 * CVS:   If you have not had it reviewed then delete this line.
118 *
119 * Revision 1.3  2006/06/19 06:47:27  mranga
120 * javadoc fixups
121 *
122 * Revision 1.2  2006/06/16 15:26:28  mranga
123 * Added NIST disclaimer to all public domain files. Clean up some javadoc. Fixed a leak
124 *
125 * Revision 1.1  2005/10/27 20:49:00  jeroen
126 * added support for RFC3903 PUBLISH
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 */
145