FileDocCategorySizeDatePackage
SubscriptionStateHeader.javaAPI DocphoneME MR2 API (J2ME)6543Wed May 02 18:00:42 BST 2007gov.nist.siplite.header

SubscriptionStateHeader

public class SubscriptionStateHeader extends ParametersHeader
Subscription-State Header class.

RFC 3265, p. 36:
Subscription-State = "Subscription-State" HCOLON substate-value
*( SEMI subexp-params )
substate-value = "active" / "pending" / "terminated"
/ extension-substate
extension-substate = token
subexp-params = ("reason" EQUAL event-reason-value)
/ ("expires" EQUAL delta-seconds)
/ ("retry-after" EQUAL delta-seconds)
/ generic-param
event-reason-value = "deactivated"
/ "probation"
/ "rejected"
/ "timeout"
/ "giveup"
/ "noresource"
/ event-reason-extension
event-reason-extension = token

Fields Summary
public static Class
clazz
Class handle.
public static final String
NAME
SubscriptionState header field label.
public static final String
STATE_ACTIVE
'active' state label.
public static final String
STATE_PENDING
'pending' state label.
public static final String
STATE_TERMINATED
'terminated' state label.
public static final String
PARAM_REASON
'reason' parameter label.
public static final String
PARAM_EXPIRES
'expires' parameter label.
public static final String
PARAM_RETRY_AFTER
'retry-after' parameter label.
private String
state
Current subscription state.
Constructors Summary
public SubscriptionStateHeader()
Default constructor.


           
     
        clazz = new SubscriptionStateHeader().getClass();
    
        super(NAME);
    
public SubscriptionStateHeader(String subscriptionState)
Constructor given a state.

param
subscriptionState state of the subscription
throws
IllegalArgumentException if the subscriptionState is invalid.

        super(NAME);
        setState(subscriptionState);
    
Methods Summary
public java.lang.StringencodeBody()
Encode this into a cannonical String.

return
String

        if (state == null) {
            return "";
        }

        return state + encodeWithSep();
    
public java.lang.StringgetExpires()
Returns the subscription expiration time in seconds.

return
subscription expiration time.

        return getParameter(PARAM_EXPIRES);
    
public java.lang.StringgetState()
Returns the current subscription state.

return
subscription state.

        return state;
    
public java.lang.ObjectgetValue()
Returns the value of the current object, i.e., the subscription state.

return
subscription state.

        return state;
    
public booleanisActive()
Checks if the current subscription state is "active".

return
true if the subscription is active, false otherwise.

        if (state == null) {
            return false;
        }
        return state.equalsIgnoreCase(STATE_ACTIVE);
    
public booleanisTerminated()
Checks if the current subscription state is "terminated".

return
true if the subscription is terminated, false otherwise.

        if (state == null) {
            return false;
        }
        return state.equalsIgnoreCase(STATE_TERMINATED);
    
public voidsetExpires(java.lang.String expires)
Sets the subscription expiration time in seconds.

param
expires expiration time to set.
throws
IllegalArgumentException if the expires parameter is invalid.

        int intExpires;

        try {
          intExpires = Integer.parseInt(expires);
        } catch (NumberFormatException e) {
            intExpires = -1;
        }

        if (intExpires < 0) {
            throw new IllegalArgumentException("Invalid 'expires': " + expires);
        }

        setParameter(PARAM_EXPIRES, expires);
    
public voidsetExpires(int expires)
Sets the subscription expiration time in seconds.

param
expires expiration time to set.
throws
IllegalArgumentException if the expires parameter is invalid.

        if (expires < 0) {
            throw new IllegalArgumentException("Invalid 'expires': " + expires);
        }
        setParameter(PARAM_EXPIRES, new Integer(expires).toString());
    
public voidsetState(java.lang.String newState)
Sets the subscription state.

param
newState subscription state to set.
throws
IllegalArgumentException if the newState value is invalid.

        if (newState == null || newState.equals("")) {
            throw new IllegalArgumentException("Invalid state value: " +
                newState);
        }
        state = newState.trim();