• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 /*******************************************************************************
3 * Product of NIST/ITL Advanced Networking Technologies Division (ANTD).        *
4 *******************************************************************************/
5 
6 package gov.nist.javax.sip.header.extensions;
7 
8 import gov.nist.javax.sip.header.ParametersHeader;
9 
10 import java.text.ParseException;
11 
12 import javax.sip.InvalidArgumentException;
13 import javax.sip.header.ExtensionHeader;
14 
15 /**
16  * ReferredBy SIP Header.
17  *
18  * @version JAIN-SIP-1.1 $Revision: 1.5 $ $Date: 2009/10/18 13:46:36 $
19  *
20  * @author Peter Musgrave.
21  *
22  */
23 public final class SessionExpires
24     extends ParametersHeader implements ExtensionHeader, SessionExpiresHeader {
25 
26     // TODO: Need a unique UID
27     private static final long serialVersionUID = 8765762413224043300L;
28 
29     // TODO: When the MinSEHeader is added to javax - move this there...pmusgrave
30     public static final String NAME = "Session-Expires";
31 
32     public int expires;
33 
34     public static final String REFRESHER = "refresher";
35     /** default Constructor.
36      */
SessionExpires()37     public SessionExpires() {
38         super(NAME);
39     }
40 
41     /**
42      * Gets the expires value of the SessionExpiresHeader. This expires value is
43      * relative time.
44      *
45      *
46      *
47      * @return the expires value of the ExpiresHeader.
48      *
49      * @since JAIN SIP v1.1
50      *
51      */
getExpires()52     public int getExpires() {
53         return expires;
54     }
55 
56     /**
57      * Sets the relative expires value of the SessionExpiresHeader.
58      * The expires value MUST be greater than zero and MUST be
59      * less than 2**31.
60      *
61      * @param expires - the new expires value
62      *
63      * @throws InvalidArgumentException if supplied value is less than zero.
64      *
65      * @since JAIN SIP v1.1
66      *
67      */
setExpires(int expires)68     public void setExpires(int expires) throws InvalidArgumentException {
69         if (expires < 0)
70             throw new InvalidArgumentException("bad argument " + expires);
71         this.expires = expires;
72     }
73 
setValue(String value)74     public void setValue(String value) throws ParseException {
75         // not implemented.
76         throw new ParseException(value,0);
77 
78     }
79 
80     /**
81      * Encode the header content into a String.
82      * @return String
83      */
encodeBody()84     protected String encodeBody() {
85 
86         String retval = Integer.toString(expires);
87 
88         if (!parameters.isEmpty()) {
89             retval += SEMICOLON + parameters.encode();
90         }
91         return retval;
92     }
93 
getRefresher()94     public String getRefresher() {
95        return parameters.getParameter(REFRESHER);
96     }
97 
setRefresher(String refresher)98     public void setRefresher(String refresher) {
99         this.parameters.set(REFRESHER,refresher);
100     }
101 }
102 
103 
104 
105