com.partnersoft.io
Class RandomAccessDataRecordSource

java.lang.Object
  extended by com.partnersoft.io.AbstractIterableInput<Naming<java.lang.Object>>
      extended by com.partnersoft.io.DataRecordSource
          extended by com.partnersoft.io.RandomAccessDataRecordSource
All Implemented Interfaces:
Coggable, IterableInput<Naming<java.lang.Object>>, java.lang.Iterable<Naming<java.lang.Object>>

public abstract class RandomAccessDataRecordSource
extends DataRecordSource

Superclass for DataRecordSources whose records can also be retrieved via a numeric index.

Provides a basic implementation of fetchImp() that keeps track of a recordCount and currentRecordNumber; it simply iterates through the numbers 0 <= currentRecordNumber < recordCount. You should set recordCount on open. Copyright 2008 Partner Software, Inc.

Version:
$Id$
Author:
Paul Reavis

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.partnersoft.io.IterableInput
IterableInput.Status
 
Field Summary
 int currentRecordNumber
           
 int recordCount
           
 
Fields inherited from class com.partnersoft.io.DataRecordSource
currentValues, fieldNames, verbose
 
Constructor Summary
RandomAccessDataRecordSource()
           
 
Method Summary
protected  boolean fetchImp()
          Subclass implementation of guts of fetch() method.
 Naming<java.lang.Object> fetchRecordAt(int recordNumber)
          Return the record at the given number.
abstract  java.lang.Object[] fetchValuesAt(int recordNumber)
          Return the values for the record at the given number.
 int getRecordCount()
           
 
Methods inherited from class com.partnersoft.io.DataRecordSource
copy, fetch, getCurrentValues, getFetched, getFieldNames, isVerbose, setVerbose, toCog
 
Methods inherited from class com.partnersoft.io.AbstractIterableInput
close, closeImp, getException, getStatus, isFetchValid, iterator, open, openImp
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentRecordNumber

public int currentRecordNumber

recordCount

public int recordCount
Constructor Detail

RandomAccessDataRecordSource

public RandomAccessDataRecordSource()
Method Detail

fetchValuesAt

public abstract java.lang.Object[] fetchValuesAt(int recordNumber)
Return the values for the record at the given number. Returns null if the fetch fails for any reason.

Subclasses must implement this to take care of the actual fetching.

Parameters:
recordNumber - number of the record desired, starting with zero.
Returns:
values for the record at recordNumber

fetchRecordAt

public Naming<java.lang.Object> fetchRecordAt(int recordNumber)
Return the record at the given number. Returns null if the fetch fails for any reason.

Parameters:
recordNumber - number of the record desired, starting with zero.
Returns:
record at recordNumber

fetchImp

protected boolean fetchImp()
                    throws java.lang.Exception
Description copied from class: AbstractIterableInput
Subclass implementation of guts of fetch() method.

Subclasses must implement this to do the actual work required by fetch(). Feel free to throw exceptions; these are caught inside the fetch() itself and applied to the exception variable. Thus, you can focus on the actual task instead of paperwork.

Specified by:
fetchImp in class AbstractIterableInput<Naming<java.lang.Object>>
Returns:
true if fetch successful
Throws:
java.lang.Exception

getRecordCount

public int getRecordCount()