org.mortbay.util

Class FileResource

Implemented Interfaces:
Serializable

public class FileResource
extends URLResource

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 if the platform does not have the "/" path separator, or it can be controlled with the "org.mortbay.util.FileResource.checkAliases" system parameter. If alias checking is turned on, then aliased resources are treated as if they do not exist, nor can they be created.
Version:
$Revision: 1.31 $
Author:
Greg Wilkins (gregw)

Field Summary

Fields inherited from class org.mortbay.util.URLResource

_connection, _in, _url, _urlString

Method Summary

Resource
addPath(String path)
boolean
delete()
Deletes the given resource
String
encode(String uri)
Encode according to this resource type.
boolean
equals(Object o)
boolean
exists()
Returns true if the resource exists.
URL
getAlias()
static boolean
getCheckAliases()
getCheckAliases.
File
getFile()
Returns an File representing the given resource or NULL if this is not possible.
InputStream
getInputStream()
Returns an input stream to the resource
String
getName()
Returns the name of the resource
OutputStream
getOutputStream()
Returns an output stream to the resource
int
hashCode()
boolean
isDirectory()
Returns true if the respresenetd resource is a container/directory.
long
lastModified()
Returns the last modified time
long
length()
Return the length of the resource
String[]
list()
Returns a list of resources contained in the given resource
boolean
renameTo(Resource dest)
Rename the given resource
static void
setCheckAliases(boolean checkAliases)
setCheckAliases.

Methods inherited from class org.mortbay.util.URLResource

addPath, checkConnection, delete, equals, exists, getFile, getInputStream, getName, getOutputStream, getURL, hashCode, isDirectory, lastModified, length, list, release, renameTo, toString

Methods inherited from class org.mortbay.util.Resource

addPath, cache, delete, encode, exists, finalize, getAlias, getAssociate, getFile, getInputStream, getListHTML, getName, getOutputStream, getURL, isDirectory, lastModified, length, list, newResource, newResource, newSystemResource, release, renameTo, setAssociate, writeTo

Method Details

addPath

public Resource addPath(String path)
            throws IOException,
                   MalformedURLException
Overrides:
addPath in interface URLResource

delete

public boolean delete()
            throws SecurityException
Deletes the given resource
Overrides:
delete in interface URLResource

encode

public String encode(String uri)
Encode according to this resource type. File URIs are encoded.
Overrides:
encode in interface Resource
Parameters:
uri - URI to encode.
Returns:
The uri unchanged.

equals

public boolean equals(Object o)
Overrides:
equals in interface URLResource
Parameters:
o -
Returns:

exists

public boolean exists()
Returns true if the resource exists.
Overrides:
exists in interface URLResource

getAlias

public URL getAlias()
Overrides:
getAlias in interface Resource

getCheckAliases

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

getFile

public File getFile()
Returns an File representing the given resource or NULL if this is not possible.
Overrides:
getFile in interface URLResource

getInputStream

public InputStream getInputStream()
            throws IOException
Returns an input stream to the resource
Overrides:
getInputStream in interface URLResource

getName

public String getName()
Returns the name of the resource
Overrides:
getName in interface URLResource

getOutputStream

public OutputStream getOutputStream()
            throws IOException,
                   SecurityException
Returns an output stream to the resource
Overrides:
getOutputStream in interface URLResource

hashCode

public int hashCode()
Overrides:
hashCode in interface URLResource
Returns:
the hashcode.

isDirectory

public boolean isDirectory()
Returns true if the respresenetd resource is a container/directory.
Overrides:
isDirectory in interface URLResource

lastModified

public long lastModified()
Returns the last modified time
Overrides:
lastModified in interface URLResource

length

public long length()
Return the length of the resource
Overrides:
length in interface URLResource

list

public String[] list()
Returns a list of resources contained in the given resource
Overrides:
list in interface URLResource

renameTo

public boolean renameTo(Resource dest)
            throws SecurityException
Rename the given resource
Overrides:
renameTo in interface URLResource

setCheckAliases

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

Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.