APIdia Launch Partner
Top Description Fields Constructors Methods
io.github.spannm.jackcess

public Class ColumnBuilder

extends Object
Class Inheritance
Imports
io.github.spannm.jackcess.Database.FileFormat, io.github.spannm.jackcess.impl.ColumnImpl, .DatabaseImpl, .JetFormat, .PropertyMapImpl, .TableImpl, .TableUpdater, io.github.spannm.jackcess.util.ToStringBuilder, java.io.IOException, java.util.HashMap, .Map

Builder style class for constructing a Column. See TableBuilder for example usage. Additionally, a Column can be added to an existing Table using the addToTable(Table) method.
See Also
TableBuilder

Field Summary

Modifier and TypeField and Description
private boolean
autoNumber

whether or not the column is auto-number

private boolean
calculated

whether or not the column is calculated

private short
columnId

id for the new column, or UNSET_COLUMN_ID to use the column number

private short
columnNumber

0-based column number

private boolean
compressedUnicode

whether or not the column allows compressed unicode

private boolean
hyperlink

whether or not the column is a hyperlink (memo only)

private Short
length

optional length for the new column

private String
name

name of the new column

private Byte
precision

optional precision for the new column

private Map<String, PropertyMap.Property>
props

table properties (if any)

private Byte
scale

optional scale for the new column

private ColumnImpl.SortOrder
sortOrder

the collating sort order for a text field

private DataType
type

the type of the new column

private static final short
UNSET_COLUMN_ID

marks a column id which has not been assigned yet

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public Column
addToTable(Table table)

Adds a new Column to the given Table with the currently configured attributes.

public Column
addToTableDefinition(TableDefinition table)

Adds a new Column to the given TableDefinition with the currently configured attributes.

public ColumnBuilder
escapeName()

Escapes the new column's name using TableBuilder#escapeIdentifier.

public short

Returns:

the column id
getColumnId
()

Returns the id of the new column, which defaults to the column number.

public short
public int
public short
public String
public byte
public Map<String, PropertyMap.Property>
private PropertyMap.Property
getProperty(String propName)

public byte
public ColumnImpl.SortOrder
public DataType
public boolean
public boolean
public boolean
public boolean
public void
setColumnId(short
the column id
newColumnId
)

Sets the id of the new column.

public void
setColumnNumber(short newColumnNumber)

private void
public void
public boolean
public ColumnBuilder
toColumn()

Creates a new Column with the currently configured attributes.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public void
validate(JetFormat format)

Checks that this column definition is valid.

public ColumnBuilder
withAutoNumber(boolean newAutoNumber)

Sets whether of not the new column is an auto-number column.

public ColumnBuilder
withCalculated(boolean newCalculated)

Sets whether of not the new column is a calculated column.

public ColumnBuilder
withCalculatedInfo(String expression)

Convenience method to set the various info for a calculated type (flag, result type property and expression)

public ColumnBuilder
withCompressedUnicode(boolean newCompressedUnicode)

Sets whether of not the new column allows unicode compression.

private String
public ColumnBuilder
withFromColumn(Column template)

Sets all attributes except name from the given Column template (including all column properties except GUID).

public ColumnBuilder
withFromColumn(ColumnBuilder template)

Sets all attributes except name from the given Column template.

public ColumnBuilder
withLength(int newLength)

Sets the length (in bytes) for the new column.

public ColumnBuilder
withLengthInUnits(int unitLength)

Sets the length (in type specific units) for the new column.

public ColumnBuilder
withMaxLength()

Sets the length for the new column to the max length for the type.

public ColumnBuilder
withMaxPrecision()

Sets the precision for the new column to the max length for the type.

public ColumnBuilder
withMaxScale()

Sets the scale for the new column to the max length for the type.

public ColumnBuilder
withPrecision(int newPrecision)

Sets the precision for the new column.

public ColumnBuilder
withProperty(String propName, Object value)

Sets the column property with the given name to the given value.

public ColumnBuilder
withProperty(String propName, DataType propType, Object value)

Sets the column property with the given name and type to the given value.

public ColumnBuilder
withScale(int newScale)

Sets the scale for the new column.

public ColumnBuilder
withSqlType(int sqlType)

Sets the type for the new column based on the given SQL type.

public ColumnBuilder
withSqlType(int sqlType, int lengthInUnits)

Sets the type for the new column based on the given SQL type and target data length (in type specific units).

public ColumnBuilder
withSqlType(int sqlType, int lengthInUnits, Database.FileFormat fileFormat)

Sets the type for the new column based on the given SQL type, target data length (in type specific units), and target FileFormat.

public ColumnBuilder
withType(DataType newType)

Sets the type for the new column.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

autoNumberback to summary
private boolean autoNumber

whether or not the column is auto-number

calculatedback to summary
private boolean calculated

whether or not the column is calculated

columnIdback to summary
private short columnId

id for the new column, or UNSET_COLUMN_ID to use the column number

columnNumberback to summary
private short columnNumber

0-based column number

compressedUnicodeback to summary
private boolean compressedUnicode

whether or not the column allows compressed unicode

lengthback to summary
private Short length

optional length for the new column

nameback to summary
private String name

name of the new column

precisionback to summary
private Byte precision

optional precision for the new column

propsback to summary
private Map<String, PropertyMap.Property> props

table properties (if any)

scaleback to summary
private Byte scale

optional scale for the new column

sortOrderback to summary
private ColumnImpl.SortOrder sortOrder

the collating sort order for a text field

typeback to summary
private DataType type

the type of the new column

UNSET_COLUMN_IDback to summary
private static final short UNSET_COLUMN_ID

marks a column id which has not been assigned yet

Constructor Detail

ColumnBuilderback to summary
public ColumnBuilder(String name)
ColumnBuilderback to summary
public ColumnBuilder(String name, DataType type)

Method Detail

addToTableback to summary
public Column addToTable(Table table) throws IOException

Adds a new Column to the given Table with the currently configured attributes.

addToTableDefinitionback to summary
public Column addToTableDefinition(TableDefinition table) throws IOException

Adds a new Column to the given TableDefinition with the currently configured attributes.

escapeNameback to summary
public ColumnBuilder escapeName()

Escapes the new column's name using TableBuilder#escapeIdentifier.

getColumnIdback to summary
public short getColumnId()

Returns the id of the new column, which defaults to the column number.

Returns:short

the column id

getColumnNumberback to summary
public short getColumnNumber()
getFixedDataSizeback to summary
public int getFixedDataSize()
getLengthback to summary
public short getLength()
getNameback to summary
public String getName()
getPrecisionback to summary
public byte getPrecision()
getPropertiesback to summary
public Map<String, PropertyMap.Property> getProperties()
getPropertyback to summary
private PropertyMap.Property getProperty(String propName)
getScaleback to summary
public byte getScale()
getTextSortOrderback to summary
public ColumnImpl.SortOrder getTextSortOrder()
getTypeback to summary
public DataType getType()
isAutoNumberback to summary
public boolean isAutoNumber()
isCalculatedback to summary
public boolean isCalculated()
isCompressedUnicodeback to summary
public boolean isCompressedUnicode()
isVariableLengthback to summary
public boolean isVariableLength()
setColumnIdback to summary
public void setColumnId(short newColumnId)

Sets the id of the new column. Access never reuses or renumbers column ids.

Parameters
newColumnId:short

the column id

setColumnNumberback to summary
public void setColumnNumber(short newColumnNumber)
setPropertyback to summary
private void setProperty(String propName, PropertyMap.Property prop)
setTextSortOrderback to summary
public void setTextSortOrder(ColumnImpl.SortOrder newTextSortOrder)
storeInNullMaskback to summary
public boolean storeInNullMask()
toColumnback to summary
public ColumnBuilder toColumn()

Creates a new Column with the currently configured attributes.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
validateback to summary
public void validate(JetFormat format)

Checks that this column definition is valid.

Exceptions
IllegalArgumentException:
if this column definition is invalid.
withAutoNumberback to summary
public ColumnBuilder withAutoNumber(boolean newAutoNumber)

Sets whether of not the new column is an auto-number column.

withCalculatedback to summary
public ColumnBuilder withCalculated(boolean newCalculated)

Sets whether of not the new column is a calculated column.

withCalculatedInfoback to summary
public ColumnBuilder withCalculatedInfo(String expression)

Convenience method to set the various info for a calculated type (flag, result type property and expression)

withCompressedUnicodeback to summary
public ColumnBuilder withCompressedUnicode(boolean newCompressedUnicode)

Sets whether of not the new column allows unicode compression.

withErrorContextback to summary
private String withErrorContext(String msg)
withFromColumnback to summary
public ColumnBuilder withFromColumn(Column template) throws IOException

Sets all attributes except name from the given Column template (including all column properties except GUID).

withFromColumnback to summary
public ColumnBuilder withFromColumn(ColumnBuilder template)

Sets all attributes except name from the given Column template.

withLengthback to summary
public ColumnBuilder withLength(int newLength)

Sets the length (in bytes) for the new column.

withLengthInUnitsback to summary
public ColumnBuilder withLengthInUnits(int unitLength)

Sets the length (in type specific units) for the new column.

withMaxLengthback to summary
public ColumnBuilder withMaxLength()

Sets the length for the new column to the max length for the type. Does nothing for types which are not variable length.

withMaxPrecisionback to summary
public ColumnBuilder withMaxPrecision()

Sets the precision for the new column to the max length for the type. Does nothing for types which do not have a precision.

withMaxScaleback to summary
public ColumnBuilder withMaxScale()

Sets the scale for the new column to the max length for the type. Does nothing for types which do not have a scale.

withPrecisionback to summary
public ColumnBuilder withPrecision(int newPrecision)

Sets the precision for the new column.

withPropertyback to summary
public ColumnBuilder withProperty(String propName, Object value)

Sets the column property with the given name to the given value. Attempts to determine the type of the property (see PropertyMap#put(String, Object) for details on determining the property type).

withPropertyback to summary
public ColumnBuilder withProperty(String propName, DataType propType, Object value)

Sets the column property with the given name and type to the given value.

withScaleback to summary
public ColumnBuilder withScale(int newScale)

Sets the scale for the new column.

withSqlTypeback to summary
public ColumnBuilder withSqlType(int sqlType) throws IOException

Sets the type for the new column based on the given SQL type.

withSqlTypeback to summary
public ColumnBuilder withSqlType(int sqlType, int lengthInUnits) throws IOException

Sets the type for the new column based on the given SQL type and target data length (in type specific units).

withSqlTypeback to summary
public ColumnBuilder withSqlType(int sqlType, int lengthInUnits, Database.FileFormat fileFormat) throws IOException

Sets the type for the new column based on the given SQL type, target data length (in type specific units), and target FileFormat.

withTypeback to summary
public ColumnBuilder withType(DataType newType)

Sets the type for the new column.