/* * Conditions Of Use * * This software was developed by employees of the National Institute of * Standards and Technology (NIST), an agency of the Federal Government. * Pursuant to title 15 Untied States Code Section 105, works of NIST * employees are not subject to copyright protection in the United States * and are considered to be in the public domain. As a result, a formal * license is not needed to use the software. * * This software is provided by NIST as a service and is expressly * provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED * OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT * AND DATA ACCURACY. NIST does not warrant or make any representations * regarding the use of the software or the results thereof, including but * not limited to the correctness, accuracy, reliability or usefulness of * the software. * * Permission to use this software is contingent upon your acceptance * of the terms of this agreement * * . * */ /******************************************* * PRODUCT OF PT INOVACAO - EST DEPARTMENT * *******************************************/ package gov.nist.javax.sip.header.ims; import java.text.ParseException; import javax.sip.header.ExtensionHeader; import gov.nist.javax.sip.header.ims.PChargingVectorHeader; import gov.nist.javax.sip.header.ims.ParameterNamesIms; /** * P-Charging-Vector header SIP Private Header: RFC 3455. * * @author ALEXANDRE MIGUEL SILVA SANTOS */ public class PChargingVector extends gov.nist.javax.sip.header.ParametersHeader implements PChargingVectorHeader, SIPHeaderNamesIms, ExtensionHeader { /** * Default Constructor */ public PChargingVector() { super(P_CHARGING_VECTOR); } /* * (non-Javadoc) * * @see gov.nist.javax.sip.header.ParametersHeader#encodeBody() */ protected String encodeBody() { StringBuffer encoding = new StringBuffer(); /* * no need to check for the presence of icid-value. According to the * spec above this is a mandatory field. if it does not exist, then we * should throw an exception * * JvB 26/5: fix for issue #159, check for quotes around icid value */ gov.nist.core.NameValue nv = getNameValue( ParameterNamesIms.ICID_VALUE ); nv.encode( encoding ); //the remaining parameters are optional. // check for their presence, then add the parameter if it exists. if (parameters.containsKey(ParameterNamesIms.ICID_GENERATED_AT)) encoding.append(SEMICOLON).append( ParameterNamesIms.ICID_GENERATED_AT).append(EQUALS).append( getICIDGeneratedAt()); if (parameters.containsKey(ParameterNamesIms.TERM_IOI)) encoding.append(SEMICOLON).append(ParameterNamesIms.TERM_IOI) .append(EQUALS).append(getTerminatingIOI()); if (parameters.containsKey(ParameterNamesIms.ORIG_IOI)) encoding.append(SEMICOLON).append(ParameterNamesIms.ORIG_IOI) .append(EQUALS).append(getOriginatingIOI()); return encoding.toString(); } /** *
* Get the icid-value parameter value *
* * @return the value of the icid-value parameter */ public String getICID() { return getParameter(ParameterNamesIms.ICID_VALUE); } /** ** Set the icid-value parameter *
* * @param icid - * value to set in the icid-value parameter * @throws ParseException */ public void setICID(String icid) throws ParseException { if (icid == null) throw new NullPointerException( "JAIN-SIP Exception, " + "P-Charging-Vector, setICID(), the icid parameter is null."); setParameter(ParameterNamesIms.ICID_VALUE, icid); } /** ** Get the icid-generated-at parameter value *
* * @return the icid-generated-at parameter value */ public String getICIDGeneratedAt() { return getParameter(ParameterNamesIms.ICID_GENERATED_AT); } /** ** Set the icid-generated-at parameter *
* * @param host - * value to set in the icid-generated-at parameter * @throws ParseException */ public void setICIDGeneratedAt(String host) throws ParseException { if (host == null) throw new NullPointerException( "JAIN-SIP Exception, " + "P-Charging-Vector, setICIDGeneratedAt(), the host parameter is null."); setParameter(ParameterNamesIms.ICID_GENERATED_AT, host); } /** ** Get the orig-ioi parameter value *
* * @return the orig-ioi parameter value */ public String getOriginatingIOI() { return getParameter(ParameterNamesIms.ORIG_IOI); } /** ** Set the orig-ioi parameter *
* * @param origIOI - * value to set in the orig-ioi parameter. If value is null or * empty, the parameter is removed * @throws ParseException */ public void setOriginatingIOI(String origIOI) throws ParseException { if (origIOI == null || origIOI.length() == 0) { removeParameter(ParameterNamesIms.ORIG_IOI); } else setParameter(ParameterNamesIms.ORIG_IOI, origIOI); } /** ** Get the term-ioi parameter value *
* * @return the term-ioi parameter value */ public String getTerminatingIOI() { return getParameter(ParameterNamesIms.TERM_IOI); } /** ** Set the term-ioi parameter *
* * @param termIOI - * value to set in the term-ioi parameter. If value is null or * empty, the parameter is removed * @throws ParseException */ public void setTerminatingIOI(String termIOI) throws ParseException { if (termIOI == null || termIOI.length() == 0) { removeParameter(ParameterNamesIms.TERM_IOI); } else setParameter(ParameterNamesIms.TERM_IOI, termIOI); } public void setValue(String value) throws ParseException { throw new ParseException(value, 0); } }