Package org.czeal.urireference
Class Authority
- java.lang.Object
-
- org.czeal.urireference.Authority
-
- All Implemented Interfaces:
Serializable,Comparable<Authority>
public class Authority extends Object implements Serializable, Comparable<Authority>
A class representing theauthoritycomponent of a URI reference.This class provides the
parse(String)method, which parses a given string as anauthoritycomponent, according to RFC 3986. If parsing succeeds, it creates anAuthorityobject. If parsing fails due to invalid input, it throws anIllegalArgumentException. Individual components of the authority, such asuserinfo, can be accessed through corresponding getter methods, such asgetUserinfo().This class is immutable.
- Author:
- Hideki Ikeda
- See Also:
- RFC 3986, 3.2. Authority, Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(Authority other)booleanequals(Object obj)Compares thisAuthorityobject with the specified object for equality.HostgetHost()Get the value of thehostcomponent of thisAuthorityobject.intgetPort()Get the value of theportcomponent of thisAuthorityobject.StringgetUserinfo()Get the value of theuserinfocomponent of thisAuthorityobject.inthashCode()Returns the hash code value for thisAuthorityobject.StringtoString()Returns a string representation of thisAuthorityobject.
-
-
-
Method Detail
-
getUserinfo
public String getUserinfo()
Get the value of theuserinfocomponent of thisAuthorityobject.- Returns:
- The value of the
userinfocomponent of thisAuthorityobject.
-
getHost
public Host getHost()
Get the value of thehostcomponent of thisAuthorityobject.- Returns:
- The value of the
hostcomponent of thisAuthorityobject.
-
getPort
public int getPort()
Get the value of theportcomponent of thisAuthorityobject.- Returns:
- The value of the
portcomponent of thisAuthorityobject.
-
toString
public String toString()
Returns a string representation of thisAuthorityobject. The string is constructed by concatenating theuserinfo,host, andportcomponents.
-
equals
public boolean equals(Object obj)
Compares thisAuthorityobject with the specified object for equality. The comparison is based on the values ofuserinfo,host, andportcomponents.
-
hashCode
public int hashCode()
Returns the hash code value for thisAuthorityobject. The hash code is generated based on the values ofuserinfo,host, andportcomponents.
-
compareTo
public int compareTo(Authority other)
Compares thisAuthorityobject with anotherAuthorityobject for order. The comparison is based on the string representation of theAuthorityobjects.- Specified by:
compareToin interfaceComparable<Authority>- Parameters:
other- TheAuthorityobject to be compared.- Returns:
- 0 if this
Authorityobject is equal to the specifiedAuthorityobject. A negative value if thisAuthorityobject is less than the specified object. A positive value if thisAuthorityobject is greater than the specified object. - Throws:
NullPointerException- If the specifiedAuthorityobject isnull.
-
-