| 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 INOVAO - EST DEPARTMENT * |
| 28 |
*******************************************/ |
| 29 |
|
| 30 |
package gov.nist.javax.sip.parser.ims; |
| 31 |
|
| 32 |
import java.text.ParseException; |
| 33 |
|
| 34 |
import gov.nist.javax.sip.header.ims.ServiceRoute; |
| 35 |
import gov.nist.javax.sip.header.ims.ServiceRouteList; |
| 36 |
import gov.nist.javax.sip.header.SIPHeader; |
| 37 |
import gov.nist.javax.sip.parser.AddressParametersParser; |
| 38 |
import gov.nist.javax.sip.parser.Lexer; |
| 39 |
import gov.nist.javax.sip.parser.TokenTypes; |
| 40 |
|
| 41 |
/** |
| 42 |
* Service-Route header parser. |
| 43 |
* |
| 44 |
* @author ALEXANDRE MIGUEL SILVA SANTOS |
| 45 |
*/ |
| 46 |
|
| 47 |
public class ServiceRouteParser extends AddressParametersParser { |
| 48 |
|
| 49 |
/** |
| 50 |
* Constructor |
| 51 |
*/ |
| 52 |
public ServiceRouteParser(String serviceRoute) { |
| 53 |
super(serviceRoute); |
| 54 |
|
| 55 |
} |
| 56 |
|
| 57 |
protected ServiceRouteParser(Lexer lexer) { |
| 58 |
super(lexer); |
| 59 |
|
| 60 |
} |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
/** |
| 66 |
* parse the String message and generate the RecordRoute List Object |
| 67 |
* @return SIPHeader the RecordRoute List object |
| 68 |
* @throws ParseException if errors occur during the parsing |
| 69 |
*/ |
| 70 |
|
| 71 |
public SIPHeader parse() throws ParseException { |
| 72 |
ServiceRouteList serviceRouteList = new ServiceRouteList(); |
| 73 |
|
| 74 |
if (debug) |
| 75 |
dbg_enter("ServiceRouteParser.parse"); |
| 76 |
|
| 77 |
try { |
| 78 |
this.lexer.match(TokenTypes.SERVICE_ROUTE); |
| 79 |
this.lexer.SPorHT(); |
| 80 |
this.lexer.match(':'); |
| 81 |
this.lexer.SPorHT(); |
| 82 |
while (true) { |
| 83 |
ServiceRoute serviceRoute = new ServiceRoute(); |
| 84 |
super.parse(serviceRoute); |
| 85 |
serviceRouteList.add(serviceRoute); |
| 86 |
this.lexer.SPorHT(); |
| 87 |
if (lexer.lookAhead(0) == ',') { |
| 88 |
this.lexer.match(','); |
| 89 |
this.lexer.SPorHT(); |
| 90 |
} else if (lexer.lookAhead(0) == '\n') |
| 91 |
break; |
| 92 |
else |
| 93 |
throw createParseException("unexpected char"); |
| 94 |
} |
| 95 |
return serviceRouteList; |
| 96 |
} finally { |
| 97 |
if (debug) |
| 98 |
dbg_leave("ServiceRouteParser.parse"); |
| 99 |
} |
| 100 |
|
| 101 |
} |
| 102 |
|
| 103 |
} |