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

RAckHeader

public class RAckHeader extends ParameterLessHeader
RAck Header. The RAck header is sent in a PRACK request to support reliability of provisional responses. For details please see RFC 3262, section 7.2

Fields Summary
public static Class
clazz
Class handle.
public static final String
NAME
Sequence header.
protected Integer
responseNum
response number - it is actually a value of RSeq header in the reliable provisional response
protected Integer
cseqNum
CSeq number : value of CSeq header field
protected String
method
method name
Constructors Summary
public RAckHeader()
Constructor.

        super(RACK);
    
public RAckHeader(int responseNumber, int cseqNumber, String method)
Constructor given the sequence number and method.

param
responseNumber is the response number to assign.
param
cseqNumber is the CSeq number to assign.
param
method is the method string.

        this();
        responseNum = new Integer(responseNumber);
        cseqNum = new Integer(cseqNumber);
        method = method;
    
Methods Summary
public java.lang.Objectclone()
Copies the current instance.

return
copy of current object

        RAckHeader retval = new RAckHeader();

        if (this.responseNum != null)
            retval.responseNum = new Integer(this.responseNum.intValue());
        if (this.cseqNum != null)
            retval.cseqNum = new Integer(this.cseqNum.intValue());
        retval.method = this.method;

        return retval;
    
public java.lang.StringencodeBody()
Return canonical header content. (encoded header except headerName:)

return
encoded string.

        return responseNum + Separators.SP +
                cseqNum + Separators.SP + method.toUpperCase();
    
public booleanequals(java.lang.Object other)
Compare two RAck headers for equality. Equality of RAck headers means that the class, method, response number and cseq number are same for both the headers

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

        if (! other.getClass().equals(this.getClass())) {
            return false;
        }
        RAckHeader that = (RAckHeader) other;
        if (! this.responseNum.equals(that.responseNum)) {
            return false;
        }
        if (! this.cseqNum.equals(that.cseqNum)) {
            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 intgetResponseNumber()
Gets the response number of this RAckHeaderHeader.

return
response number of the RAckHeaderHeader

        if (this.responseNum == null)
            return 0;
        else return this.responseNum.intValue();
    
public intgetSequenceNumber()
Gets the sequence number of this RAckHeaderHeader.

return
sequence number of the RAckHeaderHeader

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

return
the header value

        return responseNum + Separators.SP +
               cseqNum + 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    newResponseNo;
        int    newSeqNo;
        String newMethod;
        String strCseqMethod;

        value = value.trim();

        // Check if the sequence number presents
        int delimIndex1 = value.indexOf(' ");
        if (delimIndex1 == -1) {
            throw new IllegalArgumentException("Invalid value");
        }

        try {
            String strResponse = value.substring(0, delimIndex1).trim();
            newResponseNo = Integer.parseInt(strResponse);
            setResponseNumber(newResponseNo);
        } catch (IllegalArgumentException iae) {
            throw iae;
        }

        strCseqMethod = value.substring(delimIndex1, value.length()).trim();
        int delimIndex2 = strCseqMethod.indexOf(' ");
        if (delimIndex2 == -1) {
            throw new IllegalArgumentException("Invalid value");
        }

        try {
            String strCseq = strCseqMethod.substring(0, delimIndex2).trim();
            newSeqNo = Integer.parseInt(strCseq);
            setSequenceNumber(newSeqNo);
        } catch (IllegalArgumentException iae) {
            throw iae;
        }

        newMethod = strCseqMethod.substring(delimIndex2,
            strCseqMethod.length()).trim();
        setMethod(newMethod);
    
public voidsetMethod(java.lang.String newMethod)
Set the method member

param
newMethod Method to be set

        if (newMethod == null)
            throw new NullPointerException("parameter is null");
        method = newMethod;
    
public voidsetResponseNumber(int responseNumber)
Sets the response number of this RAckHeaderHeader.

param
responseNumber is the response number to be set

        if (responseNumber < 0)
            throw new IllegalArgumentException
                    ("the sequence number parameter is < 0");
        responseNum = new Integer(responseNumber);
    
public voidsetSequenceNumber(int sequenceNumber)
Sets the sequence number of this RAckHeaderHeader. 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");
        cseqNum = new Integer(sequenceNumber);