|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--net.larsan.urd.util.fileset.ResourceBase
Abstract base class for resources. This class keeps track size, visited time path and an error handler.
| Field Summary | |
protected ErrorHandler |
errorHandler
Error handler |
protected java.lang.String |
filePath
File path, relative to the file set root folder. |
protected long |
size
Optional file size in bytes, defaults to -1 if not set. |
protected long |
visited
Exact time the file was visited in milliconds since epoch. |
| Constructor Summary | |
ResourceBase(java.lang.String filePath)
Construct file resource with a path with a visited time set to the current system time. |
|
ResourceBase(java.lang.String filePath,
long visited,
ErrorHandler errorHandler)
Construct file resource with a path and a visited time. |
|
| Method Summary | |
boolean |
equals(java.lang.Object o)
Equality check on the relative path. |
abstract boolean |
exists()
Check if the resource is valid. |
abstract byte[] |
getBytes()
Get a byte array from the file. |
abstract java.security.cert.Certificate[] |
getCertificates()
Get resource Certificates if the resource have been signed. |
ErrorHandler |
getErrorHandler()
Get the error handler for this resource. |
long |
getFileSize()
Get file size in bytes. |
java.lang.String |
getPath()
Get file path, this path will not start with a separator and should be relative to the file set root and case sensitive. |
abstract java.io.InputStream |
getStream()
Get a byte stream from the file. |
abstract java.net.URL |
getURL()
Get a URL to the resource. |
long |
getVisitedTime()
Get visited time in milliseconds. |
int |
hashCode()
Hash code based on the relative file path. |
protected java.lang.Object |
report(java.io.IOException e)
Report an IO exception to the error handle of the enclosing file set. |
void |
setErrorHandler(ErrorHandler errorHandler)
Set the error handler for this resource. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface net.larsan.urd.util.Resource |
getCodeSource |
| Field Detail |
protected ErrorHandler errorHandler
protected long visited
protected java.lang.String filePath
protected long size
| Constructor Detail |
public ResourceBase(java.lang.String filePath,
long visited,
ErrorHandler errorHandler)
filePath - Resource path, must not be nullvisited - Time of resource visitationerrorHandler - Error handler to use, may be nullpublic ResourceBase(java.lang.String filePath)
filePath - Resource path, must not be null| Method Detail |
public abstract java.io.InputStream getStream()
getStream in interface Resourcepublic abstract byte[] getBytes()
getBytes in interface Resourcepublic abstract java.net.URL getURL()
getURL in interface Resourcepublic abstract java.security.cert.Certificate[] getCertificates()
getCertificates in interface Resourcepublic abstract boolean exists()
public java.lang.String getPath()
getPath in interface Resourcepublic long getVisitedTime()
public long getFileSize()
public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic ErrorHandler getErrorHandler()
public void setErrorHandler(ErrorHandler errorHandler)
errorHandler - Error handler for this resourceprotected java.lang.Object report(java.io.IOException e)
This method only returns null.
e - IOException to report
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||