Debian Codegraph @

java/gov/nist/javax/sip/header/AlertInfo.java

raw
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 * Product of NIST/ITL Advanced Networking Technologies Division (ANTD) *
26 *******************************************************************************/
27 package gov.nist.javax.sip.header;
28
29 import java.text.ParseException;
30
31 import gov.nist.javax.sip.address.*;
32 import javax.sip.address.*;
33
34 /**
35 * AlertInfo SIP Header.
36 *
37 * @author M. Ranganathan <br/>
38 *
39 * @since 1.1
40 *
41 * @version 1.2 $Revision: 1.8 $ $Date: 2009/07/17 18:57:25 $
42 *
43 *
44 */
45 public final class AlertInfo
46 extends ParametersHeader
47 implements javax.sip.header.AlertInfoHeader {
48
49 /**
50 * Comment for <code>serialVersionUID</code>
51 */
52 private static final long serialVersionUID = 4159657362051508719L;
53 /** URI field
54 */
55 protected GenericURI uri;
56 /** String field
57 */
58 protected String string;
59
60 /** Constructor
61 */
62 public AlertInfo() {
63 super(NAME);
64 }
65
66 /**
67 * Return value encoding in canonical form.
68 * @return The value of the header in canonical encoding.
69 */
70 protected String encodeBody() {
71 StringBuffer encoding = new StringBuffer();
72 if (uri != null) {
73 encoding.append(LESS_THAN).append(uri.encode()).append(GREATER_THAN);
74 } else if (string != null) {
75 encoding.append(string);
76 }
77 if (!parameters.isEmpty()) {
78 encoding.append(SEMICOLON).append(parameters.encode());
79 }
80 return encoding.toString();
81 }
82
83 /**
84 * Set the uri member
85 * @param uri URI to set
86 */
87 public void setAlertInfo(URI uri) {
88 this.uri = (GenericURI) uri;
89 }
90
91 /**
92 * Set the string member
93 * @param string String to set
94 */
95 public void setAlertInfo(String string) {
96 this.string = string;
97 }
98
99 /**
100 * Returns the AlertInfo value of this AlertInfoHeader.
101 * @return the URI representing the AlertInfo.
102 */
103 public URI getAlertInfo() {
104 URI alertInfoUri = null;
105
106 if (this.uri != null) {
107 alertInfoUri = (URI) this.uri;
108 } else {
109 try {
110 alertInfoUri = (URI) new GenericURI(string);
111 } catch (ParseException e) {
112 ; // Eat the exception.
113 }
114 }
115
116 return alertInfoUri;
117 }
118
119 public Object clone() {
120 AlertInfo retval = (AlertInfo) super.clone();
121 if (this.uri != null) {
122 retval.uri = (GenericURI) this.uri.clone();
123 } else if (this.string != null) {
124 retval.string = this.string;
125 }
126 return retval;
127 }
128 }