|
FreeHEP API Version current |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.freehep.record.loop.SequentialRecordLoopImpl
This class is the default implementation of the
SequentialRecordLoop
interface.
This class is minimally thread safe i.e. only the "setInterruptResquested"
and "isInterruptRequested" methods are considered thread safe. The rest
of the implementation is designed to run in a single thread. When its
RecordListener responses to any RecordEvents, a return from that
method signals that the listener has completed all responsibilities
related to that message.
Constructor Summary | |
SequentialRecordLoopImpl()
Create an instance of this class. |
|
SequentialRecordLoopImpl(SequentialRecordSource supplier)
Create an instance of this class with the specified SequentialRecordSource. |
Method Summary | |
void |
addRecordListener(RecordListener listener)
Adds the specified RecordListener to this object. |
void |
addRecordLoopListener(RecordLoopListener listener)
Adds the specified RecordLoopListener to this object. |
void |
dispose()
Signals that this object in no longer going to be used. |
void |
doNotCount(Object record)
Tells this object that if it is currently supplying the specified record then it should not be added to the "countable" record total. |
RecordListener |
getRecordListener()
Returns this objects RecordListener if there is one. |
SequentialRecordSource |
getRecordSource()
Returns the SequentialRecordSource used by this object. |
long |
getTotalCountableSupplied()
Returns the total number of countable records supplied. |
long |
getTotalSupplied()
Returns the total number of records supplied. |
boolean |
isInterruptRequested()
Returns true if an interrupt has been requested and the loop method has not yet returned. |
long |
loop(long number)
Processes the specified number of records through the record loop. |
void |
removeRecordListener(RecordListener listener)
Removes the specified listener from this object if it is this objects listener, otherwise it does nothing. |
void |
removeRecordLoopListener(RecordLoopListener listener)
Removes the specified listener from this object if it is this objects listener, otherwise it does nothing. |
void |
reset()
Resets the loop so that the next time loop is called this object will behave as if the previous calls to loop never happened. |
void |
setConfiguration(Object configuration)
Sets the configuration object which should be passed to this objects RecordListener next time the loop(long) method is invoked. |
void |
setInterruptRequested(boolean interruptRequested)
This method can either request that the loop method
terminate when it has finished dealing with all its current data or
clear such a request.
|
void |
setProgessByRecords(long records)
Set the progress reporting interval in terms of records. |
void |
setProgessByTime(long milliseconds)
Set the progress reporting interval in terms of milliseconds. |
void |
setRecordSource(SequentialRecordSource supplier)
Sets this objects SequentialRecordSource to the one that is specified. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public SequentialRecordLoopImpl()
public SequentialRecordLoopImpl(SequentialRecordSource supplier)
supplier
- the SequentialRecordSource to use with this object.setRecordSource(org.freehep.record.source.SequentialRecordSource)
Method Detail |
public void addRecordListener(RecordListener listener) throws TooManyListenersException
RecordListenerManager
addRecordListener
in interface RecordListenerManager
listener
- the RecordListener to add.
TooManyListenersException
- if a listener is already present.RecordListenerManager.removeRecordListener(org.freehep.record.loop.event.RecordListener)
public void addRecordLoopListener(RecordLoopListener listener)
SequentialRecordLoop
addRecordLoopListener
in interface SequentialRecordLoop
listener
- the RecordLoopListener to add.SequentialRecordLoop.removeRecordLoopListener(org.freehep.record.loop.event.RecordLoopListener)
public void dispose()
SequentialRecordLoop
finish
event.
dispose
in interface SequentialRecordLoop
public void doNotCount(Object record)
SequentialRecordLoop
doNotCount
in interface SequentialRecordLoop
record
- the recornd that should not be counted.public RecordListener getRecordListener()
RecordListenerManager
getRecordListener
in interface RecordListenerManager
public SequentialRecordSource getRecordSource()
SequentialRecordLoop
getRecordSource
in interface SequentialRecordLoop
public long getTotalSupplied()
SequentialRecordLoop
getTotalSupplied
in interface SequentialRecordLoop
public long getTotalCountableSupplied()
SequentialRecordLoop
getTotalCountableSupplied
in interface SequentialRecordLoop
public boolean isInterruptRequested()
SequentialRecordLoop
isInterruptRequested
in interface SequentialRecordLoop
public long loop(long number) throws LoopException, IOException
SequentialRecordLoop
SequentialRecordSource
throws a LoopSourceExhaustedException
respose to its
getCurrentRecord
method.
If the SequentialRecordLoop.doNotCount(java.lang.Object)
method is called while this method is
executing and its argument is a record that is currently being supplied
by this object then that record will not count towards the specified
number of records requested. Nor will it be counted in the return value
of this method.
If the loop is interrupted before it is completed then a
LoopInterruptedException
is thrown, even if the requested
number of records have been supplied. The number of completed countable
records is contained in the LoopInterruptedException
so\
this value can be used to determine whether all requested records where
supplied on not.
loop
in interface SequentialRecordLoop
number
- the number of countable records to supply.
IOException
- if there is problems reading a record.
LoopException
public void removeRecordListener(RecordListener listener)
RecordListenerManager
removeRecordListener
in interface RecordListenerManager
listener
- the RecordListener to remove.RecordListenerManager.addRecordListener(org.freehep.record.loop.event.RecordListener)
public void removeRecordLoopListener(RecordLoopListener listener)
SequentialRecordLoop
removeRecordLoopListener
in interface SequentialRecordLoop
listener
- the RecordLoopListener to remove.SequentialRecordLoop.addRecordLoopListener(org.freehep.record.loop.event.RecordLoopListener)
public void reset() throws IOException
SequentialRecordLoop
rewing
method called while the objects listener, if it exists, will be sent a
finish
event. At the next loop call the listener will receive a
configure
event rather than a reconfigure
or
resume
event.
reset
in interface SequentialRecordLoop
IOException
- if there is problems rewinding this object's source.public void setConfiguration(Object configuration)
SequentialRecordLoop
SequentialRecordLoop.loop(long)
method is invoked. If this
method is called any time after the first loop invocation (even with the
same configuration object) then a reconfigure
event will be used to start the next loop. Otherwise the next loop will
start with a resume
event.
setConfiguration
in interface SequentialRecordLoop
configuration
- the configuration object to pass to this object's
RecordListener.public void setInterruptRequested(boolean interruptRequested)
SequentialRecordLoop
loop
method
terminate when it has finished dealing with all its current data or
clear such a request.
For a meaningful interrupt to happen it must come from a thread other
than the one executing the loop
method, therefore this
method must always be implemented in a thread-safe manner.
setInterruptRequested
in interface SequentialRecordLoop
interruptRequested
- true if the loop should be interrupted.public void setProgessByRecords(long records)
SequentialRecordLoop
setProgessByRecords
in interface SequentialRecordLoop
records
- the number of records between progress reports.public void setProgessByTime(long milliseconds)
SequentialRecordLoop
setProgessByTime
in interface SequentialRecordLoop
milliseconds
- the number of milliseconds between progress reports.public void setRecordSource(SequentialRecordSource supplier)
SequentialRecordLoop
setRecordSource
in interface SequentialRecordLoop
supplier
- the SequentialRecordSource to use with this object.
|
FreeHEP API Version current |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |