• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Conditions Of Use
3  *
4  * This software was developed by employees of the National Institute of
5  * Standards and Technology (NIST), an agency of the Federal Government.
6  * Pursuant to title 15 Untied States Code Section 105, works of NIST
7  * employees are not subject to copyright protection in the United States
8  * and are considered to be in the public domain.  As a result, a formal
9  * license is not needed to use the software.
10  *
11  * This software is provided by NIST as a service and is expressly
12  * provided "AS IS."  NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED
13  * OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF
14  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT
15  * AND DATA ACCURACY.  NIST does not warrant or make any representations
16  * regarding the use of the software or the results thereof, including but
17  * not limited to the correctness, accuracy, reliability or usefulness of
18  * the software.
19  *
20  * Permission to use this software is contingent upon your acceptance
21  * of the terms of this agreement
22  *
23  * .
24  *
25  */
26 /*******************************************************************************
27  * Product of NIST/ITL Advanced Networking Technologies Division (ANTD).        *
28  *******************************************************************************/
29 package gov.nist.javax.sip.header;
30 
31 import javax.sip.InvalidArgumentException;
32 import java.text.ParseException;
33 
34 /**
35  * RAck SIP Header implementation
36  *
37  * @version 1.2 $Revision: 1.7 $ $Date: 2009/07/17 18:57:34 $
38  *
39  * @author M. Ranganathan <br/>
40  *
41  *
42  */
43 public class RAck extends SIPHeader implements javax.sip.header.RAckHeader {
44 
45     /**
46      * Comment for <code>serialVersionUID</code>
47      */
48     private static final long serialVersionUID = 743999286077404118L;
49 
50     protected long cSeqNumber;
51 
52     protected long rSeqNumber;
53 
54     protected String method;
55 
56     /** Creates a new instance of RAck */
RAck()57     public RAck() {
58         super(NAME);
59     }
60 
61     /**
62      * Encode the body of this header (the stuff that follows headerName). A.K.A
63      * headerValue.
64      *
65      */
encodeBody()66     protected String encodeBody() {
67         // Bug reported by Bruno Konik - was encoded in
68         // the wrong order.
69         return new StringBuffer().append(rSeqNumber).append(SP).append(
70                 cSeqNumber).append(SP).append(method).toString();
71 
72     }
73 
74     /**
75      * Gets the CSeq sequence number of this RAckHeader.
76      *
77      * @deprecated
78      * @return the integer value of the cSeq number of the RAckHeader
79      */
getCSeqNumber()80     public int getCSeqNumber() {
81         return (int) cSeqNumber;
82     }
83 
84     /**
85      * Gets the CSeq sequence number of this RAckHeader.
86      *
87      * @return the integer value of the cSeq number of the RAckHeader
88      */
getCSeqNumberLong()89     public long getCSeqNumberLong() {
90         return cSeqNumber;
91     }
92 
93     /**
94      * Gets the method of RAckHeader
95      *
96      * @return method of RAckHeader
97      */
getMethod()98     public String getMethod() {
99         return this.method;
100     }
101 
102     /**
103      * Gets the RSeq sequence number of this RAckHeader.
104      *
105      * @deprecated
106      * @return the integer value of the RSeq number of the RAckHeader
107      */
getRSeqNumber()108     public int getRSeqNumber() {
109         return (int) rSeqNumber;
110     }
111 
112     /**
113      * @deprecated
114      * @see javax.sip.header.RAckHeader#setCSeqNumber(int)
115      */
setCSeqNumber(int cSeqNumber)116     public void setCSeqNumber(int cSeqNumber) throws InvalidArgumentException {
117         this.setCSequenceNumber(cSeqNumber);
118     }
119 
setMethod(String method)120     public void setMethod(String method) throws ParseException {
121         this.method = method;
122     }
123 
124 
getCSequenceNumber()125     public long getCSequenceNumber() {
126         return this.cSeqNumber;
127     }
128 
getRSequenceNumber()129     public long getRSequenceNumber() {
130         return this.rSeqNumber;
131     }
132 
setCSequenceNumber(long cSeqNumber)133     public void setCSequenceNumber(long cSeqNumber)
134             throws InvalidArgumentException {
135         if (cSeqNumber <= 0 || cSeqNumber > ((long) 1) << 32 - 1)
136             throw new InvalidArgumentException("Bad CSeq # " + cSeqNumber);
137         this.cSeqNumber = cSeqNumber;
138 
139     }
140 
141     /**
142      *@deprecated
143      * @see javax.sip.header.RAckHeader#setRSeqNumber(int)
144      */
setRSeqNumber(int rSeqNumber)145     public void setRSeqNumber(int rSeqNumber) throws InvalidArgumentException {
146         this.setRSequenceNumber(rSeqNumber);
147     }
148 
149 
setRSequenceNumber(long rSeqNumber)150     public void setRSequenceNumber(long rSeqNumber)
151             throws InvalidArgumentException {
152         if (rSeqNumber <= 0 || cSeqNumber > ((long) 1) << 32 - 1)
153             throw new InvalidArgumentException("Bad rSeq # " + rSeqNumber);
154         this.rSeqNumber = rSeqNumber;
155     }
156 }
157