• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
31 import gov.nist.javax.sip.address.*;
32 import javax.sip.header.*;
33 import javax.sip.address.*;
34 import java.text.ParseException;
35 
36 /**
37  * ErrorInfo SIP Header.
38  *
39  * @version 1.2 $Revision: 1.6 $ $Date: 2009/07/17 18:57:30 $
40  * @since 1.1
41  *
42  * @author M. Ranganathan   <br/>
43  * @author Olivier Deruelle <br/>
44  *
45  */
46 public final class ErrorInfo
47     extends ParametersHeader
48     implements ErrorInfoHeader {
49 
50     /**
51      * Comment for <code>serialVersionUID</code>
52      */
53     private static final long serialVersionUID = -6347702901964436362L;
54 
55     protected GenericURI errorInfo;
56 
57     /**
58      * Default constructor.
59      */
ErrorInfo()60     public ErrorInfo() {
61         super(NAME);
62     }
63 
64     /**
65      * Constructor given the error info
66      * @param errorInfo -- the error information to set.
67      */
ErrorInfo(GenericURI errorInfo)68     public ErrorInfo(GenericURI errorInfo) {
69         this();
70         this.errorInfo = errorInfo;
71     }
72 
73     /**
74      * Encode into canonical form.
75      * @return String
76      */
encodeBody()77     public String encodeBody() {
78         StringBuffer retval =
79             new StringBuffer(LESS_THAN).append(errorInfo.toString()).append(
80                 GREATER_THAN);
81         if (!parameters.isEmpty()) {
82             retval.append(SEMICOLON).append(parameters.encode());
83         }
84         return retval.toString();
85     }
86 
87     /**
88      * Sets the ErrorInfo of the ErrorInfoHeader to the <var>errorInfo</var>
89      * parameter value.
90      *
91      * @param errorInfo the new ErrorInfo of this ErrorInfoHeader.
92      */
setErrorInfo(javax.sip.address.URI errorInfo)93     public void setErrorInfo(javax.sip.address.URI errorInfo) {
94         this.errorInfo = (GenericURI) errorInfo;
95 
96     }
97 
98     /**
99      * Returns the ErrorInfo value of this ErrorInfoHeader. This message
100      * may return null if a String message identifies the ErrorInfo.
101      *
102      * @return the URI representing the ErrorInfo.
103      */
getErrorInfo()104     public URI getErrorInfo() {
105         return errorInfo;
106     }
107 
108     /**
109      * Sets the Error information message to the new <var>message</var> value
110      * supplied to this method.
111      *
112      * @param message - the new string value that represents the error message.
113      * @throws ParseException which signals that an error has been reached
114      * unexpectedly while parsing the error message.
115      */
setErrorMessage(String message)116     public void setErrorMessage(String message) throws ParseException {
117         if (message == null)
118             throw new NullPointerException(
119                 "JAIN-SIP Exception "
120                     + ", ErrorInfoHeader, setErrorMessage(), the message parameter is null");
121         setParameter("message", message);
122     }
123 
124     /**
125      * Get the Error information message of this ErrorInfoHeader.
126      *
127      * @return the stringified version of the ErrorInfo header.
128      */
getErrorMessage()129     public String getErrorMessage() {
130         return getParameter("message");
131     }
132 
clone()133     public Object clone() {
134         ErrorInfo retval = (ErrorInfo) super.clone();
135         if (this.errorInfo != null)
136             retval.errorInfo = (GenericURI) this.errorInfo.clone();
137         return retval;
138     }
139 }
140 
141