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