Home | History | Annotate | Download | only in ims
      1 package gov.nist.javax.sip.header.ims;
      2 /*
      3 * Conditions Of Use
      4 *
      5 * This software was developed by employees of the National Institute of
      6 * Standards and Technology (NIST), an agency of the Federal Government.
      7 * Pursuant to title 15 Untied States Code Section 105, works of NIST
      8 * employees are not subject to copyright protection in the United States
      9 * and are considered to be in the public domain.  As a result, a formal
     10 * license is not needed to use the software.
     11 *
     12 * This software is provided by NIST as a service and is expressly
     13 * provided "AS IS."  NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED
     14 * OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF
     15 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT
     16 * AND DATA ACCURACY.  NIST does not warrant or make any representations
     17 * regarding the use of the software or the results thereof, including but
     18 * not limited to the correctness, accuracy, reliability or usefulness of
     19 * the software.
     20 *
     21 * Permission to use this software is contingent upon your acceptance
     22 * of the terms of this agreement
     23 *
     24 * .
     25 *
     26 */
     27 import java.text.ParseException;
     28 import gov.nist.javax.sip.header.SIPHeader;
     29 import javax.sip.header.ExtensionHeader;
     30 /**
     31  *
     32  * @author aayush.bhatnagar
     33  * Rancore Technologies Pvt Ltd, Mumbai India.
     34  *
     35  */
     36 public class PAssertedService extends SIPHeader implements PAssertedServiceHeader, SIPHeaderNamesIms, ExtensionHeader{
     37 
     38     private String subServiceIds;
     39     private String subAppIds;
     40 
     41     protected PAssertedService(String name) {
     42         super(NAME);
     43     }
     44 
     45     public PAssertedService()
     46     {
     47         super(P_ASSERTED_SERVICE);
     48     }
     49 
     50     @Override
     51     protected String encodeBody() {
     52         StringBuffer retval = new StringBuffer();
     53 
     54          retval.append(ParameterNamesIms.SERVICE_ID);
     55 
     56             if(this.subServiceIds!=null)
     57             {
     58                 retval.append(ParameterNamesIms.SERVICE_ID_LABEL).append(".");
     59 
     60             retval.append(this.getSubserviceIdentifiers());
     61             }
     62 
     63             else if(this.subAppIds!=null)
     64             {
     65                 retval.append(ParameterNamesIms.APPLICATION_ID_LABEL).append(".");
     66                 retval.append(this.getApplicationIdentifiers());
     67             }
     68 
     69         return retval.toString();
     70     }
     71 
     72     public void setValue(String value) throws ParseException {
     73         throw new ParseException(value,0);
     74 
     75     }
     76 
     77     public String getApplicationIdentifiers() {
     78         if(this.subAppIds.charAt(0)=='.')
     79         {
     80             return this.subAppIds.substring(1);
     81         }
     82         return this.subAppIds;
     83     }
     84 
     85     public String getSubserviceIdentifiers() {
     86         if(this.subServiceIds.charAt(0)=='.')
     87         {
     88             return this.subServiceIds.substring(1);
     89         }
     90         return this.subServiceIds;
     91     }
     92     public void setApplicationIdentifiers(String appids) {
     93         this.subAppIds = appids;
     94 
     95     }
     96 
     97     public void setSubserviceIdentifiers(String subservices) {
     98         this.subServiceIds = subservices;
     99 
    100     }
    101 
    102     public boolean equals(Object other)
    103     {
    104         return (other instanceof PAssertedServiceHeader) && super.equals(other);
    105 
    106     }
    107 
    108 
    109     public Object clone() {
    110         PAssertedService retval = (PAssertedService) super.clone();
    111         return retval;
    112     }
    113 
    114 
    115 }
    116