|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmessif.objects.extraction.ExtractorDataSource
public class ExtractorDataSource
Provides a data source for Extractor
s.
It can be constructed either from a InputStream
, File
or a URL
.
Depending on that, the source's name is set to either null, the name of the file, or the URL.
The data can be used by the extractors as either
InputStream
- use getInputStream()
method,BufferedReader
- use getBufferedReader()
method,byte[]
- use getBinaryData()
method, orOutputStream
- use pipe(java.io.OutputStream)
method.Note that the data can be used only as one of the aforementioned types and, once read, they are no longer available from the source.
Constructor Summary | |
---|---|
ExtractorDataSource(java.io.File file)
Create new instance of ExtractorDataSource using data from File . |
|
ExtractorDataSource(java.io.InputStream inputStream,
java.lang.String name)
Create new instance of ExtractorDataSource using data from InputStream . |
|
ExtractorDataSource(java.net.URL url,
java.lang.String mimeTypeRegexp)
Create new instance of ExtractorDataSource using data downloaded from URL . |
Method Summary | |
---|---|
void |
close()
|
byte[] |
getBinaryData()
Return this data source as a byte buffer. |
java.io.BufferedReader |
getBufferedReader()
Return this data source as buffered reader. |
java.lang.Object |
getDataSource()
Returns the remembered data source (can be File , InputStream or URL ). |
java.io.InputStream |
getInputStream()
Return this data source as input stream. |
java.lang.String |
getName()
Returns the name of this data source. |
void |
pipe(java.io.OutputStream outputStream)
Output all data from this data source to the given outputStream . |
void |
reset()
Reset this data source, i.e. the data will be provided from beginning. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ExtractorDataSource(java.io.InputStream inputStream, java.lang.String name)
InputStream
.
inputStream
- the input stream from which to download the dataname
- the name of this data sourcepublic ExtractorDataSource(java.net.URL url, java.lang.String mimeTypeRegexp) throws java.io.IOException
URL
.
url
- the URL from which to download the datamimeTypeRegexp
- regular expression for the mimetype of the data on the given url
java.io.IOException
- if there was an error reading the datapublic ExtractorDataSource(java.io.File file) throws java.io.IOException
File
.
file
- the file from which to download the data
java.io.IOException
- if there was an error opening the fileMethod Detail |
---|
public java.lang.String getName()
public java.lang.Object getDataSource()
File
, InputStream
or URL
).
public java.io.InputStream getInputStream()
Note that the data source is not closed - use InputStream.close()
method instead.
public java.io.BufferedReader getBufferedReader()
Note that the data source is not closed - use BufferedReader.close()
method instead.
public byte[] getBinaryData() throws java.io.IOException
Note that the data source is closed after this method is used.
java.io.IOException
- if there was a problem reading from the data sourcepublic void pipe(java.io.OutputStream outputStream) throws java.io.IOException
outputStream
.
Note that the data source is closed after this method is used.
outputStream
- the stream to which to write the data
java.io.IOException
- if there was an error reading from this data source or writing to the output streampublic void close() throws java.io.IOException
close
in interface java.io.Closeable
java.io.IOException
public void reset() throws java.io.IOException
java.io.IOException
- if there was an I/O error re-opening the data source
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |