Package org.refcodes.data
Enum Scheme
- java.lang.Object
-
- java.lang.Enum<Scheme>
-
- org.refcodes.data.Scheme
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<Scheme>
,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
TheScheme
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 emptyString
where as for "http" it would be "//" (as of "http://", "http" being the name).
-
-
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 thatScheme
represented by the given name.static Scheme
fromProtocol(java.lang.String aProtocol)
Returns thatScheme
represented by the given protocol.static Scheme
fromScheme(java.lang.String aUrl)
Determines theScheme
from the given URL.java.lang.String
getMarker()
Returns the prefix for the resource locator as of theScheme
.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.
-
-
-
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 namejava.lang.NullPointerException
- if the argument is null
-
getName
public java.lang.String getName()
- Specified by:
getName
in interfaceorg.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 theScheme
. 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 interfaceorg.refcodes.mixin.PortAccessor
-
fromName
public static Scheme fromName(java.lang.String aName)
Returns thatScheme
represented by the given name.
-
fromProtocol
public static Scheme fromProtocol(java.lang.String aProtocol)
Returns thatScheme
represented by the given protocol.
-
-