RowDescriptor
.
The row descriptor is constructed by defining the fields, and using addField()
to add the current field
definition to the row. The field data is then reset (as if resetField()
was called,
to prepare for the next field to add.
This class can also be used to construct individual FieldDescriptor
objects.
- Since:
- 3.0
- Author:
- Mark Rotteveel
-
Constructor Summary
ConstructorsConstructorDescriptionRowDescriptorBuilder
(int size, DatatypeCoder datatypeCoder) Constructs an instance of RowDescriptorBuilder for size fields. -
Method Summary
Modifier and TypeMethodDescriptionaddField()
Adds the current field data to the row and prepares this builder for the next field by resetting all values.addField
(FieldDescriptor fieldDescriptor) Adds theFieldDescriptor
on the current fieldIndex as the next in the row, and increments the current field index by 1.at
(int index) Convenience shortcut forsetFieldIndex(int)
.copyFieldFrom
(FieldDescriptor sourceFieldDescriptor) Set this builder with the values of the sourceFieldDescriptor
for further modification through this builder.int
int
int
getSize()
boolean
Resets the fields of this builder to the Java defaults.setFieldIndex
(int index) Sets the field index for the current field under construction.setFieldName
(String fieldName) Sets the (aliased) field name.setLength
(int length) Set the defined length of the field.setOriginalName
(String originalName) Sets the original field name.setOriginalTableName
(String originalTableName) Sets the original name of the underlying table.setOwnerName
(String ownerName) Sets the owner (database username) of the field.setScale
(int scale) Set the scale of the field.setSubType
(int subType) Set the Firebird subtype of the field.setTableAlias
(String tableAlias) Sets the alias of the underlying table.setType
(int type) Set the Firebird data type of the field.Convenience method to populate the basic field information used in metadata result sets (e.g.Creates aFieldDescriptor
based on the current field data of this RowDescriptorBuilder.Constructs theRowDescriptor
with the current content.
-
Constructor Details
-
RowDescriptorBuilder
Constructs an instance of RowDescriptorBuilder for size fields.- Parameters:
size
- Number of fieldsdatatypeCoder
- DatatypeCoder for decoding field data
-
-
Method Details
-
getSize
public int getSize()- Returns:
- Number of fields the row will hold.
-
setType
Set the Firebird data type of the field.- Parameters:
type
- Data type- Returns:
- this builder
-
setSubType
Set the Firebird subtype of the field.- Parameters:
subType
- Subtype- Returns:
- this builder
- See Also:
-
setScale
Set the scale of the field.- Parameters:
scale
- Scale- Returns:
- this builder
- See Also:
-
setLength
Set the defined length of the field.- Parameters:
length
- Defined (maximum) length of the field- Returns:
- this builder
-
setFieldName
Sets the (aliased) field name.- Parameters:
fieldName
- The field name- Returns:
- this builder
- See Also:
-
setTableAlias
Sets the alias of the underlying table.- Parameters:
tableAlias
- The table alias- Returns:
- this builder
- See Also:
-
setOriginalName
Sets the original field name.- Parameters:
originalName
- The original field name- Returns:
- this builder
- See Also:
-
setOriginalTableName
Sets the original name of the underlying table.- Parameters:
originalTableName
- The table name- Returns:
- this builder
- See Also:
-
setFieldIndex
Sets the field index for the current field under construction.Even though
addField()
increments the current field index, it is advisable to always explicitly set the index using this method orat(int)
as it improves readability.- Parameters:
index
- Index of the field- Returns:
- this builder
- Throws:
IndexOutOfBoundsException
- Whenindex
is not between 0 (inclusive) andgetSize()
(exclusive)IllegalStateException
- When aFieldDescriptor
is already defined on the specifiedindex
-
at
Convenience shortcut forsetFieldIndex(int)
.- Parameters:
index
- Index of the field- Returns:
- this builder
- See Also:
-
getCurrentFieldIndex
public int getCurrentFieldIndex()- Returns:
- The index for the current field
-
setOwnerName
Sets the owner (database username) of the field.- Parameters:
ownerName
- Name of the owner- Returns:
- this builder
-
simple
public RowDescriptorBuilder simple(int type, int length, String originalName, String originalTableName) Convenience method to populate the basic field information used in metadata result sets (e.g. for use inFBDatabaseMetaData
).- Parameters:
type
- Firebird data typelength
- Defined (maximum) length of the fieldoriginalName
- The original field nameoriginalTableName
- The table name- Returns:
- this builder
- See Also:
-
toFieldDescriptor
Creates aFieldDescriptor
based on the current field data of this RowDescriptorBuilder.- Returns:
- FieldDescriptor
-
resetField
Resets the fields of this builder to the Java defaults. -
copyFieldFrom
Set this builder with the values of the sourceFieldDescriptor
for further modification through this builder.- Parameters:
sourceFieldDescriptor
- Source for the initial values- Returns:
- this builder
-
addField
Adds the current field data to the row and prepares this builder for the next field by resetting all values.- Returns:
- this builder
- See Also:
-
addField
Adds theFieldDescriptor
on the current fieldIndex as the next in the row, and increments the current field index by 1.This method does not call
resetField()
, so a partial definition of a field can exist inside this builder after calling this method.- Parameters:
fieldDescriptor
- FieldDescriptor to add- Returns:
- this builder
-
toRowDescriptor
Constructs theRowDescriptor
with the current content.This method can also return a partially filled
RowDescriptor
. Caller can check for completeness by callingisComplete()
.- Returns:
- RowDescriptor instance.
- See Also:
-
isComplete
public boolean isComplete()- Returns:
- true when all
FieldDescriptor
entries have been defined
-
getFirstUnprocessedIndex
public int getFirstUnprocessedIndex()- Returns:
- Returns the index of the first unprocessed FieldDescriptor, or
getSize()
if all fields have been set.
-