FileDocCategorySizeDatePackage
ContentTypeHeader.javaAPI DocphoneME MR2 API (J2ME)6004Wed May 02 18:00:42 BST 2007gov.nist.siplite.header

ContentTypeHeader

public class ContentTypeHeader extends ParametersHeader
ContentTypeHeader 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.

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

For details please see RFC 2616, section 14.17
version
JAIN-SIP-1.1 This code is in the public domain.

Fields Summary
protected MediaRange
mediaRange
Media range header field.
public static Class
clazz
Handle for class.
public static final String
NAME
Media range header field label.
Constructors Summary
public ContentTypeHeader()
Default constructor.

    
    
     
        clazz = new ContentTypeHeader().getClass();
    
        super(CONTENT_TYPE);
    
public ContentTypeHeader(String contentType, String contentSubtype)
Constructor given a content type and subtype.

param
contentType is the content type.
param
contentSubtype is the content subtype

        this();
        this.setContentType(contentType, contentSubtype);
    
Methods Summary
public java.lang.Objectclone()
Copies the current instance.

return
copy od the current object

        ContentTypeHeader retval = new ContentTypeHeader();
        retval.parameters = (NameValueList) this.parameters.clone();
        retval.mediaRange = (MediaRange)this.mediaRange.clone();
        return retval;
    
public intcompareMediaRange(java.lang.String media)
Compares two MediaRange headers.

param
media String to set
return
int.

        return compareToIgnoreCase
                (mediaRange.type + "/" + mediaRange.subtype, media);
    
public java.lang.StringencodeBody()
Encodes into a canonical string.

return
String.

        if (hasParameters())
            return new StringBuffer(mediaRange.encode())
            .append(encodeWithSep()).toString();
        else return mediaRange.encode();
    
public java.lang.StringgetCharset()
Gets the charset parameter.

return
the content type header value

        return this.getParameter("charset");
    
public java.lang.StringgetContentSubType()
Gets the content subtype.

return
the content subtype string (or null if not set).

        return mediaRange == null ? null : mediaRange.getSubtype();
    
public java.lang.StringgetContentTypeHeader()
Get the content subtype.

return
the content tyep string (or null if not set).

        return mediaRange == null ? null : mediaRange.getType();
    
public MediaRangegetMediaRange()
Gets the mediaRange field.

return
MediaRange.

        return mediaRange;
    
public java.lang.StringgetMediaSubType()
Gets the MediaSubType field.

return
String.

        return mediaRange.subtype;
    
public java.lang.StringgetMediaType()
Gets the Media Type.

return
String.

        return mediaRange.type;
    
public java.lang.ObjectgetValue()
Gets the content type header value.

return
the content type

        return this.mediaRange;
    
public voidsetContentSubType(java.lang.String contentType)
Sets the content subtype.

param
contentType String to set

        if (contentType == null)
            throw new NullPointerException("null arg");
        if (mediaRange == null) mediaRange = new MediaRange();
        mediaRange.setSubtype(contentType);
    
public voidsetContentType(java.lang.String contentType, java.lang.String contentSubType)
Sets the content type and subtype.

param
contentType Content type string.
param
contentSubType content subtype string

        if (mediaRange == null) mediaRange = new MediaRange();
        mediaRange.setType(contentType);
        mediaRange.setSubtype(contentSubType);
    
public voidsetContentType(java.lang.String contentType)
Sets the content type.

param
contentType Content type string.

        if (contentType == null)
            throw new NullPointerException("null arg");
        if (mediaRange == null) mediaRange = new MediaRange();
        mediaRange.setType(contentType);
    
public voidsetMediaRange(MediaRange m)
Sets the mediaRange member

param
m mediaRange field.

        mediaRange = m;