Class URIParser

java.lang.Object
com.aoapps.net.URIParser

public final class URIParser extends Object
URI parsing utilities.
Author:
AO Industries, Inc.
  • Method Details

    • getSchemeLength

      public static int getSchemeLength(CharSequence uri)
      Gets the length of a scheme.
      Returns:
      The index of the ':' or -1 on empty scheme, invalid character in scheme, or no colon found.
    • isScheme

      public static boolean isScheme(String uri, String scheme) throws IllegalArgumentException
      Checks if a URI starts with the given scheme.
      Parameters:
      scheme - The scheme to look for, not including colon. For example "http".
      Throws:
      IllegalArgumentException - when scheme is determined to be invalid. Please note that this determination is not guaranteed as shortcuts may skip individual character comparisons.
    • hasScheme

      public static boolean hasScheme(String uri)
      Checks if a URI has a scheme, not including any empty scheme (starts with ':').
    • getScheme

      public static final String getScheme(String uri)
      Gets the scheme for a URI, or null when no scheme found. The scheme must start the URI, and match ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) before the first colon (:) found. The scheme is normalized to lower-case. An empty scheme will never be returned (if the URI starts with ':').
      Returns:
      The scheme, not including colon, or null when not found. For example "http".
    • getPathEnd

      public static int getPathEnd(String uri, int fromIndex)
      Find the first of '?' or '#' from the given starting index.
      Returns:
      The index of the first '?' or '#' or uri.length() when not found.
    • getPathEnd

      public static int getPathEnd(String uri)
      Find the first of '?' or '#'.
      Returns:
      The index of the first '?' or '#' or uri.length() when not found.