Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
  * Conditions Of Use
  *
  * This software was developed by employees of the National Institute of
  * Standards and Technology (NIST), an agency of the Federal Government.
  * Pursuant to title 15 Untied States Code Section 105, works of NIST
  * employees are not subject to copyright protection in the United States
  * and are considered to be in the public domain.  As a result, a formal
  * license is not needed to use the software.
 *
 * This software is provided by NIST as a service and is expressly
 * provided "AS IS."  NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED
 * OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT
 * AND DATA ACCURACY.  NIST does not warrant or make any representations
 * regarding the use of the software or the results thereof, including but
 * not limited to the correctness, accuracy, reliability or usefulness of
 * the software.
 *
 * Permission to use this software is contingent upon your acceptance
 * of the terms of this agreement
 *
 * .
 *
 */
Product of NIST/ITL Advanced Networking Technologies Division (ANTD). * /
 
 package gov.nist.javax.sip.header;
 
 
CSeq SIP Header.

Author(s):
M. Ranganathan
Version:
1.2 $Revision: 1.11 $ $Date: 2010-05-06 14:07:48 $
Since:
1.1
 
 
 public class CSeq extends SIPHeader implements javax.sip.header.CSeqHeader {

    
Comment for serialVersionUID
 
     private static final long serialVersionUID = -5405798080040422910L;

    
seqno field
 
     protected Long seqno;

    
method field
 
     protected String method;

    
Constructor.
 
     public CSeq() {
         super();
     }

    
Constructor given the sequence number and method.

Parameters:
seqno is the sequence number to assign.
method is the method string.
 
     public CSeq(long seqnoString method) {
         this();
         this. = Long.valueOf(seqno);
         this. = SIPRequest.getCannonicalName(method);
     }

    
Compare two cseq headers for equality.

Parameters:
other Object to compare against.
Returns:
true if the two cseq headers are equals, false otherwise.
 
     public boolean equals(Object other) {
 
         if (other instanceof CSeqHeader) {
             final CSeqHeader o = (CSeqHeaderother;
             return this.getSeqNumber() == o.getSeqNumber()
                 && this.getMethod().equalso.getMethod() );
         }
         return false;
     }

    
Return canonical encoded header.

Returns:
String with canonical encoded header.
    public String encode() {
        return  +  +  + encodeBody() + ;
    }

    
Return canonical header content. (encoded header except headerName:)

Returns:
encoded string.
    public String encodeBody() {
        return encodeBody(new StringBuilder()).toString();
    }
    protected StringBuilder encodeBody(StringBuilder buffer) {
        return buffer.append().append().append(.toUpperCase());
    }

    
Get the method.

Returns:
String the method.
    public String getMethod() {
        return ;
    }
    /*
     * (non-Javadoc)
     * @see javax.sip.header.CSeqHeader#setSequenceNumber(long)
     */
    public void setSeqNumber(long sequenceNumber)
        throws InvalidArgumentException {
        if (sequenceNumber < 0 )
            throw new InvalidArgumentException(
                "JAIN-SIP Exception, CSeq, setSequenceNumber(), "
                    + "the sequence number parameter is < 0 : " + sequenceNumber);
        else if ( sequenceNumber >  ((long)1)<<32 - 1)
            throw new InvalidArgumentException(
                    "JAIN-SIP Exception, CSeq, setSequenceNumber(), "
                        + "the sequence number parameter is too large : " + sequenceNumber);
         = Long.valueOf(sequenceNumber);
    }

    
For backwards compatibility
    public void setSequenceNumber(int sequenceNumberthrows InvalidArgumentException {
        this.setSeqNumber( (longsequenceNumber );
    }
    /*
     * (non-Javadoc)
     * @see javax.sip.header.CSeqHeader#setMethod(java.lang.String)
     */
    public void setMethod(String meththrows ParseException {
        if (meth == null)
            throw new NullPointerException(
                "JAIN-SIP Exception, CSeq"
                    + ", setMethod(), the meth parameter is null");
        this. = SIPRequest.getCannonicalName(meth);
    }
    /*
     * (non-Javadoc)
     * @see javax.sip.header.CSeqHeader#getSequenceNumber()
     */
    public int getSequenceNumber() {
        if (this. == null)
            return 0;
        else
            return this..intValue();
    }
    public long getSeqNumber() {
        return this..longValue();
    }
New to GrepCode? Check out our FAQ X