Home | History | Annotate | Download | only in header
      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 * Pursuant to title 15 Untied States Code Section 105, works of NIST
      7 * employees are not subject to copyright protection in the United States
      8 * and are considered to be in the public domain.  As a result, a formal
      9 * license is not needed to use the software.
     10 *
     11 * This software is provided by NIST as a service and is expressly
     12 * provided "AS IS."  NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED
     13 * OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF
     14 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT
     15 * AND DATA ACCURACY.  NIST does not warrant or make any representations
     16 * regarding the use of the software or the results thereof, including but
     17 * not limited to the correctness, accuracy, reliability or usefulness of
     18 * the software.
     19 *
     20 * Permission to use this software is contingent upon your acceptance
     21 * of the terms of this agreement
     22 *
     23 * .
     24 *
     25 */
     26 /*******************************************************************************
     27 * Product of NIST/ITL Advanced Networking Technologies Division (ANTD).        *
     28 *******************************************************************************/
     29 package gov.nist.javax.sip.header;
     30 import gov.nist.javax.sip.address.*;
     31 import java.text.ParseException;
     32 
     33 /**
     34  * CallInfo SIPHeader.
     35  *
     36  *
     37  * @author "M. Ranganathan"  <br/>
     38  * @version 1.2 $Revision: 1.7 $ $Date: 2009/07/17 18:57:28 $
     39  * @since 1.1
     40  */
     41 public final class CallInfo
     42     extends ParametersHeader
     43     implements javax.sip.header.CallInfoHeader {
     44 
     45     /**
     46      * Comment for <code>serialVersionUID</code>
     47      */
     48     private static final long serialVersionUID = -8179246487696752928L;
     49 
     50     protected GenericURI info;
     51 
     52     /**
     53      * Default constructor
     54      */
     55     public CallInfo() {
     56         super(CALL_INFO);
     57     }
     58 
     59     /**
     60      * Return canonical representation.
     61      * @return String
     62      */
     63     public String encodeBody() {
     64         return encodeBody(new StringBuffer()).toString();
     65     }
     66 
     67     protected StringBuffer encodeBody(StringBuffer buffer) {
     68         buffer.append(LESS_THAN);
     69         info.encode(buffer);
     70         buffer.append(GREATER_THAN);
     71 
     72         if (parameters != null && !parameters.isEmpty()) {
     73             buffer.append(SEMICOLON);
     74             parameters.encode(buffer);
     75         }
     76 
     77         return buffer;
     78     }
     79 
     80     /**
     81      * get the purpose field
     82      * @return String
     83      */
     84     public String getPurpose() {
     85         return this.getParameter("purpose");
     86     }
     87 
     88     /**
     89      * get the URI field
     90      * @return URI
     91      */
     92     public javax.sip.address.URI getInfo() {
     93         return info;
     94     }
     95 
     96     /**
     97      * set the purpose field
     98      * @param purpose is the purpose field.
     99      */
    100     public void setPurpose(String purpose) {
    101         if (purpose == null)
    102             throw new NullPointerException("null arg");
    103         try {
    104             this.setParameter("purpose", purpose);
    105         } catch (ParseException ex) {
    106         }
    107     }
    108 
    109     /**
    110      * set the URI field
    111      * @param info is the URI to set.
    112      */
    113     public void setInfo(javax.sip.address.URI info) {
    114         this.info = (GenericURI) info;
    115     }
    116 
    117     public Object clone() {
    118         CallInfo retval = (CallInfo) super.clone();
    119         if (this.info != null)
    120             retval.info = (GenericURI) this.info.clone();
    121         return retval;
    122     }
    123 }
    124