com.levigo.jadice.document.read
Class Reader

java.lang.Object
  extended by com.levigo.jadice.document.read.Reader
All Implemented Interfaces:
PropertiesProvider

public class Reader
extends Object
implements PropertiesProvider

The Reader is responsible for loading and creating instances of Document.


Field Summary
static int AFTER_LAST_PAGE
           
static int BEFORE_FIRST_PAGE
           
protected  boolean complete
           
 
Constructor Summary
Reader()
           
 
Method Summary
 void addReaderListener(ReaderListener listener)
          Add the given ReaderListener to the list of load listeners.
 void clearSettings(Class<? extends ReaderSettings> c)
           
 void complete()
          Signal the reader that the current read process is complete.
protected  com.levigo.jadice.document.internal.read.ReadTask createTask(Provider<? extends InputStream,IOException> streamProvider)
           
protected  void finalize()
           
 Document getDocument()
           
 Format getFormat()
           
 Map<DocumentLayer,DocumentLayer> getLayerMapping()
           
 Metadata getMetadata()
           
 Map<String,Object> getProperties()
          Return a map of user properties.
 String getReadID()
           
<S extends ReaderSettings>
S
getSettings(Class<S> c)
           
 int getStreamIndex()
           
 int getTargetIndex()
          Get the target page index to be used for page segments read by the next call to read(InputStream).
protected  void handleTask(com.levigo.jadice.document.internal.read.ReadTask task)
           
 com.levigo.jadice.document.internal.read.ReadTask read(File file)
           
 com.levigo.jadice.document.internal.read.ReadTask read(InputStream is)
           
 com.levigo.jadice.document.internal.read.ReadTask read(Provider<? extends InputStream,IOException> streamProvider)
           
 com.levigo.jadice.document.internal.read.ReadTask read(URL url)
          Reads a document from the given URL.
 void removeReaderListener(ReaderListener listener)
          Remove the given ReaderListener from the list of load listeners.
 void setDocument(Document document)
          Sets the document.
 void setFormat(Format format)
           
 void setLayerMapping(Map<DocumentLayer,DocumentLayer> mapping)
           
 void setMetadata(Metadata metadata)
           
 void setReaderControls(ReaderControls rc)
          Replace the existing ReaderControls instance with all its ReaderSettings.
 void setReadID(String readID)
           
 void setTargetIndex(int targetIndex)
          Set the target page index to be used for page segments read by the next call to read(InputStream).
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AFTER_LAST_PAGE

public static final int AFTER_LAST_PAGE
See Also:
Constant Field Values

BEFORE_FIRST_PAGE

public static final int BEFORE_FIRST_PAGE
See Also:
Constant Field Values

complete

protected boolean complete
Constructor Detail

Reader

public Reader()
Method Detail

clearSettings

public void clearSettings(Class<? extends ReaderSettings> c)

getSettings

public <S extends ReaderSettings> S getSettings(Class<S> c)

addReaderListener

public void addReaderListener(ReaderListener listener)
Add the given ReaderListener to the list of load listeners.

Parameters:
listener - the listener to add

removeReaderListener

public void removeReaderListener(ReaderListener listener)
Remove the given ReaderListener from the list of load listeners.

Parameters:
listener - the listener to remove

read

public com.levigo.jadice.document.internal.read.ReadTask read(URL url)
                                                       throws JadiceException,
                                                              IOException,
                                                              IllegalArgumentException
Reads a document from the given URL.

Parameters:
url - the URL to be read.
Returns:
the ReadTask used to execute the read request
Throws:
JadiceException
IOException - if an I/O error occurs
IllegalArgumentException - if the given URL is null
IllegalStateException - it an attempt is made to read with an instance that has already been marked as complete().

read

public com.levigo.jadice.document.internal.read.ReadTask read(File file)
                                                       throws JadiceException,
                                                              IOException
Parameters:
file - file to read
Returns:
the ReadTask handling the read operation
Throws:
JadiceException
IOException
IllegalStateException - it an attempt is made to read with an instance that has already been marked as complete().

read

public com.levigo.jadice.document.internal.read.ReadTask read(InputStream is)
                                                       throws JadiceException,
                                                              IOException
Parameters:
is -
Returns:
the ReadTask handling the read operation
Throws:
JadiceException
IOException
IllegalStateException - it an attempt is made to read with an instance that has already been marked as complete().

read

public com.levigo.jadice.document.internal.read.ReadTask read(Provider<? extends InputStream,IOException> streamProvider)
                                                       throws JadiceException,
                                                              IOException
Parameters:
streamProvider -
Returns:
the ReadTask handling the read operation
Throws:
JadiceException
IOException
IllegalStateException - it an attempt is made to read with an instance that has already been marked as complete().

createTask

protected com.levigo.jadice.document.internal.read.ReadTask createTask(Provider<? extends InputStream,IOException> streamProvider)

handleTask

protected void handleTask(com.levigo.jadice.document.internal.read.ReadTask task)
                   throws IOException,
                          JadiceException
Throws:
IOException
JadiceException

getDocument

public Document getDocument()

setDocument

public void setDocument(Document document)
Sets the document.

Parameters:
document - The document to set

getTargetIndex

public int getTargetIndex()
Get the target page index to be used for page segments read by the next call to read(InputStream).

Returns:
the zero-based target index or one of the special cases BEFORE_FIRST_PAGE and AFTER_LAST_PAGE.
See Also:
BEFORE_FIRST_PAGE, AFTER_LAST_PAGE

setTargetIndex

public void setTargetIndex(int targetIndex)
Set the target page index to be used for page segments read by the next call to read(InputStream).

Parameters:
targetIndex - the zero-based target index or one of the special cases BEFORE_FIRST_PAGE and AFTER_LAST_PAGE.
See Also:
BEFORE_FIRST_PAGE, AFTER_LAST_PAGE

getMetadata

public Metadata getMetadata()

setMetadata

public void setMetadata(Metadata metadata)

getProperties

public Map<String,Object> getProperties()
Description copied from interface: PropertiesProvider
Return a map of user properties. What to store and which keys to use is largely up to the user of classes implementing this interface, since those classes will generally be oblivious to the map's contents. There are no guarantees regarding the thread-safety of the returned map, unless otherwise specified by implementors.

Specified by:
getProperties in interface PropertiesProvider
Returns:
the map of user properties

getLayerMapping

public Map<DocumentLayer,DocumentLayer> getLayerMapping()

setLayerMapping

public void setLayerMapping(Map<DocumentLayer,DocumentLayer> mapping)

getFormat

public Format getFormat()

setFormat

public void setFormat(Format format)

setReaderControls

public void setReaderControls(ReaderControls rc)
Replace the existing ReaderControls instance with all its ReaderSettings. Passing a null-argument resets the internal controls instance to its initial state.


getReadID

public String getReadID()

setReadID

public void setReadID(String readID)

getStreamIndex

public int getStreamIndex()

complete

public void complete()
Signal the reader that the current read process is complete. This information is propagated to the currently active ReaderListeners. Furthermore, on the Document retrieved by a call to getDocument(), Document.BasicState.READY is set as the new state. After calling this method, further calls to any of the read(...) methods will result in IllegalStateExceptions.

Using this method is encouraged, but not mandatory.


finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable


Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.