Package com.yahoo.jrt

Class Spec

  • All Implemented Interfaces:
    java.lang.Comparable<Spec>

    public class Spec
    extends java.lang.Object
    implements java.lang.Comparable<Spec>
    A Spec is a network address used for either listening or connecting.
    • Constructor Summary

      Constructors 
      Constructor Description
      Spec​(int port)
      Create a Spec with a wildcard address.
      Spec​(java.lang.String spec)
      Create a Spec from a string.
      Spec​(java.lang.String host, int port)
      Create a Spec from a host name and a port number.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(Spec o)  
      boolean equals​(java.lang.Object o)  
      int hashCode()  
      java.lang.String host()
      Obtain the host name of this address
      boolean malformed()
      If this Spec was created from a string, this method will tell you whether that string was malformed.
      int port()
      Obtain the port number if this address
      java.lang.String toString()
      Obtain a string representation of this address.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Spec

        public Spec​(java.lang.String spec)
        Create a Spec from a string. The form of the input string is 'tcp/host:port' or 'tcp/port' where 'host' is the host name and 'port' is the port number.
        Parameters:
        spec - input string to be parsed
        See Also:
        malformed
      • Spec

        public Spec​(java.lang.String host,
                    int port)
        Create a Spec from a host name and a port number.
        Parameters:
        host - host name
        port - port number
      • Spec

        public Spec​(int port)
        Create a Spec with a wildcard address. WARNING: Do not use this constructor to connect to localhost - use e.g. Spec("localhost", port) instead. Why? Because Java may end up picking the wrong localhost hostname to connect to (for reasons detailed in HostName.getLocalhost).
        Parameters:
        port - port number
    • Method Detail

      • host

        public java.lang.String host()
        Obtain the host name of this address
        Returns:
        host name
      • port

        public int port()
        Obtain the port number if this address
        Returns:
        port number
      • malformed

        public boolean malformed()
        If this Spec was created from a string, this method will tell you whether that string was malformed.
        Returns:
        true if this address is malformed
      • toString

        public java.lang.String toString()
        Obtain a string representation of this address. The return value from this method may be used to create a new Spec.
        Overrides:
        toString in class java.lang.Object
        Returns:
        string representation of this address
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • compareTo

        public int compareTo​(Spec o)
        Specified by:
        compareTo in interface java.lang.Comparable<Spec>