| 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.*; |
| 32 |
|
| 33 |
/** |
| 34 |
* Expires SIP Header. |
| 35 |
* |
| 36 |
* @version 1.2 $Revision: 1.6 $ $Date: 2009/07/17 18:57:30 $ |
| 37 |
* @since 1.1 |
| 38 |
* |
| 39 |
* @author M. Ranganathan <br/> |
| 40 |
* |
| 41 |
* |
| 42 |
*/ |
| 43 |
public class Expires |
| 44 |
extends SIPHeader |
| 45 |
implements javax.sip.header.ExpiresHeader { |
| 46 |
|
| 47 |
/** |
| 48 |
* Comment for <code>serialVersionUID</code> |
| 49 |
*/ |
| 50 |
private static final long serialVersionUID = 3134344915465784267L; |
| 51 |
|
| 52 |
/** expires field |
| 53 |
*/ |
| 54 |
protected int expires; |
| 55 |
|
| 56 |
/** default constructor |
| 57 |
*/ |
| 58 |
public Expires() { |
| 59 |
super(NAME); |
| 60 |
} |
| 61 |
|
| 62 |
/** |
| 63 |
* Return canonical form. |
| 64 |
* @return String |
| 65 |
*/ |
| 66 |
public String encodeBody() { |
| 67 |
return encodeBody(new StringBuffer()).toString(); |
| 68 |
} |
| 69 |
|
| 70 |
protected StringBuffer encodeBody(StringBuffer buffer) { |
| 71 |
return buffer.append(expires); |
| 72 |
} |
| 73 |
|
| 74 |
/** |
| 75 |
* Gets the expires value of the ExpiresHeader. This expires value is |
| 76 |
* |
| 77 |
* relative time. |
| 78 |
* |
| 79 |
* |
| 80 |
* |
| 81 |
* @return the expires value of the ExpiresHeader. |
| 82 |
* |
| 83 |
* |
| 84 |
*/ |
| 85 |
public int getExpires() { |
| 86 |
return expires; |
| 87 |
} |
| 88 |
|
| 89 |
/** |
| 90 |
* Sets the relative expires value of the ExpiresHeader. |
| 91 |
* The expires value MUST be greater than zero and MUST be |
| 92 |
* less than 2**31. |
| 93 |
* |
| 94 |
* @param expires - the new expires value of this ExpiresHeader |
| 95 |
* |
| 96 |
* @throws InvalidArgumentException if supplied value is less than zero. |
| 97 |
* |
| 98 |
* |
| 99 |
*/ |
| 100 |
public void setExpires(int expires) throws InvalidArgumentException { |
| 101 |
if (expires < 0) |
| 102 |
throw new InvalidArgumentException("bad argument " + expires); |
| 103 |
this.expires = expires; |
| 104 |
} |
| 105 |
} |