public final class RowDescriptorBuilder
extends java.lang.Object
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.
Constructor and Description |
---|
RowDescriptorBuilder(int size,
DatatypeCoder datatypeCoder)
Constructs an instance of RowDescriptorBuilder for size fields.
|
Modifier and Type | Method and Description |
---|---|
RowDescriptorBuilder |
addField()
Adds the current field data to the row and prepares this builder for the next field by resetting all values.
|
RowDescriptorBuilder |
addField(FieldDescriptor fieldDescriptor)
Adds the
FieldDescriptor on the current fieldIndex as the next in the row, and increments the current
field index by 1. |
RowDescriptorBuilder |
at(int index)
Convenience shortcut for
setFieldIndex(int) . |
RowDescriptorBuilder |
copyFieldFrom(FieldDescriptor sourceFieldDescriptor)
Set this builder with the values of the source
FieldDescriptor for further modification through this builder. |
int |
getCurrentFieldIndex() |
int |
getFirstUnprocessedIndex() |
int |
getSize() |
boolean |
isComplete() |
RowDescriptorBuilder |
resetField()
Resets the fields of this builder to the Java defaults.
|
RowDescriptorBuilder |
setFieldIndex(int index)
Sets the field index for the current field under construction.
|
RowDescriptorBuilder |
setFieldName(java.lang.String fieldName)
Sets the (aliased) field name.
|
RowDescriptorBuilder |
setLength(int length)
Set the defined length of the field.
|
RowDescriptorBuilder |
setOriginalName(java.lang.String originalName)
Sets the original field name.
|
RowDescriptorBuilder |
setOriginalTableName(java.lang.String originalTableName)
Sets the original name of the underlying table.
|
RowDescriptorBuilder |
setOwnerName(java.lang.String ownerName)
Sets the owner (database username) of the field.
|
RowDescriptorBuilder |
setScale(int scale)
Set the scale of the field.
|
RowDescriptorBuilder |
setSubType(int subType)
Set the Firebird sub type of the field.
|
RowDescriptorBuilder |
setTableAlias(java.lang.String tableAlias)
Sets the alias of the underlying table.
|
RowDescriptorBuilder |
setType(int type)
Set the Firebird data type of the field.
|
RowDescriptorBuilder |
simple(int type,
int length,
java.lang.String originalName,
java.lang.String originalTableName)
Convenience method to populate the basic field information used in metadata result sets (eg for use in
FBDatabaseMetaData ). |
FieldDescriptor |
toFieldDescriptor()
Creates a
FieldDescriptor based on the current field data of this RowDescriptorBuilder. |
RowDescriptor |
toRowDescriptor()
Constructs the
RowDescriptor with the current content. |
public RowDescriptorBuilder(int size, DatatypeCoder datatypeCoder)
size
- Number of fieldsdatatypeCoder
- DatatypeCoder for decoding field datapublic int getSize()
public RowDescriptorBuilder setType(int type)
type
- Data typepublic RowDescriptorBuilder setSubType(int subType)
subType
- Sub typesetType(int)
public RowDescriptorBuilder setScale(int scale)
scale
- ScalesetType(int)
public RowDescriptorBuilder setLength(int length)
length
- Defined (maximum) length of the fieldpublic RowDescriptorBuilder setFieldName(java.lang.String fieldName)
fieldName
- The field namesetOriginalName(String)
public RowDescriptorBuilder setTableAlias(java.lang.String tableAlias)
tableAlias
- The table aliassetOriginalTableName(String)
public RowDescriptorBuilder setOriginalName(java.lang.String originalName)
originalName
- The original field namesetFieldName(String)
public RowDescriptorBuilder setOriginalTableName(java.lang.String originalTableName)
originalTableName
- The table namesetTableAlias(String)
public RowDescriptorBuilder setFieldIndex(int index)
Even though addField()
increments the current field index, it is advisable to always explicitly
set the index using this method or at(int)
as it improves readability.
index
- Index of the fieldjava.lang.IndexOutOfBoundsException
- When index
is not between 0 (inclusive) and getSize()
(exclusive)java.lang.IllegalStateException
- When a FieldDescriptor
is already defined on the specified index
public RowDescriptorBuilder at(int index)
setFieldIndex(int)
.index
- Index of the fieldsetFieldIndex(int)
public int getCurrentFieldIndex()
public RowDescriptorBuilder setOwnerName(java.lang.String ownerName)
ownerName
- Name of the ownerpublic RowDescriptorBuilder simple(int type, int length, java.lang.String originalName, java.lang.String originalTableName)
FBDatabaseMetaData
).type
- Firebird data typelength
- Defined (maximum) length of the fieldoriginalName
- The original field nameoriginalTableName
- The table namesetType(int)
,
setLength(int)
,
setOriginalTableName(String)
,
setOriginalName(String)
public FieldDescriptor toFieldDescriptor()
FieldDescriptor
based on the current field data of this RowDescriptorBuilder.public RowDescriptorBuilder resetField()
public RowDescriptorBuilder copyFieldFrom(FieldDescriptor sourceFieldDescriptor)
FieldDescriptor
for further modification through this builder.sourceFieldDescriptor
- Source for the initial valuespublic RowDescriptorBuilder addField()
resetField()
public RowDescriptorBuilder addField(FieldDescriptor fieldDescriptor)
FieldDescriptor
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.
fieldDescriptor
- FieldDescriptor to addpublic RowDescriptor toRowDescriptor()
RowDescriptor
with the current content.
This method can also return a partially filled RowDescriptor
. Caller can check for completeness by
calling isComplete()
.
isComplete()
public boolean isComplete()
FieldDescriptor
entries have been definedpublic int getFirstUnprocessedIndex()
getSize()
if all fields have been set.Copyright © 2001-2021 Jaybird (Firebird JDBC/JCA) team. All rights reserved.