|
|||||||||
| Home >> All >> org >> mortbay >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.mortbay.util
Class CachedResource

java.lang.Objectorg.mortbay.util.Resource
org.mortbay.util.CachedResource
- All Implemented Interfaces:
- java.io.Serializable
- public class CachedResource
- extends Resource
Cached resource class. This resource caches in memory the contents of another resource. The update() method must be called to check if the real resource has been modified.
- Version:
- $Id: CachedResource.java,v 1.5 2002/12/14 13:03:06 bretts Exp $
| Field Summary | |
(package private) byte[] |
_buf
|
(package private) long |
_lastModified
|
(package private) java.lang.String[] |
_list
|
(package private) Resource |
_resource
|
| Fields inherited from class org.mortbay.util.Resource |
_associate |
| Constructor Summary | |
(package private) |
CachedResource(Resource resource)
|
| Method Summary | |
Resource |
addPath(java.lang.String path)
Returns the resource contained inside the current resource with the given name |
void |
clear()
|
boolean |
delete()
Deletes the given resource |
boolean |
equals(java.lang.Object o)
Determine whether this Object is semantically equal to another Object. |
boolean |
exists()
Returns true if the respresened resource exists. |
byte[] |
getCachedData()
|
java.io.File |
getFile()
Returns an File representing the given resource or NULL if this is not possible. |
java.io.InputStream |
getInputStream()
Returns an input stream to the resource |
java.lang.String |
getName()
Returns the name of the resource |
java.io.OutputStream |
getOutputStream()
Returns an output stream to the resource |
java.net.URL |
getURL()
Returns an URL representing the given resource |
int |
hashCode()
Get a value that represents this Object, as uniquely as possible within the confines of an int. |
boolean |
isDirectory()
Returns true if the respresenetd resource is a container/directory. |
boolean |
isUptoDate()
|
long |
lastModified()
Returns the last modified time |
long |
length()
Return the length of the resource |
java.lang.String[] |
list()
Returns a list of resource names contained in the given resource |
void |
release()
Release any resources held by the resource. |
boolean |
renameTo(Resource dest)
Rename the given resource |
void |
setCachedData(byte[] buf)
|
java.lang.String |
toString()
Convert this Object to a human-readable String. |
boolean |
update()
|
void |
writeTo(java.io.OutputStream os,
long startByte,
long count)
|
| Methods inherited from class org.mortbay.util.Resource |
cache, encode, finalize, getAlias, getAssociate, getListHTML, newResource, newResource, newSystemResource, setAssociate |
| Methods inherited from class java.lang.Object |
clone, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
_resource
Resource _resource
_lastModified
long _lastModified
_buf
byte[] _buf
_list
java.lang.String[] _list
| Constructor Detail |
CachedResource
CachedResource(Resource resource) throws java.io.IOException
| Method Detail |
isUptoDate
public boolean isUptoDate()
throws java.io.IOException
update
public boolean update()
throws java.io.IOException
clear
public void clear()
release
public void release()
exists
public boolean exists()
isDirectory
public boolean isDirectory()
- Description copied from class:
Resource - Returns true if the respresenetd resource is a container/directory.
If the resource is not a file, resources ending with "/" are
considered directories.
- Specified by:
isDirectoryin classResource
lastModified
public long lastModified()
- Description copied from class:
Resource - Returns the last modified time
- Specified by:
lastModifiedin classResource
length
public long length()
- Description copied from class:
Resource - Return the length of the resource
getURL
public java.net.URL getURL()
- Description copied from class:
Resource - Returns an URL representing the given resource
getFile
public java.io.File getFile() throws java.io.IOException
- Description copied from class:
Resource - Returns an File representing the given resource or NULL if this
is not possible.
getName
public java.lang.String getName()
getInputStream
public java.io.InputStream getInputStream() throws java.io.IOException
- Returns an input stream to the resource
- Specified by:
getInputStreamin classResource
getOutputStream
public java.io.OutputStream getOutputStream() throws java.io.IOException, java.lang.SecurityException
- Returns an output stream to the resource
- Specified by:
getOutputStreamin classResource
delete
public boolean delete()
throws java.lang.SecurityException
renameTo
public boolean renameTo(Resource dest) throws java.lang.SecurityException
list
public java.lang.String[] list()
- Returns a list of resource names contained in the given resource
addPath
public Resource addPath(java.lang.String path) throws java.io.IOException, java.net.MalformedURLException
- Returns the resource contained inside the current resource with the
given name
toString
public java.lang.String toString()
- Description copied from class:
java.lang.Object - Convert this Object to a human-readable String.
There are no limits placed on how long this String
should be or what it should contain. We suggest you
make it as intuitive as possible to be able to place
it into System.out.println() 55
and such.
It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.
This method will be called when performing string concatenation with this object. If the result is
null, string concatenation will instead use"null".The default implementation returns
getClass().getName() + "@" + Integer.toHexString(hashCode()).
hashCode
public int hashCode()
- Description copied from class:
java.lang.Object - Get a value that represents this Object, as uniquely as
possible within the confines of an int.
There are some requirements on this method which subclasses must follow:
- Semantic equality implies identical hashcodes. In other
words, if
a.equals(b)is true, thena.hashCode() == b.hashCode()must be as well. However, the reverse is not necessarily true, and two objects may have the same hashcode without being equal. - It must be consistent. Whichever value o.hashCode() returns on the first invocation must be the value returned on all later invocations as long as the object exists. Notice, however, that the result of hashCode may change between separate executions of a Virtual Machine, because it is not invoked on the same object.
Notice that since
hashCodeis used in java.util.Hashtable and other hashing classes, a poor implementation will degrade the performance of hashing (so don't blindly implement it as returning a constant!). Also, if calculating the hash is time-consuming, a class may consider caching the results.The default implementation returns
System.identityHashCode(this) - Semantic equality implies identical hashcodes. In other
words, if
equals
public boolean equals(java.lang.Object o)
- Description copied from class:
java.lang.Object - Determine whether this Object is semantically equal
to another Object.
There are some fairly strict requirements on this method which subclasses must follow:
- It must be transitive. If
a.equals(b)andb.equals(c), thena.equals(c)must be true as well. - It must be symmetric.
a.equals(b)andb.equals(a)must have the same value. - It must be reflexive.
a.equals(a)must always be true. - It must be consistent. Whichever value a.equals(b) returns on the first invocation must be the value returned on all later invocations.
a.equals(null)must be false.- It must be consistent with hashCode(). That is,
a.equals(b)must implya.hashCode() == b.hashCode(). The reverse is not true; two objects that are not equal may have the same hashcode, but that has the potential to harm hashing performance.
This is typically overridden to throw a java.lang.ClassCastException if the argument is not comparable to the class performing the comparison, but that is not a requirement. It is legal for
a.equals(b)to be true even thougha.getClass() != b.getClass(). Also, it is typical to never cause a java.lang.NullPointerException.In general, the Collections API (
java.util) use theequalsmethod rather than the==operator to compare objects. However, java.util.IdentityHashMap is an exception to this rule, for its own good reasons.The default implementation returns
this == o. - It must be transitive. If
writeTo
public void writeTo(java.io.OutputStream os, long startByte, long count) throws java.io.IOException
getCachedData
public byte[] getCachedData()
setCachedData
public void setCachedData(byte[] buf)
|
|||||||||
| Home >> All >> org >> mortbay >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC