FreeHEP API
Version current

org.freehep.record.source
Interface SequentialRecordSource

All Known Subinterfaces:
AsynchronousRecordSource, RandomAccessRecordSource, TaggedRecordSource
All Known Implementing Classes:
EchoStrings.LineSupplier

public interface SequentialRecordSource

The base interface that all record sources must implement.

Version:
$Id: SequentialRecordSource.java,v 1.3 2003/05/09 21:41:54 tonyj Exp $
Source Code:
SequentialRecordSource.java

Field Summary
static int UNKNOWN
          A value that may be returned by getEstimatedSize
 
Method Summary
 void close()
          Close the record source and free any associated resources
 Object getCurrentRecord()
          Get the current record.
 long getEstimatedSize()
          Returns the number of records in this record source, if known.
 Class getRecordClass()
          Find out what type of records are returned by this record source.
 String getSourceName()
          Get the (human readable) name of this record source.
 void next()
          Go to the next record.
 void releaseRecord(Object record)
          Releases any resources associated with the specified record.
 void rewind()
          Repositions the record source before the first record.
 

Field Detail

UNKNOWN

public static final int UNKNOWN
A value that may be returned by getEstimatedSize

See Also:
Constant Field Values
Method Detail

getEstimatedSize

public long getEstimatedSize()
Returns the number of records in this record source, if known.

This is allowed to be an approximation (for example the number of events may be known but not the total number of records, or the expected number of records may be known, but the actual number may be different). The primary use of this method is for giving the user feedback on how much of a record source has been read, it should not be used as the limit for a for loop. Use hasNext() instead.

Returns:
The approximate number of records, or UNKNOWN.

getCurrentRecord

public Object getCurrentRecord()
                        throws NoSuchRecordException,
                               IOException,
                               EndOfSourceException
Get the current record.

Returns:
The current record, or null if no current record.
Throws:
NoSuchRecordException
IOException
EndOfSourceException

releaseRecord

public void releaseRecord(Object record)
Releases any resources associated with the specified record.


next

public void next()
          throws IOException
Go to the next record. Note that record sources are initially positioned before the first record, so next() must be called once before calling getCurrentRecord().

Throws:
IOException

getRecordClass

public Class getRecordClass()
Find out what type of records are returned by this record source. All records returned are gauranteed to be of this type. This method should return Object.class if nothing more is known.

Returns:
The class of records returned by this record source.

getSourceName

public String getSourceName()
Get the (human readable) name of this record source. This is typically the file name for RecordSources associated with files.

Returns:
The record source name.

rewind

public void rewind()
            throws IOException
Repositions the record source before the first record.

Throws:
IOException

close

public void close()
           throws IOException
Close the record source and free any associated resources

Throws:
IOException

FreeHEP API
Version current

Copyright © 2000-2004 FreeHEP, All Rights Reserved.