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 javax.sip.*; 29 import gov.nist.javax.sip.header.*; 30 import java.text.ParseException; 31 32 /** 33 * Parser for Max Forwards Header. 34 * 35 * @version 1.2 $Revision: 1.7 $ $Date: 2009/07/17 18:58:00 $ 36 * 37 * @author M. Ranganathan <br/> 38 * 39 * 40 */ 41 public class MaxForwardsParser extends HeaderParser { 42 MaxForwardsParser(String contentLength)43 public MaxForwardsParser(String contentLength) { 44 super(contentLength); 45 } 46 MaxForwardsParser(Lexer lexer)47 protected MaxForwardsParser(Lexer lexer) { 48 super(lexer); 49 } 50 parse()51 public SIPHeader parse() throws ParseException { 52 if (debug) 53 dbg_enter("MaxForwardsParser.enter"); 54 try { 55 MaxForwards contentLength = new MaxForwards(); 56 headerName(TokenTypes.MAX_FORWARDS); 57 String number = this.lexer.number(); 58 contentLength.setMaxForwards(Integer.parseInt(number)); 59 this.lexer.SPorHT(); 60 this.lexer.match('\n'); 61 return contentLength; 62 } catch (InvalidArgumentException ex) { 63 throw createParseException(ex.getMessage()); 64 } catch (NumberFormatException ex) { 65 throw createParseException(ex.getMessage()); 66 } finally { 67 if (debug) 68 dbg_leave("MaxForwardsParser.leave"); 69 } 70 } 71 72 73 } 74 /* 75 * $Log: MaxForwardsParser.java,v $ 76 * Revision 1.7 2009/07/17 18:58:00 emcho 77 * Converts indentation tabs to spaces so that we have a uniform indentation policy in the whole project. 78 * 79 * Revision 1.6 2006/07/13 09:02:05 mranga 80 * Issue number: 81 * Obtained from: 82 * Submitted by: jeroen van bemmel 83 * Reviewed by: mranga 84 * Moved some changes from jain-sip-1.2 to java.net 85 * 86 * CVS: ---------------------------------------------------------------------- 87 * CVS: Issue number: 88 * CVS: If this change addresses one or more issues, 89 * CVS: then enter the issue number(s) here. 90 * CVS: Obtained from: 91 * CVS: If this change has been taken from another system, 92 * CVS: then name the system in this line, otherwise delete it. 93 * CVS: Submitted by: 94 * CVS: If this code has been contributed to the project by someone else; i.e., 95 * CVS: they sent us a patch or a set of diffs, then include their name/email 96 * CVS: address here. If this is your work then delete this line. 97 * CVS: Reviewed by: 98 * CVS: If we are doing pre-commit code reviews and someone else has 99 * CVS: reviewed your changes, include their name(s) here. 100 * CVS: If you have not had it reviewed then delete this line. 101 * 102 * Revision 1.3 2006/06/19 06:47:27 mranga 103 * javadoc fixups 104 * 105 * Revision 1.2 2006/06/16 15:26:28 mranga 106 * Added NIST disclaimer to all public domain files. Clean up some javadoc. Fixed a leak 107 * 108 * Revision 1.1.1.1 2005/10/04 17:12:35 mranga 109 * 110 * Import 111 * 112 * 113 * Revision 1.4 2004/08/10 21:35:44 mranga 114 * Reviewed by: mranga 115 * move test cases out to another package 116 * 117 * Revision 1.3 2004/01/22 13:26:31 sverker 118 * Issue number: 119 * Obtained from: 120 * Submitted by: sverker 121 * Reviewed by: mranga 122 * 123 * Major reformat of code to conform with style guide. Resolved compiler and javadoc warnings. Added CVS tags. 124 * 125 * CVS: ---------------------------------------------------------------------- 126 * CVS: Issue number: 127 * CVS: If this change addresses one or more issues, 128 * CVS: then enter the issue number(s) here. 129 * CVS: Obtained from: 130 * CVS: If this change has been taken from another system, 131 * CVS: then name the system in this line, otherwise delete it. 132 * CVS: Submitted by: 133 * CVS: If this code has been contributed to the project by someone else; i.e., 134 * CVS: they sent us a patch or a set of diffs, then include their name/email 135 * CVS: address here. If this is your work then delete this line. 136 * CVS: Reviewed by: 137 * CVS: If we are doing pre-commit code reviews and someone else has 138 * CVS: reviewed your changes, include their name(s) here. 139 * CVS: If you have not had it reviewed then delete this line. 140 * 141 */ 142