org.restlet.data
Class LocalReference

java.lang.Object
  extended by org.restlet.data.Reference
      extended by org.restlet.data.LocalReference

public final class LocalReference
extends Reference

Reference to a local (i.e. non remote) resource. It has helper methods for the three following schemes: CLAP, FILE and JAR.

CLAP (ClassLoader Access Protocol) is a custom scheme to access to representations via classloaders. Example URI: "clap://thread/org/restlet/Restlet.class".

JAR is a common scheme to access to representations inside Java ARchives. Example URI: "jar:http://www.foo.com/bar/baz.jar!/COM/foo/Quux.class".

FILE is a standard scheme to access to representations stored in the file system (locally most of the time). Example URI: "file:///D/root/index.html".

Author:
Jerome Louvel (contact@noelios.com)

Field Summary
static int CLAP_CLASS
          The resources will be resolved from the classloader associated with the local class.
static int CLAP_SYSTEM
          The resources will be resolved from the system's classloader.
static int CLAP_THREAD
          The resources will be resolved from the current thread's classloader.
 
Constructor Summary
LocalReference(Reference localRef)
          Constructor.
LocalReference(String localUri)
          Constructor.
 
Method Summary
static LocalReference createClapReference(int authorityType, String path)
          Constructor.
static LocalReference createFileReference(File file)
          Constructor.
static LocalReference createFileReference(String filePath)
          Constructor.
static LocalReference createFileReference(String hostName, String filePath)
          Constructor.
static LocalReference createJarReference(Reference jarFile, String entryPath)
          Constructor.
static String getAuthorityName(int authority)
          Returns an authority name.
 int getClapAuthorityType()
          Returns the type of authority.
 File getFile()
          Gets the local file corresponding to the reference.
 String getJarEntryPath()
          Returns the JAR entry path.
 Reference getJarFileRef()
          Returns the JAR file reference.
static String localizePath(String path)
          Localize a path by converting all the separator characters to the system-dependant separator character.
static String normalizePath(String path)
          Normalize a path by converting all the system-dependant separator characters to the standard '/' separator character.
 
Methods inherited from class org.restlet.data.Reference
decode, decode, encode, encode, equals, getAuthority, getBaseRef, getFragment, getHierarchicalPart, getHostDomain, getHostIdentifier, getHostPort, getIdentifier, getLastSegment, getParentRef, getPath, getQuery, getQueryAsForm, getQueryAsForm, getRelativePart, getRelativeRef, getRelativeRef, getRemainingPart, getScheme, getSchemeProtocol, getSchemeSpecificPart, getSegments, getTargetRef, getUserInfo, hashCode, isAbsolute, isEquivalentTo, isHierarchical, isOpaque, isParent, isRelative, normalize, setAuthority, setBaseRef, setBaseRef, setFragment, setHostDomain, setHostPort, setIdentifier, setPath, setProtocol, setQuery, setRelativePart, setScheme, setSchemeSpecificPart, setSegments, setUserInfo, toString, toString, toString, toString, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

CLAP_CLASS

public static final int CLAP_CLASS
The resources will be resolved from the classloader associated with the local class. Examples: clap://class/rootPkg/subPkg/myClass.class or clap://class/rootPkg/file.html

See Also:
Class.getClassLoader(), Constant Field Values

CLAP_SYSTEM

public static final int CLAP_SYSTEM
The resources will be resolved from the system's classloader. Examples: clap://system/rootPkg/subPkg/myClass.class or clap://system/rootPkg/file.html

See Also:
ClassLoader.getSystemClassLoader(), Constant Field Values

CLAP_THREAD

public static final int CLAP_THREAD
The resources will be resolved from the current thread's classloader. Examples: clap://thread/rootPkg/subPkg/myClass.class or clap://thread/rootPkg/file.html

See Also:
Thread.getContextClassLoader(), Constant Field Values
Constructor Detail

LocalReference

public LocalReference(Reference localRef)
Constructor.

Parameters:
localRef - The local reference.

LocalReference

public LocalReference(String localUri)
Constructor.

Parameters:
localUri - The local URI.
Method Detail

createClapReference

public static LocalReference createClapReference(int authorityType,
                                                 String path)
Constructor.

Parameters:
authorityType - The authority type for the resource path.
path - The resource path.

createFileReference

public static LocalReference createFileReference(File file)
Constructor.

Parameters:
file - The file whose path must be used.

createFileReference

public static LocalReference createFileReference(String filePath)
Constructor.

Parameters:
filePath - The local file path.

createFileReference

public static LocalReference createFileReference(String hostName,
                                                 String filePath)
Constructor.

Parameters:
hostName - The authority (can be a host name or the special "localhost" or an empty value).
filePath - The file path.

createJarReference

public static LocalReference createJarReference(Reference jarFile,
                                                String entryPath)
Constructor.

Parameters:
jarFile - The JAR file reference.
entryPath - The entry path inside the JAR file.

getAuthorityName

public static String getAuthorityName(int authority)
Returns an authority name.

Parameters:
authority - The authority.
Returns:
The name.

localizePath

public static String localizePath(String path)
Localize a path by converting all the separator characters to the system-dependant separator character.

Parameters:
path - The path to localize.
Returns:
The localized path.

normalizePath

public static String normalizePath(String path)
Normalize a path by converting all the system-dependant separator characters to the standard '/' separator character.

Parameters:
path - The path to normalize.
Returns:
The normalize path.

getClapAuthorityType

public int getClapAuthorityType()
Returns the type of authority.

Returns:
The type of authority.

getFile

public File getFile()
Gets the local file corresponding to the reference. Only URIs referring to the "localhost" or to an empty authority are supported.

Returns:
The local file corresponding to the reference.

getJarEntryPath

public String getJarEntryPath()
Returns the JAR entry path.

Returns:
The JAR entry path.

getJarFileRef

public Reference getJarFileRef()
Returns the JAR file reference.

Returns:
The JAR file reference.


Copyright © 2005-2007 Noelios Consulting.