Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
  * Conditions Of Use
  *
  * This software was developed by employees of the National Institute of
  * Standards and Technology (NIST), an agency of the Federal Government.
  * Pursuant to title 15 Untied States Code Section 105, works of NIST
  * employees are not subject to copyright protection in the United States
  * and are considered to be in the public domain.  As a result, a formal
  * license is not needed to use the software.
 *
 * This software is provided by NIST as a service and is expressly
 * provided "AS IS."  NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED
 * OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT
 * AND DATA ACCURACY.  NIST does not warrant or make any representations
 * regarding the use of the software or the results thereof, including but
 * not limited to the correctness, accuracy, reliability or usefulness of
 * the software.
 *
 * Permission to use this software is contingent upon your acceptance
 * of the terms of this agreement
 *
 * .
 *
 */
Product of NIST/ITL Advanced Networking Technologies Division (ANTD). * /
 
 package gov.nist.javax.sip.address;
Authority part of a URI structure. Section 3.2.2 RFC2396

Author(s):
M. Ranganathan
Version:
1.2 $Revision: 1.10 $ $Date: 2009/12/16 14:48:33 $
 
 public class Authority extends NetObject {
 
     private static final long serialVersionUID = -3570349777347017894L;

    
hostport field
 
     protected HostPort hostPort;

    
userInfo field
 
     protected UserInfo userInfo;

    
Return the host name in encoded form.

Returns:
encoded string (does the same thing as toString)
 
     public String encode() {
         return encode(new StringBuffer()).toString();
     }
 
     public StringBuffer encode(StringBuffer buffer) {
         if ( != null) {
             .encode(buffer);
             buffer.append();
             .encode(buffer);
         } else {
             .encode(buffer);
         }
         return buffer;
     }

    
retruns true if the two Objects are equals , false otherwise.

Parameters:
other Object to test.
Returns:
boolean
 
     @Override
     public boolean equals(Object other) {
         if (other == nullreturn false;
         if (other.getClass() != getClass()) {
             return false;
         }
         Authority otherAuth = (Authorityother;
         if (!this..equals(otherAuth.hostPort)) {
             return false;
         }
         if (this. != null && otherAuth.userInfo != null) {
             if (!this..equals(otherAuth.userInfo)) {
                 return false;
             }
         }
         return true;
     }

    
get the hostPort member.

Returns:
HostPort
 
     public HostPort getHostPort() {
        return ;
    }

    
get the userInfo memnber.

Returns:
UserInfo
    public UserInfo getUserInfo() {
        return ;
    }

    
Get password from the user info.

Returns:
String
    public String getPassword() {
        if ( == null)
            return null;
        else
            return .;
    }

    
Get the user name if it exists.

Returns:
String user or null if not set.
    public String getUser() {
        return  != null ? . : null;
    }

    
Get the host name.

Returns:
Host (null if not set)
    public Host getHost() {
        if ( == null)
            return null;
        else
            return .getHost();
    }

    
Get the port.

Returns:
int port (-1) if port is not set.
    public int getPort() {
        if ( == null)
            return -1;
        else
            return .getPort();
    }

    
remove the port.
    public void removePort() {
        if ( != null)
            .removePort();
    }

    
set the password.

Parameters:
passwd String to set
    public void setPassword(String passwd) {
        if ( == null)
             = new UserInfo();
        .setPassword(passwd);
    }

    
Set the user name of the userInfo member.

Parameters:
user String to set
    public void setUser(String user) {
        if ( == null)
             = new UserInfo();
        this..setUser(user);
    }

    
set the host.

Parameters:
host Host to set
    public void setHost(Host host) {
        if ( == null)
             = new HostPort();
        .setHost(host);
    }

    
Set the port.

Parameters:
port int to set
    public void setPort(int port) {
        if ( == null)
             = new HostPort();
        .setPort(port);
    }

    
Set the hostPort member

Parameters:
h HostPort to set
    public void setHostPort(HostPort h) {
         = h;
    }

    
Set the userInfo member

Parameters:
u UserInfo to set
    public void setUserInfo(UserInfo u) {
         = u;
    }

    
Remove the user Infor.
    public void removeUserInfo() {
        this. = null;
    }
    public Object clone() {
        Authority retval = (Authoritysuper.clone();
        if (this. != null)
            retval.hostPort = (HostPortthis..clone();
        if (this. != null)
            retval.userInfo = (UserInfothis..clone();
        return retval;
    }
    
    @Override
    public int hashCode() {
        if ( this. == null ) throw new UnsupportedOperationException("Null hostPort cannot compute hashcode");
        return this..encode().hashCode();
    }
New to GrepCode? Check out our FAQ X