Class Port


  • public final class Port
    extends java.lang.Object
    A non-negative integer port. Immutable and thread safe.
    See Also:
    RFC 3986 - Port
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object object)  
      int hashCode()  
      static Port port​(int port)
      Factory method for creating ports from non-negative ints.
      static Port port​(java.lang.String port)
      Factory method for creating ports from String representations of non-negative integers.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • port

        public static Port port​(int port)
        Factory method for creating ports from non-negative ints. Note that RFC 3986 permits any non-negative integer here, but this method limits you to integers up to java.lang.Integer.MAX_VALUE. For integers greater than this, use Port(String).
        Parameters:
        port - a non-negative int.
        Returns:
        a Port representing the given int.
        Throws:
        java.lang.IllegalArgumentException - if the given int is negative.
      • port

        public static Port port​(java.lang.String port)
        Factory method for creating ports from String representations of non-negative integers. This means Strings consisting solely of digits in the range 0-9.
        Parameters:
        port - a String consisting solely of digits in the range 0-9.
        Returns:
        a Port representing the given String.
        Throws:
        java.lang.IllegalArgumentException - if the given String contains characters outside the range 0-9.
      • equals

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

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

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object