1 /* 2 * Conditions Of Use 3 * 4 * This software was developed by employees of the National Institute of 5 * Standards and Technology (NIST), an agency of the Federal Government, 6 * and others. 7 * Pursuant to title 15 Untied States Code Section 105, works of NIST 8 * employees are not subject to copyright protection in the United States 9 * and are considered to be in the public domain. As a result, a formal 10 * license is not needed to use the software. 11 * 12 * This software is provided by NIST as a service and is expressly 13 * provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED 14 * OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF 15 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT 16 * AND DATA ACCURACY. NIST does not warrant or make any representations 17 * regarding the use of the software or the results thereof, including but 18 * not limited to the correctness, accuracy, reliability or usefulness of 19 * the software. 20 * 21 * Permission to use this software is contingent upon your acceptance 22 * of the terms of this agreement. 23 * 24 */ 25 /***************************************************************************** 26 * PRODUCT OF PT INOVACAO - EST DEPARTMENT and Aveiro University - Portugal) * 27 *****************************************************************************/ 28 29 package gov.nist.javax.sip.header.ims; 30 31 import java.text.ParseException; 32 33 import javax.sip.header.ContactHeader; 34 import javax.sip.header.ExtensionHeader; 35 36 import gov.nist.javax.sip.header.ParametersHeader; 37 38 /** 39 * <p>P-Access-Network-Info SIP Private Header</p> 40 * 41 * @author Miguel Freitas (IT) PT-Inovacao 42 * 43 * @since 1.2 44 */ 45 46 public class PAccessNetworkInfo 47 extends ParametersHeader 48 implements PAccessNetworkInfoHeader, ExtensionHeader { 49 50 // TODO: serialVersionUID 51 52 private String accessType; 53 54 private Object extendAccessInfo; 55 56 /** 57 * Public constructor. 58 */ 59 public PAccessNetworkInfo() { 60 super(PAccessNetworkInfoHeader.NAME); 61 parameters.setSeparator(SEMICOLON); 62 } 63 64 /** 65 * Constructor. 66 */ 67 public PAccessNetworkInfo(String accessTypeVal) { 68 this(); 69 setAccessType(accessTypeVal); 70 } 71 72 /** 73 * Set the accessTpe 74 * 75 * @param accessTypeVal - access type 76 * @throws NullPointerException 77 */ 78 public void setAccessType(String accessTypeVal) { 79 if (accessTypeVal == null) 80 throw new NullPointerException( 81 "JAIN-SIP Exception, " 82 + "P-Access-Network-Info, setAccessType(), the accessType parameter is null."); 83 84 this.accessType = accessTypeVal; 85 } 86 87 /** 88 * @return String access type 89 */ 90 public String getAccessType() { 91 return accessType; 92 } 93 94 /** 95 * 96 * @param cgi -- String CGI value 97 * @throws NullPointerException -- if null argument passed in 98 * @throws ParseException -- if bad argument passed in. 99 */ 100 public void setCGI3GPP(String cgi) throws ParseException { 101 102 if (cgi == null) 103 throw new NullPointerException( 104 "JAIN-SIP Exception, " 105 + "P-Access-Network-Info, setCGI3GPP(), the cgi parameter is null."); 106 107 setParameter(ParameterNamesIms.CGI_3GPP, cgi); 108 109 } 110 111 /** 112 * 113 * @return String CGI value 114 */ 115 public String getCGI3GPP() { 116 return getParameter(ParameterNamesIms.CGI_3GPP); 117 } 118 119 /** 120 * Set the UtranCellID field. 121 * 122 * @param utranCellID -- String UTRAN Cell ID value 123 * @throws NullPointerException 124 * @throws ParseException 125 */ 126 public void setUtranCellID3GPP(String utranCellID) throws ParseException { 127 128 if (utranCellID == null) 129 throw new NullPointerException( 130 "JAIN-SIP Exception, " 131 + "P-Access-Network-Info, setUtranCellID3GPP(), the utranCellID parameter is null."); 132 133 setParameter(ParameterNamesIms.UTRAN_CELL_ID_3GPP, utranCellID); 134 135 } 136 137 /** 138 * 139 * @return String UTRAN Cell ID value 140 */ 141 public String getUtranCellID3GPP() { 142 return getParameter(ParameterNamesIms.UTRAN_CELL_ID_3GPP); 143 } 144 145 /** 146 * 147 * @param dslLocation - String with the DSL location value 148 * @throws NullPointerException 149 * @throws ParseException 150 */ 151 public void setDSLLocation(String dslLocation) throws ParseException { 152 153 if (dslLocation == null) 154 throw new NullPointerException( 155 "JAIN-SIP Exception, " 156 + "P-Access-Network-Info, setDSLLocation(), the dslLocation parameter is null."); 157 158 setParameter(ParameterNamesIms.DSL_LOCATION, dslLocation); 159 160 } 161 162 /** 163 * 164 * @return String DSL location value 165 */ 166 public String getDSLLocation() { 167 return getParameter(ParameterNamesIms.DSL_LOCATION); 168 } 169 170 /** 171 * 172 * @param ci3Gpp2 -- String CI 3GPP2 value 173 * @throws NullPointerException -- if arg is null 174 * @throws ParseException -- if arg is bad. 175 */ 176 public void setCI3GPP2(String ci3Gpp2) throws ParseException { 177 if (ci3Gpp2 == null) 178 throw new NullPointerException( 179 "JAIN-SIP Exception, " 180 + "P-Access-Network-Info, setCI3GPP2(), the ci3Gpp2 parameter is null."); 181 182 setParameter(ParameterNamesIms.CI_3GPP2, ci3Gpp2); 183 } 184 185 /** 186 * 187 * @return String CI 3GPP2 value 188 */ 189 public String getCI3GPP2() { 190 return getParameter(ParameterNamesIms.CI_3GPP2); 191 } 192 193 /** 194 * 195 * @param name -- 196 * parameter name 197 * @param value -- 198 * value of parameter 199 */ 200 public void setParameter(String name, Object value) { 201 /** 202 * @todo ParametersHeader needs to be fix!? missing "throws 203 * ParseException" in setParameter(String, Object) 204 */ 205 206 if (name.equalsIgnoreCase(ParameterNamesIms.CGI_3GPP) 207 || name.equalsIgnoreCase(ParameterNamesIms.UTRAN_CELL_ID_3GPP) 208 || name.equalsIgnoreCase(ParameterNamesIms.DSL_LOCATION) 209 || name.equalsIgnoreCase(ParameterNamesIms.CI_3GPP2)) { 210 try { 211 super.setQuotedParameter(name, value.toString()); 212 } catch (ParseException e) { 213 214 } 215 216 } else { 217 // value can be token either than a quoted-string 218 super.setParameter(name, value); 219 220 } 221 222 } 223 224 /** 225 * extension-access-info = gen-value gen-value = token / host / 226 * quoted-string 227 * 228 * @param extendAccessInfo - extended Access Information 229 */ 230 public void setExtensionAccessInfo(Object extendAccessInfo) 231 throws ParseException { 232 233 if (extendAccessInfo == null) 234 throw new NullPointerException( 235 "JAIN-SIP Exception, " 236 + "P-Access-Network-Info, setExtendAccessInfo(), the extendAccessInfo parameter is null."); 237 238 // or -> setParameter("", extendAccessInfo); 239 240 this.extendAccessInfo = extendAccessInfo; 241 242 } 243 244 public Object getExtensionAccessInfo() { 245 return this.extendAccessInfo; 246 } 247 248 protected String encodeBody() { 249 250 StringBuffer encoding = new StringBuffer(); 251 252 if (getAccessType() != null) 253 encoding.append(getAccessType()); 254 255 if (!parameters.isEmpty()) { 256 encoding.append(SEMICOLON + SP + this.parameters.encode()); 257 } 258 // else if (getExtendAccessInfo() != null) // stack deve limitar, de 259 // acordo com a especificao ? 260 if (getExtensionAccessInfo() != null) { 261 encoding.append(SEMICOLON + SP 262 + getExtensionAccessInfo().toString()); 263 } 264 265 return encoding.toString(); 266 267 } 268 269 public void setValue(String value) throws ParseException { 270 throw new ParseException(value, 0); 271 272 } 273 274 275 public boolean equals(Object other) { 276 return (other instanceof PAccessNetworkInfoHeader) && super.equals(other); 277 } 278 279 /* 280 * Makes a deep clone. (ParametersHeader) 281 */ 282 public Object clone() { 283 PAccessNetworkInfo retval = (PAccessNetworkInfo) super.clone(); 284 return retval; 285 } 286 287 288 } 289