| 1 |
/******************************************************************************* |
| 2 |
* Product of NIST/ITL Advanced Networking Technologies Division (ANTD). * |
| 3 |
*******************************************************************************/ |
| 4 |
/* |
| 5 |
* This code has been contributed by the author to the public domain. |
| 6 |
*/ |
| 7 |
package gov.nist.javax.sip.header.extensions; |
| 8 |
|
| 9 |
import java.text.ParseException; |
| 10 |
import gov.nist.javax.sip.header.*; |
| 11 |
|
| 12 |
import javax.sip.*; |
| 13 |
import javax.sip.header.ExtensionHeader; |
| 14 |
|
| 15 |
/** |
| 16 |
* MinSE SIP Header. |
| 17 |
* |
| 18 |
* (Created by modifying Expires.java) |
| 19 |
* |
| 20 |
* @version JAIN-SIP-1.1 $Revision: 1.4 $ $Date: 2009/10/18 13:46:36 $ |
| 21 |
* |
| 22 |
* @author P. Musgrave <[email protected]> <br/> |
| 23 |
* |
| 24 |
*/ |
| 25 |
public class MinSE |
| 26 |
extends ParametersHeader implements ExtensionHeader, MinSEHeader { |
| 27 |
|
| 28 |
// TODO: When the MinSEHeader is added to javax - move this there...pmusgrave |
| 29 |
public static final String NAME = "Min-SE"; |
| 30 |
|
| 31 |
/** |
| 32 |
* Comment for <code>serialVersionUID</code> |
| 33 |
*/ |
| 34 |
private static final long serialVersionUID = 3134344915465784267L; |
| 35 |
|
| 36 |
/** expires field |
| 37 |
*/ |
| 38 |
public int expires; |
| 39 |
|
| 40 |
/** default constructor |
| 41 |
*/ |
| 42 |
public MinSE() { |
| 43 |
super(NAME); |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* Return canonical form. |
| 48 |
* @return String |
| 49 |
*/ |
| 50 |
public String encodeBody() { |
| 51 |
String retval = Integer.toString(expires); // seems overkill - but Expires did this. |
| 52 |
|
| 53 |
if (!parameters.isEmpty()) { |
| 54 |
retval += SEMICOLON + parameters.encode(); |
| 55 |
} |
| 56 |
return retval; |
| 57 |
} |
| 58 |
|
| 59 |
public void setValue(String value) throws ParseException { |
| 60 |
// not implemented. |
| 61 |
throw new ParseException(value,0); |
| 62 |
|
| 63 |
} |
| 64 |
|
| 65 |
/** |
| 66 |
* Gets the expires value of the ExpiresHeader. This expires value is |
| 67 |
* |
| 68 |
* relative time. |
| 69 |
* |
| 70 |
* |
| 71 |
* |
| 72 |
* @return the expires value of the ExpiresHeader. |
| 73 |
* |
| 74 |
* @since JAIN SIP v1.1 |
| 75 |
* |
| 76 |
*/ |
| 77 |
public int getExpires() { |
| 78 |
return expires; |
| 79 |
} |
| 80 |
|
| 81 |
/** |
| 82 |
* Sets the relative expires value of the ExpiresHeader. |
| 83 |
* The expires value MUST be greater than zero and MUST be |
| 84 |
* less than 2**31. |
| 85 |
* |
| 86 |
* @param expires - the new expires value of this ExpiresHeader |
| 87 |
* |
| 88 |
* @throws InvalidArgumentException if supplied value is less than zero. |
| 89 |
* |
| 90 |
* @since JAIN SIP v1.2 |
| 91 |
* |
| 92 |
*/ |
| 93 |
public void setExpires(int expires) throws InvalidArgumentException { |
| 94 |
if (expires < 0) |
| 95 |
throw new InvalidArgumentException("bad argument " + expires); |
| 96 |
this.expires = expires; |
| 97 |
} |
| 98 |
} |