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 java.text.ParseException; 30 import javax.sip.*; 31 32 /** 33 * Parser for RSeq header. 34 * 35 * @version 1.2 $Revision: 1.8 $ $Date: 2009/07/17 18:58:03 $ 36 * 37 * @author Olivier Deruelle <br/> 38 * @author M. Ranganathan <br/> 39 * 40 * 41 */ 42 public class RSeqParser extends HeaderParser { 43 44 /** 45 * Creates a new instance of RSeqParser 46 * @param rseq the header to parse 47 */ 48 public RSeqParser(String rseq) { 49 super(rseq); 50 } 51 52 /** 53 * Constructor 54 * param lexer the lexer to use to parse the header 55 */ 56 protected RSeqParser(Lexer lexer) { 57 super(lexer); 58 } 59 60 /** 61 * parse the String message 62 * @return SIPHeader ( RSeq object) 63 * @throws SIPParseException if the message does not respect the spec. 64 */ 65 public SIPHeader parse() throws ParseException { 66 67 if (debug) 68 dbg_enter("RSeqParser.parse"); 69 RSeq rseq = new RSeq(); 70 try { 71 headerName(TokenTypes.RSEQ); 72 73 rseq.setHeaderName(SIPHeaderNames.RSEQ); 74 75 String number = this.lexer.number(); 76 try { 77 rseq.setSeqNumber(Long.parseLong(number)); 78 } catch (InvalidArgumentException ex) { 79 throw createParseException(ex.getMessage()); 80 } 81 this.lexer.SPorHT(); 82 83 this.lexer.match('\n'); 84 85 return rseq; 86 } finally { 87 if (debug) 88 dbg_leave("RSeqParser.parse"); 89 } 90 } 91 92 /** Test program 93 public static void main(String args[]) throws ParseException { 94 String r[] = { 95 "RSeq: 988789 \n" 96 }; 97 98 for (int i = 0; i < r.length; i++ ) { 99 RSeqParser parser = 100 new RSeqParser(r[i]); 101 RSeq rs= (RSeq) parser.parse(); 102 System.out.println("encoded = " + rs.encode()); 103 } 104 } 105 */ 106 107 } 108 /* 109 * $Log: RSeqParser.java,v $ 110 * Revision 1.8 2009/07/17 18:58:03 emcho 111 * Converts indentation tabs to spaces so that we have a uniform indentation policy in the whole project. 112 * 113 * Revision 1.7 2006/08/15 21:44:49 mranga 114 * Issue number: 115 * Obtained from: 116 * Submitted by: mranga 117 * Reviewed by: mranga 118 * Incorporating the latest API changes from Phelim 119 * CVS: ---------------------------------------------------------------------- 120 * CVS: Issue number: 121 * CVS: If this change addresses one or more issues, 122 * CVS: then enter the issue number(s) here. 123 * CVS: Obtained from: 124 * CVS: If this change has been taken from another system, 125 * CVS: then name the system in this line, otherwise delete it. 126 * CVS: Submitted by: 127 * CVS: If this code has been contributed to the project by someone else; i.e., 128 * CVS: they sent us a patch or a set of diffs, then include their name/email 129 * CVS: address here. If this is your work then delete this line. 130 * CVS: Reviewed by: 131 * CVS: If we are doing pre-commit code reviews and someone else has 132 * CVS: reviewed your changes, include their name(s) here. 133 * CVS: If you have not had it reviewed then delete this line. 134 * 135 * Revision 1.6 2006/07/13 09:01:53 mranga 136 * Issue number: 137 * Obtained from: 138 * Submitted by: jeroen van bemmel 139 * Reviewed by: mranga 140 * Moved some changes from jain-sip-1.2 to java.net 141 * 142 * CVS: ---------------------------------------------------------------------- 143 * CVS: Issue number: 144 * CVS: If this change addresses one or more issues, 145 * CVS: then enter the issue number(s) here. 146 * CVS: Obtained from: 147 * CVS: If this change has been taken from another system, 148 * CVS: then name the system in this line, otherwise delete it. 149 * CVS: Submitted by: 150 * CVS: If this code has been contributed to the project by someone else; i.e., 151 * CVS: they sent us a patch or a set of diffs, then include their name/email 152 * CVS: address here. If this is your work then delete this line. 153 * CVS: Reviewed by: 154 * CVS: If we are doing pre-commit code reviews and someone else has 155 * CVS: reviewed your changes, include their name(s) here. 156 * CVS: If you have not had it reviewed then delete this line. 157 * 158 * Revision 1.4 2006/06/19 06:47:27 mranga 159 * javadoc fixups 160 * 161 * Revision 1.3 2006/06/16 15:26:28 mranga 162 * Added NIST disclaimer to all public domain files. Clean up some javadoc. Fixed a leak 163 * 164 * Revision 1.2 2006/05/24 06:21:43 mranga 165 * change to use the long setter 166 * 167 * Revision 1.1.1.1 2005/10/04 17:12:36 mranga 168 * 169 * Import 170 * 171 * 172 * Revision 1.4 2004/01/22 13:26:31 sverker 173 * Issue number: 174 * Obtained from: 175 * Submitted by: sverker 176 * Reviewed by: mranga 177 * 178 * Major reformat of code to conform with style guide. Resolved compiler and javadoc warnings. Added CVS tags. 179 * 180 * CVS: ---------------------------------------------------------------------- 181 * CVS: Issue number: 182 * CVS: If this change addresses one or more issues, 183 * CVS: then enter the issue number(s) here. 184 * CVS: Obtained from: 185 * CVS: If this change has been taken from another system, 186 * CVS: then name the system in this line, otherwise delete it. 187 * CVS: Submitted by: 188 * CVS: If this code has been contributed to the project by someone else; i.e., 189 * CVS: they sent us a patch or a set of diffs, then include their name/email 190 * CVS: address here. If this is your work then delete this line. 191 * CVS: Reviewed by: 192 * CVS: If we are doing pre-commit code reviews and someone else has 193 * CVS: reviewed your changes, include their name(s) here. 194 * CVS: If you have not had it reviewed then delete this line. 195 * 196 */ 197