Enum Scheme

  • All Implemented Interfaces:
    org.refcodes.mixin.NameAccessor, org.refcodes.mixin.PortAccessor


    public enum Scheme
    extends java.lang.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 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
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int firstMarkerIndex​(java.lang.String aUrl)
      Returns the index of locator part pointing into the resource of the given URL.
      static Scheme fromName​(java.lang.String aName)
      Returns that Scheme represented by the given name.
      static Scheme fromProtocol​(java.lang.String aProtocol)
      Returns that Scheme represented by the given protocol.
      static Scheme fromScheme​(java.lang.String aUrl)
      Determines the Scheme from the given URL.
      java.lang.String getMarker​()
      Returns the prefix for the resource locator as of the Scheme.
      java.lang.String getName​()
      int getPort​()
      java.lang.String getSpecific​()
      Returns the scheme's specific part as of "name:scheme-specific-part".
      int nextMarkerIndex​(java.lang.String aUrl, int aBeginIndex)
      Returns the index of the locator part pointing into the resource of the given URL.
      java.lang.String toProtocol​()
      Returns protocol being the scheme name and the scheme specific part , e.g.
      java.lang.String toUrl​(java.lang.String aUrl)
      Returns the locator part pointing into the resource of the given URL.
      java.lang.String toUrl​(java.lang.String aUrl, int aBeginIndex)
      Returns the locator part pointing into the resource of the given URL.
      static Scheme valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static Scheme[] values​()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • 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​(java.lang.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:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • getName

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

        public java.lang.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 java.lang.String toProtocol​()
        Returns protocol being the scheme name and the scheme specific part , e.g. "http://" or "file:".
        Returns:
        The protocol.
      • toUrl

        public java.lang.String toUrl​(java.lang.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 java.lang.String toUrl​(java.lang.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​(java.lang.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​(java.lang.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 java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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.