|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.semanticdesktop.aperture.accessor.base.DataObjectBase
org.semanticdesktop.aperture.accessor.base.FileDataObjectBase
public class FileDataObjectBase
A trivial default implementation of FileDataObject.
Constructor Summary | |
---|---|
FileDataObjectBase()
Default constructor. |
|
FileDataObjectBase(URI id,
DataSource dataSource,
RDFContainer metadata,
File file)
Constructor accepting a file. |
|
FileDataObjectBase(URI id,
DataSource dataSource,
RDFContainer metadata,
InputStream content)
Constructor accepting a content stream. |
Method Summary | |
---|---|
protected void |
closeContent()
Closes the content stream and sets it to null. |
void |
dispose()
Closes the stream encapsulated by this FileDataObject. |
File |
downloadContent()
Downloads the entire content of the stream to a temporary file (created with File.createTempFile(String, String) ). |
void |
finalize()
|
InputStream |
getContent()
Gets an InputStream containing the content represented by the DataObject. |
File |
getFile()
Returns an instance of java.io.File representing the content of this FileDataObject. |
void |
setContent(InputStream content)
Sets the InputStream containing the content represented by the DataObject. |
void |
setFile(File file)
Sets the file containing the content represented by this FileDataObject. |
protected void |
setFileWithoutChecks(File file)
Sets the file without checking if it exists and is readable, and without updating the content. |
Methods inherited from class org.semanticdesktop.aperture.accessor.base.DataObjectBase |
---|
getDataSource, getID, getMetadata, getWrappedDataObject, isDisposed, setDataSource, setID, setMetadata, setWrappedDataObject |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.semanticdesktop.aperture.accessor.DataObject |
---|
getDataSource, getID, getMetadata |
Constructor Detail |
---|
public FileDataObjectBase()
public FileDataObjectBase(URI id, DataSource dataSource, RDFContainer metadata, InputStream content)
id
- URI of this data object (obligatory)dataSource
- the data source where this data object came from (optional)metadata
- the metadata of this data object (obligatory)content
- the content stream (must support mark()).public FileDataObjectBase(URI id, DataSource dataSource, RDFContainer metadata, File file)
id
- URI of this data object (obligatory)dataSource
- the data source where this data object came from (optional)metadata
- the metadata of this data object (obligatory)file
- the java.io.File instance with the content of this data object. The file must be non-null,
must exist and be readable, otherwise exceptions will be thrownMethod Detail |
---|
public void finalize() throws Throwable
finalize
in class DataObjectBase
Throwable
public void setContent(InputStream content)
FileDataObject
setContent
in interface FileDataObject
content
- The InputStream containing the resource's content.public InputStream getContent()
FileDataObject
The returned InputStream is required to support marking (markSupported() must return true). Calling this method multiple times may return references to one-and-the-same InputStream instance. Care should therefore be taken to mark and reset the stream when the stream's content is to be read again later.
The returned InputStream is null in cases where the physical resource could not be accessed, e.g. in case of missing file read permissions.
getContent
in interface FileDataObject
public void setFile(File file)
FileDataObject
setFile
in interface FileDataObject
file
- the file with the content of this FileDataObjectpublic File getFile()
FileDataObject
File
instance (e.g. to pass it to a FileExtractor) and this method returns null,
you can use the FileDataObject.downloadContent()
method. If the FileDataObject.downloadContent()
method doesn't meet
your needs, you can use the stream returned by FileDataObject.getContent()
and implement the download process
by yourself. Note that the IOUtil.writeStream(InputStream, File)
method may be useful for this.
getFile
in interface FileDataObject
protected void setFileWithoutChecks(File file)
file
- the file to setpublic File downloadContent() throws IOException
FileDataObject
File.createTempFile(String, String)
). It is the responsibility of the user to delete the file
if it is no longer needed. FileDataObject.getFile()
method
returns a non-null value.
downloadContent
in interface FileDataObject
File
instance for the temporary file where the content of the stream has been
downloaded.
IOException
- If the content stream is not at the beginning of the file, or if an I/O error
occured during the download process.public void dispose()
DataObjectBase.setWrappedDataObject(DataObject)
) method - the wrapped data object is also
disposed.
dispose
in interface DataObject
dispose
in class DataObjectBase
protected void closeContent()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |