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 java.text.*;
32 
33 /**
34  * Content Dispositon SIP Header.
35  *
36  * @author M. Ranganathan   <br/>
37  * @version 1.2 $Revision: 1.5 $ $Date: 2009/07/17 18:57:29 $
38  * @since 1.1
39  *
40  */
41 public final class ContentDisposition
42     extends ParametersHeader
43     implements javax.sip.header.ContentDispositionHeader {
44 
45     /**
46      * Comment for <code>serialVersionUID</code>
47      */
48     private static final long serialVersionUID = 835596496276127003L;
49     /**
50      * DispositionType field.
51      */
52     protected String dispositionType;
53 
54     /**
55      * Default constructor.
56      */
57     public ContentDisposition() {
58         super(NAME);
59     }
60 
61     /**
62      * Encode value of header into canonical string.
63      * @return encoded value of header.
64      *
65      */
66     public String encodeBody() {
67         StringBuffer encoding = new StringBuffer(dispositionType);
68         if (!this.parameters.isEmpty()) {
69             encoding.append(SEMICOLON).append(parameters.encode());
70         }
71         return encoding.toString();
72     }
73 
74     /**
75      * Set the disposition type.
76      * @param dispositionType type.
77      */
78     public void setDispositionType(String dispositionType)
79         throws ParseException {
80         if (dispositionType == null)
81             throw new NullPointerException(
82                 "JAIN-SIP Exception"
83                     + ", ContentDisposition, setDispositionType(), the dispositionType parameter is null");
84         this.dispositionType = dispositionType;
85     }
86 
87     /**
88      * Get the disposition type.
89      * @return Disposition Type
90      */
91     public String getDispositionType() {
92         return this.dispositionType;
93     }
94 
95     /**
96      * Get the dispositionType field.
97      * @return String
98      */
99     public String getHandling() {
100         return this.getParameter("handling");
101     }
102 
103     /** set the dispositionType field.
104      * @param handling String to set.
105      */
106     public void setHandling(String handling) throws ParseException {
107         if (handling == null)
108             throw new NullPointerException(
109                 "JAIN-SIP Exception"
110                     + ", ContentDisposition, setHandling(), the handling parameter is null");
111         this.setParameter("handling", handling);
112     }
113 
114     /**
115      * Gets the interpretation of the message body or message body part of
116      * this ContentDispositionHeader.
117      *
118      * @return interpretation of the message body or message body part
119      */
120     public String getContentDisposition() {
121         return this.encodeBody();
122     }
123 }
124 /*
125  * $Log: ContentDisposition.java,v $
126  * Revision 1.5  2009/07/17 18:57:29  emcho
127  * Converts indentation tabs to spaces so that we have a uniform indentation policy in the whole project.
128  *
129  * Revision 1.4  2006/07/13 09:01:06  mranga
130  * Issue number:
131  * Obtained from:
132  * Submitted by:  jeroen van bemmel
133  * Reviewed by:   mranga
134  * Moved some changes from jain-sip-1.2 to java.net
135  *
136  * CVS: ----------------------------------------------------------------------
137  * CVS: Issue number:
138  * CVS:   If this change addresses one or more issues,
139  * CVS:   then enter the issue number(s) here.
140  * CVS: Obtained from:
141  * CVS:   If this change has been taken from another system,
142  * CVS:   then name the system in this line, otherwise delete it.
143  * CVS: Submitted by:
144  * CVS:   If this code has been contributed to the project by someone else; i.e.,
145  * CVS:   they sent us a patch or a set of diffs, then include their name/email
146  * CVS:   address here. If this is your work then delete this line.
147  * CVS: Reviewed by:
148  * CVS:   If we are doing pre-commit code reviews and someone else has
149  * CVS:   reviewed your changes, include their name(s) here.
150  * CVS:   If you have not had it reviewed then delete this line.
151  *
152  * Revision 1.3  2006/06/19 06:47:26  mranga
153  * javadoc fixups
154  *
155  * Revision 1.2  2006/06/16 15:26:28  mranga
156  * Added NIST disclaimer to all public domain files. Clean up some javadoc. Fixed a leak
157  *
158  * Revision 1.1.1.1  2005/10/04 17:12:34  mranga
159  *
160  * Import
161  *
162  *
163  * Revision 1.2  2004/01/22 13:26:29  sverker
164  * Issue number:
165  * Obtained from:
166  * Submitted by:  sverker
167  * Reviewed by:   mranga
168  *
169  * Major reformat of code to conform with style guide. Resolved compiler and javadoc warnings. Added CVS tags.
170  *
171  * CVS: ----------------------------------------------------------------------
172  * CVS: Issue number:
173  * CVS:   If this change addresses one or more issues,
174  * CVS:   then enter the issue number(s) here.
175  * CVS: Obtained from:
176  * CVS:   If this change has been taken from another system,
177  * CVS:   then name the system in this line, otherwise delete it.
178  * CVS: Submitted by:
179  * CVS:   If this code has been contributed to the project by someone else; i.e.,
180  * CVS:   they sent us a patch or a set of diffs, then include their name/email
181  * CVS:   address here. If this is your work then delete this line.
182  * CVS: Reviewed by:
183  * CVS:   If we are doing pre-commit code reviews and someone else has
184  * CVS:   reviewed your changes, include their name(s) here.
185  * CVS:   If you have not had it reviewed then delete this line.
186  *
187  */
188