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.javax.sip.address.*; 30 import java.text.ParseException; 31 32 /** 33 * Parser for CallInfo header. 34 * 35 * @version 1.2 $Revision: 1.8 $ $Date: 2009/10/22 10:27:36 $ 36 * 37 * @author Olivier Deruelle 38 * @author M. Ranganathan 39 * 40 */ 41 public class CallInfoParser extends ParametersParser{ 42 43 /** 44 * Creates a new instance of CallInfoParser 45 * @param callInfo the header to parse 46 */ CallInfoParser(String callInfo)47 public CallInfoParser(String callInfo) { 48 super(callInfo); 49 } 50 51 /** 52 * Constructor 53 * @param lexer the lexer to use to parse the header 54 */ CallInfoParser(Lexer lexer)55 protected CallInfoParser(Lexer lexer) { 56 super(lexer); 57 } 58 59 /** 60 * parse the CallInfo String header 61 * @return SIPHeader (CallInfoList object) 62 * @throws SIPParseException if the message does not respect the spec. 63 */ parse()64 public SIPHeader parse() throws ParseException { 65 66 if (debug) dbg_enter("CallInfoParser.parse"); 67 CallInfoList list=new CallInfoList(); 68 69 try { 70 headerName(TokenTypes.CALL_INFO); 71 72 while (lexer.lookAhead(0) != '\n') { 73 CallInfo callInfo= new CallInfo(); 74 callInfo.setHeaderName(SIPHeaderNames.CALL_INFO); 75 76 this.lexer.SPorHT(); 77 this.lexer.match('<'); 78 URLParser urlParser=new URLParser((Lexer)this.lexer); 79 GenericURI uri=urlParser.uriReference(true); 80 callInfo.setInfo(uri); 81 this.lexer.match('>'); 82 this.lexer.SPorHT(); 83 84 super.parse(callInfo); 85 list.add(callInfo); 86 87 while (lexer.lookAhead(0) == ',') { 88 this.lexer.match(','); 89 this.lexer.SPorHT(); 90 91 callInfo= new CallInfo(); 92 93 this.lexer.SPorHT(); 94 this.lexer.match('<'); 95 urlParser=new URLParser((Lexer)this.lexer); 96 uri=urlParser.uriReference(true); 97 callInfo.setInfo(uri); 98 this.lexer.match('>'); 99 this.lexer.SPorHT(); 100 101 super.parse(callInfo); 102 list.add(callInfo); 103 } 104 } 105 106 return list; 107 } 108 finally { 109 if (debug) dbg_leave("CallInfoParser.parse"); 110 } 111 } 112 113 114 } 115 /* 116 * $Log: CallInfoParser.java,v $ 117 * Revision 1.8 2009/10/22 10:27:36 jbemmel 118 * Fix for issue #230, restructured the code such that parsing for any address appearing without '<' '>' 119 * stops at ';', then parameters are assigned to the header as expected 120 * 121 * Revision 1.7 2006/07/13 09:02:15 mranga 122 * Issue number: 123 * Obtained from: 124 * Submitted by: jeroen van bemmel 125 * Reviewed by: mranga 126 * Moved some changes from jain-sip-1.2 to java.net 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 * Revision 1.3 2006/06/19 06:47:27 mranga 145 * javadoc fixups 146 * 147 * Revision 1.2 2006/06/16 15:26:28 mranga 148 * Added NIST disclaimer to all public domain files. Clean up some javadoc. Fixed a leak 149 * 150 * Revision 1.1.1.1 2005/10/04 17:12:35 mranga 151 * 152 * Import 153 * 154 * 155 * Revision 1.5 2004/07/28 14:13:54 mranga 156 * Submitted by: mranga 157 * 158 * Move out the test code to a separate test/unit class. 159 * Fixed some encode methods. 160 * 161 * Revision 1.4 2004/01/22 13:26:31 sverker 162 * Issue number: 163 * Obtained from: 164 * Submitted by: sverker 165 * Reviewed by: mranga 166 * 167 * Major reformat of code to conform with style guide. Resolved compiler and javadoc warnings. Added CVS tags. 168 * 169 * CVS: ---------------------------------------------------------------------- 170 * CVS: Issue number: 171 * CVS: If this change addresses one or more issues, 172 * CVS: then enter the issue number(s) here. 173 * CVS: Obtained from: 174 * CVS: If this change has been taken from another system, 175 * CVS: then name the system in this line, otherwise delete it. 176 * CVS: Submitted by: 177 * CVS: If this code has been contributed to the project by someone else; i.e., 178 * CVS: they sent us a patch or a set of diffs, then include their name/email 179 * CVS: address here. If this is your work then delete this line. 180 * CVS: Reviewed by: 181 * CVS: If we are doing pre-commit code reviews and someone else has 182 * CVS: reviewed your changes, include their name(s) here. 183 * CVS: If you have not had it reviewed then delete this line. 184 * 185 */ 186