|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jicengine.io.AbstractResource
implements the most general methods of the Resource-interface.
Constructor Summary | |
protected |
AbstractResource(java.lang.String identifier)
|
Method Summary | |
java.lang.String |
getIdentifier()
Returns the identifier of this resource. |
abstract java.io.InputStream |
getInputStream()
A primary way reading the resource. |
java.lang.String |
getMimeType()
Returns the mime-type set with setMimeType(). |
java.io.Reader |
getReader()
Simple implementation of getReader() that
wraps the InputStream obtained from getInputStream()
with a InputStreamReader .
|
abstract Resource |
getResource(java.lang.String relativePath)
Locates another Resource whose path is defined relative to this Resource. |
boolean |
isAvailable()
Determines the availability of the Resource by calling getInputStream() : resource is available if the method doesn't
throw an exception.
|
void |
setMimeType(java.lang.String mimeType)
|
java.lang.String |
toString()
|
void |
writeTo(java.io.OutputStream out)
Writes the content of this resource into an OutputStream. |
void |
writeTo(java.io.Writer writer)
Writes the content of this resource into a Writer. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
protected AbstractResource(java.lang.String identifier)
Method Detail |
public abstract java.io.InputStream getInputStream() throws java.io.IOException
Resource
getInputStream
in interface Resource
java.io.IOException
- if the reading fails - if the resource doesn't exist,
for example.public java.io.Reader getReader() throws java.io.IOException
Simple implementation of getReader()
that
wraps the InputStream
obtained from getInputStream()
with a InputStreamReader
.
Override this method if a better alternative for creating the Reader
is available.
getReader
in interface Resource
java.io.IOException
- if the reading fails - if the resource doesn't exist,
for example.public boolean isAvailable()
Determines the availability of the Resource by calling
getInputStream()
: resource is available if the method doesn't
throw an exception.
Override this if a more efficient way for determining the availability is possible.
isAvailable
in interface Resource
public void writeTo(java.io.OutputStream out) throws java.io.IOException
Resource
writeTo
in interface Resource
java.io.IOException
- if the content of this Resource isn't available - if
the resource doesn't exist, for example.public void writeTo(java.io.Writer writer) throws java.io.IOException
Resource
Writes the content of this resource into a Writer. This is an alternative way for obtaining the data of this Resource.
writeTo
in interface Resource
java.io.IOException
- if the content of this Resource isn't available - if
the resource doesn't exist, for example.public java.lang.String getIdentifier()
Resource
getIdentifier
in interface Resource
public void setMimeType(java.lang.String mimeType)
public java.lang.String getMimeType()
getMimeType
in interface Resource
public abstract Resource getResource(java.lang.String relativePath) throws java.io.IOException
Resource
Locates another Resource whose path is defined relative to this Resource.
the path scheme used with files and urls is used for specifying relative paths.
the method generally returns instances of the same Resource-subclass than the current instance, but this is not obligatory.
NOTE:
NOTE: there is no support for absolute paths. yet.
getResource
in interface Resource
relativePath
- name of the neighbouring resource. only relative paths
are allowed, don't put the root mark '/' in the beginning. notations
like '../' can be used (in most of the cases, at least) Windows-like
paths '\joku\jotain.txt' won't work.
java.io.IOException
- if a reference to the neighbouring resource couldn't be
created.public java.lang.String toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |