Package com.bayesserver.data
Class DataReaderFiltered
- java.lang.Object
-
- com.bayesserver.data.DataReaderFiltered
-
- All Implemented Interfaces:
DataReader,DataRecord,Closeable,AutoCloseable
public final class DataReaderFiltered extends Object implements DataReader
Wraps an existing data reader while filtering records.
-
-
Constructor Summary
Constructors Constructor Description DataReaderFiltered(DataReader inner, DataReaderFilter filter)Initializes a new instance of theDataReaderFilteredclass.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the reader and any associated resources, such as database connections or files.booleangetBoolean(int columnIndex)Gets a boolean value for the specified column.intgetColumnCount()Gets the number of columns (fields) in the data.intgetColumnIndex(String columnName)Gets the zero based column index for a column name.StringgetColumnName(int columnIndex)Gets the name of the column at the specified index.Class<?>getColumnType(int columnIndex)Get the data type for the specified column.doublegetDouble(int columnIndex)Gets a double value for the specified column.floatgetFloat(int columnIndex)Gets a float value for the specified column.intgetInt(int columnIndex)Gets an integer value for the specified column.longgetLong(int columnIndex)Gets a long value for the specified column.ObjectgetObject(int columnIndex)Gets an Object representation for the value at the specified column.StringgetString(int columnIndex)Gets a string value for the specified column.booleanisNull(int columnIndex)Determines whether the value is null (missing) for the specified column.booleanread()Moves to the next record, if any exist.
-
-
-
Constructor Detail
-
DataReaderFiltered
public DataReaderFiltered(DataReader inner, DataReaderFilter filter)
Initializes a new instance of theDataReaderFilteredclass.- Parameters:
inner- The existing data reader to filter.filter- Determines whether a record should be included in the filtered data reader or not.
-
-
Method Detail
-
read
public boolean read()
Moves to the next record, if any exist. This must be called to move to the first record.- Specified by:
readin interfaceDataReader- Returns:
trueif the reader successfully moved to a new record, orfalseif no more records are present.
-
close
public void close()
Description copied from interface:DataReaderClose the reader and any associated resources, such as database connections or files.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceDataReader
-
getColumnIndex
public int getColumnIndex(String columnName)
Description copied from interface:DataRecordGets the zero based column index for a column name.- Specified by:
getColumnIndexin interfaceDataRecord- Parameters:
columnName- The name of the column.- Returns:
- A zero based index for the column.
-
getColumnName
public String getColumnName(int columnIndex)
Description copied from interface:DataRecordGets the name of the column at the specified index.- Specified by:
getColumnNamein interfaceDataRecord- Parameters:
columnIndex- The zero based index of the column.- Returns:
- The name of the column at the specified index.
-
getColumnType
public Class<?> getColumnType(int columnIndex)
Description copied from interface:DataRecordGet the data type for the specified column. @param columnIndex the zero based index of the column @return- Specified by:
getColumnTypein interfaceDataRecord
-
getColumnCount
public int getColumnCount()
Description copied from interface:DataRecordGets the number of columns (fields) in the data.- Specified by:
getColumnCountin interfaceDataRecord- Returns:
- The column (field) count.
-
isNull
public boolean isNull(int columnIndex)
Description copied from interface:DataRecordDetermines whether the value is null (missing) for the specified column.- Specified by:
isNullin interfaceDataRecord- Returns:
trueif the value is null (missing),falseotherwise.
-
getObject
public Object getObject(int columnIndex)
Description copied from interface:DataRecordGets an Object representation for the value at the specified column.- Specified by:
getObjectin interfaceDataRecord- Returns:
- The value at the specified column, or null if the value is missing.
-
getString
public String getString(int columnIndex)
Description copied from interface:DataRecordGets a string value for the specified column.- Specified by:
getStringin interfaceDataRecord- Returns:
- The string at the specified column index.
-
getBoolean
public boolean getBoolean(int columnIndex)
Description copied from interface:DataRecordGets a boolean value for the specified column.- Specified by:
getBooleanin interfaceDataRecord- Parameters:
columnIndex- The zero based column index.- Returns:
- The boolean value at the specified index.
-
getInt
public int getInt(int columnIndex)
Description copied from interface:DataRecordGets an integer value for the specified column.- Specified by:
getIntin interfaceDataRecord- Parameters:
columnIndex- The zero based column index.- Returns:
- The integer value at the specified index.
-
getLong
public long getLong(int columnIndex)
Description copied from interface:DataRecordGets a long value for the specified column.- Specified by:
getLongin interfaceDataRecord- Parameters:
columnIndex- The zero based column index.- Returns:
- The long value at the specified index.
-
getDouble
public double getDouble(int columnIndex)
Description copied from interface:DataRecordGets a double value for the specified column.- Specified by:
getDoublein interfaceDataRecord- Parameters:
columnIndex- The zero based column index.- Returns:
- The double value at the specified index.
-
getFloat
public float getFloat(int columnIndex)
Description copied from interface:DataRecordGets a float value for the specified column.- Specified by:
getFloatin interfaceDataRecord- Parameters:
columnIndex- The zero based column index.- Returns:
- The float value at the specified index.
-
-