Class URIFragments


  • public class URIFragments
    extends Object
    This class represents a URI, fragmented into 7 major components. These components are namely scheme, user info, host, port, path, query and ref. Out of these seven components, port is an integer whereas all other components are strings. These fragments can be combined to form a valid URI according to RFC-2396. This collection strictly deals with URI fragments and not URL fragments. Therefore this abstraction can be used to represent any URI, URL or URN thus allowing room for a wider range of usecases.
    • Constructor Detail

      • URIFragments

        public URIFragments()
      • URIFragments

        public URIFragments​(URI uri)
    • Method Detail

      • setFragments

        public void setFragments​(URI uri)
        Break down the given URI into fragments and reinitialize the current fragments set
        Parameters:
        uri - the URI to be assigned to the fragments
      • setPort

        public void setPort​(int port)
      • getPort

        public int getPort()
      • setStringFragment

        public void setStringFragment​(int index,
                                      String value)
      • getStringFragment

        public String getStringFragment​(int index)
      • toURI

        public URI toURI()
                  throws URISyntaxException
        Construct a valid URI by combining the current fragment values
        Returns:
        a valid URI instance
        Throws:
        URISyntaxException - if the fragments form a malformed URI
      • toURIString

        public String toURIString()
                           throws URISyntaxException
        Construct a valid URI string by combining the current fragment values
        Returns:
        a string representation of a valid URI
        Throws:
        URISyntaxException - if the fragments form a malformed URI