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

CSeqHeader

public class CSeqHeader extends ParameterLessHeader
CSeqHeader SIP Header. This code is in the public domain.
version
JAIN-SIP-1.1

Fields Summary
public static Class
clazz
Class handle.
public static final String
NAME
Sequence header.
protected Integer
seqno
seqno field
protected String
method
method field
Constructors Summary
public CSeqHeader()
Constructor.

        super(CSEQ);
    
public CSeqHeader(int seqno, String method)
Constructor given the sequence number and method.

param
seqno is the sequence number to assign.
param
method is the method string.

        this();
        this.seqno = new Integer(seqno);
        this.method = method;
    
Methods Summary
public java.lang.Objectclone()
Copies the current instance.

return
copy of current object

        CSeqHeader retval = new CSeqHeader();
        
        if (this.seqno != null)
            retval.seqno = new Integer(this.seqno.intValue());
        retval.method = this.method;
        
        return retval;
    
public java.lang.StringencodeBody()
Return canonical header content. (encoded header except headerName:)

return
encoded string.

        return seqno + Separators.SP + method.toUpperCase();
    
public booleanequals(java.lang.Object other)
Compare two cseq headers for equality.

param
other Object to compare against.
return
true if the two cseq headers are equals, false otherwise.

        if (! other.getClass().equals(this.getClass())) {
            return false;
        }
        CSeqHeader that = (CSeqHeader) other;
        if (! this.seqno.equals(that.seqno)) {
            return false;
        }
        if (! equalsIgnoreCase(this.method, that.method)) {
            return false;
        }
        return true;
    
public java.lang.StringgetMethod()
Get the method.

return
String the method.

        return method.toUpperCase();
    
public NameValueListgetParameters()
Gets the parameters.

return
name value list

        return null;
    
public intgetSequenceNumber()
Gets the sequence number of this CSeqHeaderHeader.

return
sequence number of the CSeqHeaderHeader

        if (this.seqno == null)
            return 0;
        else return this.seqno.intValue();
    
public java.lang.ObjectgetValue()
Gets the header value.

return
the header value

        return seqno + Separators.SP + method.toUpperCase();
    
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    newSeqNo;
        String newMethod;
        
        value = value.trim();
        
        // Check if the sequence number presents
        int delimIndex = value.indexOf(' ");
        
        if (delimIndex == -1) {
            // IMPL_NOTE: set some flag to indicate that
            //       the Sequence Number is not set.
            setMethod(value.trim());
            return;
        }
        
               
        try {
            String strNum = value.substring(0, delimIndex).trim();
            newSeqNo = Integer.parseInt(strNum);
            setSequenceNumber(newSeqNo);
        } catch (IllegalArgumentException iae) {
            throw iae;
        }
        
        newMethod = value.substring(delimIndex, value.length()).trim();
        setMethod(newMethod);
    
public voidsetMethod(java.lang.String meth)
Set the method member

param
meth -- String to set

        if (meth == null)
            throw new NullPointerException("parameter is null");
        method = meth;
    
public voidsetSequenceNumber(int sequenceNumber)
Sets the sequence number of this CSeqHeaderHeader. The sequence number MUST be expressible as a 32-bit unsigned integer and MUST be less than 2**31.

param
sequenceNumber - the sequence number to set.
throws
InvalidArgumentException -- if the seq number is <= 0

        if (sequenceNumber < 0)
            throw new IllegalArgumentException
                    ("the sequence number parameter is < 0");
        seqno = new Integer(sequenceNumber);