Module net.sourceforge.urin
Package net.sourceforge.urin
Class UrinReference<SEGMENT,QUERY extends Query<?>,FRAGMENT extends Fragment<?>>
- java.lang.Object
-
- net.sourceforge.urin.UrinReference<SEGMENT,QUERY,FRAGMENT>
-
- Type Parameters:
SEGMENT- The type ofSegmentused by paths of this URI reference.QUERY- The type ofQueryused by this URI reference.FRAGMENT- The type ofFragmentused by this URI reference.
- Direct Known Subclasses:
RelativeReference,Urin
public abstract class UrinReference<SEGMENT,QUERY extends Query<?>,FRAGMENT extends Fragment<?>> extends java.lang.ObjectA URI reference - either a URI or a relative reference. Immutable and thread safe.- See Also:
- RFC 3986 - URI Reference
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract java.lang.StringasString()Generates theStringrepresentation of this URI reference.java.net.URIasUri()Generates aURIrepresentation of this URI reference.abstract Authorityauthority()Gets theAuthoritycomponent of thisUrinReference, if it has one, or throwsUnsupportedOperationExceptionotherwise.abstract FRAGMENTfragment()Gets theFragmentcomponent of thisUrinReference, if it has one, or throwsUnsupportedOperationExceptionotherwise.abstract booleanhasAuthority()Returns true ifauthority()can be called on thisUrinReference.abstract booleanhasFragment()Returns true iffragment()can be called on thisUrinReference.abstract booleanhasQuery()Returns true ifquery()can be called on thisUrinReference.abstract Path<SEGMENT>path()Returns the path component of the URI reference this represents.abstract QUERYquery()Gets theQuerycomponent of thisUrinReference, if it has one, or throwsUnsupportedOperationExceptionotherwise.java.lang.StringtoString()abstract UrinReference<SEGMENT,QUERY,FRAGMENT>withPath(AbsolutePath<SEGMENT> path)Returns a copy of thisUrinReferencewith the path replaced with the given path.
-
-
-
Method Detail
-
asString
public abstract java.lang.String asString()
Generates theStringrepresentation of this URI reference.- Returns:
- an RFC 3986 compliant
Stringrepresentation of this URI reference.
-
asUri
public final java.net.URI asUri()
Generates aURIrepresentation of this URI reference.Note that this class represents URI references as defined in the current RFC 3986, but Java's
URIclass represents URI references as defined in the obsolete RFC 2396. RFC 3986 extends the definition of URI references, so this class can represent URI references that cannot be represented by Java'sURIclass.- Returns:
- a
URIrepresentation of thisUrinReference. - Throws:
java.lang.IllegalArgumentException- if Java'sURIclass is unable to represent this URI reference.
-
path
public abstract Path<SEGMENT> path()
Returns the path component of the URI reference this represents. All URI references have a path, though this maybe the empty path, and in some cases, the path is implicitly the empty path.- Returns:
- a
Pathrepresenting the path component of this URI reference.
-
withPath
public abstract UrinReference<SEGMENT,QUERY,FRAGMENT> withPath(AbsolutePath<SEGMENT> path)
Returns a copy of thisUrinReferencewith the path replaced with the given path.- Parameters:
path- the path to use in the newUrinReference.- Returns:
- a copy of this
UrinReferencewith the path replaced with the given path.
-
hasFragment
public abstract boolean hasFragment()
Returns true iffragment()can be called on thisUrinReference. This method returns false forUrinReferences that do not have a fragment component.- Returns:
- true if
fragment()can be called on thisUrinReference.
-
fragment
public abstract FRAGMENT fragment()
Gets theFragmentcomponent of thisUrinReference, if it has one, or throwsUnsupportedOperationExceptionotherwise.The existence of a
Fragmentcomponent can be tested by callinghasFragment().- Returns:
- the
Fragmentcomponent of thisUrinReference. - Throws:
java.lang.UnsupportedOperationException- if this is aUrinReferencethat does not have aFragmentcomponent.
-
hasQuery
public abstract boolean hasQuery()
Returns true ifquery()can be called on thisUrinReference. This method returns false forUrinReferences that do not have a query component.- Returns:
- true if
query()can be called on thisUrinReference.
-
query
public abstract QUERY query()
Gets theQuerycomponent of thisUrinReference, if it has one, or throwsUnsupportedOperationExceptionotherwise.The existence of a
Querycomponent can be tested by callinghasQuery().- Returns:
- the
Querycomponent of thisUrinReference. - Throws:
java.lang.UnsupportedOperationException- if this is aUrinReferencethat does not have aQuerycomponent.
-
hasAuthority
public abstract boolean hasAuthority()
Returns true ifauthority()can be called on thisUrinReference. This method returns false forUrinReferences that do not have an authority component.- Returns:
- true if
authority()can be called on thisUrinReference.
-
authority
public abstract Authority authority()
Gets theAuthoritycomponent of thisUrinReference, if it has one, or throwsUnsupportedOperationExceptionotherwise.The existence of an
Authoritycomponent can be tested by callinghasAuthority().- Returns:
- the
Authoritycomponent of thisUrinReference. - Throws:
java.lang.UnsupportedOperationException- if this is aUrinReferencethat does not have anAuthoritycomponent.
-
toString
public final java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-