Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
  * Conditions Of Use
  *
  * This software was developed by employees of the National Institute of
  * Standards and Technology (NIST), an agency of the Federal Government.
  * Pursuant to title 15 Untied States Code Section 105, works of NIST
  * employees are not subject to copyright protection in the United States
  * and are considered to be in the public domain.  As a result, a formal
  * license is not needed to use the software.
 *
 * This software is provided by NIST as a service and is expressly
 * provided "AS IS."  NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED
 * OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT
 * AND DATA ACCURACY.  NIST does not warrant or make any representations
 * regarding the use of the software or the results thereof, including but
 * not limited to the correctness, accuracy, reliability or usefulness of
 * the software.
 *
 * Permission to use this software is contingent upon your acceptance
 * of the terms of this agreement
 *
 * .
 *
 */
Product of NIST/ITL Advanced Networking Technologies Division (ANTD). * /
 
 package gov.nist.javax.sip.header;
 
ContentType SIP Header
14.17 Content-Type

   The Content-Type entity-header field indicates the media type of the
   entity-body sent to the recipient or, in the case of the HEAD method,
   the media type that would have been sent had the request been a GET.

   Content-Type   = "Content-Type" ":" media-type

   Media types are defined in section 3.7. An example of the field is

       Content-Type: text/html; charset=ISO-8859-4

   Further discussion of methods for identifying the media type of an
   entity is provided in section 7.2.1.

 From  HTTP RFC 2616
 

Author(s):
M. Ranganathan
Olivier Deruelle
Version:
1.2
1.2 $Revision: 1.7 $ $Date: 2009/07/17 18:57:29 $
Since:
1.1
 
 public class ContentType
     extends ParametersHeader
     implements javax.sip.header.ContentTypeHeader {

    
Comment for serialVersionUID
 
     private static final long serialVersionUID = 8475682204373446610L;
    
mediaRange field.
 
     protected MediaRange mediaRange;

    
Default constructor.
 
     public ContentType() {
         super();
     }

    
Constructor given a content type and subtype.

Parameters:
contentType is the content type.
contentSubtype is the content subtype
 
     public ContentType(String contentTypeString contentSubtype) {
         this();
         this.setContentType(contentTypecontentSubtype);
     }

    
compare two MediaRange headers.

Parameters:
media String to set
Returns:
int.
 
     public int compareMediaRange(String media) {
         return (
             . + "/" + .).compareToIgnoreCase(
             media);
     }

    
Encode into a canonical string.

Returns:
String.
    public String encodeBody() {
        return encodeBody(new StringBuffer()).toString();
    }
    protected StringBuffer encodeBody(StringBuffer buffer) {
        .encode(buffer);
        if (hasParameters()) {
            buffer.append();
            .encode(buffer);
        }
        return buffer;
    }

    
get the mediaRange field.

Returns:
MediaRange.
    public MediaRange getMediaRange() {
        return ;
    }

    
get the Media Type.

Returns:
String.
    public String getMediaType() {
        return .;
    }

    
get the MediaSubType field.

Returns:
String.
    public String getMediaSubType() {
        return .;
    }

    
Get the content subtype.

Returns:
the content subtype string (or null if not set).
    public String getContentSubType() {
        return  == null ? null : .getSubtype();
    }

    
Get the content subtype.

Returns:
the content tyep string (or null if not set).
    public String getContentType() {
        return  == null ? null : .getType();
    }

    
Get the charset parameter.
    public String getCharset() {
        return this.getParameter("charset");
    }

    
Set the mediaRange member

Parameters:
m mediaRange field.
    public void setMediaRange(MediaRange m) {
         = m;
    }

    
set the content type and subtype.

Parameters:
contentType Content type string.
contentSubType content subtype string
    public void setContentType(String contentTypeString contentSubType) {
        if ( == null)
             = new MediaRange();
        .setType(contentType);
        .setSubtype(contentSubType);
    }

    
set the content type.

Parameters:
contentType Content type string.
    public void setContentType(String contentTypethrows ParseException {
        if (contentType == null)
            throw new NullPointerException("null arg");
        if ( == null)
             = new MediaRange();
        .setType(contentType);
    }

    
Set the content subtype.

Parameters:
contentType String to set
    public void setContentSubType(String contentTypethrows ParseException {
        if (contentType == null)
            throw new NullPointerException("null arg");
        if ( == null)
             = new MediaRange();
        .setSubtype(contentType);
    }
    public Object clone() {
        ContentType retval = (ContentTypesuper.clone();
        if (this. != null)
            retval.mediaRange = (MediaRangethis..clone();
        return retval;
    }
    public boolean equals(Object other) {
        if (other instanceof ContentTypeHeader) {
            final ContentTypeHeader o = (ContentTypeHeaderother;
            return this.getContentType().equalsIgnoreCaseo.getContentType() )
                && this.getContentSubType().equalsIgnoreCaseo.getContentSubType() )
                && equalParameterso );
        }
        return false;
    }
New to GrepCode? Check out our FAQ X