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.core;
 import java.net.*;

Holds the hostname:port.

Author(s):
M. Ranganathan
Version:
1.2
 
 public final class HostPort extends GenericObject {
 
 
     private static final long serialVersionUID = -7103412227431884523L;
 
     // host / ipv4/ ipv6/
     
host field
 
     protected Host host;

    
port field
 
     protected int port;

    
Default constructor
 
     public HostPort() {
 
          = null;
          = -1; // marker for not set.
     }

    
Encode this hostport into its string representation. Note that this could be different from the string that has been parsed if something has been edited.

Returns:
String
 
     public String encode() {
         return encode(new StringBuilder()).toString();
     }
 
     public StringBuilder encode(StringBuilder buffer) {
         .encode(buffer);
         if ( != -1)
             buffer.append().append();
         return buffer;
     }

    
returns true if the two objects are equals, false otherwise.

Parameters:
other Object to set
Returns:
boolean
 
     public boolean equals(Object other) {
         if (other == nullreturn false;
         if (getClass () != other.getClass ()) {
             return false;
         }
         HostPort that = (HostPortother;
         return  == that.port && .equals(that.host);
     }

    
get the Host field

Returns:
host field
 
     public Host getHost() {
         return ;
    }

    
get the port field

Returns:
int
    public int getPort() {
        return ;
    }

    
Returns boolean value indicating if Header has port

Returns:
boolean value indicating if Header has port
    public boolean hasPort() {
        return  != -1;
    }

    
remove port.
    public void removePort() {
         = -1;
    }

    
Set the host member

Parameters:
h Host to set
    public void setHost(Host h) {
         = h;
    }

    
Set the port member

Parameters:
p int to set
    public void setPort(int p) {
         = p;
    }

    
Return the internet address corresponding to the host.

Returns:
the inet address for the host.
Throws:
java.net.UnkownHostException if host name cannot be resolved.
        if ( == null)
            return null;
        else
            return .getInetAddress();
    }
    public void merge(Object mergeObject) {
        super.merge (mergeObject);
        if ( == -1)
             = ((HostPortmergeObject).;
    }
    public Object clone() {
        HostPort retval = (HostPortsuper.clone();
        if (this. != null)
            retval.host = (Hostthis..clone();
        return retval;
    }
    public String toString() {
        return this.encode();
    }
    
    @Override
    public int hashCode() {
        return this..hashCode() + this.;
    }
New to GrepCode? Check out our FAQ X