Class UrinReference<SEGMENT,​QUERY extends Query<?>,​FRAGMENT extends Fragment<?>>

  • Type Parameters:
    SEGMENT - The type of Segment used by paths of this URI reference.
    QUERY - The type of Query used by this URI reference.
    FRAGMENT - The type of Fragment 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 the String representation of this URI reference.
      java.net.URI asUri()
      Generates a URI representation of this URI reference.
      abstract Authority authority()
      Gets the Authority component of this UrinReference, if it has one, or throws UnsupportedOperationException otherwise.
      abstract FRAGMENT fragment()
      Gets the Fragment component of this UrinReference, if it has one, or throws UnsupportedOperationException otherwise.
      abstract boolean hasAuthority()
      Returns true if authority() can be called on this UrinReference.
      abstract boolean hasFragment()
      Returns true if fragment() can be called on this UrinReference.
      abstract boolean hasQuery()
      Returns true if query() can be called on this UrinReference.
      abstract Path<SEGMENT> path()
      Returns the path component of the URI reference this represents.
      abstract QUERY query()
      Gets the Query component of this UrinReference, if it has one, or throws UnsupportedOperationException otherwise.
      java.lang.String toString()  
      abstract UrinReference<SEGMENT,​QUERY,​FRAGMENT> withPath​(AbsolutePath<SEGMENT> path)
      Returns a copy of this UrinReference with the path replaced with the given path.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Method Detail

      • asString

        public abstract java.lang.String asString()
        Generates the String representation of this URI reference.
        Returns:
        an RFC 3986 compliant String representation of this URI reference.
      • asUri

        public final java.net.URI asUri()
        Generates a URI 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's URI class.

        Returns:
        a URI representation of this UrinReference.
        Throws:
        java.lang.IllegalArgumentException - if Java's URI 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 this UrinReference with the path replaced with the given path.
        Parameters:
        path - the path to use in the new UrinReference.
        Returns:
        a copy of this UrinReference with the path replaced with the given path.
      • hasFragment

        public abstract boolean hasFragment()
        Returns true if fragment() can be called on this UrinReference. This method returns false for UrinReferences that do not have a fragment component.
        Returns:
        true if fragment() can be called on this UrinReference.
      • fragment

        public abstract FRAGMENT fragment()
        Gets the Fragment component of this UrinReference, if it has one, or throws UnsupportedOperationException otherwise.

        The existence of a Fragment component can be tested by calling hasFragment().

        Returns:
        the Fragment component of this UrinReference.
        Throws:
        java.lang.UnsupportedOperationException - if this is a UrinReference that does not have a Fragment component.
      • hasQuery

        public abstract boolean hasQuery()
        Returns true if query() can be called on this UrinReference. This method returns false for UrinReferences that do not have a query component.
        Returns:
        true if query() can be called on this UrinReference.
      • query

        public abstract QUERY query()
        Gets the Query component of this UrinReference, if it has one, or throws UnsupportedOperationException otherwise.

        The existence of a Query component can be tested by calling hasQuery().

        Returns:
        the Query component of this UrinReference.
        Throws:
        java.lang.UnsupportedOperationException - if this is a UrinReference that does not have a Query component.
      • hasAuthority

        public abstract boolean hasAuthority()
        Returns true if authority() can be called on this UrinReference. This method returns false for UrinReferences that do not have an authority component.
        Returns:
        true if authority() can be called on this UrinReference.
      • authority

        public abstract Authority authority()
        Gets the Authority component of this UrinReference, if it has one, or throws UnsupportedOperationException otherwise.

        The existence of an Authority component can be tested by calling hasAuthority().

        Returns:
        the Authority component of this UrinReference.
        Throws:
        java.lang.UnsupportedOperationException - if this is a UrinReference that does not have an Authority component.
      • toString

        public final java.lang.String toString()
        Overrides:
        toString in class java.lang.Object