FileDocCategorySizeDatePackage
HostPort.javaAPI DocphoneME MR2 API (J2ME)4268Wed May 02 18:00:42 BST 2007gov.nist.core

HostPort

public final class HostPort extends Object
Holds the hostname:port.
version
JAIN-SIP-1.1 This code is in the public domain.

Fields Summary
protected Host
host
Host field.
protected Integer
port
Port field.
Constructors Summary
public HostPort()
Default constructor.

        
        host = null;
        port = null; // marker for not set.
    
Methods Summary
public java.lang.Objectclone()
Makes a copy of the current instance.

return
copy of current object

        HostPort retval = new HostPort();
        if (this.host != null) retval.host = (Host)this.host.clone();
        if (this.port != null) retval.port = new Integer
                (this.port.intValue());
        return retval;
    
public java.lang.Stringencode()
Encodes this hostport into its string representation. Note that this could be different from the string that has been parsed if something has been edited.

return
host and port encoded string

        StringBuffer retval = new StringBuffer();
        if (host != null)
            retval.append(host.encode());
        if (port != null)
            retval.append(':").append(port.toString());
        return retval.toString();
    
public booleanequals(java.lang.Object other)
Returns true if the two objects are equals, false otherwise.

param
other Object to set
return
boolean

        if (! this.getClass().equals(other.getClass())) {
            return false;
        }
        HostPort that = (HostPort) other;
        if ((this.port == null && that.port != null) ||
                (this.port != null && that.port == null))
            return false;
        else if (this.port == that.port && this.host.equals(that.host))
            return true;
        else
            return this.host.equals(that.host) && this.port.equals(that.port);
    
public HostgetHost()
Gets the Host field.

return
host field

        return host;
    
public intgetPort()
Gets the port field.

return
int

        if (port == null) {
            return -1;
        } else {
            return port.intValue();
        }
    
public booleanhasPort()
Returns boolean value indicating if Header has port

return
boolean value indicating if Header has port

        return  port != null;
    
public voidremovePort()
Removes the port.

        port = null;
    
public voidsetHost(Host h)
Sets the host member.

param
h Host to set

        host = h;
    
public voidsetPort(int p)
Sets the port member.

param
p int to set
throws
IllegalArgumentException in case of illegal port value

        if (p > 65535 || p < 0) {
            throw new IllegalArgumentException("Illegal port value " + p);
        }
        port = new Integer(p);