Package org.loboevolution.pdfview
Class BaseWatchable
java.lang.Object
org.loboevolution.pdfview.BaseWatchable
- Direct Known Subclasses:
PDFParser,PDFRenderer
An abstract implementation of the watchable interface, that is extended
by the parser and renderer to do their thing.
-
Field Summary
Fields inherited from interface org.loboevolution.pdfview.Watchable
COMPLETED, ERROR, NEEDS_DATA, NOT_STARTED, PAUSED, RUNNING, STOPPED, UNKNOWN -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcleanup()Clean up after a set of iterations.protected voidexecute(boolean synchronous) Start executing this watchablestatic PDFErrorHandlerGetter for the fielderrorHandler.intGet the status of this watchablevoidgo()Start this watchable and run until it is finished or stopped.voidgo(boolean synchronous) Start this watchable and run until it is finished or stopped.voidgo(int steps) Start this watchable and run for the given number of steps or until finished or stopped.voidgo(long millis) Start this watchable and run for the given amount of time, or until finished or stopped.booleanreturn true if this watchable is ready to be executedbooleanReturn whether this watchable has finished.protected abstract intiterate()Perform a single iteration of this watchable.voidrun()protected voidSet an error on this watchableprotected voidsetStatus(int status) Set the status of this watchableprotected voidsetup()Prepare for a set of iterations.voidstop()Stop this watchable.
-
Constructor Details
-
BaseWatchable
protected BaseWatchable()Creates a new instance of BaseWatchable
-
-
Method Details
-
getErrorHandler
Getter for the field
errorHandler.- Returns:
- a
PDFErrorHandlerobject.
-
iterate
Perform a single iteration of this watchable. This is the minimum granularity which the go() commands operate over.- Returns:
- one of three values:
- Watchable.RUNNING if there is still data to be processed
- Watchable.NEEDS_DATA if there is no data to be processed but the execution is not yet complete
- Watchable.COMPLETED if the execution is complete
- Throws:
Exception- if any.
-
setup
protected void setup()Prepare for a set of iterations. Called before the first iterate() call in a sequence. Subclasses should extend this method if they need to do anything to setup. -
cleanup
protected void cleanup()Clean up after a set of iterations. Called after iteration has stopped due to completion, manual stopping, or error. -
run
public void run() -
getStatus
public int getStatus()Get the status of this watchableGet the status of this watchable
-
setStatus
protected void setStatus(int status) Set the status of this watchable- Parameters:
status- aIntegerobject.
-
isFinished
public boolean isFinished()Return whether this watchable has finished. A watchable is finished when its status is either COMPLETED, STOPPED or ERROR- Returns:
- a boolean.
-
isExecutable
public boolean isExecutable()return true if this watchable is ready to be executed- Returns:
- a boolean.
-
stop
public void stop()Stop this watchable. Stop will cause all processing to cease, and the watchable to be destroyed.Stop this watchable if it is not already finished. Stop will cause all processing to cease, and the watchable to be destroyed.
-
go
public void go()Start this watchable and run until it is finished or stopped. Note the watchable may be stopped if go() with a different time is called during execution.Start this watchable and run in a new thread until it is finished or stopped. Note the watchable may be stopped if go() with a different time is called during execution.
-
go
public void go(boolean synchronous) Start this watchable and run until it is finished or stopped. Note the watchable may be stopped if go() with a different time is called during execution.- Parameters:
synchronous- if true, run in this thread
-
go
public void go(int steps) Start this watchable and run for the given number of steps or until finished or stopped.Start this watchable and run for the given number of steps or until finished or stopped.
-
go
public void go(long millis) Start this watchable and run for the given amount of time, or until finished or stopped.Start this watchable and run for the given amount of time, or until finished or stopped.
-
execute
protected void execute(boolean synchronous) Start executing this watchable- Parameters:
synchronous- if true, run in this thread
-
setError
Set an error on this watchable- Parameters:
error- aExceptionobject.
-