1package gov.nist.javax.sip.parser.ims; 2/* 3* Conditions Of Use 4* 5* This software was developed by employees of the National Institute of 6* Standards and Technology (NIST), an agency of the Federal Government. 7* Pursuant to title 15 Untied States Code Section 105, works of NIST 8* employees are not subject to copyright protection in the United States 9* and are considered to be in the public domain. As a result, a formal 10* license is not needed to use the software. 11* 12* This software is provided by NIST as a service and is expressly 13* provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED 14* OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF 15* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT 16* AND DATA ACCURACY. NIST does not warrant or make any representations 17* regarding the use of the software or the results thereof, including but 18* not limited to the correctness, accuracy, reliability or usefulness of 19* the software. 20* 21* Permission to use this software is contingent upon your acceptance 22* of the terms of this agreement 23* 24* . 25* 26*/ 27 28import java.text.ParseException; 29import gov.nist.javax.sip.header.SIPHeader; 30import gov.nist.javax.sip.header.ims.PUserDatabase; 31import gov.nist.javax.sip.parser.Lexer; 32import gov.nist.javax.sip.parser.ParametersParser; 33import gov.nist.javax.sip.parser.TokenTypes; 34 35/** 36 * 37 * @author aayush.bhatnagar 38 * Rancore Technologies Pvt Ltd, Mumbai India. 39 * 40 * This is the parser for the P-user-database header. 41 * The syntax for the P-user-database header as per 42 * RFC 4457 is given below: 43 * 44 * P-User-Database = "P-User-Database" HCOLON database 45 * *( SEMI generic-param ) 46 * database = LAQUOT DiameterURI RAQUOT 47 * 48 * Eg: P-User-Database: <aaa://host.example.com;transport=tcp> 49 * 50 */ 51public class PUserDatabaseParser extends ParametersParser implements TokenTypes{ 52 53 /** 54 * 55 * @param databaseName 56 */ 57 public PUserDatabaseParser(String databaseName) 58 { 59 super(databaseName); 60 } 61 62 /** 63 * 64 * @param lexer 65 */ 66 public PUserDatabaseParser(Lexer lexer) 67 { 68 super(lexer); 69 } 70 71 public SIPHeader parse() throws ParseException { 72 73 if (debug) 74 dbg_enter("PUserDatabase.parse"); 75 76 try{ 77 this.lexer.match(TokenTypes.P_USER_DATABASE); 78 this.lexer.SPorHT(); 79 this.lexer.match(':'); 80 this.lexer.SPorHT(); 81 82 PUserDatabase userDatabase = new PUserDatabase(); 83 this.parseheader(userDatabase); 84 85 return userDatabase; 86 } 87 finally{ 88 if(debug) 89 dbg_leave("PUserDatabase.parse"); 90 } 91 } 92 93 private void parseheader(PUserDatabase userDatabase) throws ParseException 94 { 95 StringBuffer dbname = new StringBuffer(); 96 this.lexer.match(LESS_THAN); 97 98 while(this.lexer.hasMoreChars()) 99 { 100 char next = this.lexer.getNextChar(); 101 if (next!='>'&&next!='\n') 102 { 103 dbname.append(next); 104 } 105 106 } 107 userDatabase.setDatabaseName(dbname.toString()); 108 super.parse(userDatabase); 109 110} 111} 112