Enum Class Scheme

java.lang.Object
java.lang.Enum<Scheme>
org.refcodes.data.Scheme
All Implemented Interfaces:
Serializable, Comparable<Scheme>, Constable, org.refcodes.mixin.NameAccessor, org.refcodes.mixin.PortAccessor

public enum Scheme extends Enum<Scheme> implements org.refcodes.mixin.NameAccessor, org.refcodes.mixin.PortAccessor
The Scheme define values useful when working with files or a file-system. An URL-Scheme is constructed as follows: "name:scheme-specific-part" The name is the protocol of the scheme such as "file" or "http". The scheme specific part is the part after the colon (":") specific to the given scheme. For a "file" scheme it would be just an empty String where as for "http" it would be "//" (as of "http://", "http" being the name).
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>

    Nested classes/interfaces inherited from interface org.refcodes.mixin.NameAccessor

    org.refcodes.mixin.NameAccessor.NameBuilder<B extends org.refcodes.mixin.NameAccessor.NameBuilder<B>>, org.refcodes.mixin.NameAccessor.NameMutator, org.refcodes.mixin.NameAccessor.NameProperty

    Nested classes/interfaces inherited from interface org.refcodes.mixin.PortAccessor

    org.refcodes.mixin.PortAccessor.PortBuilder<B extends org.refcodes.mixin.PortAccessor.PortBuilder<B>>, org.refcodes.mixin.PortAccessor.PortMutator, org.refcodes.mixin.PortAccessor.PortProperty
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
     
     
     
     
     
     
     
     
     
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the index of locator part pointing into the resource of the given URL.
    static Scheme
    Returns that Scheme represented by the given name.
    static Scheme
    fromProtocol(String aProtocol)
    Returns that Scheme represented by the given protocol.
    static Scheme
    Determines the Scheme from the given URL.
    Returns the prefix for the resource locator as of the Scheme.
    int
    Returns the scheme's specific part as of "name:scheme-specific-part".
    int
    nextMarkerIndex(String aUrl, int aBeginIndex)
    Returns the index of the locator part pointing into the resource of the given URL.
    Returns protocol being the scheme name and the scheme specific part , e.g.
    toUrl(String aUrl)
    Returns the locator part pointing into the resource of the given URL.
    toUrl(String aUrl, int aBeginIndex)
    Returns the locator part pointing into the resource of the given URL.
    static Scheme
    Returns the enum constant of this class with the specified name.
    static Scheme[]
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • JAR

      public static final Scheme JAR
    • ZIP

      public static final Scheme ZIP
    • SH

      public static final Scheme SH
    • FILE

      public static final Scheme FILE
    • HTTP

      public static final Scheme HTTP
    • HTTPS

      public static final Scheme HTTPS
    • SOCKS

      public static final Scheme SOCKS
    • SOCKS4

      public static final Scheme SOCKS4
    • SOCKS5

      public static final Scheme SOCKS5
    • UNKNOWN

      public static final Scheme UNKNOWN
  • Method Details

    • values

      public static Scheme[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Scheme valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getName

      public String getName()
      Specified by:
      getName in interface org.refcodes.mixin.NameAccessor
    • getSpecific

      public String getSpecific()
      Returns the scheme's specific part as of "name:scheme-specific-part". The double-slash "//" is the scheme-specific-part of "http://".
      Returns:
      The scheme's specific part. For HTTP it would be "//".
    • toProtocol

      public String toProtocol()
      Returns protocol being the scheme name and the scheme specific part , e.g. "http://" or "file:".
      Returns:
      The protocol.
    • toUrl

      public String toUrl(String aUrl, int aBeginIndex)
      Returns the locator part pointing into the resource of the given URL.
      Parameters:
      aUrl - The URL from which to retrieve the locator part.
      aBeginIndex - The index from where to start.
      Returns:
      The locator part of the given URL or null if there is no valid resource protocol found.
    • toUrl

      public String toUrl(String aUrl)
      Returns the locator part pointing into the resource of the given URL.
      Parameters:
      aUrl - The URL from which to retrieve the locator part.
      Returns:
      The locator part of the given URL or null if there is no valid resource protocol found.
    • nextMarkerIndex

      public int nextMarkerIndex(String aUrl, int aBeginIndex)
      Returns the index of the locator part pointing into the resource of the given URL.
      Parameters:
      aUrl - The URL from which to retrieve the locator part.
      aBeginIndex - The index from where to start.
      Returns:
      The index of locator part of the given URL or -1 if there is no valid resource protocol found.
    • firstMarkerIndex

      public int firstMarkerIndex(String aUrl)
      Returns the index of locator part pointing into the resource of the given URL.
      Parameters:
      aUrl - The URL from which to retrieve the locator part.
      Returns:
      The the index locator part of the given URL or -1 if there is no valid resource protocol found.
    • getMarker

      public String getMarker()
      Returns the prefix for the resource locator as of the Scheme. E.g. a HTTP protocol will provide the resource locator prefix "http://" and a FILE protocol will provide the resource locator prefix "file:/" prefix.
      Returns:
      The resource locator's prefix.
    • getPort

      public int getPort()
      Specified by:
      getPort in interface org.refcodes.mixin.PortAccessor
    • fromName

      public static Scheme fromName(String aName)
      Returns that Scheme represented by the given name.
      Parameters:
      aName - The name for which to determine the Scheme.
      Returns:
      The determined Scheme or null if none was determinable.
    • fromProtocol

      public static Scheme fromProtocol(String aProtocol)
      Returns that Scheme represented by the given protocol.
      Parameters:
      aProtocol - The protocol for which to determine the Scheme.
      Returns:
      The determined Scheme or null if none was determinable.
    • fromScheme

      public static Scheme fromScheme(String aUrl)
      Determines the Scheme from the given URL.
      Parameters:
      aUrl - The URL from which to determine the Scheme.
      Returns:
      The according Scheme or null if none matching was found.