|
EAF 7.4 API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.lutris.classloader.Resource
public abstract class Resource
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.gifSince 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.
ClassPathEntry
Field Summary | |
---|---|
protected long |
lastModifiedTime
The last-modified time of the resource when this object was created. |
protected com.lutris.classloader.ClassPathEntry |
location
The location of the resource, which can be local or remote. |
protected LogChannel |
logChannel
Log channel to write messages to |
protected boolean |
loggingEnabled
Is logging enabled? |
protected int |
logLevel
Numeric log level number for LOGLEVEL string |
protected java.lang.String |
name
The file name of the resource relative to the location. |
protected long |
size
The size of the resource in bytes. |
Constructor Summary | |
---|---|
protected |
Resource(java.lang.String name,
com.lutris.classloader.ClassPathEntry location,
LogChannel loadLogChannel)
Constructs resource with specified name, location and log channel. |
Method Summary | |
---|---|
boolean |
equals(Resource resource)
Determines if the specified resource is equal to this resource. |
byte[] |
getBytes()
Gets byte array representing resource. |
abstract long |
getCurrentLastModifiedTime()
Get current last-modification time of resource. |
abstract java.io.InputStream |
getInputStream()
Gets input stream representing resource. |
long |
getLastModifiedTime()
Gets last-modification time of resource at the time this Resource object was created. |
com.lutris.classloader.ClassPathEntry |
getLocation()
Gets location of resource set previously by constructor. |
java.lang.String |
getName()
Gets file name of resource set previously by constructor. |
long |
getSize()
Gets size of resource in bytes. |
long |
getTime()
Gets last-modified time of resource in milliseconds. |
boolean |
hasBeenModified()
Determine if the resource has been modified since it was loaded. |
java.lang.String |
toString()
Stringifies resource described previously by constructor. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.lang.String name
protected com.lutris.classloader.ClassPathEntry location
protected long size
protected long lastModifiedTime
protected boolean loggingEnabled
protected LogChannel logChannel
protected int logLevel
Constructor Detail |
---|
protected Resource(java.lang.String name, com.lutris.classloader.ClassPathEntry location, LogChannel loadLogChannel) throws java.lang.NullPointerException
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 ("/");
name
- The file name of the resource.location
- The location of the resource.loadLogChannel
- The log channel for logging.
java.lang.NullPointerException
- if either the name
or
location
parameters are null.ClassPathEntry
Method Detail |
---|
public java.lang.String getName()
String
.public com.lutris.classloader.ClassPathEntry getLocation()
ClassPathEntry
.public java.lang.String toString()
toString
in class java.lang.Object
String
composed of
the file name and location.public long getSize()
All subclasses are expected to determine this size prior to this method being called.
public long getLastModifiedTime()
All subclasses are expected to determine this time prior to this method being called.
public long getTime()
getlastModifiedTime
public abstract long getCurrentLastModifiedTime() throws java.io.FileNotFoundException
java.io.FileNotFoundException
public boolean hasBeenModified() throws java.io.FileNotFoundException
true
if the resource has been modified,
false
if not.
java.io.FileNotFoundException
public byte[] getBytes() throws java.io.IOException
This method relies on the implementation of
getInputStream
.
java.io.IOException
- if the byte array can not be constructed.public abstract java.io.InputStream getInputStream() throws java.io.IOException
This method is abstract and must be implemented by all subclasses.
The getBytes
method also depends upon this implementation.
java.io.IOException
- if the input stream can not be constructed.public boolean equals(Resource resource)
|
EAF 7.4 API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |