FileDocCategorySizeDatePackage
Authority.javaAPI DocphoneME MR2 API (J2ME)6282Wed May 02 18:00:42 BST 2007gov.nist.siplite.address

Authority

public class Authority extends GenericObject
Authority part of a URI structure. Section 3.2.2 RFC2396
version
JAIN-SIP-1.1 This code is in the public domain.

Fields Summary
protected HostPort
hostPort
Host and port field.
protected UserInfo
userInfo
User information field.
Constructors Summary
Methods Summary
public java.lang.Objectclone()
Copies the object contents

return
the copy of this object

        Authority retval = new Authority();

        try {
          retval.setUser(getUser());
          retval.setPassword(getPassword());
        } catch (IllegalArgumentException e) {
          // intentionally ignored
          // it shoild be impossible to get here due to getUser()
          // and getPassword() return verified values
        }
        retval.setHostPort(getHostPort());

        return retval;
    
public java.lang.Stringencode()
Returns the host name in encoded form.

return
encoded string (does the same thing as toString)

        StringBuffer retval = new StringBuffer();

        if (userInfo != null) {
            String user = userInfo.encode();
            if (user != null) {
                retval.append(user).append(Separators.AT);
            }
        }

        if (hostPort != null) {
            retval.append(hostPort.encode());
        }

        return retval.toString();
    
public booleanequals(java.lang.Object other)
Returns true if the two Objects are equals , false otherwise.

param
other Object to test.
return
true if objects match

        if (!other.getClass().getName().equals(this.getClass().getName())) {
            return false;
        }
        Authority otherAuth = (Authority) other;
        if (! this.hostPort.equals(otherAuth.hostPort)) {
            return false;
        }
        if (this.userInfo != null && otherAuth.userInfo != null) {
            if (! this.userInfo.equals(otherAuth.userInfo)) {
                return false;
            }
        }
        return true;
    
public HostgetHost()
Gets the host name.

return
Host (null if not set)

        if (hostPort == null)
            return null;
        else
            return hostPort.getHost();
    
public HostPortgetHostPort()
Gets the host and port member.

return
the host and port

        return hostPort;
    
public java.lang.StringgetPassword()
Gets the password from the user informatio.

return
the password

        if (userInfo == null) {
            return null;
        } else {
            return userInfo.getPassword();
        }
    
public intgetPort()
Gets the port.

return
port (-1) if port is not set.

        if (hostPort == null)
            return -1;
        else
            return hostPort.getPort();
    
public java.lang.StringgetUser()
Gets the user name if it exists.

return
user or null if not set.

        return (userInfo != null) ? userInfo.getUser() : null;
    
public UserInfogetUserInfo()
Gets the user information memnber.

return
the user information

        return userInfo;
    
public voidremovePort()
Removes the port.

        if (hostPort != null) {
            hostPort.removePort();
        }
    
public voidremoveUserInfo()
Removes the user information.

        userInfo = null;
    
public voidsetHost(Host host)
Sets the host.

param
host Host to set

        if (hostPort == null) {
            hostPort = new HostPort();
        }

        hostPort.setHost(host);
    
public voidsetHostPort(HostPort h)
Sets the host and port member.

param
h HostPort to set

        hostPort = h;
    
public voidsetPassword(java.lang.String passwd)
Sets the password.

param
passwd String to set
throws
IllegalArgumentException if password contains invalid characters

        if (userInfo == null) userInfo = new UserInfo();
        userInfo.setPassword(passwd);
    
public voidsetPort(int port)
Sets the port.

param
port int to set

        if (hostPort == null) {
            hostPort = new HostPort();
        }
        hostPort.setPort(port);
    
public voidsetUser(java.lang.String user)
Sets the user name of the user information member.

param
user String to set
throws
IllegalArgumentException if user name contains invalid characters

        if (userInfo == null) {
            userInfo = new UserInfo();
        }

        userInfo.setUser(user);
    
public voidsetUserInfo(UserInfo u)
Sets the user information member.

param
u UserInfo to set

        userInfo = u;