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

ContentLengthHeader

public class ContentLengthHeader extends ParameterLessHeader
ContentLengthHeader Header (of which there can be only one in a SIPMessage).
Format:
Content-Length = "Content-Length" ":" 1*DIGIT
For details please see RFC 2616, section 14.13
IMPL_NOTE: think about removing the specific parser for ContentLengthHeader.

Fields Summary
protected Integer
contentLength
Content length field.
public static final String
NAME
Conten length header field label.
protected static Class
clazz
Handle for class.
Constructors Summary
public ContentLengthHeader()
Default constructor.

    
    
     
        clazz = new ContentLengthHeader().getClass();
    
        super(CONTENT_LENGTH);
    
public ContentLengthHeader(int length)
Constructor given a length.

param
length the initial content length

        super(CONTENT_LENGTH);
        this.contentLength = new Integer(length);
        this.headerValue = String.valueOf(contentLength.intValue());
    
Methods Summary
public java.lang.Objectclone()
Copies the cirrent instance.

return
copy of the current object

        ContentLengthHeader retval = new ContentLengthHeader();
        
        if (contentLength != null) {
            retval.contentLength =
                    new Integer(contentLength.intValue());
        }
        
        return retval;
    
public java.lang.StringencodeBody()
Encodes into a canonical string.

return
String

        if (contentLength == null)
            return "0";
        else
            return contentLength.toString();
    
public intgetContentLength()
Gets the content length header field.

return
the content length

        return contentLength.intValue();
    
public java.lang.ObjectgetValue()
Gets the content length header value.

return
the content length

        return this.contentLength;
    
public voidsetContentLength(int contentLength)
Sets the content length member.

param
contentLength int to set

        if (contentLength < 0)
            throw new IllegalArgumentException("parameter is <0");
        
        this.contentLength = new Integer(contentLength);
        this.headerValue = String.valueOf(contentLength);
    
public voidsetHeaderValue(java.lang.String value)
Sets the header value field.

param
value is the value field to set.
throws
IllegalArgumentException if the value is invalid.

        int val;
                
        try {
            val = Integer.parseInt(value);
            setContentLength(val);
        } catch (IllegalArgumentException iae) {
            throw iae;
        }