NIST-SIP: The Reference Implementation for JAIN-SIP 1.2

gov.nist.javax.sip.header
Class ContentLength

java.lang.Object
  extended by gov.nist.core.GenericObject
      extended by gov.nist.javax.sip.header.SIPObject
          extended by gov.nist.javax.sip.header.SIPHeader
              extended by gov.nist.javax.sip.header.ContentLength
All Implemented Interfaces:
HeaderExt, SIPHeaderNames, Serializable, Cloneable, ContentLengthHeader, Header

public class ContentLength
extends SIPHeader
implements ContentLengthHeader

ContentLength SIPHeader (of which there can be only one in a SIPMessage).

Fielding, et al.            Standards Track                   [Page 119]
RFC 2616                        HTTP/1.1                       June 1999


      14.13 Content-Length

   The Content-Length entity-header field indicates the size of the
   entity-body, in decimal number of OCTETs, sent to the recipient or,
   in the case of the HEAD method, the size of the entity-body that
   would have been sent had the request been a GET.

       Content-Length    = "Content-Length" ":" 1*DIGIT

   An example is

       Content-Length: 3495

   Applications SHOULD use this field to indicate the transfer-length of
   the message-body, unless this is prohibited by the rules in section
   4.4.

   Any Content-Length greater than or equal to zero is a valid value.
   Section 4.4 describes how to determine the length of a message-body
   if a Content-Length is not given.

   Note that the meaning of this field is significantly different from
   the corresponding definition in MIME, where it is an optional field
   used within the "message/external-body" content-type. In HTTP, it
   SHOULD be sent whenever the message's length can be determined prior
   to being transferred, unless this is prohibited by the rules in
   section 4.4.
 

Since:
1.1
Version:
1.2 $Revision: 1.6 $ $Date: 2009/07/17 18:57:29 $
Author:
M. Ranganathan
, Olivier Deruelle
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface javax.sip.header.ContentLengthHeader
NAME
 
Fields inherited from interface gov.nist.javax.sip.header.SIPHeaderNames
ACCEPT, ACCEPT_ENCODING, ACCEPT_LANGUAGE, ALERT_INFO, ALLOW, ALLOW_EVENTS, AUTHENTICATION_INFO, AUTHORIZATION, CALL_ID, CALL_INFO, CONTACT, CONTENT_DISPOSITION, CONTENT_ENCODING, CONTENT_LANGUAGE, CONTENT_LENGTH, CONTENT_TYPE, CSEQ, DATE, ERROR_INFO, EVENT, EXPIRES, FROM, IN_REPLY_TO, JOIN, MAX_FORWARDS, MIME_VERSION, MIN_EXPIRES, MIN_SE, ORGANIZATION, PRIORITY, PROXY_AUTHENTICATE, PROXY_AUTHORIZATION, PROXY_REQUIRE, RACK, REASON, RECORD_ROUTE, REFERRED_BY, REPLACES, REPLY_TO, REQUIRE, RETRY_AFTER, ROUTE, RSEQ, SERVER, SESSION_EXPIRES, SIP_ETAG, SIP_IF_MATCH, SUBJECT, SUBSCRIPTION_STATE, SUPPORTED, TIMESTAMP, TO, UNSUPPORTED, USER_AGENT, VIA, WARNING, WWW_AUTHENTICATE
 
Constructor Summary
ContentLength()
          Default constructor.
ContentLength(int length)
          Constructor given a length.
 
Method Summary
 String encodeBody()
          Encode into a canonical string.
 boolean equals(Object other)
          An introspection based equality predicate for SIPObjects.
 int getContentLength()
          get the ContentLength field.
 boolean match(Object other)
          Pattern matcher ignores content length.
 void setContentLength(int contentLength)
          Set the contentLength member
 
Methods inherited from class gov.nist.javax.sip.header.SIPHeader
encode, encode, getHeaderName, getHeaderValue, getName, getValue, hashCode, isHeaderList, setHeaderName, toString
 
Methods inherited from class gov.nist.javax.sip.header.SIPObject
dbgPrint, debugDump, debugDump
 
Methods inherited from class gov.nist.core.GenericObject
clone, getClassFromName, getMatcher, isMySubclass, makeClone, merge, setMatcher
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.sip.header.Header
clone, getName, hashCode, toString
 

Constructor Detail

ContentLength

public ContentLength()
Default constructor.


ContentLength

public ContentLength(int length)
Constructor given a length.

Method Detail

getContentLength

public int getContentLength()
get the ContentLength field.

Specified by:
getContentLength in interface ContentLengthHeader
Returns:
int

setContentLength

public void setContentLength(int contentLength)
                      throws InvalidArgumentException
Set the contentLength member

Specified by:
setContentLength in interface ContentLengthHeader
Parameters:
contentLength - int to set
Throws:
InvalidArgumentException - if contentLength is less than zero.

encodeBody

public String encodeBody()
Encode into a canonical string.

Returns:
String

match

public boolean match(Object other)
Pattern matcher ignores content length.

Overrides:
match in class SIPObject
Parameters:
other - the match pattern to test against. The match object has to be of the same type (class). Primitive types and non-sip fields that are non null are matched for equality. Null in any field matches anything. Some book-keeping fields are ignored when making the comparison.

equals

public boolean equals(Object other)
Description copied from class: SIPObject
An introspection based equality predicate for SIPObjects.

Specified by:
equals in interface Header
Overrides:
equals in class SIPObject
Parameters:
other - the other object to test against.
Returns:
true if the objects are euqal and false otherwise

NIST-SIP: The Reference Implementation for JAIN-SIP 1.2

A product of the NIST/ITL Advanced Networking Technologies Division.
See conditions of use.
Submit a bug report or feature request.