| java.lang.Object com.lutris.classloader.Resource
All known Subclasses: com.lutris.classloader.LocalZipResource, com.lutris.classloader.RemoteZipResource, com.lutris.classloader.RemoteDirResource, com.lutris.classloader.LocalDirResource,
Resource | abstract public class Resource (Code) | | A resource that is a file existing on the local machine or a remote
machine. The properties of a resource include file name, location, size,
and last-modified time. The location of the resource is represented by a
ClassPathEntry and is either a directory or a zip file.
The file name, described by a String, is relative to the specified location.
The resource size is the file size in bytes and the resource time is the
last-modified time of the file in milliseconds.
This is an abstract class. All subclasses must determine the size
and last-modified time for the resource, and must implement the
getInputStream method.
Resources can be ASCII or binary files, such as text files, HTML files,
Java source-code files, Java byte-code files, Java archive (JAR) files, and
gif files. Some examples resource file names are:
/users/kristen/text/schedule.txt
/webserver/htdocs/index.html
/jdk1.1.5/src/java/util/Enumeration.java
/jdk1.1.5/classes/java/util/Enumeration.class
/users/kristen/lutris/lutris.jar
/webserver/htdocs/banner.gif
Since the file names are relative to the location, the beginning slash ("/")
does NOT mean that the file name is given as the absolute path on its
host machine.
author: Kristen Pol, Lutris Technologies version: $Revision : 1.1 $ See Also: com.lutris.classloader.ClassPathEntry |
Constructor Summary | |
protected | Resource(String name, ClassPathEntry location, LogChannel loadLogChannel) Constructs resource with specified name, location and log channel.
The file name must be described relative to the location. |
Method Summary | |
public boolean | equals(Resource resource) Determines if the specified resource is equal to this resource. | public byte[] | getBytes() Gets byte array representing resource. | abstract public long | getCurrentLastModifiedTime() Get current last-modification time of resource. | abstract public InputStream | getInputStream() Gets input stream representing resource. | public long | getLastModifiedTime() Gets last-modification time of resource at the time this
Resource object was created. | public ClassPathEntry | getLocation() Gets location of resource set previously by constructor. | public String | getName() Gets file name of resource set previously by constructor. | public long | getSize() Gets size of resource in bytes. | public long | getTime() Gets last-modified time of resource in milliseconds. | public boolean | hasBeenModified() Determine if the resource has been modified since it was loaded. | public String | toString() Stringifies resource described previously by constructor. |
lastModifiedTime | protected long lastModifiedTime(Code) | | The last-modified time of the resource when this object was created.
|
location | protected ClassPathEntry location(Code) | | The location of the resource, which can be local or remote.
|
logChannel | protected LogChannel logChannel(Code) | | Log channel to write messages to
|
logLevel | protected int logLevel(Code) | | Numeric log level number for LOGLEVEL string
|
loggingEnabled | protected boolean loggingEnabled(Code) | | Is logging enabled?
|
name | protected String name(Code) | | The file name of the resource relative to the location.
|
size | protected long size(Code) | | The size of the resource in bytes.
|
Resource | protected Resource(String name, ClassPathEntry location, LogChannel loadLogChannel) throws NullPointerException(Code) | | Constructs resource with specified name, location and log channel.
The file name must be described relative to the location. The location,
described by the ClassPathEntry , can be a directory
or a zip file on the local or a remote machine.
Assumes that all slashes in the name parameter are
forward slashes ("/");
Parameters: name - The file name of the resource. Parameters: location - The location of the resource. Parameters: loadLogChannel - The log channel for logging. exception: NullPointerException - if either the name orlocation parameters are null. See Also: ClassPathEntry |
equals | public boolean equals(Resource resource)(Code) | | Determines if the specified resource is equal to this resource.
Resources are considered equal if the file names, locations, sizes,
and last-modified times are all the same.
true if the resources are equal, false if not. |
getBytes | public byte[] getBytes() throws IOException(Code) | | Gets byte array representing resource.
This method relies on the implementation of
getInputStream .
an array of bytes representing the resource. exception: IOException - if the byte array can not be constructed. |
getCurrentLastModifiedTime | abstract public long getCurrentLastModifiedTime() throws FileNotFoundException(Code) | | Get current last-modification time of resource. This is the
time on the disk file the resource is associated with.
the last-modified time of the permanent copy of the resourcein milliseconds. |
getInputStream | abstract public InputStream getInputStream() throws IOException(Code) | | Gets input stream representing resource.
This method is abstract and must be implemented by all subclasses.
The getBytes method also depends upon this implementation.
the input stream that represents the resource. exception: IOException - if the input stream can not be constructed. |
getLastModifiedTime | public long getLastModifiedTime()(Code) | | Gets last-modification time of resource at the time this
Resource object was created.
All subclasses are expected to determine this time prior to
this method being called.
the last-modified time of the resource in milliseconds. |
getLocation | public ClassPathEntry getLocation()(Code) | | Gets location of resource set previously by constructor.
the location of the resource represented by aClassPathEntry . |
getName | public String getName()(Code) | | Gets file name of resource set previously by constructor.
the file name of the resource represented by aString . |
getSize | public long getSize()(Code) | | Gets size of resource in bytes.
All subclasses are expected to determine this size prior to
this method being called.
the size of the resource in bytes. |
getTime | public long getTime()(Code) | | Gets last-modified time of resource in milliseconds.
See Also: getlastModifiedTime |
hasBeenModified | public boolean hasBeenModified() throws FileNotFoundException(Code) | | Determine if the resource has been modified since it was loaded.
true if the resource has been modified,false if not. |
toString | public String toString()(Code) | | Stringifies resource described previously by constructor. The
the file name and location are concatenated together to represent
the resource.
the resource represented by a String composed ofthe file name and location. |
|
|