1600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang/* 2600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang* Conditions Of Use 3600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang* 4600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang* This software was developed by employees of the National Institute of 5600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang* Standards and Technology (NIST), an agency of the Federal Government. 6600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang* Pursuant to title 15 Untied States Code Section 105, works of NIST 7600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang* employees are not subject to copyright protection in the United States 8600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang* and are considered to be in the public domain. As a result, a formal 9600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang* license is not needed to use the software. 10600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang* 11600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang* This software is provided by NIST as a service and is expressly 12600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang* provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED 13600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang* OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF 14600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT 15600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang* AND DATA ACCURACY. NIST does not warrant or make any representations 16600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang* regarding the use of the software or the results thereof, including but 17600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang* not limited to the correctness, accuracy, reliability or usefulness of 18600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang* the software. 19600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang* 20600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang* Permission to use this software is contingent upon your acceptance 21600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang* of the terms of this agreement. 22600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang* 23600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang*/ 24600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang/******************************************************************************* 25600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang* Product of NIST/ITL Advanced Networking Technologies Division (ANTD). * 26600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang*******************************************************************************/ 27600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wangpackage gov.nist.javax.sip.header; 28600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wangimport gov.nist.javax.sip.header.ims.*; /* IMS headers - issued by Miguel Freitas */ 29600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wangimport gov.nist.javax.sip.header.extensions.*; // extension headers - pmusgrave 30600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wangimport javax.sip.header.*; 31600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 32600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wangimport gov.nist.javax.sip.parser.*; 33600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wangimport gov.nist.javax.sip.parser.extensions.ReferencesParser; 34600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 35600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wangimport javax.sip.address.*; 36600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wangimport java.text.ParseException; 37600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wangimport javax.sip.InvalidArgumentException; 38600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wangimport java.util.*; 39600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wangimport gov.nist.javax.sip.address.*; 40600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 41600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang/* 42600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang* This file contains enhancements contributed by Alexandre Silva Santos 43600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang* (PT-Inovacao) and Miguel Freitas 44600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang*/ 45600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 46600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang/** Implementation of the JAIN SIP HeaderFactory 47600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang* 48600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang* @version 1.2 $Revision: 1.22 $ $Date: 2010/01/12 18:58:48 $ 49600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang* @since 1.1 50600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang* 51600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang*@author M. Ranganathan <br/> 52600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang*@author Olivier Deruelle <br/> 53600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang* 54600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang* 55600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang*/ 56600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wangpublic class HeaderFactoryImpl implements HeaderFactory , HeaderFactoryExt { 57600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 58600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 59600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Determines whether or not we should tolerate and strip address scope 60600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * zones from IPv6 addresses. Address scope zones are sometimes returned 61600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * at the end of IPv6 addresses generated by InetAddress.getHostAddress(). 62600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * They are however not part of the SIP semantics so basically this method 63600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * determines whether or not the parser should be stripping them (as 64600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * opposed simply being blunt and throwing an exception). 65600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 66600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang private boolean stripAddressScopeZones = false; 67600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 68600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 69600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Set pretty encoding on / off. 70600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * This splits up via headers into multiple lines for readability ( better for 71600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * debugging ). 72600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 73600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 74600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public void setPrettyEncoding(boolean flag) { 75600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang SIPHeaderList.setPrettyEncode(flag); 76600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 77600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 78600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 79600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new AcceptEncodingHeader based on the newly supplied encoding 80600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * value. 81600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 82600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param encoding - the new string containing the encoding value. 83600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException which signals that an error has been reached 84600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * unexpectedly while parsing the encoding value. 85600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created AcceptEncodingHeader object. 86600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 87600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public AcceptEncodingHeader createAcceptEncodingHeader(String encoding) 88600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws ParseException { 89600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (encoding == null) 90600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("the encoding parameter is null"); 91600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang AcceptEncoding acceptEncoding = new AcceptEncoding(); 92600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang acceptEncoding.setEncoding(encoding); 93600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return acceptEncoding; 94600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 95600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 96600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 97600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new AcceptHeader based on the newly supplied contentType and 98600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * contentSubType values. 99600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 100600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param contentType The new string content type value. 101600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param contentSubType The new string content sub-type value. 102600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException which signals that an error has been reached 103600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * unexpectedly while parsing the content type or content subtype value. 104600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created AcceptHeader object. 105600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 106600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public AcceptHeader createAcceptHeader( 107600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang String contentType, 108600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang String contentSubType) 109600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws ParseException { 110600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (contentType == null || contentSubType == null) 111600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("contentType or subtype is null "); 112600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang Accept accept = new Accept(); 113600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang accept.setContentType(contentType); 114600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang accept.setContentSubType(contentSubType); 115600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 116600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return accept; 117600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 118600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 119600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 120600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new AcceptLanguageHeader based on the newly supplied 121600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * language value. 122600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 123600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param language - the new Locale value of the language 124600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created AcceptLanguageHeader object. 125600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 126600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public AcceptLanguageHeader createAcceptLanguageHeader(Locale language) { 127600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (language == null) 128600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null arg"); 129600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang AcceptLanguage acceptLanguage = new AcceptLanguage(); 130600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang acceptLanguage.setAcceptLanguage(language); 131600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 132600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return acceptLanguage; 133600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 134600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 135600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 136600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new AlertInfoHeader based on the newly supplied alertInfo value. 137600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 138600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param alertInfo - the new URI value of the alertInfo 139600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created AlertInfoHeader object. 140600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @since v1.1 141600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 142600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public AlertInfoHeader createAlertInfoHeader(URI alertInfo) { 143600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (alertInfo == null) 144600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null arg alertInfo"); 145600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang AlertInfo a = new AlertInfo(); 146600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang a.setAlertInfo(alertInfo); 147600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return a; 148600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 149600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 150600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 151600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new AllowEventsHeader based on the newly supplied event type 152600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * value. 153600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 154600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param eventType - the new string containing the eventType value. 155600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException which signals that an error has been reached 156600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * unexpectedly while parsing the eventType value. 157600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created AllowEventsHeader object. 158600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @since v1.1 159600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 160600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public AllowEventsHeader createAllowEventsHeader(String eventType) 161600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws ParseException { 162600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (eventType == null) 163600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null arg eventType"); 164600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang AllowEvents allowEvents = new AllowEvents(); 165600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang allowEvents.setEventType(eventType); 166600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return allowEvents; 167600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 168600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 169600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 170600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new AllowHeader based on the newly supplied method value. 171600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 172600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param method - the new string containing the method value. 173600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException which signals that an error has been reached 174600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * unexpectedly while parsing the method value. 175600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created AllowHeader object. 176600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 177600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public AllowHeader createAllowHeader(String method) throws ParseException { 178600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (method == null) 179600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null arg method"); 180600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang Allow allow = new Allow(); 181600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang allow.setMethod(method); 182600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 183600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return allow; 184600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 185600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 186600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 187600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new AuthenticationInfoHeader based on the newly supplied 188600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * response value. 189600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 190600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param response - the new string value of the response. 191600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException which signals that an error has been reached 192600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * unexpectedly while parsing the response value. 193600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created AuthenticationInfoHeader object. 194600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @since v1.1 195600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 196600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public AuthenticationInfoHeader createAuthenticationInfoHeader(String response) 197600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws ParseException { 198600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (response == null) 199600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null arg response"); 200600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang AuthenticationInfo auth = new AuthenticationInfo(); 201600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang auth.setResponse(response); 202600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 203600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return auth; 204600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 205600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 206600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 207600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new AuthorizationHeader based on the newly supplied 208600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * scheme value. 209600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 210600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param scheme - the new string value of the scheme. 211600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException which signals that an error has been reached 212600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * unexpectedly while parsing the scheme value. 213600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created AuthorizationHeader object. 214600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 215600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public AuthorizationHeader createAuthorizationHeader(String scheme) 216600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws ParseException { 217600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (scheme == null) 218600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null arg scheme "); 219600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang Authorization auth = new Authorization(); 220600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang auth.setScheme(scheme); 221600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 222600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return auth; 223600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 224600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 225600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 226600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new CSeqHeader based on the newly supplied sequence number and 227600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * method values. 228600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 229600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param sequenceNumber - the new integer value of the sequence number. 230600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param method - the new string value of the method. 231600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws InvalidArgumentException if supplied sequence number is less 232600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * than zero. 233600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException which signals that an error has been reached 234600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * unexpectedly while parsing the method value. 235600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created CSeqHeader object. 236600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 237600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public CSeqHeader createCSeqHeader( long sequenceNumber, String method) 238600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws ParseException, InvalidArgumentException { 239600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (sequenceNumber < 0) 240600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new InvalidArgumentException("bad arg " + sequenceNumber); 241600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (method == null) 242600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null arg method"); 243600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang CSeq cseq = new CSeq(); 244600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang cseq.setMethod(method); 245600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang cseq.setSeqNumber(sequenceNumber); 246600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 247600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return cseq; 248600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 249600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 250600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 251600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * For backwards compatibility, also accept int 252600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @deprecated 253600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 254600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public CSeqHeader createCSeqHeader( int sequenceNumber, String method) 255600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws ParseException, InvalidArgumentException { 256600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return this.createCSeqHeader( (long) sequenceNumber, method ); 257600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 258600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 259600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 260600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new CallIdHeader based on the newly supplied callId value. 261600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 262600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param callId - the new string value of the call-id. 263600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException which signals that an error has been reached 264600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * unexpectedly while parsing the callId value. 265600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created CallIdHeader object. 266600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 267600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public CallIdHeader createCallIdHeader(String callId) 268600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws ParseException { 269600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (callId == null) 270600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null arg callId"); 271600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang CallID c = new CallID(); 272600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang c.setCallId(callId); 273600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return c; 274600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 275600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 276600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 277600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new CallInfoHeader based on the newly supplied callInfo value. 278600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 279600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param callInfo The new string value of the callInfo. 280600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created CallInfoHeader object. 281600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 282600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public CallInfoHeader createCallInfoHeader(URI callInfo) { 283600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (callInfo == null) 284600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null arg callInfo"); 285600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 286600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang CallInfo c = new CallInfo(); 287600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang c.setInfo(callInfo); 288600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return c; 289600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 290600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 291600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 292600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new ContactHeader based on the newly supplied address value. 293600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 294600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param address - the new Address value of the address. 295600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created ContactHeader object. 296600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 297600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public ContactHeader createContactHeader(Address address) { 298600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (address == null) 299600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null arg address"); 300600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang Contact contact = new Contact(); 301600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang contact.setAddress(address); 302600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 303600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return contact; 304600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 305600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 306600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 307600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new wildcard ContactHeader. This is used in Register requests 308600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * to indicate to the server that it should remove all locations the 309600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * at which the user is currently available. This implies that the 310600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * following conditions are met: 311600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * <ul> 312600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * <li><code>ContactHeader.getAddress.getAddress.getUserInfo() == *;</code> 313600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * <li><code>ContactHeader.getAddress.getAddress.isWildCard() == true;</code> 314600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * <li><code>ContactHeader.getExpires() == 0;</code> 315600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * </ul> 316600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 317600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created wildcard ContactHeader. 318600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 319600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public ContactHeader createContactHeader() { 320600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang Contact contact = new Contact(); 321600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang contact.setWildCardFlag(true); 322600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang contact.setExpires(0); 323600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 324600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return contact; 325600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 326600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 327600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 328600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new ContentDispositionHeader based on the newly supplied 329600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * contentDisposition value. 330600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 331600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param contentDisposition - the new string value of the contentDisposition. 332600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException which signals that an error has been reached 333600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * unexpectedly while parsing the contentDisposition value. 334600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created ContentDispositionHeader object. 335600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @since v1.1 336600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 337600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public ContentDispositionHeader createContentDispositionHeader(String contentDisposition) 338600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws ParseException { 339600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (contentDisposition == null) 340600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null arg contentDisposition"); 341600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang ContentDisposition c = new ContentDisposition(); 342600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang c.setDispositionType(contentDisposition); 343600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 344600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return c; 345600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 346600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 347600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 348600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new ContentEncodingHeader based on the newly supplied encoding 349600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * value. 350600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 351600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param encoding - the new string containing the encoding value. 352600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException which signals that an error has been reached 353600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * unexpectedly while parsing the encoding value. 354600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created ContentEncodingHeader object. 355600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 356600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public ContentEncodingHeader createContentEncodingHeader(String encoding) 357600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws ParseException { 358600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (encoding == null) 359600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null encoding"); 360600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang ContentEncoding c = new ContentEncoding(); 361600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang c.setEncoding(encoding); 362600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 363600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return c; 364600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 365600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 366600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 367600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new ContentLanguageHeader based on the newly supplied 368600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * contentLanguage value. 369600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 370600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param contentLanguage - the new Locale value of the contentLanguage. 371600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created ContentLanguageHeader object. 372600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @since v1.1 373600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 374600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public ContentLanguageHeader createContentLanguageHeader(Locale contentLanguage) { 375600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (contentLanguage == null) 376600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null arg contentLanguage"); 377600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang ContentLanguage c = new ContentLanguage(); 378600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang c.setContentLanguage(contentLanguage); 379600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 380600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return c; 381600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 382600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 383600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 384600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new CSeqHeader based on the newly supplied contentLength value. 385600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 386600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param contentLength - the new integer value of the contentLength. 387600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws InvalidArgumentException if supplied contentLength is less 388600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * than zero. 389600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created ContentLengthHeader object. 390600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 391600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public ContentLengthHeader createContentLengthHeader(int contentLength) 392600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws InvalidArgumentException { 393600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (contentLength < 0) 394600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new InvalidArgumentException("bad contentLength"); 395600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang ContentLength c = new ContentLength(); 396600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang c.setContentLength(contentLength); 397600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 398600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return c; 399600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 400600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 401600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 402600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new ContentTypeHeader based on the newly supplied contentType and 403600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * contentSubType values. 404600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 405600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param contentType - the new string content type value. 406600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param contentSubType - the new string content sub-type value. 407600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException which signals that an error has been reached 408600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * unexpectedly while parsing the content type or content subtype value. 409600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created ContentTypeHeader object. 410600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 411600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public ContentTypeHeader createContentTypeHeader( 412600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang String contentType, 413600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang String contentSubType) 414600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws ParseException { 415600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (contentType == null || contentSubType == null) 416600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null contentType or subType"); 417600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang ContentType c = new ContentType(); 418600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang c.setContentType(contentType); 419600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang c.setContentSubType(contentSubType); 420600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return c; 421600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 422600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 423600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 424600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new DateHeader based on the newly supplied date value. 425600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 426600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param date - the new Calender value of the date. 427600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created DateHeader object. 428600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 429600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public DateHeader createDateHeader(Calendar date) { 430600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang SIPDateHeader d = new SIPDateHeader(); 431600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (date == null) 432600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null date"); 433600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang d.setDate(date); 434600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 435600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return d; 436600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 437600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 438600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 439600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new EventHeader based on the newly supplied eventType value. 440600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 441600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param eventType - the new string value of the eventType. 442600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException which signals that an error has been reached 443600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * unexpectedly while parsing the eventType value. 444600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created EventHeader object. 445600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @since v1.1 446600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 447600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public EventHeader createEventHeader(String eventType) 448600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws ParseException { 449600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (eventType == null) 450600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null eventType"); 451600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang Event event = new Event(); 452600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang event.setEventType(eventType); 453600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 454600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return event; 455600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 456600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 457600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 458600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new ExpiresHeader based on the newly supplied expires value. 459600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 460600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param expires - the new integer value of the expires. 461600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws InvalidArgumentException if supplied expires is less 462600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * than zero. 463600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created ExpiresHeader object. 464600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 465600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public ExpiresHeader createExpiresHeader(int expires) 466600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws InvalidArgumentException { 467600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (expires < 0) 468600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new InvalidArgumentException("bad value " + expires); 469600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang Expires e = new Expires(); 470600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang e.setExpires(expires); 471600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 472600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return e; 473600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 474600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 475600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 476600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new ExtensionHeader based on the newly supplied name and 477600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * value values. 478600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 479600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param name - the new string name of the ExtensionHeader value. 480600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param value - the new string value of the ExtensionHeader. 481600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException which signals that an error has been reached 482600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * unexpectedly while parsing the name or value values. 483600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created ExtensionHeader object. 484600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 485600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public javax.sip.header.ExtensionHeader createExtensionHeader( 486600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang String name, 487600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang String value) 488600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws ParseException { 489600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (name == null) 490600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("bad name"); 491600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 492600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang gov.nist.javax.sip.header.ExtensionHeaderImpl ext = 493600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang new gov.nist.javax.sip.header.ExtensionHeaderImpl(); 494600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang ext.setName(name); 495600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang ext.setValue(value); 496600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 497600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return ext; 498600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 499600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 500600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 501600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new FromHeader based on the newly supplied address and 502600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * tag values. 503600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 504600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param address - the new Address object of the address. 505600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param tag - the new string value of the tag. 506600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException which signals that an error has been reached 507600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * unexpectedly while parsing the tag value. 508600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created FromHeader object. 509600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 510600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public FromHeader createFromHeader(Address address, String tag) 511600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws ParseException { 512600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (address == null) 513600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null address arg"); 514600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang From from = new From(); 515600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang from.setAddress(address); 516600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (tag != null) 517600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang from.setTag(tag); 518600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 519600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return from; 520600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 521600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 522600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 523600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new InReplyToHeader based on the newly supplied callId 524600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * value. 525600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 526600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param callId - the new string containing the callId value. 527600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException which signals that an error has been reached 528600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * unexpectedly while parsing the callId value. 529600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created InReplyToHeader object. 530600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @since v1.1 531600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 532600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public InReplyToHeader createInReplyToHeader(String callId) 533600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws ParseException { 534600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (callId == null) 535600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null callId arg"); 536600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang InReplyTo inReplyTo = new InReplyTo(); 537600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang inReplyTo.setCallId(callId); 538600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 539600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return inReplyTo; 540600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 541600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 542600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new MaxForwardsHeader based on the newly 543600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * supplied maxForwards value. 544600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 545600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param maxForwards The new integer value of the maxForwards. 546600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws InvalidArgumentException if supplied maxForwards is less 547600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * than zero or greater than 255. 548600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created MaxForwardsHeader object. 549600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 550600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public MaxForwardsHeader createMaxForwardsHeader(int maxForwards) 551600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws InvalidArgumentException { 552600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (maxForwards < 0 || maxForwards > 255) 553600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new InvalidArgumentException( 554600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang "bad maxForwards arg " + maxForwards); 555600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang MaxForwards m = new MaxForwards(); 556600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang m.setMaxForwards(maxForwards); 557600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 558600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return m; 559600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 560600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 561600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 562600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new MimeVersionHeader based on the newly 563600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * supplied mimeVersion value. 564600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 565600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param majorVersion - the new integer value of the majorVersion. 566600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param minorVersion - the new integer value of the minorVersion. 567600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws InvalidArgumentException if supplied mimeVersion is less 568600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * than zero. 569600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created MimeVersionHeader object. 570600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @since v1.1 571600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 572600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public MimeVersionHeader createMimeVersionHeader( 573600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang int majorVersion, 574600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang int minorVersion) 575600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws InvalidArgumentException { 576600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (majorVersion < 0 || minorVersion < 0) 577600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new javax.sip.InvalidArgumentException( 578600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang "bad major/minor version"); 579600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang MimeVersion m = new MimeVersion(); 580600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang m.setMajorVersion(majorVersion); 581600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang m.setMinorVersion(minorVersion); 582600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 583600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return m; 584600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 585600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 586600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 587600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new MinExpiresHeader based on the newly supplied minExpires value. 588600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 589600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param minExpires - the new integer value of the minExpires. 590600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws InvalidArgumentException if supplied minExpires is less 591600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * than zero. 592600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created MinExpiresHeader object. 593600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @since v1.1 594600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 595600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public MinExpiresHeader createMinExpiresHeader(int minExpires) 596600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws InvalidArgumentException { 597600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (minExpires < 0) 598600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new InvalidArgumentException("bad minExpires " + minExpires); 599600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang MinExpires min = new MinExpires(); 600600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang min.setExpires(minExpires); 601600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 602600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return min; 603600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 604600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 605600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 606600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new MinSEHeader based on the newly supplied expires value. 607600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 608600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param expires - the new integer value of the expires. 609600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws InvalidArgumentException if supplied expires is less 610600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * than zero. 611600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created ExpiresHeader object. 612600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 613600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * TODO: Once interfaces are in javax, change the type to MinSEHeader 614600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * and add to HeaderFactory. - pmusgrave 615600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 616600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * pmusgrave 617600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 618600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public ExtensionHeader createMinSEHeader(int expires) 619600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws InvalidArgumentException { 620600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (expires < 0) 621600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new InvalidArgumentException("bad value " + expires); 622600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang MinSE e = new MinSE(); 623600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang e.setExpires(expires); 624600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 625600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return e; 626600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 627600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 628600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 629600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new OrganizationHeader based on the newly supplied 630600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * organization value. 631600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 632600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param organization - the new string value of the organization. 633600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException which signals that an error has been reached 634600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * unexpectedly while parsing the organization value. 635600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created OrganizationHeader object. 636600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 637600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public OrganizationHeader createOrganizationHeader(String organization) 638600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws ParseException { 639600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (organization == null) 640600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("bad organization arg"); 641600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang Organization o = new Organization(); 642600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang o.setOrganization(organization); 643600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 644600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return o; 645600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 646600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 647600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 648600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new PriorityHeader based on the newly supplied priority value. 649600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 650600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param priority - the new string value of the priority. 651600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException which signals that an error has been reached 652600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * unexpectedly while parsing the priority value. 653600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created PriorityHeader object. 654600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 655600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public PriorityHeader createPriorityHeader(String priority) 656600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws ParseException { 657600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (priority == null) 658600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("bad priority arg"); 659600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang Priority p = new Priority(); 660600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang p.setPriority(priority); 661600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 662600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return p; 663600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 664600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 665600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 666600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new ProxyAuthenticateHeader based on the newly supplied 667600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * scheme value. 668600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 669600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param scheme - the new string value of the scheme. 670600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException which signals that an error has been reached 671600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * unexpectedly while parsing the scheme value. 672600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created ProxyAuthenticateHeader object. 673600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 674600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public ProxyAuthenticateHeader createProxyAuthenticateHeader(String scheme) 675600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws ParseException { 676600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (scheme == null) 677600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("bad scheme arg"); 678600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang ProxyAuthenticate p = new ProxyAuthenticate(); 679600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang p.setScheme(scheme); 680600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 681600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return p; 682600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 683600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 684600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 685600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new ProxyAuthorizationHeader based on the newly supplied 686600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * scheme value. 687600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 688600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param scheme - the new string value of the scheme. 689600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException which signals that an error has been reached 690600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * unexpectedly while parsing the scheme value. 691600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created ProxyAuthorizationHeader object. 692600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 693600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public ProxyAuthorizationHeader createProxyAuthorizationHeader(String scheme) 694600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws ParseException { 695600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (scheme == null) 696600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("bad scheme arg"); 697600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang ProxyAuthorization p = new ProxyAuthorization(); 698600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang p.setScheme(scheme); 699600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 700600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return p; 701600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 702600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 703600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 704600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new ProxyRequireHeader based on the newly supplied optionTag 705600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * value. 706600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 707600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param optionTag - the new string OptionTag value. 708600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created ProxyRequireHeader object. 709600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException which signals that an error has been reached 710600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * unexpectedly while parsing the optionTag value. 711600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 712600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public ProxyRequireHeader createProxyRequireHeader(String optionTag) 713600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws ParseException { 714600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (optionTag == null) 715600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("bad optionTag arg"); 716600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang ProxyRequire p = new ProxyRequire(); 717600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang p.setOptionTag(optionTag); 718600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 719600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return p; 720600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 721600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 722600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 723600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new RAckHeader based on the newly supplied rSeqNumber, 724600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * cSeqNumber and method values. 725600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 726600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param rSeqNumber - the new integer value of the rSeqNumber. 727600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param cSeqNumber - the new integer value of the cSeqNumber. 728600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param method - the new string value of the method. 729600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws InvalidArgumentException if supplied rSeqNumber or cSeqNumber is 730600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * less than zero or greater than than 2**31-1. 731600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException which signals that an error has been reached 732600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * unexpectedly while parsing the method value. 733600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created RAckHeader object. 734600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @since v1.1 735600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 736600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public RAckHeader createRAckHeader( 737600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang long rSeqNumber, 738600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang long cSeqNumber, 739600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang String method) 740600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws InvalidArgumentException, ParseException { 741600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (method == null) 742600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("Bad method"); 743600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (cSeqNumber < 0 || rSeqNumber < 0) 744600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new InvalidArgumentException("bad cseq/rseq arg"); 745600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang RAck rack = new RAck(); 746600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang rack.setMethod(method); 747600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang rack.setCSequenceNumber(cSeqNumber); 748600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang rack.setRSequenceNumber(rSeqNumber); 749600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 750600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return rack; 751600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 752600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 753600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 754600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @deprecated 755600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @see javax.sip.header.HeaderFactory#createRAckHeader(int, int, java.lang.String) 756600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 757600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public RAckHeader createRAckHeader(int rSeqNumber, int cSeqNumber, String method) throws InvalidArgumentException, ParseException { 758600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 759600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return createRAckHeader((long)rSeqNumber, (long)cSeqNumber, method); 760600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 761600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 762600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 763600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 764600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @deprecated 765600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @see javax.sip.header.HeaderFactory#createRSeqHeader(int) 766600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 767600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public RSeqHeader createRSeqHeader(int sequenceNumber) throws InvalidArgumentException { 768600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 769600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return createRSeqHeader((long) sequenceNumber) ; 770600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 771600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 772600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 773600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new RSeqHeader based on the newly supplied sequenceNumber value. 774600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 775600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param sequenceNumber - the new integer value of the sequenceNumber. 776600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws InvalidArgumentException if supplied sequenceNumber is 777600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * less than zero or greater than than 2**31-1. 778600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created RSeqHeader object. 779600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @since v1.1 780600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 781600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public RSeqHeader createRSeqHeader(long sequenceNumber) 782600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws InvalidArgumentException { 783600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (sequenceNumber < 0) 784600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new InvalidArgumentException( 785600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang "invalid sequenceNumber arg " + sequenceNumber); 786600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang RSeq rseq = new RSeq(); 787600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang rseq.setSeqNumber(sequenceNumber); 788600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 789600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return rseq; 790600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 791600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 792600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 793600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new ReasonHeader based on the newly supplied reason value. 794600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 795600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param protocol - the new string value of the protocol. 796600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param cause - the new integer value of the cause. 797600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param text - the new string value of the text. 798600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException which signals that an error has been reached 799600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * unexpectedly while parsing the protocol, cause or text value. 800600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created ReasonHeader object. 801600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @since v1.1 802600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 803600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public ReasonHeader createReasonHeader( 804600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang String protocol, 805600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang int cause, 806600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang String text) 807600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws InvalidArgumentException, ParseException { 808600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (protocol == null) 809600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("bad protocol arg"); 810600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (cause < 0) 811600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new InvalidArgumentException("bad cause"); 812600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang Reason reason = new Reason(); 813600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang reason.setProtocol(protocol); 814600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang reason.setCause(cause); 815600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang reason.setText(text); 816600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 817600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return reason; 818600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 819600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 820600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 821600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new RecordRouteHeader based on the newly supplied address value. 822600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 823600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param address - the new Address object of the address. 824600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created RecordRouteHeader object. 825600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 826600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public RecordRouteHeader createRecordRouteHeader(Address address) { 827600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if ( address == null) throw new NullPointerException("Null argument!"); 828600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang RecordRoute recordRoute = new RecordRoute(); 829600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang recordRoute.setAddress(address); 830600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 831600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return recordRoute; 832600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 833600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 834600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 835600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new ReplyToHeader based on the newly supplied address value. 836600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 837600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param address - the new Address object of the address. 838600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created ReplyToHeader object. 839600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @since v1.1 840600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 841600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public ReplyToHeader createReplyToHeader(Address address) { 842600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (address == null) 843600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null address"); 844600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang ReplyTo replyTo = new ReplyTo(); 845600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang replyTo.setAddress(address); 846600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 847600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return replyTo; 848600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 849600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 850600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 851600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new RequireHeader based on the newly supplied optionTag 852600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * value. 853600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 854600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param optionTag - the new string value containing the optionTag value. 855600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException which signals that an error has been reached 856600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * unexpectedly while parsing the List of optionTag value. 857600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created RequireHeader object. 858600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 859600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public RequireHeader createRequireHeader(String optionTag) 860600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws ParseException { 861600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (optionTag == null) 862600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null optionTag"); 863600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang Require require = new Require(); 864600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang require.setOptionTag(optionTag); 865600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 866600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return require; 867600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 868600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 869600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 870600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new RetryAfterHeader based on the newly supplied retryAfter 871600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * value. 872600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 873600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param retryAfter - the new integer value of the retryAfter. 874600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws InvalidArgumentException if supplied retryAfter is less 875600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * than zero. 876600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created RetryAfterHeader object. 877600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 878600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public RetryAfterHeader createRetryAfterHeader(int retryAfter) 879600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws InvalidArgumentException { 880600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (retryAfter < 0) 881600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new InvalidArgumentException("bad retryAfter arg"); 882600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang RetryAfter r = new RetryAfter(); 883600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang r.setRetryAfter(retryAfter); 884600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 885600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return r; 886600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 887600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 888600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 889600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new RouteHeader based on the newly supplied address value. 890600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 891600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param address - the new Address object of the address. 892600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created RouteHeader object. 893600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 894600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public RouteHeader createRouteHeader(Address address) { 895600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (address == null) 896600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null address arg"); 897600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang Route route = new Route(); 898600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang route.setAddress(address); 899600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 900600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return route; 901600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 902600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 903600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 904600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new ServerHeader based on the newly supplied product value. 905600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 906600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param product - the new list value of the product. 907600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException which signals that an error has been reached 908600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * unexpectedly while parsing the product value. 909600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created ServerHeader object. 910600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 911600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public ServerHeader createServerHeader(List product) 912600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws ParseException { 913600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (product == null) 914600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null productList arg"); 915600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang Server server = new Server(); 916600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang server.setProduct(product); 917600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 918600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return server; 919600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 920600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 921600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 922600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new SubjectHeader based on the newly supplied subject value. 923600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 924600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param subject - the new string value of the subject. 925600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException which signals that an error has been reached 926600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * unexpectedly while parsing the subject value. 927600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created SubjectHeader object. 928600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 929600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public SubjectHeader createSubjectHeader(String subject) 930600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws ParseException { 931600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (subject == null) 932600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null subject arg"); 933600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang Subject s = new Subject(); 934600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang s.setSubject(subject); 935600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 936600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return s; 937600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 938600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 939600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 940600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new SubscriptionStateHeader based on the newly supplied 941600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * subscriptionState value. 942600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 943600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param subscriptionState - the new string value of the subscriptionState. 944600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException which signals that an error has been reached 945600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * unexpectedly while parsing the subscriptionState value. 946600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created SubscriptionStateHeader object. 947600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @since v1.1 948600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 949600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public SubscriptionStateHeader createSubscriptionStateHeader(String subscriptionState) 950600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws ParseException { 951600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (subscriptionState == null) 952600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null subscriptionState arg"); 953600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang SubscriptionState s = new SubscriptionState(); 954600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang s.setState(subscriptionState); 955600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 956600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return s; 957600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 958600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 959600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 960600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new SupportedHeader based on the newly supplied optionTag 961600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * value. 962600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 963600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param optionTag - the new string containing the optionTag value. 964600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException which signals that an error has been reached 965600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * unexpectedly while parsing the optionTag value. 966600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created SupportedHeader object. 967600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 968600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public SupportedHeader createSupportedHeader(String optionTag) 969600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws ParseException { 970600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (optionTag == null) 971600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null optionTag arg"); 972600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang Supported supported = new Supported(); 973600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang supported.setOptionTag(optionTag); 974600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 975600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return supported; 976600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 977600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 978600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 979600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new TimeStampHeader based on the newly supplied timeStamp value. 980600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 981600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param timeStamp - the new float value of the timeStamp. 982600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws InvalidArgumentException if supplied timeStamp is less 983600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * than zero. 984600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created TimeStampHeader object. 985600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 986600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public TimeStampHeader createTimeStampHeader(float timeStamp) 987600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws InvalidArgumentException { 988600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (timeStamp < 0) 989600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new IllegalArgumentException("illegal timeStamp"); 990600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang TimeStamp t = new TimeStamp(); 991600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang t.setTimeStamp(timeStamp); 992600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 993600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return t; 994600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 995600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 996600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 997600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new ToHeader based on the newly supplied address and 998600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * tag values. 999600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 1000600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param address - the new Address object of the address. 1001600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param tag - the new string value of the tag. 1002600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException which signals that an error has been reached 1003600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * unexpectedly while parsing the tag value. 1004600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created ToHeader object. 1005600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1006600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public ToHeader createToHeader(Address address, String tag) 1007600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws ParseException { 1008600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (address == null) 1009600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null address"); 1010600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang To to = new To(); 1011600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang to.setAddress(address); 1012600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (tag != null) 1013600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang to.setTag(tag); 1014600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1015600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return to; 1016600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1017600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1018600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 1019600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new UnsupportedHeader based on the newly supplied optionTag 1020600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * value. 1021600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 1022600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param optionTag - the new string containing the optionTag value. 1023600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException which signals that an error has been reached 1024600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * unexpectedly while parsing the List of optionTag value. 1025600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created UnsupportedHeader object. 1026600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1027600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public UnsupportedHeader createUnsupportedHeader(String optionTag) 1028600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws ParseException { 1029600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (optionTag == null) 1030600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException(optionTag); 1031600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang Unsupported unsupported = new Unsupported(); 1032600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang unsupported.setOptionTag(optionTag); 1033600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1034600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return unsupported; 1035600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1036600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1037600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 1038600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new UserAgentHeader based on the newly supplied product value. 1039600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 1040600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param product - the new list value of the product. 1041600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException which signals that an error has been reached 1042600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * unexpectedly while parsing the product value. 1043600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created UserAgentHeader object. 1044600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1045600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public UserAgentHeader createUserAgentHeader(List product) 1046600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws ParseException { 1047600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1048600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (product == null) 1049600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null user agent"); 1050600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang UserAgent userAgent = new UserAgent(); 1051600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang userAgent.setProduct(product); 1052600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1053600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return userAgent; 1054600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1055600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1056600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 1057600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new ViaHeader based on the newly supplied uri and branch values. 1058600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 1059600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param host the new host value of uri. 1060600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param port the new port value of uri. 1061600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param transport the new transport value of uri. 1062600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param branch the new string value of the branch. 1063600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException which signals that an error has been reached 1064600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * unexpectedly while parsing the branch value. 1065600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created ViaHeader object. 1066600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1067600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public ViaHeader createViaHeader( 1068600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang String host, 1069600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang int port, 1070600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang String transport, 1071600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang String branch) 1072600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws ParseException, InvalidArgumentException { 1073600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang // This should be changed. 1074600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (host == null || transport == null) 1075600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null arg"); 1076600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang Via via = new Via(); 1077600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (branch != null) 1078600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang via.setBranch(branch); 1079600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1080600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang // for supporting IPv6 addresses 1081600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if(host.indexOf(':') >= 0 1082600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang && host.indexOf('[') < 0) 1083600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang { 1084600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang //strip address scope zones if any 1085600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if(stripAddressScopeZones) 1086600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang { 1087600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang int zoneStart = host.indexOf('%'); 1088600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if(zoneStart != -1) 1089600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang host = host.substring(0, zoneStart); 1090600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1091600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang host = '[' + host + ']'; 1092600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1093600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1094600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang via.setHost(host); 1095600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang via.setPort(port); 1096600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang via.setTransport(transport); 1097600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1098600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return via; 1099600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1100600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1101600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 1102600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new WWWAuthenticateHeader based on the newly supplied 1103600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * scheme value. 1104600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 1105600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param scheme - the new string value of the scheme. 1106600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException which signals that an error has been reached 1107600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * unexpectedly while parsing the scheme values. 1108600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created WWWAuthenticateHeader object. 1109600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1110600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public WWWAuthenticateHeader createWWWAuthenticateHeader(String scheme) 1111600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws ParseException { 1112600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (scheme == null) 1113600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null scheme"); 1114600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang WWWAuthenticate www = new WWWAuthenticate(); 1115600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang www.setScheme(scheme); 1116600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1117600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return www; 1118600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1119600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1120600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 1121600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new WarningHeader based on the newly supplied 1122600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * agent, code and comment values. 1123600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 1124600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param agent - the new string value of the agent. 1125600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param code - the new boolean integer of the code. 1126600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param comment - the new string value of the comment. 1127600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException which signals that an error has been reached 1128600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * unexpectedly while parsing the agent or comment values. 1129600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws InvalidArgumentException if an invalid integer code is given for 1130600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * the WarningHeader. 1131600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created WarningHeader object. 1132600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1133600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public WarningHeader createWarningHeader( 1134600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang String agent, 1135600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang int code, 1136600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang String comment) 1137600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws ParseException, InvalidArgumentException { 1138600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (agent == null) 1139600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null arg"); 1140600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang Warning warning = new Warning(); 1141600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang warning.setAgent(agent); 1142600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang warning.setCode(code); 1143600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang warning.setText(comment); 1144600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1145600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return warning; 1146600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1147600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1148600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** Creates a new ErrorInfoHeader based on the newly 1149600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * supplied errorInfo value. 1150600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 1151600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param errorInfo - the new URI value of the errorInfo. 1152600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created ErrorInfoHeader object. 1153600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1154600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public ErrorInfoHeader createErrorInfoHeader(URI errorInfo) { 1155600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (errorInfo == null) 1156600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null arg"); 1157600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return new ErrorInfo((GenericURI) errorInfo); 1158600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1159600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1160600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 1161600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Create a header from the given header text. 1162600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Header should not have the trailng crlf. 1163600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException 1164600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1165600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public javax.sip.header.Header createHeader(String headerText) throws ParseException { 1166600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang StringMsgParser smp = new StringMsgParser(); 1167600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang SIPHeader sipHeader = smp.parseSIPHeader(headerText.trim()); 1168600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (sipHeader instanceof SIPHeaderList) { 1169600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (((SIPHeaderList) sipHeader).size() > 1) { 1170600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new ParseException( 1171600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang "Only singleton allowed " + headerText, 1172600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 0); 1173600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } else if (((SIPHeaderList) sipHeader).size() == 0) { 1174600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang try { 1175600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return (Header) ((SIPHeaderList) sipHeader) 1176600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang .getMyClass() 1177600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang .newInstance(); 1178600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } catch (InstantiationException ex) { 1179600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang ex.printStackTrace(); 1180600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return null; 1181600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } catch (IllegalAccessException ex) { 1182600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang ex.printStackTrace(); 1183600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return null; 1184600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1185600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } else { 1186600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return (Header) ((SIPHeaderList) sipHeader).getFirst(); 1187600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1188600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } else { 1189600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return (Header) sipHeader; 1190600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1191600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1192600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1193600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1194600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** Create and parse a header. 1195600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 1196600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param headerName -- header name for the header to parse. 1197600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param headerValue -- header value for the header to parse. 1198600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException 1199600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the parsed sip header 1200600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1201600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public javax.sip.header.Header createHeader( 1202600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang String headerName, 1203600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang String headerValue) 1204600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws java.text.ParseException { 1205600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (headerName == null) 1206600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("header name is null"); 1207600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang String hdrText = 1208600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang new StringBuffer() 1209600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang .append(headerName) 1210600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang .append(":") 1211600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang .append(headerValue) 1212600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang .toString(); 1213600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return createHeader(hdrText); 1214600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1215600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1216600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1217600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** Create and return a list of headers. 1218600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang *@param headers -- list of headers. 1219600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang *@throws ParseException -- if a parse exception occurs or a List 1220600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * of that type of header is not alowed. 1221600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang *@return a List containing the headers. 1222600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1223600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public java.util.List createHeaders(String headers) 1224600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws java.text.ParseException { 1225600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (headers == null) 1226600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null arg!"); 1227600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang StringMsgParser smp = new StringMsgParser(); 1228600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang SIPHeader shdr = smp.parseSIPHeader(headers); 1229600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (shdr instanceof SIPHeaderList) 1230600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return (SIPHeaderList) shdr; 1231600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang else 1232600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new ParseException( 1233600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang "List of headers of this type is not allowed in a message", 1234600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 0); 1235600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1236600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1237600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** Create a ReferTo Header. 1238600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang *@param address -- address for the header. 1239600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1240600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public ReferToHeader createReferToHeader(Address address) { 1241600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (address == null) 1242600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null address!"); 1243600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang ReferTo referTo = new ReferTo(); 1244600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang referTo.setAddress(address); 1245600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return referTo; 1246600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1247600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1248600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** Create a ReferredBy Header. 1249600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 1250600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * pmusgrave 1251600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 1252600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang *@param address -- address for the header. 1253600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 1254600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * TODO: Once interfaces are in javax, change the type to MinSEHeader 1255600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * and add to HeaderFactory. - pmusgrave 1256600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1257600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1258600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public ReferredByHeader createReferredByHeader(Address address) { 1259600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (address == null) 1260600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null address!"); 1261600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang ReferredBy referredBy = new ReferredBy(); 1262600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang referredBy.setAddress(address); 1263600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return referredBy; 1264600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1265600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1266600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 1267600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Create a Replaces header with a call Id, to and from tag. 1268600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 1269600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * TODO: Once interfaces are in javax, change the type to MinSEHeader 1270600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * and add to HeaderFactory. - pmusgrave 1271600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * pmusgrave 1272600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1273600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public ReplacesHeader createReplacesHeader(String callId, String toTag, 1274600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang String fromTag) throws ParseException 1275600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang { 1276600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang Replaces replaces = new Replaces(); 1277600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang replaces.setCallId(callId); 1278600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang replaces.setFromTag(fromTag); 1279600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang replaces.setToTag(toTag); 1280600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1281600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return replaces; 1282600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1283600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1284600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 1285600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Create a Join header with a call Id, to and from tag. 1286600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 1287600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1288600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public JoinHeader createJoinHeader(String callId, String toTag, 1289600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang String fromTag) throws ParseException 1290600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang { 1291600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang Join join = new Join(); 1292600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang join.setCallId(callId); 1293600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang join.setFromTag(fromTag); 1294600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang join.setToTag(toTag); 1295600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1296600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return join; 1297600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1298600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1299600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1300600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /* 1301600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * (non-Javadoc) 1302600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @see javax.sip.header.HeaderFactory#createSIPETagHeader(java.lang.String) 1303600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1304600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public SIPETagHeader createSIPETagHeader(String etag) throws ParseException { 1305600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return new SIPETag(etag); 1306600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1307600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1308600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /* 1309600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * (non-Javadoc) 1310600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @see javax.sip.header.HeaderFactory#createSIPIfMatchHeader(java.lang.String) 1311600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1312600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public SIPIfMatchHeader createSIPIfMatchHeader(String etag) throws ParseException { 1313600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return new SIPIfMatch(etag); 1314600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1315600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1316600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang ////////////////////////////////////////////////////////////////////////// 1317600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang // The following headers are not part of the JSIP spec. 1318600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang // They are IMS headers 1319600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang // (contributed by Miguel Freitas - PT Inovacao and Telecommunications Institute) 1320600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /////////////////////////////////////////////////////////////////////////// 1321600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1322600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 1323600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * creates a P-Access-Network-Info header 1324600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return newly created P-Access-Network-Info header 1325600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1326600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public PAccessNetworkInfoHeader createPAccessNetworkInfoHeader() 1327600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang { 1328600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang PAccessNetworkInfo accessNetworkInfo = new PAccessNetworkInfo(); 1329600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1330600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return accessNetworkInfo; 1331600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1332600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1333600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1334600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 1335600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * P-Asserted-Identity header 1336600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param address - Address 1337600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return newly created P-Asserted-Identity header 1338600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException 1339600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws NullPointerException 1340600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1341600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public PAssertedIdentityHeader createPAssertedIdentityHeader(Address address) 1342600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws NullPointerException, ParseException 1343600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang { 1344600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (address == null) 1345600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null address!"); 1346600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1347600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang PAssertedIdentity assertedIdentity = new PAssertedIdentity(); 1348600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang assertedIdentity.setAddress(address); 1349600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1350600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return assertedIdentity; 1351600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1352600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1353600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1354600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1355600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1356600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 1357600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new P-Associated-URI header based on the supplied address 1358600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param assocURI - Address 1359600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return newly created P-Associated-URI header 1360600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws NullPointerException if the supplied address is null 1361600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException 1362600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1363600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public PAssociatedURIHeader createPAssociatedURIHeader(Address assocURI) 1364600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang { 1365600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (assocURI == null) 1366600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null associatedURI!"); 1367600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1368600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang PAssociatedURI associatedURI = new PAssociatedURI(); 1369600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang associatedURI.setAddress(assocURI); 1370600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1371600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return associatedURI; 1372600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1373600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1374600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1375600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1376600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1377600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 1378600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * P-Called-Party-ID header 1379600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param address - Address 1380600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return newly created P-Called-Party-ID header 1381600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws NullPointerException 1382600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException 1383600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1384600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public PCalledPartyIDHeader createPCalledPartyIDHeader(Address address) 1385600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang { 1386600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (address == null) 1387600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null address!"); 1388600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1389600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang PCalledPartyID calledPartyID = new PCalledPartyID(); 1390600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang calledPartyID.setAddress(address); 1391600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1392600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return calledPartyID; 1393600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1394600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1395600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1396600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1397600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 1398600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * P-Charging-Function-Addresses header 1399600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return newly created P-Charging-Function-Addresses header 1400600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1401600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public PChargingFunctionAddressesHeader createPChargingFunctionAddressesHeader() 1402600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang { 1403600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang PChargingFunctionAddresses cfa = new PChargingFunctionAddresses(); 1404600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1405600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return cfa; 1406600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1407600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1408600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1409600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 1410600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * P-Charging-Vector header 1411600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param icid - icid string 1412600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return newly created P-Charging-Vector header 1413600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws NullPointerException 1414600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException 1415600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1416600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public PChargingVectorHeader createChargingVectorHeader(String icid) 1417600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws ParseException 1418600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang { 1419600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (icid == null) 1420600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null icid arg!"); 1421600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1422600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang PChargingVector chargingVector = new PChargingVector(); 1423600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang chargingVector.setICID(icid); 1424600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1425600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return chargingVector; 1426600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1427600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1428600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1429600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1430600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 1431600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * P-Media-Authorization header 1432600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param token - token string 1433600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return newly created P-Media-Authorizarion header 1434600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws InvalidArgumentException 1435600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException 1436600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1437600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public PMediaAuthorizationHeader createPMediaAuthorizationHeader(String token) 1438600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws InvalidArgumentException, ParseException 1439600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang { 1440600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (token == null || token == "") 1441600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new InvalidArgumentException("The Media-Authorization-Token parameter is null or empty"); 1442600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1443600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1444600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang PMediaAuthorization mediaAuthorization = new PMediaAuthorization(); 1445600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang mediaAuthorization.setMediaAuthorizationToken(token); 1446600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1447600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return mediaAuthorization; 1448600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1449600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1450600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1451600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 1452600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * P-Preferred-Identity header 1453600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param address - Address 1454600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return newly created P-Preferred-Identity header 1455600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws NullPointerException 1456600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1457600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public PPreferredIdentityHeader createPPreferredIdentityHeader(Address address) 1458600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang { 1459600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (address == null) 1460600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null address!"); 1461600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1462600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang PPreferredIdentity preferredIdentity = new PPreferredIdentity(); 1463600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang preferredIdentity.setAddress(address); 1464600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1465600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return preferredIdentity; 1466600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1467600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1468600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1469600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 1470600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * P-Visited-Network-ID header 1471600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return newly created P-Visited-Network-ID header 1472600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1473600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public PVisitedNetworkIDHeader createPVisitedNetworkIDHeader() 1474600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang { 1475600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang PVisitedNetworkID visitedNetworkID = new PVisitedNetworkID(); 1476600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1477600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return visitedNetworkID; 1478600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1479600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1480600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1481600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1482600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 1483600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * PATH header 1484600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param address - Address 1485600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return newly created Path header 1486600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws NullPointerException 1487600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException 1488600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1489600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public PathHeader createPathHeader(Address address) 1490600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang { 1491600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (address == null) 1492600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null address!"); 1493600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1494600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1495600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang Path path = new Path(); 1496600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang path.setAddress(address); 1497600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1498600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return path; 1499600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1500600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1501600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1502600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 1503600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Privacy header 1504600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param privacyType - privacy type string 1505600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return newly created Privacy header 1506600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws NullPointerException 1507600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1508600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public PrivacyHeader createPrivacyHeader(String privacyType) 1509600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang { 1510600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (privacyType == null) 1511600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null privacyType arg"); 1512600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1513600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang Privacy privacy = new Privacy(privacyType); 1514600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1515600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return privacy; 1516600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1517600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1518600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1519600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1520600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 1521600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Service-Route header 1522600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param address - Address 1523600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return newly created Service-Route header 1524600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws NullPointerException 1525600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1526600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public ServiceRouteHeader createServiceRouteHeader(Address address) 1527600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang { 1528600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (address == null) 1529600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("null address!"); 1530600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1531600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang ServiceRoute serviceRoute = new ServiceRoute(); 1532600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang serviceRoute.setAddress(address); 1533600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1534600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return serviceRoute; 1535600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1536600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1537600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1538600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 1539600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Security-Server header 1540600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return newly created Security-Server header 1541600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1542600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public SecurityServerHeader createSecurityServerHeader() 1543600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang { 1544600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang SecurityServer secServer = new SecurityServer(); 1545600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return secServer; 1546600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1547600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1548600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 1549600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Security-Client header 1550600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return newly created Security-Client header 1551600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1552600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public SecurityClientHeader createSecurityClientHeader() 1553600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang { 1554600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang SecurityClient secClient = new SecurityClient(); 1555600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return secClient; 1556600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1557600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1558600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 1559600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Security-Verify header 1560600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return newly created Security-Verify header 1561600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1562600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public SecurityVerifyHeader createSecurityVerifyHeader() 1563600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang { 1564600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang SecurityVerify secVerify = new SecurityVerify(); 1565600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return secVerify; 1566600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1567600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1568600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 1569600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly create P-User-Database header. 1570600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Please note that this is not a SIP/TEL uri. It is a 1571600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * DIAMETER AAA URI. 1572600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1573600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public PUserDatabaseHeader createPUserDatabaseHeader(String databaseName) 1574600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang { 1575600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if((databaseName ==null)||(databaseName.equals(" "))) 1576600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("Database name is null"); 1577600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1578600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang PUserDatabase pUserDatabase = new PUserDatabase(); 1579600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang pUserDatabase.setDatabaseName(databaseName); 1580600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1581600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return pUserDatabase; 1582600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1583600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1584600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1585600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 1586600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 1587600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return The newly created P-Profile-Key header. 1588600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 1589600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1590600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public PProfileKeyHeader createPProfileKeyHeader(Address address) 1591600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang { 1592600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (address ==null) 1593600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("Address is null"); 1594600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang PProfileKey pProfileKey = new PProfileKey(); 1595600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang pProfileKey.setAddress(address); 1596600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1597600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return pProfileKey; 1598600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1599600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1600600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 1601600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 1602600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return The newly created P-Served-User header. 1603600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1604600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public PServedUserHeader createPServedUserHeader(Address address) 1605600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang { 1606600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if(address==null) 1607600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new NullPointerException("Address is null"); 1608600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang PServedUser psu = new PServedUser(); 1609600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang psu.setAddress(address); 1610600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1611600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return psu; 1612600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1613600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 1614600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return The newly created P-Preferred-Service header. 1615600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1616600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public PPreferredServiceHeader createPPreferredServiceHeader() 1617600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang { 1618600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang PPreferredService pps = new PPreferredService(); 1619600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return pps; 1620600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1621600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1622600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 1623600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 1624600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return The newly created P-Asserted-Service header. 1625600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1626600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public PAssertedServiceHeader createPAssertedServiceHeader() 1627600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang { 1628600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang PAssertedService pas = new PAssertedService(); 1629600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return pas; 1630600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1631600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1632600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 1633600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Creates a new SessionExpiresHeader based on the newly supplied expires value. 1634600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 1635600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param expires - the new integer value of the expires. 1636600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws InvalidArgumentException if supplied expires is less 1637600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * than zero. 1638600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return the newly created SessionExpiresHeader object. 1639600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 1640600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1641600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public SessionExpiresHeader createSessionExpiresHeader(int expires) 1642600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throws InvalidArgumentException { 1643600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang if (expires < 0) 1644600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang throw new InvalidArgumentException("bad value " + expires); 1645600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang SessionExpires s = new SessionExpires(); 1646600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang s.setExpires(expires); 1647600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1648600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return s; 1649600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1650600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1651600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1652600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 1653600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Create a new Request Line from a String. 1654600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 1655600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1656600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public SipRequestLine createRequestLine(String requestLine) throws ParseException { 1657600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1658600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang RequestLineParser requestLineParser = new RequestLineParser(requestLine); 1659600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return (SipRequestLine) requestLineParser.parse(); 1660600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1661600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1662600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 1663600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Create a new StatusLine from a String. 1664600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1665600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public SipStatusLine createStatusLine(String statusLine) throws ParseException { 1666600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang StatusLineParser statusLineParser = new StatusLineParser(statusLine); 1667600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return (SipStatusLine) statusLineParser.parse(); 1668600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1669600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1670600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1671600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1672600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 1673600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Create and return a references header. 1674600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * 1675600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param callId 1676600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @param rel 1677600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @return 1678600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * @throws ParseException 1679600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1680600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1681600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public ReferencesHeader createReferencesHeader(String callId, String rel) throws ParseException { 1682600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang ReferencesHeader retval = new References(); 1683600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang retval.setCallId(callId); 1684600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang retval.setRel(rel); 1685600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang return retval; 1686600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1687600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1688600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1689600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1690600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1691600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang ////////////////////////////////////////////////////////// 1692600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang // Constructor 1693600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang ////////////////////////////////////////////////////////// 1694600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang /** 1695600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang * Default constructor. 1696600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang */ 1697600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang public HeaderFactoryImpl() { 1698600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang stripAddressScopeZones 1699600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang = Boolean.getBoolean("gov.nist.core.STRIP_ADDR_SCOPES"); 1700600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang } 1701600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1702600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1703600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1704600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1705600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang 1706600c7a4bbc7348167293eac928192e695b4ad5baChung-yih Wang} 1707