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

AcceptContactHeader

public class AcceptContactHeader extends ParametersHeader
The generic AcceptContact header

Fields Summary
public static Class
clazz
Handle for class.
public static final String
NAME
Accept-contact header field label.
Constructors Summary
public AcceptContactHeader()
Default constructor.

    
    
     
        clazz = new AcceptContactHeader().getClass();
    
        super(ACCEPT_CONTACT);
    
Methods Summary
public java.lang.Objectclone()
Clone - do a deep copy.

return
Object AcceptContactHeader

        try {
            AcceptContactHeader retval = (AcceptContactHeader)
                this.getClass().newInstance();
            if (this.parameters != null)
                retval.parameters = (NameValueList)parameters.clone();
            return retval;
        } catch (Exception ex) {
            InternalErrorHandler.handleException(ex);
            return null;
        }
    
public java.lang.StringencodeBody()
Encodes in canonical form.

return
canonical string.

        return Separators.STAR + encodeWithSep();
    
public booleanequals(java.lang.Object that)
Compares for equivalence.

param
that object to compare
return
true if object matches

        if (! that.getClass().equals(this.getClass())) {
            return false;
        } else {
            AcceptContactHeader other = (AcceptContactHeader) that;
            return this.parameters.equals(other.parameters);
        }
    
public java.lang.StringgetParameter(java.lang.String name)
Returns the value of the named parameter, or null if it is not set. A zero-length String indicates flag parameter.

param
name name of parameter to retrieve
return
the value of specified parameter

        String returnValue = super.getParameter(name);
        if (returnValue != null) { // remove quotes
            returnValue = returnValue.substring(1, returnValue.length() - 1);
        }
        return returnValue;
    
public java.lang.StringgetType()
Returns the value of the "type" parameter, or null if it is not set.

return
the value of specified parameter

        return getParameter(SIPConstants.GENERAL_TYPE);
    
public java.lang.ObjectgetValue()
Gets the header value.

return
the content type

        return Separators.STAR;
    
public voidsetParameter(NameValue nv)
Sets the specified parameter.

param
nv parameter's name/value pair

        Object val = nv.getValue();
        setParameter(nv.getName(), (val == null) ? null : val.toString());
    
public voidsetParameter(java.lang.String name, java.lang.String value)
Sets the specified parameter.

param
name name of the parameter
param
value value of the parameter.

        NameValue nv =
                super.parameters.getNameValue(name.toLowerCase());
            
        if (value == null) {
            throw new NullPointerException("null value");
        }
        
        boolean quoteStart = value.startsWith(Separators.DOUBLE_QUOTE);
        boolean quoteEnd = value.endsWith(Separators.DOUBLE_QUOTE);
        
        if ((quoteStart && !quoteEnd) || (!quoteStart && quoteEnd)) {
            throw new IllegalArgumentException
                (value + " : Unexpected DOUBLE_QUOTE");
        }
        
        if (quoteStart) { // quoteEnd is true in this case
            value = value.substring(1, value.length() - 1);
        }
        
        if (nv == null) {
            nv = new NameValue(name.toLowerCase(), value);

            nv.setQuotedValue();
            super.setParameter(nv);
        
        } else {
            nv.setValue(value);
        }

    
public voidsetType(java.lang.String value)
Sets the "type" parameter.

param
value value of the parameter.

        setParameter(SIPConstants.GENERAL_TYPE, value);