Enum Scheme

  • All Implemented Interfaces:
    Serializable, Comparable<Scheme>, 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).
    • Enum Constant Detail

      • 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 Detail

      • values

        public static Scheme[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (Scheme c : Scheme.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static Scheme valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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 type 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.