Class UriUtils


  • public class UriUtils
    extends Object
    URI handling utilities.
    Author:
    aherscu
    • Constructor Detail

      • UriUtils

        public UriUtils()
    • Method Detail

      • lastSegmentOf

        public static String lastSegmentOf​(URI url)
        Extracts the last segment of the path of specified URL. For example, for http://somewhere.com/path/to/resource, resource would be returned.
        Parameters:
        url - the URL
        Returns:
        the last segment of the specified URL
      • listOfStringsFrom

        public static List<String> listOfStringsFrom​(List<URI> uris)
        Parameters:
        uris - the URIs
        Returns:
        list of strings from specified list of URIs.
      • passwordFrom

        public static String passwordFrom​(URI url)
        Extracts the password from specified URL. For example, for http://jdoe:s3cr3t@somewhere.com/path/to/resource, s3cr3t would be returned.
        Parameters:
        url - the URL
        Returns:
        the password
      • pathSegmentFrom

        public static String pathSegmentFrom​(URI url,
                                             int n)
        Extracts a path segment from specified URL.
        Parameters:
        url - the URL
        n - the index of requested path segment, where the first one is 0
        Returns:
        the requested path segment
      • stripUserInfoFrom

        public static URI stripUserInfoFrom​(URI url)
        Removes username and password from specified URL.
        Parameters:
        url - the URL
        Returns:
        URL without username and password
      • usernameFrom

        public static String usernameFrom​(URI url)
        Extracts the user-name from specified URL. For example, for http://jdoe:s3cr3t@somewhere.com/path/to/resource, jdoe would be returned.
        Parameters:
        url - the URL
        Returns:
        the password