Top Description Fields Constructors Methods
org.mortbay.resource

public Class FileResource

extends URLResource
Class Inheritance
Imports
java.io.File, .FileInputStream, .FileOutputStream, .IOException, .InputStream, .OutputStream, java.net.MalformedURLException, .URI, .URISyntaxException, .URL, .URLConnection, java.security.Permission, org.mortbay.log.Log, org.mortbay.util.URIUtil

File Resource. Handle resources of implied or explicit file type. This class can check for aliasing in the filesystem (eg case insensitivity). By default this is turned on, or it can be controlled with the "org.mortbay.util.FileResource.checkAliases" system parameter.
Author
Greg Wilkins (gregw)

Field Summary

Modifier and TypeField and Description
private static boolean
private transient URL
private transient boolean
private File
Inherited from org.mortbay.resource.URLResource:
_connection_in_url_urlString_useCaches

Constructor Summary

AccessConstructor and Description
public
pack-priv
FileResource(URL url, URLConnection connection, File file)

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
)

Overrides org.mortbay.resource.URLResource.addPath.

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

Overrides org.mortbay.resource.URLResource.delete.

Deletes the given resource
public String

Returns:

The uri unchanged.
encode
(String
URI to encode.
uri
)

Overrides org.mortbay.resource.Resource.encode.

Encode according to this resource type.
public boolean

Returns:

true of the object o is a FileResource pointing to the same file as this resource.
equals
(Object o)

Overrides org.mortbay.resource.URLResource.equals.

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

Overrides org.mortbay.resource.URLResource.exists.

Returns true if the resource exists.
public URL
public static boolean

Returns:

True of resource aliases are to be checked for (eg case insensitivity or 8.3 short names) and treated as not found.
getCheckAliases
()

getCheckAliases.

public File
getFile()

Overrides org.mortbay.resource.URLResource.getFile.

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

Overrides org.mortbay.resource.URLResource.getInputStream.

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

Overrides org.mortbay.resource.URLResource.getName.

Returns the name of the resource
public OutputStream
getOutputStream()

Overrides org.mortbay.resource.URLResource.getOutputStream.

Returns an output stream to the resource
public int

Returns:

the hashcode.
hashCode
()

Overrides org.mortbay.resource.URLResource.hashCode.

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

Overrides org.mortbay.resource.URLResource.isDirectory.

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

Overrides org.mortbay.resource.URLResource.lastModified.

Returns the last modified time
public long
length()

Overrides org.mortbay.resource.URLResource.length.

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

Overrides org.mortbay.resource.URLResource.list.

Returns a list of resources contained in the given resource
public boolean
renameTo(Resource dest)

Overrides org.mortbay.resource.URLResource.renameTo.

Rename the given resource
public static void
setCheckAliases(boolean
True of resource aliases are to be checked for (eg case insensitivity or 8.3 short names) and treated as not found.
checkAliases
)

setCheckAliases.

Inherited from org.mortbay.resource.URLResource:
checkConnectiongetURLgetUseCachesreleasetoString

Field Detail

__checkAliasesback to summary
private static boolean __checkAliases
_aliasback to summary
private transient URL _alias
_aliasCheckedback to summary
private transient boolean _aliasChecked
_fileback to summary
private File _file

Constructor Detail

FileResourceback to summary
public FileResource(URL url) throws IOException, URISyntaxException
FileResourceback to summary
pack-priv FileResource(URL url, URLConnection connection, File file)

Method Detail

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

Overrides org.mortbay.resource.URLResource.addPath.

Doc from org.mortbay.resource.URLResource.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.

deleteback to summary
public boolean delete() throws SecurityException

Overrides org.mortbay.resource.URLResource.delete.

Deletes the given resource

encodeback to summary
public String encode(String uri)

Overrides org.mortbay.resource.Resource.encode.

Encode according to this resource type. File URIs are encoded.

Parameters
uri:String

URI to encode.

Returns:String

The uri unchanged.

equalsback to summary
public boolean equals(Object o)

Overrides org.mortbay.resource.URLResource.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.

Returns:boolean

true of the object o is a FileResource pointing to the same file as this resource.

existsback to summary
public boolean exists()

Overrides org.mortbay.resource.URLResource.exists.

Returns true if the resource exists.

getAliasback to summary
public URL getAlias()

Overrides org.mortbay.resource.Resource.getAlias.

Returns:URL

Doc from org.mortbay.resource.Resource.getAlias.

The canonical Alias of this resource or null if none.

getCheckAliasesback to summary
public static boolean getCheckAliases()

getCheckAliases.

Returns:boolean

True of resource aliases are to be checked for (eg case insensitivity or 8.3 short names) and treated as not found.

getFileback to summary
public File getFile()

Overrides org.mortbay.resource.URLResource.getFile.

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

getInputStreamback to summary
public InputStream getInputStream() throws IOException

Overrides org.mortbay.resource.URLResource.getInputStream.

Returns an input stream to the resource

getNameback to summary
public String getName()

Overrides org.mortbay.resource.URLResource.getName.

Returns the name of the resource

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

Overrides org.mortbay.resource.URLResource.getOutputStream.

Returns an output stream to the resource

hashCodeback to summary
public int hashCode()

Overrides org.mortbay.resource.URLResource.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

the hashcode.

isDirectoryback to summary
public boolean isDirectory()

Overrides org.mortbay.resource.URLResource.isDirectory.

Returns true if the respresenetd resource is a container/directory.

lastModifiedback to summary
public long lastModified()

Overrides org.mortbay.resource.URLResource.lastModified.

Returns the last modified time

lengthback to summary
public long length()

Overrides org.mortbay.resource.URLResource.length.

Return the length of the resource

listback to summary
public String[] list()

Overrides org.mortbay.resource.URLResource.list.

Returns a list of resources contained in the given resource

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

Overrides org.mortbay.resource.URLResource.renameTo.

Rename the given resource

setCheckAliasesback to summary
public static void setCheckAliases(boolean checkAliases)

setCheckAliases.

Parameters
checkAliases:boolean

True of resource aliases are to be checked for (eg case insensitivity or 8.3 short names) and treated as not found.