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

AddressParametersHeader

public abstract class AddressParametersHeader extends ParametersHeader
An abstract class for headers that take an address and parameters.
version
JAIN-SIP-1.1 This code is in the public domain.

Fields Summary
protected Address
address
Saved address.
Constructors Summary
protected AddressParametersHeader(String name)
Constructor given the name of the header.

param
name header to process

        super(name);
    
Methods Summary
public java.lang.Objectclone()
Copies the current instance.

return
copy of currrent object

        Exception ex = null;
        try {
            AddressParametersHeader retval =
                    (AddressParametersHeader) this.getClass().newInstance();
            if (this.address != null)
                retval.address = (Address) this.address.clone();
            if (this.parameters != null)
                retval.parameters = (NameValueList) this.parameters.clone();
            return retval;
        } catch (InstantiationException ie) {
            ex = ie;
        } catch (IllegalAccessException iae) {
            ex = iae;
        }
        if (ex != null) {
            InternalErrorHandler.handleException(ex);
        }
        return null;
    
public java.lang.StringencodeBody()
Encode the header content into a String.

return
String

        if (address == null) {
            throw new RuntimeException("No body!");
        }
        StringBuffer retval = new StringBuffer();
        if (address.getAddressType() != Address.NAME_ADDR) {
            retval .append("<");
        }
        retval .append(address.encode());
        if (address.getAddressType() != Address.NAME_ADDR) {
            retval .append(">");
        }
        retval.append(encodeWithSep());
        return retval.toString();
    
public booleanequals(java.lang.Object other)
Compares obejct for equivalence.

param
other the object to compare
return
true if matches

        if (! other.getClass().equals(this.getClass()))
            return false;
        Address otherAddress = ((AddressParametersHeader) other).getAddress();
        if (otherAddress == null)
            return false;
        if (! otherAddress.equals(address)) {
            return false;
        }
        if (! parameters.equals
                (((AddressParametersHeader)other).parameters)) {
            return false;
        } else return true;
    
public AddressgetAddress()
Gets the Address field.

return
the imbedded Address

        return address;
    
public java.lang.StringgetDisplayName()
Gets the user friendly display name.

return
the display name

        return address.getDisplayName();
    
public HostPortgetHostPort()
Gets the host and port name.

return
host:port

        return address.getHostPort();
    
public java.lang.StringgetUserAtHostPort()
Gets the user at host and port name.

return
user@host:port

        return address.getUserAtHostPort();
    
public java.lang.ObjectgetValue()
Gets the address value.

return
the address value

        return address;
    
public voidsetAddress(Address address)
Sets the Address field.

param
address Address to set

        this.address = (Address) address;
    
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.

        Header header;
        StringMsgParser smp = new StringMsgParser();
        String strNewHeader = getName() + Separators.COLON + value;

        try {
            header = smp.parseHeader(strNewHeader);

            if (header instanceof HeaderList) {
                header = ((HeaderList)header).getFirst();
            }

            setAddress(((AddressParametersHeader)header).getAddress());
        } catch (ParseException e) {
            throw new IllegalArgumentException(e.toString());
        }