• 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 /****************************************************************************
27  * PRODUCT OF PT INOVACAO - EST DEPARTMENT and Aveiro University (Portugal) *
28  ****************************************************************************/
29 
30 package gov.nist.javax.sip.parser.ims;
31 
32 import java.text.ParseException;
33 
34 import gov.nist.core.Token;
35 import gov.nist.javax.sip.address.GenericURI;
36 import gov.nist.javax.sip.header.ims.PAssociatedURI;
37 import gov.nist.javax.sip.header.ims.PAssociatedURIList;
38 import gov.nist.javax.sip.header.ims.SIPHeaderNamesIms;
39 
40 import gov.nist.javax.sip.header.Allow;
41 import gov.nist.javax.sip.header.ErrorInfo;
42 import gov.nist.javax.sip.header.SIPHeader;
43 import gov.nist.javax.sip.header.SIPHeaderNames;
44 import gov.nist.javax.sip.parser.Lexer;
45 import gov.nist.javax.sip.parser.TokenTypes;
46 import gov.nist.javax.sip.parser.AddressParametersParser;
47 import gov.nist.javax.sip.parser.URLParser;
48 
49 import gov.nist.javax.sip.parser.ParametersParser;
50 import gov.nist.javax.sip.parser.HeaderParser;
51 
52 
53 /**
54  * P-Associated-URI header parser
55  *
56  * @author Miguel Freitas (IT) PT-Inovacao
57  */
58 
59 public class PAssociatedURIParser
60     extends AddressParametersParser
61 {
62 
63 
64     /**
65      * Constructor
66      * @param associatedURI content to set
67      */
PAssociatedURIParser(String associatedURI)68     public PAssociatedURIParser(String associatedURI)
69     {
70         super(associatedURI);
71     }
72 
PAssociatedURIParser(Lexer lexer)73     protected PAssociatedURIParser(Lexer lexer)
74     {
75         super(lexer);
76     }
77 
78 
parse()79     public SIPHeader parse() throws ParseException
80     {
81         if (debug)
82             dbg_enter("PAssociatedURIParser.parse");
83 
84         PAssociatedURIList associatedURIList = new PAssociatedURIList();
85 
86         try {
87 
88             headerName(TokenTypes.P_ASSOCIATED_URI);
89 
90             PAssociatedURI associatedURI = new PAssociatedURI();
91             associatedURI.setHeaderName(SIPHeaderNamesIms.P_ASSOCIATED_URI);
92 
93             super.parse(associatedURI);
94             associatedURIList.add(associatedURI);
95 
96             this.lexer.SPorHT();
97             while (lexer.lookAhead(0) == ',')
98             {
99                 this.lexer.match(',');
100                 this.lexer.SPorHT();
101 
102                 associatedURI = new PAssociatedURI();
103                 super.parse(associatedURI);
104                 associatedURIList.add(associatedURI);
105 
106                 this.lexer.SPorHT();
107             }
108             this.lexer.SPorHT();
109             this.lexer.match('\n');
110 
111             return associatedURIList;
112 
113 
114 
115 
116         } finally {
117             if (debug)
118                 dbg_leave("PAssociatedURIParser.parse");
119         }
120 
121     }
122 
123 
124 
125 
126 
127     /** Test program
128     public static void main(String args[]) throws ParseException
129     {
130         String rou[] = {
131 
132                 "P-Associated-URI: <sip:123qwe@ptinovacao.pt>\n",
133 
134                     "P-Associated-URI: <sip:testes1@ptinovacao.pt>,  " +
135                                     "<sip:testes2@ptinovacao.pt> \n"
136                     };
137 
138         for (int i = 0; i < rou.length; i++ ) {
139             PAssociatedURIParser rp =
140               new PAssociatedURIParser(rou[i]);
141             PAssociatedURIList list = (PAssociatedURIList) rp.parse();
142             System.out.println("encoded = " +list.encode());
143         }
144     }
145 
146     */
147 
148 }
149