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

MaxForwardsHeader

public class MaxForwardsHeader extends ParameterLessHeader
MaxForwards Header
version
JAIN-SIP-1.1 This code is in the public domain. IMPL_NOTE: think about removing the specific parser for MaxForwardsHeader.

Fields Summary
protected int
maxForwards
Max forwards field.
public static final String
NAME
Max forwards header field label.
public static final Class
clazz
Class handle.
Constructors Summary
public MaxForwardsHeader()
Default constructor.

    
     
        clazz = new MaxForwardsHeader().getClass();
    
        super(Header.MAX_FORWARDS, "");
    
Methods Summary
public voiddecrementMaxForwards()
Decrements max forwards field one by one.

        if (maxForwards >= 0) maxForwards--;
    
public java.lang.StringencodeBody()
Encodes into a string.

return
encoded string.

        return new Integer(maxForwards).toString();
    
public intgetMaxForwards()
Gets the MaxForwards field.

return
the maxForwards member.

        return maxForwards;
    
public java.lang.ObjectgetValue()
Gets the max forwards header field value.

return
the max forwards header field value

        return new Integer(maxForwards);
    
public booleanhasReachedZero()
Returns true if max forwards is zero.

return
true if MaxForwards field reached zero.

        return maxForwards == 0;
    
public voidsetHeaderValue(java.lang.String value)
Sets the header value field.

param
value is the value field to set.
throws
IllegalArgumentException if the value is invalid.

        int val;
                
        try {
            val = Integer.parseInt(value);
            setMaxForwards(val);
        } catch (IllegalArgumentException iae) {
            throw iae;
        }
    
public voidsetMaxForwards(int maxForwards)
Sets the maxForwards member.

param
maxForwards maxForwards parameter to set

        if (maxForwards < 0 || maxForwards > 255)
            throw new IllegalArgumentException
                    ("bad max forwards value " + maxForwards);
        this.maxForwards = maxForwards;