Top Description Fields Constructors Methods
org.mortbay.resource

public Class URLResource

extends Resource
Class Inheritance
Known Direct Subclasses
org.mortbay.resource.BadResource, org.mortbay.resource.FileResource, org.mortbay.resource.JarResource
Imports
java.io.File, .IOException, .InputStream, .OutputStream, java.net.MalformedURLException, .URL, .URLConnection, java.security.Permission, org.mortbay.log.Log, org.mortbay.util.URIUtil

Abstract resource class.
Authors
Nuno Pregui�a, Greg Wilkins (gregw)

Field Summary

Modifier and TypeField and Description
protected transient URLConnection
protected transient InputStream
protected URL
protected String
pack-priv transient boolean
Inherited from org.mortbay.resource.Resource:
__defaultUseCaches_associate

Constructor Summary

AccessConstructor and Description
protected
URLResource(URL url, URLConnection connection)

protected
URLResource(URL url, URLConnection connection, boolean useCaches)

Method Summary

Modifier and TypeMethod and Description
public Resource
addPath(String
The path segment to add, which should be encoded by the encode method.
path
)

Implements abstract org.mortbay.resource.Resource.addPath.

Returns the resource contained inside the current resource with the given name
protected synchronized boolean
public boolean
delete()

Implements abstract org.mortbay.resource.Resource.delete.

Deletes the given resource
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public boolean
exists()

Implements abstract org.mortbay.resource.Resource.exists.

Returns true if the represented resource exists.
public File
getFile()

Implements abstract org.mortbay.resource.Resource.getFile.

Returns an File representing the given resource or NULL if this is not possible.
public synchronized InputStream
getInputStream()

Implements abstract org.mortbay.resource.Resource.getInputStream.

Returns an input stream to the resource
public String
getName()

Implements abstract org.mortbay.resource.Resource.getName.

Returns the name of the resource
public OutputStream
getOutputStream()

Implements abstract org.mortbay.resource.Resource.getOutputStream.

Returns an output stream to the resource
public URL
getURL()

Implements abstract org.mortbay.resource.Resource.getURL.

Returns an URL representing the given resource
public boolean
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.
public boolean
isDirectory()

Implements abstract org.mortbay.resource.Resource.isDirectory.

Returns true if the respresenetd resource is a container/directory.
public long
lastModified()

Implements abstract org.mortbay.resource.Resource.lastModified.

Returns the last modified time
public long
length()

Implements abstract org.mortbay.resource.Resource.length.

Return the length of the resource
public String[]
list()

Implements abstract org.mortbay.resource.Resource.list.

Returns a list of resource names contained in the given resource
public synchronized void
release()

Implements abstract org.mortbay.resource.Resource.release.

Release any resources held by the resource.
public boolean
renameTo(Resource dest)

Implements abstract org.mortbay.resource.Resource.renameTo.

Rename the given resource
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from org.mortbay.resource.Resource:
encodefinalizegetAliasgetAssociategetDefaultUseCachesgetListHTMLnewClassPathResourcenewClassPathResourcenewResourcenewResourcenewResourcenewResourcenewSystemResourcesetAssociatesetDefaultUseCacheswriteTo

Field Detail

_connectionback to summary
protected transient URLConnection _connection
_inback to summary
protected transient InputStream _in
_urlback to summary
protected URL _url
_urlStringback to summary
protected String _urlString
_useCachesback to summary
pack-priv transient boolean _useCaches

Constructor Detail

URLResourceback to summary
protected URLResource(URL url, URLConnection connection)
URLResourceback to summary
protected URLResource(URL url, URLConnection connection, boolean useCaches)

Method Detail

addPathback to summary
public Resource addPath(String path) throws IOException, MalformedURLException

Implements abstract org.mortbay.resource.Resource.addPath.

Returns the resource contained inside the current resource with the given name

Parameters
path:String

Doc from org.mortbay.resource.Resource.addPath.

The path segment to add, which should be encoded by the encode method.

checkConnectionback to summary
protected synchronized boolean checkConnection()
deleteback to summary
public boolean delete() throws SecurityException

Implements abstract org.mortbay.resource.Resource.delete.

Deletes the given resource

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

existsback to summary
public boolean exists()

Implements abstract org.mortbay.resource.Resource.exists.

Returns true if the represented resource exists.

getFileback to summary
public File getFile() throws IOException

Implements abstract org.mortbay.resource.Resource.getFile.

Returns an File representing the given resource or NULL if this is not possible.

getInputStreamback to summary
public synchronized InputStream getInputStream() throws IOException

Implements abstract org.mortbay.resource.Resource.getInputStream.

Returns an input stream to the resource

getNameback to summary
public String getName()

Implements abstract org.mortbay.resource.Resource.getName.

Returns the name of the resource

getOutputStreamback to summary
public OutputStream getOutputStream() throws IOException, SecurityException

Implements abstract org.mortbay.resource.Resource.getOutputStream.

Returns an output stream to the resource

getURLback to summary
public URL getURL()

Implements abstract org.mortbay.resource.Resource.getURL.

Returns an URL representing the given resource

getUseCachesback to summary
public boolean getUseCaches()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

isDirectoryback to summary
public boolean isDirectory()

Implements abstract org.mortbay.resource.Resource.isDirectory.

Returns true if the respresenetd resource is a container/directory. If the resource is not a file, resources ending with "/" are considered directories.

lastModifiedback to summary
public long lastModified()

Implements abstract org.mortbay.resource.Resource.lastModified.

Returns the last modified time

lengthback to summary
public long length()

Implements abstract org.mortbay.resource.Resource.length.

Return the length of the resource

listback to summary
public String[] list()

Implements abstract org.mortbay.resource.Resource.list.

Returns a list of resource names contained in the given resource

releaseback to summary
public synchronized void release()

Implements abstract org.mortbay.resource.Resource.release.

Release any resources held by the resource.

renameToback to summary
public boolean renameTo(Resource dest) throws SecurityException

Implements abstract org.mortbay.resource.Resource.renameTo.

Rename the given resource

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object