Debian Codegraph @

java/gov/nist/javax/sip/header/extensions/Join.java

raw
1 /*******************************************************************************
2 * Product of NIST/ITL Advanced Networking Technologies Division (ANTD). *
3 *******************************************************************************/
4 package gov.nist.javax.sip.header.extensions;
5 import java.text.ParseException;
6 import gov.nist.javax.sip.header.*;
7
8 import javax.sip.header.ExtensionHeader;
9 /*
10 * This code is in the public domain.
11 */
12
13 /**
14 * Join SIPHeader.
15 *
16 * @author [email protected] <br/>
17 *
18 * @version JAIN-SIP-1.2
19 *
20 *
21 */
22
23 public class Join
24 extends ParametersHeader implements ExtensionHeader, JoinHeader {
25
26 /**
27 *
28 */
29 private static final long serialVersionUID = -840116548918120056L;
30
31 public static final String NAME = "Join";
32
33 /**
34 * callIdentifier field
35 */
36 public CallIdentifier callIdentifier;
37 public String callId;
38
39 /**
40 * Default constructor
41 */
42 public Join() {
43 super(NAME);
44 }
45
46 /** Constructor given the call Identifier.
47 *@param callId string call identifier (should be localid@host)
48 *@throws IllegalArgumentException if call identifier is bad.
49 */
50 public Join(String callId) throws IllegalArgumentException {
51 super(NAME);
52 this.callIdentifier = new CallIdentifier(callId);
53 }
54
55 /**
56 * Encode the body part of this header (i.e. leave out the hdrName).
57 * @return String encoded body part of the header.
58 */
59 public String encodeBody() {
60 if (callId == null)
61 return null;
62 else {
63 String retVal = callId;
64 if (!parameters.isEmpty()) {
65 retVal += SEMICOLON + parameters.encode();
66 }
67 return retVal;
68 }
69 }
70
71 /**
72 * get the CallId field. This does the same thing as encodeBody
73 *
74 * @return String the encoded body part of the
75 */
76 public String getCallId() {
77 return callId;
78 }
79
80 /**
81 * get the call Identifer member.
82 * @return CallIdentifier
83 */
84 public CallIdentifier getCallIdentifer() {
85 return callIdentifier;
86 }
87
88 /**
89 * set the CallId field
90 * @param cid String to set. This is the body part of the Call-Id
91 * header. It must have the form localId@host or localId.
92 * @throws IllegalArgumentException if cid is null, not a token, or is
93 * not a token@token.
94 */
95 public void setCallId(String cid) {
96 callId = cid;
97 }
98
99 /**
100 * Set the callIdentifier member.
101 * @param cid CallIdentifier to set (localId@host).
102 */
103 public void setCallIdentifier(CallIdentifier cid) {
104 callIdentifier = cid;
105 }
106
107 /**
108 * Get the to-tag parameter from the address parm list.
109 * @return tag field
110 */
111 public String getToTag() {
112 if (parameters == null)
113 return null;
114 return getParameter(ParameterNames.TO_TAG);
115 }
116 /**
117 * Set the to-tag member
118 * @param t tag to set. From tags are mandatory.
119 */
120 public void setToTag(String t) throws ParseException {
121 if (t == null)
122 throw new NullPointerException("null tag ");
123 else if (t.trim().equals(""))
124 throw new ParseException("bad tag", 0);
125 this.setParameter(ParameterNames.TO_TAG, t);
126 }
127 /** Boolean function
128 * @return true if the Tag exist
129 */
130 public boolean hasToTag() {
131 return hasParameter(ParameterNames.TO_TAG);
132 }
133
134 /** remove Tag member
135 */
136 public void removeToTag() {
137 parameters.delete(ParameterNames.TO_TAG);
138 }
139 /**
140 * Get the from-tag parameter from the address parm list.
141 * @return tag field
142 */
143 public String getFromTag() {
144 if (parameters == null)
145 return null;
146 return getParameter(ParameterNames.FROM_TAG);
147 }
148 /**
149 * Set the to-tag member
150 * @param t tag to set. From tags are mandatory.
151 */
152 public void setFromTag(String t) throws ParseException {
153 if (t == null)
154 throw new NullPointerException("null tag ");
155 else if (t.trim().equals(""))
156 throw new ParseException("bad tag", 0);
157 this.setParameter(ParameterNames.FROM_TAG, t);
158 }
159 /** Boolean function
160 * @return true if the Tag exist
161 */
162 public boolean hasFromTag() {
163 return hasParameter(ParameterNames.FROM_TAG);
164 }
165
166 /** remove Tag member
167 */
168 public void removeFromTag() {
169 parameters.delete(ParameterNames.FROM_TAG);
170 }
171
172
173
174 public void setValue(String value) throws ParseException {
175 // not implemented.
176 throw new ParseException(value,0);
177
178 }
179
180 // public Object clone() {
181 // CallID retval = (CallID) super.clone();
182 // if (this.callIdentifier != null)
183 // retval.setCallIdentifier( (CallIdentifier) this.callIdentifier.clone() );
184 // return retval;
185 // }
186 }
187