org.eclipse.jetty.util.resource
类 Resource

java.lang.Object
  继承者 org.eclipse.jetty.util.resource.Resource
所有已实现的接口:
ResourceFactory
直接已知子类:
ResourceCollection, URLResource

public abstract class Resource
extends Object
implements ResourceFactory

Abstract resource class.


字段摘要
static boolean __defaultUseCaches
           
 
构造方法摘要
Resource()
           
 
方法摘要
abstract  Resource addPath(String path)
          Returns the resource contained inside the current resource with the given name.
 void copyTo(File destination)
           
abstract  boolean delete()
          Deletes the given resource
 String encode(String uri)
          Encode according to this resource type.
abstract  boolean exists()
          Returns true if the respresened resource exists.
protected  void finalize()
           
 URL getAlias()
           
 Object getAssociate()
           
static boolean getDefaultUseCaches()
           
abstract  File getFile()
          Returns an File representing the given resource or NULL if this is not possible.
abstract  InputStream getInputStream()
          Returns an input stream to the resource
 String getListHTML(String base, boolean parent)
          Get the resource list as a HTML directory listing.
abstract  String getName()
          Returns the name of the resource
abstract  OutputStream getOutputStream()
          Returns an output stream to the resource
 Resource getResource(String path)
          Get a resource from withing this resource.
 URI getURI()
          Returns an URI representing the given resource
abstract  URL getURL()
          Returns an URL representing the given resource
 String getWeakETag()
           
abstract  boolean isContainedIn(Resource r)
           
static boolean isContainedIn(Resource r, Resource containingResource)
           
abstract  boolean isDirectory()
          Returns true if the respresenetd resource is a container/directory.
abstract  long lastModified()
          Returns the last modified time
abstract  long length()
          Return the length of the resource
abstract  String[] list()
          Returns a list of resource names contained in the given resource The resource names are not URL encoded.
static Resource newClassPathResource(String resource)
          Find a classpath resource.
static Resource newClassPathResource(String name, boolean useCaches, boolean checkParents)
          Find a classpath resource.
static Resource newResource(File file)
           
static Resource newResource(String resource)
          Construct a resource from a string.
static Resource newResource(String resource, boolean useCaches)
          Construct a resource from a string.
static Resource newResource(URI uri)
          Construct a resource from a uri.
static Resource newResource(URL url)
          Construct a resource from a url.
static Resource newSystemResource(String resource)
          Construct a system resource from a string.
abstract  void release()
          Release any temporary resources held by the resource.
abstract  boolean renameTo(Resource dest)
          Rename the given resource
 void setAssociate(Object o)
           
static void setDefaultUseCaches(boolean useCaches)
          Change the default setting for url connection caches.
static URL toURL(File file)
          Generate a properly encoded URL from a File instance.
 void writeTo(OutputStream out, long start, long count)
           
 
从类 java.lang.Object 继承的方法
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

__defaultUseCaches

public static boolean __defaultUseCaches
构造方法详细信息

Resource

public Resource()
方法详细信息

setDefaultUseCaches

public static void setDefaultUseCaches(boolean useCaches)
Change the default setting for url connection caches. Subsequent URLConnections will use this default.

参数:
useCaches -

getDefaultUseCaches

public static boolean getDefaultUseCaches()

newResource

public static Resource newResource(URI uri)
                            throws IOException
Construct a resource from a uri.

参数:
uri - A URI.
返回:
A Resource object.
抛出:
IOException - Problem accessing URI

newResource

public static Resource newResource(URL url)
                            throws IOException
Construct a resource from a url.

参数:
url - A URL.
返回:
A Resource object.
抛出:
IOException - Problem accessing URL

newResource

public static Resource newResource(String resource)
                            throws MalformedURLException,
                                   IOException
Construct a resource from a string.

参数:
resource - A URL or filename.
返回:
A Resource object.
抛出:
MalformedURLException
IOException

newResource

public static Resource newResource(String resource,
                                   boolean useCaches)
                            throws MalformedURLException,
                                   IOException
Construct a resource from a string.

参数:
resource - A URL or filename.
useCaches - controls URLConnection caching
返回:
A Resource object.
抛出:
MalformedURLException
IOException

newResource

public static Resource newResource(File file)
                            throws MalformedURLException,
                                   IOException
抛出:
MalformedURLException
IOException

newSystemResource

public static Resource newSystemResource(String resource)
                                  throws IOException
Construct a system resource from a string. The resource is tried as classloader resource before being treated as a normal resource.

参数:
resource - Resource as string representation
返回:
The new Resource
抛出:
IOException - Problem accessing resource.

newClassPathResource

public static Resource newClassPathResource(String resource)
Find a classpath resource.


newClassPathResource

public static Resource newClassPathResource(String name,
                                            boolean useCaches,
                                            boolean checkParents)
Find a classpath resource. The Class.getResource(String) method is used to lookup the resource. If it is not found, then the Loader.getResource(Class, String, boolean) method is used. If it is still not found, then ClassLoader.getSystemResource(String) is used. Unlike ClassLoader.getSystemResource(String) this method does not check for normal resources.

参数:
name - The relative name of the resource
useCaches - True if URL caches are to be used.
checkParents - True if forced searching of parent Classloaders is performed to work around loaders with inverted priorities
返回:
Resource or null

isContainedIn

public static boolean isContainedIn(Resource r,
                                    Resource containingResource)
                             throws MalformedURLException
抛出:
MalformedURLException

finalize

protected void finalize()
覆盖:
Object 中的 finalize

isContainedIn

public abstract boolean isContainedIn(Resource r)
                               throws MalformedURLException
抛出:
MalformedURLException

release

public abstract void release()
Release any temporary resources held by the resource.


exists

public abstract boolean exists()
Returns true if the respresened resource exists.


isDirectory

public abstract boolean isDirectory()
Returns true if the respresenetd resource is a container/directory. If the resource is not a file, resources ending with "/" are considered directories.


lastModified

public abstract long lastModified()
Returns the last modified time


length

public abstract long length()
Return the length of the resource


getURL

public abstract URL getURL()
Returns an URL representing the given resource


getURI

public URI getURI()
Returns an URI representing the given resource


getFile

public abstract File getFile()
                      throws IOException
Returns an File representing the given resource or NULL if this is not possible.

抛出:
IOException

getName

public abstract String getName()
Returns the name of the resource


getInputStream

public abstract InputStream getInputStream()
                                    throws IOException
Returns an input stream to the resource

抛出:
IOException

getOutputStream

public abstract OutputStream getOutputStream()
                                      throws IOException,
                                             SecurityException
Returns an output stream to the resource

抛出:
IOException
SecurityException

delete

public abstract boolean delete()
                        throws SecurityException
Deletes the given resource

抛出:
SecurityException

renameTo

public abstract boolean renameTo(Resource dest)
                          throws SecurityException
Rename the given resource

抛出:
SecurityException

list

public abstract String[] list()
Returns a list of resource names contained in the given resource The resource names are not URL encoded.


addPath

public abstract Resource addPath(String path)
                          throws IOException,
                                 MalformedURLException
Returns the resource contained inside the current resource with the given name.

参数:
path - The path segment to add, which should be encoded by the encode method.
抛出:
IOException
MalformedURLException

getResource

public Resource getResource(String path)
Get a resource from withing this resource.

This method is essentially an alias for addPath(String), but without checked exceptions. This method satisfied the ResourceFactory interface.

指定者:
接口 ResourceFactory 中的 getResource
参数:
path - The path to the resource
返回:
The resource or null
另请参见:
ResourceFactory.getResource(java.lang.String)

encode

public String encode(String uri)
Encode according to this resource type. The default implementation calls URI.encodePath(uri)

参数:
uri -
返回:
String encoded for this resource type.

getAssociate

public Object getAssociate()

setAssociate

public void setAssociate(Object o)

getAlias

public URL getAlias()
返回:
The canonical Alias of this resource or null if none.

getListHTML

public String getListHTML(String base,
                          boolean parent)
                   throws IOException
Get the resource list as a HTML directory listing.

参数:
base - The base URL
parent - True if the parent directory should be included
返回:
String of HTML
抛出:
IOException

writeTo

public void writeTo(OutputStream out,
                    long start,
                    long count)
             throws IOException
参数:
out -
start - First byte to write
count - Bytes to write or -1 for all of them.
抛出:
IOException

copyTo

public void copyTo(File destination)
            throws IOException
抛出:
IOException

getWeakETag

public String getWeakETag()

toURL

public static URL toURL(File file)
                 throws MalformedURLException
Generate a properly encoded URL from a File instance.

参数:
file - Target file.
返回:
URL of the target file.
抛出:
MalformedURLException


Copyright © 2013. All Rights Reserved.