org.arakhne.vmutil
Enum URISchemeType

java.lang.Object
  extended by java.lang.Enum<URISchemeType>
      extended by org.arakhne.vmutil.URISchemeType
All Implemented Interfaces:
Serializable, Comparable<URISchemeType>

public enum URISchemeType
extends Enum<URISchemeType>

Commonly supported types of schemes for URL.

Since:
5.0
Version:
6.3 (rev:285) 2011-10-14 12:02:41
Author:
Stéphane GALLAND
Maven Group Id:
org.arakhne.afc
Maven Artifact Id:
arakhneVmutils

Enum Constant Summary
FILE
          The file scheme is used to point to files on your computer.
FTP
          The ftp scheme is very similar to the http scheme, and is used to locate files available via FTP (File Transfer Protocol).
HTTP
          One of the most widely used URL scheme is the http scheme.
HTTPS
          One of the most widely used URL scheme is the https scheme.
JAR
          The jar scheme describes a Java ARchive (JAR) file or an entry in a JAR file.
MAILTO
          The mailto scheme is an example of an opaque URI scheme. mailto URLs identify someone's e-mail address.
NEWS
          The news scheme is another opaque URL scheme.
RESOURCE
          In the Java programming language a resource is a piece of data that can be accessed by the code of an application.
SSH
          The ssh scheme (also known as sftp - for Secure FTP) is very similar to the ftp scheme, and is used to locate files available via SSH (Secure SHell).
TELNET
          The telnet scheme has identical syntax to the ftp scheme, with the exception that there is no pathame.
UNSUPPORTED
          This value indicates that the scheme is not recognized.
 
Method Summary
static URISchemeType getSchemeType(URI uri)
          Replies the type of scheme for the given URI.
static URISchemeType getSchemeType(URL url)
          Replies the type of scheme for the given URL.
abstract  boolean isFileBasedScheme()
          Replies if this URI scheme represents a local or remote file.
 boolean isScheme(String string)
          Replies if the given string corresponds to this scheme.
 boolean isURI(URI uri)
          Replies if the given URI uses this scheme.
 boolean isURL(URL url)
          Replies if the given URL uses this scheme.
static String removeAnyScheme(String string)
          Remove any supported URI scheme from the given string.
 String removeScheme(String string)
          Remove this URI scheme from the given string.
 String toString()
          Replies the scheme string ended with a column character.
static URISchemeType valueOf(String name)
          Returns the enum constant of this type with the specified name.
static URISchemeType[] 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, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

HTTP

public static final URISchemeType HTTP
One of the most widely used URL scheme is the http scheme. The http URL scheme is used to locate documents that reside on Web servers.

A Web server is more accurately called an HTTP server. HTTP stands for Hypertext Transfer Protocol, and is a protocol designed to transfer hypertext documents over the Internet. It is used to transfer almost all of the documents you download using your Web browser.


HTTPS

public static final URISchemeType HTTPS
One of the most widely used URL scheme is the https scheme. The https URL scheme is used to locate documents that reside on Securized Web servers.

https stands for Hypertext Transfer Protocol Secure. It is a combination of the Hypertext Transfer Protocol (http) with the SSL/TLS protocol to provide encryption and secure identification of the server. HTTPS connections are often used for payment transactions on the World Wide Web and for sensitive transactions in corporate information systems. HTTPS should not be confused with Secure HTTP (S-HTTP) specified in RFC 2660.


FTP

public static final URISchemeType FTP
The ftp scheme is very similar to the http scheme, and is used to locate files available via FTP (File Transfer Protocol). The syntax is very similar to http syntax:

 ftp://sunsite.unc.edu/pub/Linux/ls-lR.gz
 

The above URL points to the FTP server on sunsite.unc.edu, to the file ls-lR.gz in the /pub/Linux directory. It is also possible to specify a username and optionally, a password for the connection. The syntax is like this:


 ftp://user@host/path/file
 ftp://user:password@host/path/file
 

Note that supplying a password like this is sometimes a bad idea. Some people might tell you this is a huge security risk, but this is not really true: a URL like the one above is typed into your browser will only be a risk if someone peeps over your shoulder and sees the password. The password itself is transmitted unencrypted anyway, and can be intercepted in transit. Before you go paranoid about this, remember that if your read your mail through POP (Post Office Protocol), like most people do, then your mail password is also transmitted in the clear. The lesson in this is that if you're going to be paranoid, at least do it for the right reasons.


FILE

public static final URISchemeType FILE
The file scheme is used to point to files on your computer. It is slightly tricky, because (most) absolute file URLs aren't really absolute; they're always relative to your computer. However, you can specify the hostname in a file URL. Remember that a URL just tells you where a resource is located, not how to locate it. So this does make sense. If the hostname is omitted, the current host is assumed. If a URL is encountered by a program with a hostname that's different than the one it's working on, it will most likely decide that it cannot access the file, but this has nothing to do with the URL itself. The syntax is again much like the http syntax, only omitting the port numbers, like this:

 file:///home/stephanos/public_html/myface.jpg
 file://localhost/temp/install_log.txt
 

Note that the pathname here represents a path name in the local filesystem, so the slashes are usually replaced by a more appropriate character before the file is accessed. Unix uses slashes, Windows uses backslashes, Macintosh and other operating systems use other conventions.


MAILTO

public static final URISchemeType MAILTO
The mailto scheme is an example of an opaque URI scheme. mailto URLs identify someone's e-mail address. Their syntax is simple. You have the scheme name, the colon, and then the e-mail address. If you're someone who has a thing for collecting e-mail addresses, you might refer to yourself in the following ways:

 mailto:someone@arakhne.org
 mailto:someone@arakhne.org?subject=Feedback
 


NEWS

public static final URISchemeType NEWS
The news scheme is another opaque URL scheme. It is used to refer to Usenet newsgroups or specific messages within these newsgroups. It has two possible syntaxes. One is the name of a Usenet newsgroup, and the other is the message id of a Usenet post. Note that the message id must be entered without the usual angle brackets (< and >).

 news:comp.infosystems.www.authoring.html
 news:ba-ciwah-1998Jun4-013702@mud.stack.nl
 news:*
 

The third example points to all available newsgroups and can be used to refer to Usenet in general.


TELNET

public static final URISchemeType TELNET
The telnet scheme has identical syntax to the ftp scheme, with the exception that there is no pathame. Only a hostname, and optionally a port, username and password may be supplied.

 telnet://user:password@somehost.internet.com:35/
 

The above indicates a telnet session for user "user" with password "password" on port 35 of somehost.internet.com.


SSH

public static final URISchemeType SSH
The ssh scheme (also known as sftp - for Secure FTP) is very similar to the ftp scheme, and is used to locate files available via SSH (Secure SHell). The syntax is very similar to ftp syntax:

 ssh://sunsite.unc.edu/pub/Linux/ls-lR.gz
 

The above URL points to the SSH server on sunsite.unc.edu, to the file ls-lR.gz in the /pub/Linux directory. It is also possible to specify a username and optionally, a password for the connection. The syntax is like this:


 ssh://user@host/path/file
 ssh://user:password@host/path/file
 

Secure Shell is a network protocol that allows data to be exchanged using a secure channel between two networked devices. Used primarily on GNU/Linux and Unix based systems to access shell accounts, SSH was designed as a replacement for Telnet and other insecure remote shells, which send information, notably passwords, in plaintext, rendering them susceptible to packet analyzation. The encryption used by SSH provides confidentiality and integrity of data over an insecure network, such as the Internet.


JAR

public static final URISchemeType JAR
The jar scheme describes a Java ARchive (JAR) file or an entry in a JAR file. The syntax of a JAR URL is:

 jar:<url>!/{entry}
 
where <url> is an URL of the JAR file, and {entry} is the absolute path of a file inside the JAR file; for example:

 jar:http://www.foo.com/bar/baz.jar!/COM/foo/Quux.class
 

Jar URLs should be used to refer to a JAR file or entries in a JAR file. The example above is a JAR URL which refers to a JAR entry. If the entry name is omitted, the URL refers to the whole JAR file:


 jar:http://www.foo.com/bar/baz.jar!/
 

When constructing a JAR url via new URL(context, spec), the following rules apply:


RESOURCE

public static final URISchemeType RESOURCE
In the Java programming language a resource is a piece of data that can be accessed by the code of an application. An application can access its resources through Uniform Resource Locators (URL), like web resources, but the resources are usually contained within the JAR file(s) of the application, or inside one directory of the JVM class paths.

The resource scheme is simulator to the file scheme. It is used to point to files somewhere in the class paths. It is always absolute filename from one of the roots given in class paths. The syntax is again much like the http syntax, only omitting the port numbers, like this:


 resource:/org/arakhne/vmutil/resource.txt
 resource:/org/arakhne/vmutil/resource.jpg
 

Because the pathname here represents a path name in the class paths, the slashes are mandatory.


UNSUPPORTED

public static final URISchemeType UNSUPPORTED
This value indicates that the scheme is not recognized.

Method Detail

values

public static URISchemeType[] 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 (URISchemeType c : URISchemeType.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static URISchemeType 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

toString

public String toString()
Replies the scheme string ended with a column character.

Overrides:
toString in class Enum<URISchemeType>
Returns:
the scheme string with a column.

isURL

public boolean isURL(URL url)
Replies if the given URL uses this scheme.

Parameters:
url -
Returns:
true if the url uses this scheme, otherwise false

isURI

public boolean isURI(URI uri)
Replies if the given URI uses this scheme.

Parameters:
uri -
Returns:
true if the uri uses this scheme, otherwise false

isScheme

public boolean isScheme(String string)
Replies if the given string corresponds to this scheme.

Parameters:
string -
Returns:
true if the string corresponds to this scheme, otherwise false

removeScheme

public String removeScheme(String string)
Remove this URI scheme from the given string.

Parameters:
string -
Returns:
the string without the URI scheme.

removeAnyScheme

public static String removeAnyScheme(String string)
Remove any supported URI scheme from the given string.

Parameters:
string -
Returns:
the string without the URI scheme.

getSchemeType

public static URISchemeType getSchemeType(URL url)
Replies the type of scheme for the given URL.

Parameters:
url -
Returns:
the type of scheme for the given URL.

getSchemeType

public static URISchemeType getSchemeType(URI uri)
Replies the type of scheme for the given URI.

Parameters:
uri -
Returns:
the type of scheme for the given URI.

isFileBasedScheme

public abstract boolean isFileBasedScheme()
Replies if this URI scheme represents a local or remote file.

Returns:
true if this scheme is file-based, otherwise false


Copyright © 2006-2011 Arakhnê.org Consortium. All rights reserved under LGPL license terms.