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

ContactHeader

public final class ContactHeader extends AddressParametersHeader
Contact Item. There can be several (strung together in a ContactList). This code is in the public domain.

Fields Summary
public static Class
clazz
Class handle.
public static final String
NAME
Contact header field label.
public static final String
PARAM_EXPIRES
'expires' parameter label.
public static final String
PARAM_ACTION
'action' parameter label.
public static final String
PARAM_Q
'q' parameter label.
protected boolean
wildCardFlag
wildCardFlag field.
protected String
comment
comment field.
Constructors Summary
public ContactHeader()
Default constructor.

        super(CONTACT);
        wildCardFlag = false;
    
Methods Summary
public java.lang.Objectclone()
Clone - do a deep copy.

return
Object Contact

        ContactHeader retval = new ContactHeader();
        retval.wildCardFlag = this.wildCardFlag;
        if (this.comment != null) retval.comment = new String(this.comment);
        if (this.parameters != null)
            retval.parameters = (NameValueList)
            parameters.clone();
        if (this.address != null) retval.address = (Address)address.clone();
        return retval;
    
public java.lang.StringencodeBody()
Encode this into a cannonical String.

return
String

        String encoding = "";

        if (wildCardFlag) {
            return encoding + "*";
        }

        if (address != null) {
            // RFC 3261, p. 223, 228
            // addr-spec  =  SIP-URI / SIPS-URI / absoluteURI
            // SIP-URI    =  "sip:" [ userinfo ] hostport
            //                uri-parameters [ headers ]
            encoding += address.encode();

            /*
            if (address.getAddressType() == Address.NAME_ADDR) {
                encoding += address.encode();
            } else {
                // Encoding in canonical form must have <> around address.
                encoding += "<" + address.encode() + ">";
            }
            */
        }

        encoding += encodeWithSep();

        if (comment != null) {
            encoding += "(" + comment + ")";
        }

        return encoding;
    
public java.lang.StringgetAction()
get the Action field.

return
String

        return getParameter(PARAM_ACTION);
    
public java.lang.StringgetComment()
get the comment field

return
String

        return comment;
    
public java.lang.StringgetExpires()
get Expires field

return
String

        return getParameter(PARAM_EXPIRES);
    
public java.lang.StringgetQValue()
get the Q-value

return
String

        return getParameter(PARAM_Q);
    
public java.lang.ObjectgetValue()
get the address field.

return
Address

        return address;
    
public booleangetWildCardFlag()
get the WildCardFlag field

return
boolean

        return wildCardFlag;
    
public booleanhasQValue()
Returns true if Q-value is present.

return
true if this header has a Q-value, false otherwise.

        return hasParameter(PARAM_Q);
    
public voidsetAddress(Address newAddress)
Sets the address member.

param
newAddress Address to set

        if (newAddress != null) {
            address = newAddress;
        }
    
public voidsetComment(java.lang.String newComment)
Sets the comment member.

param
newComment String to set

        if (newComment != null) {
            comment = newComment;
        }
    
public voidsetExpires(java.lang.String expires)
Set the expiry time in seconds.

param
expires to set.

        setParameter(PARAM_EXPIRES, expires);
    
public voidsetExpires(int expires)
Set the expiry time in seconds.

param
expires to set.

        setParameter(PARAM_EXPIRES, new Integer(expires).toString());
    
public voidsetWildCardFlag(boolean w)
Sets the wildCardFlag member.

param
w boolean to set

        wildCardFlag = w;