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 ofSegment
used by paths of this URI reference.QUERY
- The type ofQuery
used by this URI reference.FRAGMENT
- The type ofFragment
used by this URI reference.
- Direct Known Subclasses:
RelativeReference
,Urin
public abstract class UrinReference<SEGMENT,QUERY extends Query<?>,FRAGMENT extends Fragment<?>> extends java.lang.Object
A 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.String
asString()
Generates theString
representation of this URI reference.java.net.URI
asUri()
Generates aURI
representation of this URI reference.abstract Authority
authority()
Gets theAuthority
component of thisUrinReference
, if it has one, or throwsUnsupportedOperationException
otherwise.abstract FRAGMENT
fragment()
Gets theFragment
component of thisUrinReference
, if it has one, or throwsUnsupportedOperationException
otherwise.abstract boolean
hasAuthority()
Returns true ifauthority()
can be called on thisUrinReference
.abstract boolean
hasFragment()
Returns true iffragment()
can be called on thisUrinReference
.abstract boolean
hasQuery()
Returns true ifquery()
can be called on thisUrinReference
.abstract Path<SEGMENT>
path()
Returns the path component of the URI reference this represents.abstract QUERY
query()
Gets theQuery
component of thisUrinReference
, if it has one, or throwsUnsupportedOperationException
otherwise.java.lang.String
toString()
abstract UrinReference<SEGMENT,QUERY,FRAGMENT>
withPath(AbsolutePath<SEGMENT> path)
Returns a copy of thisUrinReference
with the path replaced with the given path.
-
-
-
Method Detail
-
asString
public abstract java.lang.String asString()
Generates theString
representation of this URI reference.- Returns:
- an RFC 3986 compliant
String
representation of this URI reference.
-
asUri
public final java.net.URI asUri()
Generates aURI
representation of this URI reference.Note that this class represents URI references as defined in the current RFC 3986, but Java's
URI
class 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'sURI
class.- Returns:
- a
URI
representation of thisUrinReference
. - Throws:
java.lang.IllegalArgumentException
- if Java'sURI
class 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
Path
representing the path component of this URI reference.
-
withPath
public abstract UrinReference<SEGMENT,QUERY,FRAGMENT> withPath(AbsolutePath<SEGMENT> path)
Returns a copy of thisUrinReference
with the path replaced with the given path.- Parameters:
path
- the path to use in the newUrinReference
.- Returns:
- a copy of this
UrinReference
with the path replaced with the given path.
-
hasFragment
public abstract boolean hasFragment()
Returns true iffragment()
can be called on thisUrinReference
. This method returns false forUrinReference
s that do not have a fragment component.- Returns:
- true if
fragment()
can be called on thisUrinReference
.
-
fragment
public abstract FRAGMENT fragment()
Gets theFragment
component of thisUrinReference
, if it has one, or throwsUnsupportedOperationException
otherwise.The existence of a
Fragment
component can be tested by callinghasFragment()
.- Returns:
- the
Fragment
component of thisUrinReference
. - Throws:
java.lang.UnsupportedOperationException
- if this is aUrinReference
that does not have aFragment
component.
-
hasQuery
public abstract boolean hasQuery()
Returns true ifquery()
can be called on thisUrinReference
. This method returns false forUrinReference
s that do not have a query component.- Returns:
- true if
query()
can be called on thisUrinReference
.
-
query
public abstract QUERY query()
Gets theQuery
component of thisUrinReference
, if it has one, or throwsUnsupportedOperationException
otherwise.The existence of a
Query
component can be tested by callinghasQuery()
.- Returns:
- the
Query
component of thisUrinReference
. - Throws:
java.lang.UnsupportedOperationException
- if this is aUrinReference
that does not have aQuery
component.
-
hasAuthority
public abstract boolean hasAuthority()
Returns true ifauthority()
can be called on thisUrinReference
. This method returns false forUrinReference
s that do not have an authority component.- Returns:
- true if
authority()
can be called on thisUrinReference
.
-
authority
public abstract Authority authority()
Gets theAuthority
component of thisUrinReference
, if it has one, or throwsUnsupportedOperationException
otherwise.The existence of an
Authority
component can be tested by callinghasAuthority()
.- Returns:
- the
Authority
component of thisUrinReference
. - Throws:
java.lang.UnsupportedOperationException
- if this is aUrinReference
that does not have anAuthority
component.
-
toString
public final java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-