• 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 java.text.ParseException;
32 
33 /**
34  * Content encoding part of a content encoding header list.
35  * @see ContentEncodingList
36  *<pre>
37  * From HTTP RFC 2616
38  *14.11 Content-Encoding
39  *
40  *   The Content-Encoding entity-header field is used as a modifier to the
41  *   media-type. When present, its value indicates what additional content
42  *   codings have been applied to the entity-body, and thus what decoding
43  *   mechanisms must be applied in order to obtain the media-type
44  *   referenced by the Content-Type header field. Content-Encoding is
45  *   primarily used to allow a document to be compressed without losing
46  *   the identity of its underlying media type.
47  *
48  *       Content-Encoding  = "Content-Encoding" ":" 1#content-coding
49  *
50  *   Content codings are defined in section 3.5. An example of its use is
51  *
52  *       Content-Encoding: gzip
53  *
54  *   The content-coding is a characteristic of the entity identified by
55  *   the Request-URI. Typically, the entity-body is stored with this
56  *   encoding and is only decoded before rendering or analogous usage.
57  *   However, a non-transparent proxy MAY modify the content-coding if the
58  *   new coding is known to be acceptable to the recipient, unless the
59  *   "no-transform" cache-control directive is present in the message.
60  *
61  *   If the content-coding of an entity is not "identity", then the
62  *   response MUST include a Content-Encoding entity-header (section
63  *   14.11) that lists the non-identity content-coding(s) used.
64  *
65  *   If the content-coding of an entity in a request message is not
66  *   acceptable to the origin server, the server SHOULD respond with a
67  *   status code of 415 (Unsupported Media Type).
68  *
69  *   If multiple encodings have been applied to an entity, the content
70  *   codings MUST be listed in the order in which they were applied.
71  *   Additional information about the encoding parameters MAY be provided
72  *   by other entity-header fields not defined by this specification.
73  *</pre>
74  *
75  * @author M. Ranganathan   <br/>
76  * @author Olivier Deruelle <br/>
77  * @version 1.2 $Revision: 1.5 $ $Date: 2009/07/17 18:57:29 $
78  * @since 1.1
79  */
80 public class ContentEncoding
81     extends SIPHeader
82     implements javax.sip.header.ContentEncodingHeader {
83 
84     /**
85      * Comment for <code>serialVersionUID</code>
86      */
87     private static final long serialVersionUID = 2034230276579558857L;
88     /**
89      * ContentEncoding field.
90      */
91     protected String contentEncoding;
92 
93     /**
94      * Default constructor.
95      */
ContentEncoding()96     public ContentEncoding() {
97         super(CONTENT_ENCODING);
98     }
99 
100     /**
101      * Constructor.
102      * @param enc String to set.
103      */
ContentEncoding(String enc)104     public ContentEncoding(String enc) {
105         super(CONTENT_ENCODING);
106         contentEncoding = enc;
107     }
108 
109     /**
110      * Canonical encoding of body of the header.
111      * @return  encoded body of the header.
112      */
encodeBody()113     public String encodeBody() {
114         return contentEncoding;
115     }
116 
117     /**
118      * Get the ContentEncoding field.
119      * @return String
120      */
getEncoding()121     public String getEncoding() {
122         return contentEncoding;
123     }
124 
125     /**
126      * Set the ConentEncoding field.
127      * @param encoding String to set
128      */
setEncoding(String encoding)129     public void setEncoding(String encoding) throws ParseException {
130         if (encoding == null)
131             throw new NullPointerException(
132                 "JAIN-SIP Exception, " + " encoding is null");
133         contentEncoding = encoding;
134     }
135 }
136