FreeHEP API
Version current

org.freehep.record.loop
Interface SequentialRecordLoopManager

All Known Implementing Classes:
SequentialRecordLoopImplManager

public interface SequentialRecordLoopManager

This interface allows control of a SequentialRecordLoop object to be managed by an external object. The external object is responsible for making sure the methods of this object are called in the correct order. The following how the methods should be invoked, where number is the number of records that the external object is trying to supply.

    manager.beginLoop(number);

    while (manager.hasMoreRecords()) {
        manager.supplyRecord(manager.nextRecord());
    }

    long result = manager.endLoop();

Version:
$Id: SequentialRecordLoopManager.java,v 1.1 2003/05/06 23:13:16 tonyj Exp $
Author:
patton
Source Code:
SequentialRecordLoopManager.java

Method Summary
 void beginLoop(long target)
          This method should be called before any loop begins.
 long endLoop()
          This method should be called after the loop has ended.
 SequentialRecordLoop getRecordLoop()
           
 boolean hasMoreRecords()
          Returns true if there may be more records available and the number supplied has not reached the target.
 Object nextRecord()
          This attempts to get a new record object from the source.
 void supplyRecord(Object record)
          Supplies the specified record object, if it is not null, to the listener of the SequentialRecordLoopImpl object being managed.
 

Method Detail

beginLoop

public void beginLoop(long target)
This method should be called before any loop begins.

Parameters:
target - the number of records that should have been supplied.
Throws:
IllegalStateException - if this is called before a source is set in the SequentialRecordLoopImpl object being managed.

endLoop

public long endLoop()
             throws LoopException
This method should be called after the loop has ended.

Returns:
the number of countable records that have been supplied.
Throws:
LoopInterruptedException - if the loop is interrupted.
LoopSourceExhaustedException - if target is non-negative and the source runs out of records.
NoLoopRecordException - if the record to supply could not be found.
LoopException

getRecordLoop

public SequentialRecordLoop getRecordLoop()
Returns:
the SequentialRecordLoop object this object is managing.

nextRecord

public Object nextRecord()
                  throws IOException
This attempts to get a new record object from the source. Before invoking the getCurrentRecord method, this routine checks to see if an interrupt has been requested, and if so set the internal flag to indicate this is the case.

Returns:
the record object supplied or null if no object is supplied.
Throws:
IOException - if there is a problem reading the next record.

hasMoreRecords

public boolean hasMoreRecords()
Returns true if there may be more records available and the number supplied has not reached the target.


supplyRecord

public void supplyRecord(Object record)
Supplies the specified record object, if it is not null, to the listener of the SequentialRecordLoopImpl object being managed.

Parameters:
record - the record object to be supplied.

FreeHEP API
Version current

Copyright © 2000-2004 FreeHEP, All Rights Reserved.