| 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.message.SIPRequest; |
| 30 |
|
| 31 |
import java.text.ParseException; |
| 32 |
import javax.sip.*; |
| 33 |
|
| 34 |
import gov.nist.core.*; |
| 35 |
|
| 36 |
/** |
| 37 |
* Parser for CSeq headers. |
| 38 |
* |
| 39 |
* @version 1.2 $Revision: 1.10 $ $Date: 2006/08/15 21:44:50 $ |
| 40 |
* |
| 41 |
* @author M. Ranganathan |
| 42 |
* @author Olivier Deruelle |
| 43 |
* |
| 44 |
*/ |
| 45 |
public class CSeqParser extends HeaderParser { |
| 46 |
|
| 47 |
public CSeqParser(String cseq) { |
| 48 |
super(cseq); |
| 49 |
} |
| 50 |
|
| 51 |
protected CSeqParser(Lexer lexer) { |
| 52 |
super(lexer); |
| 53 |
} |
| 54 |
|
| 55 |
public SIPHeader parse() throws ParseException { |
| 56 |
try { |
| 57 |
CSeq c = new CSeq(); |
| 58 |
|
| 59 |
this.lexer.match(TokenTypes.CSEQ); |
| 60 |
this.lexer.SPorHT(); |
| 61 |
this.lexer.match(':'); |
| 62 |
this.lexer.SPorHT(); |
| 63 |
String number = this.lexer.number(); |
| 64 |
c.setSeqNumber(Long.parseLong(number)); |
| 65 |
this.lexer.SPorHT(); |
| 66 |
String m = SIPRequest.getCannonicalName( method() ); |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
c.setMethod(m); |
| 71 |
this.lexer.SPorHT(); |
| 72 |
this.lexer.match('\n'); |
| 73 |
return c; |
| 74 |
} catch (NumberFormatException ex) { |
| 75 |
Debug.printStackTrace(ex); |
| 76 |
throw createParseException("Number format exception"); |
| 77 |
} catch (InvalidArgumentException ex) { |
| 78 |
Debug.printStackTrace(ex); |
| 79 |
throw createParseException(ex.getMessage()); |
| 80 |
} |
| 81 |
} |
| 82 |
|
| 83 |
/** |
| 84 |
* |
| 85 |
*/ |
| 86 |
} |
| 87 |
/* |
| 88 |
* $Log: CSeqParser.java,v $ |
| 89 |
* Revision 1.10 2006/08/15 21:44:50 mranga |
| 90 |
* Issue number: |
| 91 |
* Obtained from: |
| 92 |
* Submitted by: mranga |
| 93 |
* Reviewed by: mranga |
| 94 |
* Incorporating the latest API changes from Phelim |
| 95 |
* CVS: ---------------------------------------------------------------------- |
| 96 |
* CVS: Issue number: |
| 97 |
* CVS: If this change addresses one or more issues, |
| 98 |
* CVS: then enter the issue number(s) here. |
| 99 |
* CVS: Obtained from: |
| 100 |
* CVS: If this change has been taken from another system, |
| 101 |
* CVS: then name the system in this line, otherwise delete it. |
| 102 |
* CVS: Submitted by: |
| 103 |
* CVS: If this code has been contributed to the project by someone else; i.e., |
| 104 |
* CVS: they sent us a patch or a set of diffs, then include their name/email |
| 105 |
* CVS: address here. If this is your work then delete this line. |
| 106 |
* CVS: Reviewed by: |
| 107 |
* CVS: If we are doing pre-commit code reviews and someone else has |
| 108 |
* CVS: reviewed your changes, include their name(s) here. |
| 109 |
* CVS: If you have not had it reviewed then delete this line. |
| 110 |
* |
| 111 |
* Revision 1.9 2006/07/13 09:02:17 mranga |
| 112 |
* Issue number: |
| 113 |
* Obtained from: |
| 114 |
* Submitted by: jeroen van bemmel |
| 115 |
* Reviewed by: mranga |
| 116 |
* Moved some changes from jain-sip-1.2 to java.net |
| 117 |
* |
| 118 |
* CVS: ---------------------------------------------------------------------- |
| 119 |
* CVS: Issue number: |
| 120 |
* CVS: If this change addresses one or more issues, |
| 121 |
* CVS: then enter the issue number(s) here. |
| 122 |
* CVS: Obtained from: |
| 123 |
* CVS: If this change has been taken from another system, |
| 124 |
* CVS: then name the system in this line, otherwise delete it. |
| 125 |
* CVS: Submitted by: |
| 126 |
* CVS: If this code has been contributed to the project by someone else; i.e., |
| 127 |
* CVS: they sent us a patch or a set of diffs, then include their name/email |
| 128 |
* CVS: address here. If this is your work then delete this line. |
| 129 |
* CVS: Reviewed by: |
| 130 |
* CVS: If we are doing pre-commit code reviews and someone else has |
| 131 |
* CVS: reviewed your changes, include their name(s) here. |
| 132 |
* CVS: If you have not had it reviewed then delete this line. |
| 133 |
* |
| 134 |
* Revision 1.5 2006/06/19 06:47:27 mranga |
| 135 |
* javadoc fixups |
| 136 |
* |
| 137 |
* Revision 1.4 2006/06/16 15:26:28 mranga |
| 138 |
* Added NIST disclaimer to all public domain files. Clean up some javadoc. Fixed a leak |
| 139 |
* |
| 140 |
* Revision 1.3 2006/05/22 08:16:15 mranga |
| 141 |
* Added tests for retransmissionAlert flag |
| 142 |
* Added tests for transaction terminated event |
| 143 |
* |
| 144 |
* Revision 1.2 2006/04/17 17:45:01 jeroen |
| 145 |
* - Using SIPRequest method to canonicalize request name (current code was omitting some) |
| 146 |
* |
| 147 |
* Revision 1.1.1.1 2005/10/04 17:12:35 mranga |
| 148 |
* |
| 149 |
* Import |
| 150 |
* |
| 151 |
* |
| 152 |
* Revision 1.7 2005/04/27 14:12:04 mranga |
| 153 |
* Submitted by: Mario Mantak |
| 154 |
* Reviewed by: mranga |
| 155 |
* |
| 156 |
* Added a missing "short form" for event header. |
| 157 |
* |
| 158 |
* Revision 1.6 2005/04/21 00:01:59 mranga |
| 159 |
* Issue number: |
| 160 |
* Obtained from: |
| 161 |
* Submitted by: mranga |
| 162 |
* Reviewed by: mranga |
| 163 |
* |
| 164 |
* Adjust remote sequence number when sending out a 491 |
| 165 |
* CVS: ---------------------------------------------------------------------- |
| 166 |
* CVS: Issue number: |
| 167 |
* CVS: If this change addresses one or more issues, |
| 168 |
* CVS: then enter the issue number(s) here. |
| 169 |
* CVS: Obtained from: |
| 170 |
* CVS: If this change has been taken from another system, |
| 171 |
* CVS: then name the system in this line, otherwise delete it. |
| 172 |
* CVS: Submitted by: |
| 173 |
* CVS: If this code has been contributed to the project by someone else; i.e., |
| 174 |
* CVS: they sent us a patch or a set of diffs, then include their name/email |
| 175 |
* CVS: address here. If this is your work then delete this line. |
| 176 |
* CVS: Reviewed by: |
| 177 |
* CVS: If we are doing pre-commit code reviews and someone else has |
| 178 |
* CVS: reviewed your changes, include their name(s) here. |
| 179 |
* CVS: If you have not had it reviewed then delete this line. |
| 180 |
* Revision 1.5 2004/07/28 14:13:54 mranga Submitted |
| 181 |
* by: mranga |
| 182 |
* |
| 183 |
* Move out the test code to a separate test/unit class. Fixed some encode |
| 184 |
* methods. |
| 185 |
* |
| 186 |
* Revision 1.4 2004/01/22 13:26:31 sverker Issue number: Obtained from: |
| 187 |
* Submitted by: sverker Reviewed by: mranga |
| 188 |
* |
| 189 |
* Major reformat of code to conform with style guide. Resolved compiler and |
| 190 |
* javadoc warnings. Added CVS tags. |
| 191 |
* |
| 192 |
* CVS: ---------------------------------------------------------------------- |
| 193 |
* CVS: Issue number: CVS: If this change addresses one or more issues, CVS: |
| 194 |
* then enter the issue number(s) here. CVS: Obtained from: CVS: If this change |
| 195 |
* has been taken from another system, CVS: then name the system in this line, |
| 196 |
* otherwise delete it. CVS: Submitted by: CVS: If this code has been |
| 197 |
* contributed to the project by someone else; i.e., CVS: they sent us a patch |
| 198 |
* or a set of diffs, then include their name/email CVS: address here. If this |
| 199 |
* is your work then delete this line. CVS: Reviewed by: CVS: If we are doing |
| 200 |
* pre-commit code reviews and someone else has CVS: reviewed your changes, |
| 201 |
* include their name(s) here. CVS: If you have not had it reviewed then delete |
| 202 |
* this line. |
| 203 |
* |
| 204 |
*/ |