com.sun.pdfview

Class BaseWatchable

public abstract class BaseWatchable extends Object implements Watchable, Runnable

An abstract implementation of the watchable interface, that is extended by the parser and renderer to do their thing.
Constructor Summary
protected BaseWatchable()
Creates a new instance of BaseWatchable
Method Summary
protected voidcleanup()
Clean up after a set of iterations.
protected voidexecute(boolean synchronous)
Start executing this watchable
intgetStatus()
Get the status of this watchable
voidgo()
Start this watchable and run in a new thread 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.
booleanisExecutable()
return true if this watchable is ready to be executed
booleanisFinished()
Return whether this watchable has finished.
protected abstract intiterate()
Perform a single iteration of this watchable.
voidrun()
protected voidsetError(Exception error)
Set an error on this watchable
protected voidsetStatus(int status)
Set the status of this watchable
protected voidsetup()
Prepare for a set of iterations.
voidstop()
Stop this watchable.
voidwaitForFinish()
Wait for this watchable to finish

Constructor Detail

BaseWatchable

protected BaseWatchable()
Creates a new instance of BaseWatchable

Method Detail

cleanup

protected void cleanup()
Clean up after a set of iterations. Called after iteration has stopped due to completion, manual stopping, or error.

execute

protected void execute(boolean synchronous)
Start executing this watchable

Parameters: synchronous if true, run in this thread

getStatus

public int getStatus()
Get the status of this watchable

Returns: one of the well-known statuses

go

public void go()
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.

Parameters: steps the number of steps to run for

go

public void go(long millis)
Start this watchable and run for the given amount of time, or until finished or stopped.

Parameters: millis the number of milliseconds to run for

isExecutable

public boolean isExecutable()
return true if this watchable is ready to be executed

isFinished

public boolean isFinished()
Return whether this watchable has finished. A watchable is finished when its status is either COMPLETED, STOPPED or ERROR

iterate

protected abstract int iterate()
Perform a single iteration of this watchable. This is the minimum granularity which the go() commands operate over.

Returns: one of three values:

run

public void run()

setError

protected void setError(Exception error)
Set an error on this watchable

setStatus

protected void setStatus(int status)
Set the status of this watchable

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.

stop

public void stop()
Stop this watchable. Stop will cause all processing to cease, and the watchable to be destroyed.

waitForFinish

public void waitForFinish()
Wait for this watchable to finish