Debian Codegraph @

java/gov/nist/javax/sip/parser/ParametersParser.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
28 import gov.nist.javax.sip.header.*;
29 import gov.nist.core.*;
30 import java.text.ParseException;
31
32 /** parameters parser header.
33 *
34 * @version 1.2 $Revision: 1.10 $ $Date: 2009/07/17 18:58:01 $
35 *
36 * @author M. Ranganathan <br/>
37 *
38 *
39 *
40 */
41 public abstract class ParametersParser extends HeaderParser {
42
43 protected ParametersParser(Lexer lexer) {
44 super((Lexer) lexer);
45 }
46
47 protected ParametersParser(String buffer) {
48 super(buffer);
49 }
50
51 protected void parse(ParametersHeader parametersHeader)
52 throws ParseException {
53 this.lexer.SPorHT();
54 while (lexer.lookAhead(0) == ';') {
55 this.lexer.consume(1);
56 // eat white space
57 this.lexer.SPorHT();
58 NameValue nv = nameValue();
59 parametersHeader.setParameter(nv);
60 // eat white space
61 this.lexer.SPorHT();
62 }
63 }
64
65
66
67 protected void parseNameValueList(ParametersHeader parametersHeader)
68 throws ParseException{
69 parametersHeader.removeParameters();
70 while (true) {
71 this.lexer.SPorHT();
72 NameValue nv = nameValue();
73 parametersHeader.setParameter(nv.getName(), (String) nv.getValueAsObject());
74 // eat white space
75 this.lexer.SPorHT();
76 if (lexer.lookAhead(0) != ';') break;
77 else lexer.consume(1);
78 }
79 }
80 }