- java.lang.Object
-
- net.sourceforge.urin.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-negativeint
s.static Port
port(java.lang.String port)
Factory method for creating ports fromString
representations of non-negative integers.java.lang.String
toString()
-
-
-
Method Detail
-
port
public static Port port(int port)
Factory method for creating ports from non-negativeint
s. Note that RFC 3986 permits any non-negative integer here, but this method limits you to integers up tojava.lang.Integer.MAX_VALUE
. For integers greater than this, usePort(String)
.- Parameters:
port
- a non-negativeint
.- Returns:
- a
Port
representing the givenint
. - Throws:
java.lang.IllegalArgumentException
- if the givenint
is negative.
-
port
public static Port port(java.lang.String port)
Factory method for creating ports fromString
representations of non-negative integers. This meansString
s consisting solely of digits in the range 0-9.- Parameters:
port
- aString
consisting solely of digits in the range 0-9.- Returns:
- a Port representing the given
String
. - Throws:
java.lang.IllegalArgumentException
- if the givenString
contains characters outside the range 0-9.
-
equals
public boolean equals(java.lang.Object object)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-