Package org.czeal.urireference
Class Host
- java.lang.Object
-
- org.czeal.urireference.Host
-
- All Implemented Interfaces:
Serializable,Comparable<Host>
public class Host extends Object implements Serializable, Comparable<Host>
A class representing thehostcomponent of a URI reference.This class provides the
parse(String)method, which parses a given string as thehostcomponent of a URI reference, according to RFC 3986. If parsing succeeds, it creates aHostobject, classifying the parsedhostinto one of the specific types: "Registered Name", "IPv4 Address", "IPv6 Address" or "IPvFuture Address". If parsing fails due to invalid input string, anIllegalArgumentExceptionwill be thrown. ThegetType()method can be used to retrieve the type of the host.This class is immutable.
- Author:
- Hideki Ikeda
- See Also:
- RFC 3986 Uniform Resource Identifier (URI): Generic Syntax, Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(Host other)booleanequals(Object obj)Compares thisHostobject with the specified object for equality.HostTypegetType()Get the type of thisHostobject.StringgetValue()Get the value of thisHostobject.inthashCode()Returns a hash code value for thisHostobject.StringtoString()Returns a string representation of thisHostobject.
-
-
-
Method Detail
-
getValue
public String getValue()
Get the value of thisHostobject.- Returns:
- The value of this
Hostobject.
-
getType
public HostType getType()
Get the type of thisHostobject.- Returns:
- The type of this
Hostobject.
-
toString
public String toString()
-
equals
public boolean equals(Object obj)
-
hashCode
public int hashCode()
-
compareTo
public int compareTo(Host other)
Compares thisHostobject with anotherHostobject for order. The comparison is based on the hash code of theHostobjects.- Specified by:
compareToin interfaceComparable<Host>- Parameters:
other- TheHostobject to be compared.- Returns:
- 0 if this
Hostobject is equal to the specifiedHostobject. A negative value if thisHostobject is less than the specified object. A positive value if thisHostobject is greater than the specified object. - Throws:
NullPointerException- If the specifiedHostobject isnull.
-
-