|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--sam.event.ProgressEventNotifier
Class for dispatching ProgressEvent
through registered ProgressEventListener
s.
Typical usage is:
Note that event posting is asynchronous in order to preserve computationnal resources of the main thread.ProgressEventNotifier notifier = new ProgressEventNotifier(); notifier.register( new ProgressEventListener() { public void progress(Event event) { System.out.println(event); } // Or anything else } ); OutputStream output = notifier.new EncodedOutputStream( new FileOutputStream("encoded.dat") ); output = ... ; // which includes various filtering operations called "encoding" output = notifier.new PlainOutputStream(output); ... ; // Write plain bytes of data to output
Settings.Constants#PROGRESS_NOTIFICATION_PRIORITY
Nested Class Summary | |
class |
ProgressEventNotifier.EncodedInputStream
Instance inner-class for notifying the number of bytes read from an encoded InputStream . |
class |
ProgressEventNotifier.EncodedOutputStream
Instance inner-class for notifying the number of encoded bytes written to an OutputStream . |
class |
ProgressEventNotifier.PlainInputStream
Instance inner-class for notifying the number of bytes read from a plain InputStream . |
class |
ProgressEventNotifier.PlainOutputStream
Instance inner-class for notifying the number of plain bytes written to an OutputStream . |
Constructor Summary | |
ProgressEventNotifier()
Builds a new ProgressEvent notifier. |
Method Summary | |
protected sam.event.ProgressEvent |
createEvent()
Creates a new ProgressEvent describing the current progress state |
protected void |
finalize()
On destruction the postmaster thread must be stopped. |
protected void |
notifyEncoded(long encodedIncrement)
Notifies more bytes of encoded data to have been processed. |
protected void |
notifyListeners()
Notifies all registered listeners of the current progress state Note that notification is asynchronous. |
void |
notifyNextEntry(sam.entry.Entry entry)
Notifies a new entry being processed. |
protected void |
notifyPlain(long plainIncrement)
Notifies more bytes of plain data to have been processed This is called automatically by inner input/output streams |
void |
register(sam.event.ProgressEventListener listener)
Registers a new ProgressEvent listener |
void |
setTotalNumberOfEntries(int totalNumberOfEntries)
Sets the total number of Entry that have to be processed |
void |
setTotalNumberOfPlainBytes(long totalNumberOfPlainBytes)
Sets the total number of bytes that have to be processed |
void |
start()
Starts the event postmaster thread. |
void |
terminate()
Notifies the termination of the process. |
void |
unregister(sam.event.ProgressEventListener listener)
Unregisters a previously registered ProgressEvent listener |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ProgressEventNotifier()
ProgressEvent
notifier.
Note that a call to setTotalNumberOfPlainBytes
and one to setTotalNumberOfEntries
are required before proper use.
This also starts one postmaster thread, which will be stopped once this ProgressEventNotifier
is elected by the GC for finalization.
Method Detail |
public void setTotalNumberOfPlainBytes(long totalNumberOfPlainBytes)
public void setTotalNumberOfEntries(int totalNumberOfEntries)
Entry
that have to be processed
public void register(sam.event.ProgressEventListener listener)
ProgressEvent
listener
public void unregister(sam.event.ProgressEventListener listener)
ProgressEvent
listener
protected void notifyListeners()
public void start()
public void terminate()
ProgressEvent
to have been handled.
protected void notifyPlain(long plainIncrement)
protected void notifyEncoded(long encodedIncrement)
public void notifyNextEntry(sam.entry.Entry entry)
protected final sam.event.ProgressEvent createEvent()
ProgressEvent
describing the current progress state
ProgressEvent
protected void finalize()
Thread.stop()
finalize
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |