|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.apache.excalibur.source.impl.FileSource
A ModifiableTraversableSource for filesystem objects.
| Constructor Summary | |
FileSource(java.lang.String uri)
Builds a FileSource given an URI, which doesn't necessarily have to start with "file:" |
|
FileSource(java.lang.String scheme,
java.io.File file)
Builds a FileSource, given an URI scheme and a File. |
|
| Method Summary | |
boolean |
canCancel(java.io.OutputStream stream)
Can the data sent to an OutputStream returned by
getOutputStream() be cancelled ? |
void |
cancel(java.io.OutputStream stream)
Cancel the data sent to an OutputStream returned by
getOutputStream(). |
void |
copyTo(Source destination)
Copy the current source to a specified destination. |
void |
delete()
Delete the source. |
boolean |
exists()
Does this source actually exist ? |
Source |
getChild(java.lang.String name)
Get a child of this source, given its name. |
java.util.Collection |
getChildren()
Get the children of this source if this source is traversable. |
long |
getContentLength()
Get the content length of this source's content or -1 if the length is unknown. |
java.io.File |
getFile()
Get the associated file |
java.io.InputStream |
getInputStream()
Return an InputStream to read from the source. |
long |
getLastModified()
Get the last modification date of this source. |
java.lang.String |
getMimeType()
Get the mime-type of the content described by this object. |
java.lang.String |
getName()
Return the name of this source relative to its parent. |
java.io.OutputStream |
getOutputStream()
Get an InputStream where raw bytes can be written to. |
Source |
getParent()
Get the parent of this source as a Source object. |
java.lang.String |
getScheme()
Return the URI scheme identifier, i.e. |
java.lang.String |
getURI()
Get the absolute URI for this source. |
SourceValidity |
getValidity()
Return a validity object based on the file's modification date. |
boolean |
isCollection()
Is this source a collection, i.e. |
void |
makeCollection()
If it doesn't already exist, ensure this source is traversable (equivalent to File.mkdirs())
|
void |
moveTo(Source destination)
Move the current source to a specified destination. |
void |
refresh()
Refresh the content of this object after the underlying data content has changed. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public FileSource(java.lang.String uri)
throws SourceException,
java.net.MalformedURLException
uri -
SourceException
java.net.MalformedURLException
public FileSource(java.lang.String scheme,
java.io.File file)
throws SourceException
scheme - file -
SourceException| Method Detail |
public java.io.File getFile()
public long getContentLength()
Source
getContentLength in interface SourceSource.getContentLength()
public java.io.InputStream getInputStream()
throws java.io.IOException,
SourceNotFoundException
SourceInputStream to read from the source.
This is the data at the point of invocation of this method,
so if this is Modifiable, you might get different content
from two different invocations.
The returned stream must be closed by the calling code.
getInputStream in interface SourceInputStream to read data from (never null).
SourceNotFoundException - if the source doesn't exist.
java.io.IOException - if some I/O problem occurs.Source.getInputStream()public long getLastModified()
Source0 if it's unknown.
getLastModified in interface Source0.Source.getLastModified()public java.lang.String getMimeType()
Sourcenull.
getMimeType in interface Sourcenull.Source.getMimeType()public java.lang.String getScheme()
Source
This scheme can be used to get the SourceFactory responsible for this object.
getScheme in interface Sourcepublic java.lang.String getURI()
Source
getURI in interface Sourcepublic SourceValidity getValidity()
getValidity in interface Sourcenull.Source.getValidity()public void refresh()
SourceSome implementations may cache some values to speedup sucessive calls. Refreshing ensures you get the latest information.
refresh in interface SourceSource.refresh()public boolean exists()
exists in interface Source
public Source getChild(java.lang.String name)
throws SourceException
TraversableSourceSource.exists().
getChild in interface TraversableSourcename - the child name.
SourceException - if this source is not traversable or if some other
error occurs.TraversableSource.getChild(java.lang.String)
public java.util.Collection getChildren()
throws SourceException
TraversableSource
Note: only those sources actually fetched from the
collection need to be released using the SourceResolver.
getChildren in interface TraversableSourceSources (actually most probably TraversableSources).
SourceException - this source is not traversable, or if some problem occurs.TraversableSource.getChildren()public java.lang.String getName()
TraversableSource
getName in interface TraversableSourceTraversableSource.getName()
public Source getParent()
throws SourceException
TraversableSourceSource object.
getParent in interface TraversableSourcenull if this source has no parent.
SourceException - if some problem occurs.TraversableSource.getParent()public boolean isCollection()
TraversableSource
isCollection in interface TraversableSourceTraversableSource.isCollection()
public java.io.OutputStream getOutputStream()
throws java.io.IOException
InputStream where raw bytes can be written to.
The signification of these bytes is implementation-dependent and
is not restricted to a serialized XML document.
The output stream returned actually writes to a temp file that replaces
the real one on close. This temp file is used as lock to forbid multiple
simultaneous writes. The real file is updated atomically when the output
stream is closed.
The returned stream must be closed or cancelled by the calling code.
getOutputStream in interface ModifiableSourcejava.util.ConcurrentModificationException - if another thread is currently
writing to this file.
java.io.IOExceptionpublic boolean canCancel(java.io.OutputStream stream)
OutputStream returned by
getOutputStream() be cancelled ?
canCancel in interface ModifiableSource
public void cancel(java.io.OutputStream stream)
throws SourceException
OutputStream returned by
getOutputStream().
After cancel, the stream should no more be used.
cancel in interface ModifiableSourceSourceException
public void delete()
throws SourceException
delete in interface ModifiableSourceSourceException
public void makeCollection()
throws SourceException
ModifiableTraversableSourceFile.mkdirs())
If the source already exists, this method does nothing if it's already traversable, and fails otherwise.
makeCollection in interface ModifiableTraversableSourceSourceExceptionModifiableTraversableSource.makeCollection()
public void copyTo(Source destination)
throws SourceException
MoveableSource
copyTo in interface MoveableSourcedestination - Destination of the source.
SourceException - If an exception occurs during
the copy.MoveableSource.copyTo(org.apache.excalibur.source.Source)
public void moveTo(Source destination)
throws SourceException
MoveableSource
moveTo in interface MoveableSourcedestination - Destination of the source.
SourceException - If an exception occurs during
the move.MoveableSource.moveTo(org.apache.excalibur.source.Source)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||