Package org.firebirdsql.gds.ng.fields
Class RowValueBuilder
java.lang.Object
org.firebirdsql.gds.ng.fields.RowValueBuilder
Builder for
RowValue instances.
This class allows for sparse population of column values (ie: null values can be skipped). It is
intended for use in tests and classes like FBDatabaseMetaData.
The main advantage over RowValue.of(RowDescriptor, byte[][]) is that it is clearer to which field
the value is assigned, and it allows for sparse population (ie: skipping null values).
- Author:
- Mark Rotteveel
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionRowValueBuilder(RowDescriptor rowDescriptor) Creates instance of RowValueBuilder. -
Method Summary
Modifier and TypeMethodDescriptionat(int index) Convenience shortcut forsetFieldIndex(int).byte[]get(int index) Retrieves the field data set at the specified index.intgetSize()reset()Resets this builder to a new RowValue.set(byte[] fieldData) Sets the field data of the current field.setFieldIndex(int index) Sets the index of the current field to populate.toRowValue(boolean initialize) Returns the populatedRowValueand resets the RowValueBuilder.
-
Constructor Details
-
RowValueBuilder
Creates instance of RowValueBuilder.- Parameters:
rowDescriptor- The RowDescriptor for the row(s) to be created
-
-
Method Details
-
setFieldIndex
Sets the index of the current field to populate.- Parameters:
index- Index of the field- Returns:
- this builder
- Throws:
IndexOutOfBoundsException- Whenindexis not between 0 (inclusive) andgetSize()(exclusive)
-
at
Convenience shortcut forsetFieldIndex(int).- Parameters:
index- Index- Returns:
- this builder
- See Also:
-
set
Sets the field data of the current field.- Parameters:
fieldData- Data- Returns:
- this builder
-
get
public byte[] get(int index) Retrieves the field data set at the specified index.- Parameters:
index- Index- Returns:
- The field data
- Throws:
IndexOutOfBoundsException- When @{code index} is not between 0 (inclusive) andgetSize()(exclusive)
-
reset
Resets this builder to a new RowValue. All previous values set are cleared.- Returns:
- this builder.
-
getSize
public int getSize()- Returns:
- Number of fields in the row
-
toRowValue
Returns the populatedRowValueand resets the RowValueBuilder.- Parameters:
initialize-trueset field data to null for all uninitialized fields,falseleaves fields uninitialized. In most cases you want to usetrue.- Returns:
- The row value object
- See Also:
-