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

public Class ColumnImpl

extends Object
implements Column, Comparable<ColumnImpl>, DateTimeContext
Class Inheritance
All Implemented Interfaces
io.github.spannm.jackcess.impl.DateTimeContext, java.lang.Comparable, io.github.spannm.jackcess.Column
Known Direct Subclasses
io.github.spannm.jackcess.impl.ComplexColumnImpl, io.github.spannm.jackcess.impl.LongValueColumnImpl, io.github.spannm.jackcess.impl.NumericColumnImpl, io.github.spannm.jackcess.impl.PropertyMaps.Handler.PropColumn, io.github.spannm.jackcess.impl.TextColumnImpl, io.github.spannm.jackcess.impl.UnsupportedColumnImpl, io.github.spannm.jackcess.impl.CalculatedColumnUtil.CalcColImpl, io.github.spannm.jackcess.impl.CalculatedColumnUtil.CalcBooleanColImpl
Imports
io.github.spannm.jackcess.Column, .ColumnBuilder, .DataType, .DateTimeType, .InvalidValueException, .JackcessRuntimeException, .PropertyMap, .Table, io.github.spannm.jackcess.complex.ComplexColumnInfo, .ComplexValue, .ComplexValueForeignKey, io.github.spannm.jackcess.expr.Identifier, io.github.spannm.jackcess.impl.complex.ComplexValueForeignKeyImpl, io.github.spannm.jackcess.impl.expr.LocaleUtil, .NumberFormatter, io.github.spannm.jackcess.util.ColumnValidator, .SimpleColumnValidator, .ToStringBuilder, java.io.ByteArrayOutputStream, .IOException, .InputStream, .ObjectOutputStream, .ObjectStreamException, .Reader, .Serializable, java.math.BigDecimal, .BigInteger, java.nio.ByteBuffer, .ByteOrder, .CharBuffer, java.nio.charset.Charset, java.time.DateTimeException, .Duration, .Instant, .LocalDate, .LocalDateTime, .LocalTime, .ZoneId, .ZonedDateTime, java.time.temporal.ChronoUnit, .TemporalAccessor, .TemporalQueries, java.util.Calendar, .Collection, .Date, .List, .Map, .TimeZone, .UUID, java.util.logging.Level, .Logger, java.util.regex.Matcher, .Pattern

Access database column definition
Author
Tim McCune

Nested and Inner Type Summary

Modifier and TypeClass and Description
public abstract static class
ColumnImpl.AutoNumberGenerator

Base class for the supported autonumber types.

private class
private static class
ColumnImpl.DateExt

Date subclass which stashes the original date bits, in case we attempt to re-write the value (will not lose precision).

protected abstract static class
ColumnImpl.DateTimeFactory

Factory which handles date/time values appropriately for a DateTimeType.

private static class
ColumnImpl.DefaultDateTimeFactory

Factory impl for legacy Date handling.

private static class
pack-priv static class
ColumnImpl.InitArgs

Utility struct for passing params through ColumnImpl constructors.

pack-priv static interface
ColumnImpl.InMemoryBlob

internal interface for types which hold bytes in memory

private static class
ColumnImpl.LDTDateTimeFactory

Factory impl for LocalDateTime handling.

private class
private static class
ColumnImpl.NoZeroLenColValidator

"Internal" column validator for text columns with the "allow zero len" property disabled.

private static class
ColumnImpl.RawData

Wrapper for raw column data which can be re-written.

private static class
ColumnImpl.RequiredColValidator

"Internal" column validator for columns with the "required" property enabled.

public static class
ColumnImpl.SortOrder

Collation sort order stored per text column in an MS Access database file.

private static class

Field Summary

Modifier and TypeField and Description
public static final byte
AUTO_NUMBER_FLAG_MASK

mask for the auto number bit

public static final byte
AUTO_NUMBER_GUID_FLAG_MASK

mask for the auto number guid bit

private static final LocalDate
private static final LocalDateTime
private static final LocalTime
public static final LocalDate
public static final LocalDateTime
public static final LocalTime
private static final byte
public static final byte
COMPLEX_FK_EXT_FLAG_MASK

mask for the ext flag which marks the complex value foreign key column of a complex column's flat table.

protected static final byte
private static final ColumnImpl.DateTimeFactory
private ColDefaultValueEvalContext
defValue

default value generator

private static final byte[]
public static final byte
FIXED_LEN_FLAG_MASK

mask for the fixed len bit

public static final ColumnImpl.SortOrder
GENERAL_97_SORT_ORDER

Sort order used by Access 97 databases (LCID 1033, version −1).

public static final ColumnImpl.SortOrder
GENERAL_LEGACY_SORT_ORDER

Sort order used by Access 2000–2007 databases (LCID 1033, version 0).

public static final ColumnImpl.SortOrder
GENERAL_SORT_ORDER

Sort order used by Access 2010 and later databases (LCID 1033, version 1).

private static final short
GENERAL_SORT_ORDER_VALUE

Windows LCID for the "General" English/default sort order used by all three General variants.

private static final Pattern
GUID_PATTERN

pattern matching textual guid strings (allows for optional surrounding '{' and '}')

pack-priv static final int
INVALID_AUTO_NUMBER

auto numbers must be > 0

pack-priv static final int
pack-priv static final ColumnImpl.DateTimeFactory
private int
lengthInUnits

length of the column in units, lazily computed

protected static final Logger
private final boolean
mautoNumber

Whether or not the column is an autonumber column

private final ColumnImpl.AutoNumberGenerator
mautoNumberGenerator

the auto number generator for this column (if autonumber column)

private static final char
private final boolean
mcalculated

Whether or not the column is a calculated column

private final short
mcolumnId

id assigned to this column when it was created.

private int
mcolumnIndex

index of the data for this column within a list of row data

private final short
mcolumnLength

Maximum column length

private final short
mcolumnNumber

0-based column number

private final boolean
mcomplexValueForeignKey

Whether or not the column is the complex value foreign key of a complex column's flat table

private final int
mdisplayIndex

display index of the data for this column

private final int
mfixedDataOffset

the offset of the fixed data in the row

pack-priv static final long
MILLIS_BETWEEN_EPOCH_AND_1900

Access starts counting dates at Dec 30, 1899 (note, this strange date seems to be caused by MS compatibility with Lotus-1-2-3 and incorrect leap years).

private static final long
private static final long
MILLISECONDS_PER_DAY

Access stores numeric dates in days.

private static final char
private final String
mname

Column name

private final TableImpl
mtable

owning table

private final DataType
mtype

Data type

private final boolean
mvariableLength

Whether or not the column is of variable length

private final int
mvarLenTableIndex

the index of the variable length data in the var len offset table

private static final long
private static final long
pack-priv static final byte
private PropertyMap
props

properties for this column, if any

public static final Object
RETURN_ROW_ID

Placeholder object for adding rows which indicates that the caller wants the RowId of the new row.

public static final ColumnImpl.SortOrder
RUSSIAN_SORT_ORDER

Sort order used by MS Access databases configured with the Russian/Cyrillic collation (LCID 1049, version 0).

private static final long
private static final byte[]
TEXT_COMPRESSION_HEADER

header used to indicate unicode text compression

public static final ColumnImpl.SortOrder
TURKISH_SORT_ORDER

Sort order used by MS Access databases configured with the Turkish collation (LCID 1055, version 0).

public static final ColumnImpl.SortOrder
UKRAINIAN_SORT_ORDER

Sort order used by MS Access databases configured with the Ukrainian/Cyrillic collation (LCID 1058, version 0).

public static final byte
UPDATABLE_FLAG_MASK

mask for the "is updatable" field bit

private ColumnValidator
validator

Validator for writing new values

Constructor Summary

AccessConstructor and Description
protected
ColumnImpl(TableImpl _table, String _name, DataType _type, int _colNumber, int _fixedOffset, int _varLenIndex)

pack-priv
ColumnImpl(ColumnImpl.InitArgs args)

Read a column definition in from a buffer

Method Summary

Modifier and TypeMethod and Description
protected static Object
booleanToInteger(Object obj)

Treat booleans as integers (access-style).

protected int
pack-priv void
public int
compareTo(ColumnImpl other)

Implements java.lang.Comparable.compareTo.

Orders Columns by column number.

public static short

Returns:

The number of variable length columns found in the list
countVariableLength
(List<ColumnBuilder>
A list of columns in a table definition
columns
)

Returns the number of variable length columns found in the list.

public static ColumnImpl
create(TableImpl
owning table
table
,
ByteBuffer
Buffer containing column definition
buffer
,
int
Offset in the buffer at which the column definition starts
offset
,
String name, int displayIndex)

Creates the appropriate ColumnImpl class and reads a column definition in from a buffer

private ColumnImpl.AutoNumberGenerator
private void
decodeTextSegment(byte[] data, int dataStart, int dataEnd, boolean inCompressedMode, StringBuilder textBuf)

Decodes a segnment of a text value into the given buffer according to the given status of the segment (compressed/uncompressed).

pack-priv String
decodeTextValue(byte[] data)

Decodes a compressed or uncompressed text value.

private static CharBuffer
decodeUncompressedText(byte[]
bytes of text to decode
textBytes
,
int startPos, int length, Charset charset)

Returns: the decoded string

public static String

Returns:

the decoded string
decodeUncompressedText
(byte[]
bytes of text to decode
textBytes
,
Charset
relevant charset
charset
)

Returns the decoded string.

private static Duration
pack-priv ByteBuffer
encodeTextValue(Object obj, int minChars, int maxChars, boolean forceUncompressed)

Encodes a text value, possibly compressing.

public static ByteBuffer

Returns:

A buffer with the text encoded
encodeUncompressedText
(CharSequence
Text to encode
text
,
Charset
database charset
charset
)

Returns a buffer with the text encoded.

private static void
fixNumericByteOrder(byte[] bytes)

Swaps the bytes of the given numeric in place.

public long
fromDateDouble(double value)

Returns a java long time value converted from an access date double.

private static long
fromDateDouble(double value, TimeZone tz)

pack-priv static long
fromLocalDateDouble(double value)

public Object
generateDefaultValue()

Returns a default value for this column

public ColumnImpl.AutoNumberGenerator
getAutoNumberGenerator()

Returns the AutoNumberGenerator for this column if this is an autonumber column, null otherwise.

protected CalcColEvalContext
getCalculationContext()

Returns the context used to manage calculated column values.

protected Charset
private static byte
getColumnBitFlags(ColumnBuilder col)

Constructs a byte containing the flags for this column.

public short

Returns:

the column id
getColumnId
()

Returns the id the engine gave this column when it was created.

public int
getColumnIndex()

Implements io.github.spannm.jackcess.Column.getColumnIndex.

Returns the position of this column within its table, i.e. the index at which this column's value is stored in the Object[] row arrays accepted/returned by getRowValue(Object[]) and setRowValue(Object[], Object).

public short
public ColumnValidator
getColumnValidator()

Implements io.github.spannm.jackcess.Column.getColumnValidator.

Gets currently configured ColumnValidator (always non-null).

public ComplexColumnInfo<? extends ComplexValue>
getComplexInfo()

Implements io.github.spannm.jackcess.Column.getComplexInfo.

Returns extended functionality for "complex" columns.

public DatabaseImpl
getDatabase()

Implements io.github.spannm.jackcess.Column.getDatabase.

Returns the database to which this column's table belongs.

public ColumnImpl.DateTimeFactory
protected static ColumnImpl.DateTimeFactory
public int
public int
protected int
public JetFormat
private static long
getFromLocalTimeZoneOffset(long time, TimeZone tz)

Gets the timezone offset from local time to UTC for the given time (including DST).

public short
getLength()

Implements io.github.spannm.jackcess.Column.getLength.

Returns the length of this column in bytes, as stored in the database.

public final short
getLengthInUnits()

Implements io.github.spannm.jackcess.Column.getLengthInUnits.

Returns the length of this column in "units" appropriate for its type (e.g. characters for TEXT columns), which may differ from getLength() for columns whose storage unit is wider than one byte.

public String
getName()

Implements io.github.spannm.jackcess.Column.getName.

Returns the name of this column.

pack-priv byte
public int
getOwnedPageCount()

Returns the number of database pages owned by this column.

public PageChannel
public byte
getPrecision()

Implements io.github.spannm.jackcess.Column.getPrecision.

Returns the numeric precision of this column (only meaningful for DataTypes NUMERIC and MONEY).

public PropertyMap
getProperties()

Implements io.github.spannm.jackcess.Column.getProperties.

Returns the properties for this column.

public Object
getRowValue(Object[] rowArray)

Implements io.github.spannm.jackcess.Column.getRowValue.

Returns this column's value at the position given by getColumnIndex() within rowArray.

public Object
getRowValue(Map<String, ?> rowMap)

Implements io.github.spannm.jackcess.Column.getRowValue.

Returns this column's value, keyed by getName(), within rowMap.

public byte
getScale()

Implements io.github.spannm.jackcess.Column.getScale.

Returns the numeric scale of this column (only meaningful for DataTypes NUMERIC and MONEY).

public int
getSQLType()

Implements io.github.spannm.jackcess.Column.getSQLType.

Returns the java.sql.Types constant corresponding to this column's DataType.

public TableImpl
getTable()

Implements io.github.spannm.jackcess.Column.getTable.

Returns the table to which this column belongs.

public short
public ColumnImpl.SortOrder
public TimeZone
public DataType
getType()

Implements io.github.spannm.jackcess.Column.getType.

Returns the data type of this column.

public int
public ColumnImpl
getVersionHistoryColumn()

Implements io.github.spannm.jackcess.Column.getVersionHistoryColumn.

Returns the column which tracks the version history for an "append only" column.

public ZoneId
pack-priv void
public boolean
isAppendOnly()

Implements io.github.spannm.jackcess.Column.isAppendOnly.

Whether or not this column is "append only" (its history is tracked by a separate version history column).

public boolean
isAutoNumber()

Implements io.github.spannm.jackcess.Column.isAutoNumber.

Returns true if this is an autonumber column, whose values are assigned automatically by the database.

public boolean
isCalculated()

Implements io.github.spannm.jackcess.Column.isCalculated.

Returns whether or not this is a calculated column.

public boolean

Returns:

whether this column is a complex value foreign key
isComplexValueForeignKey
()

Returns true if this column is the complex value foreign key of a complex column's flat table, the column which points back at the row in the owning table.

public boolean
isCompressedUnicode()

Implements io.github.spannm.jackcess.Column.isCompressedUnicode.

Returns true if this text column uses compressed unicode storage, false otherwise (not applicable to non-text columns).

pack-priv static boolean
isGUIDValue(Object value)

Returns true if the given value is a "guid" value.

pack-priv static boolean
isImmutableValue(Object value)

Returns true if the value is immutable, false otherwise.

public static boolean
isRawData(Object value)

Returns true if the given value is "raw" column data, false otherwise.

pack-priv boolean
private static boolean
isUnicodeCompressible(CharSequence text)

Returns true if the given text can be compressed using compressed unicode, false otherwise.

public boolean
isVariableLength()

Implements io.github.spannm.jackcess.Column.isVariableLength.

Returns true if this column's values are variable-length (e.g. TEXT, MEMO, BINARY), false if fixed-length (e.g. LONG, DOUBLE).

public static LocalDateTime
ldtFromLocalDateDouble(double value)

pack-priv void
postTableLoadInit()

Secondary column initialization after the table is fully loaded.

pack-priv void
public static ColumnImpl.RawData
rawDataWrapper(byte[] bytes)

Returns a wrapper for raw column data that can be written without understanding the data.

public Object

Returns:

The deserialized Object
read
(byte[]
The raw byte value
data
)

Deserialize a raw byte value for this column into an Object

public Object

Returns:

The deserialized Object
read
(byte[]
The raw byte value
data
,
ByteOrder
Byte order in which the raw value is stored
order
)

Deserialize a raw byte value for this column into an Object

pack-priv static short
readCodePage(ByteBuffer buffer, int offset, JetFormat format)

Reads the column cade page info from the given buffer, if supported for this db.

private BigDecimal

Returns:

BigDecimal representing the monetary value
readCurrencyValue
(ByteBuffer
Column value that points to currency data
buffer
)

Decodes "Currency" values.

private Object
readDateValue(ByteBuffer buffer)

Decodes a date value.

private static long
readExtDateLong(ByteBuffer buffer, int numChars)

Reads the given number of ascii encoded characters as a long value.

private static Object
readExtendedDateValue(ByteBuffer buffer)

Decodes an "extended" date/time value.

pack-priv static byte
readExtraFlags(ByteBuffer buffer, int offset, JetFormat format)

Read the extra flags field for a column definition.

public Object
readFromNullMask(boolean isNull)

private static String
readGUIDValue(ByteBuffer buffer, ByteOrder order)

Decodes a GUID value.

private BigDecimal
readNumericValue(ByteBuffer buffer)

Decodes a NUMERIC field.

pack-priv static ColumnImpl.SortOrder

Returns:

the sort order for the column; never null
readSortOrder
(ByteBuffer
table definition buffer, positioned arbitrarily (absolute read)
buffer
,
int
byte offset of the sort-order field within buffer
position
,
JetFormat
JetFormat of the database, providing SIZE_SORT_ORDER and DEFAULT_SORT_ORDER
format
)

Reads the collating sort order for a text column from the table-definition buffer.

pack-priv void
private static double
roundToMillis(double dbl)

Rounds the given decimal to milliseconds (3 decimal places) using the standard access rounding mode.

protected void
public void
setColumnIndex(int newColumnIndex)

public void
setColumnValidator(ColumnValidator newValidator)

Implements io.github.spannm.jackcess.Column.setColumnValidator.

Sets a new ColumnValidator.

public Object
setRowValue(Object[] rowArray, Object value)

Implements io.github.spannm.jackcess.Column.setRowValue.

Sets this column's value at the position given by getColumnIndex() within rowArray.

public Object
setRowValue(Map<String, Object> rowMap, Object value)

Implements io.github.spannm.jackcess.Column.setRowValue.

Sets this column's value, keyed by getName(), within rowMap.

pack-priv void
setUsageMaps(UsageMap ownedPages, UsageMap freeSpacePages)

Sets the usage maps for this column.

public void
public boolean
private static LocalDateTime
pack-priv static BigDecimal
toBigDecimal(byte[] bytes, boolean negate, int scale)

pack-priv BigDecimal

Returns:

an appropriate BigDecimal representation of the given object. null is returned as 0 and Numbers are converted using their double representation.
toBigDecimal
(Object value)

Returns an appropriate BigDecimal representation of the given object.

pack-priv static BigDecimal

Returns:

an appropriate BigDecimal representation of the given object. null is returned as 0 and Numbers are converted using their double representation.
toBigDecimal
(Object value, DatabaseImpl db)

Returns an appropriate BigDecimal representation of the given object.

public static boolean
toBooleanValue(Object obj)

Interpret a boolean value (null == false)

public static byte[]

Returns:

an appropriate byte[] representation of the given object.
toByteArray
(Object value)

Returns an appropriate byte[] representation of the given object.

public static CharSequence

Returns:

an appropriate CharSequence representation of the given object.
toCharSequence
(Object value)

Returns an appropriate CharSequence representation of the given object.

public double
toDateDouble(Object value)

Returns an access date double converted from a java Date/Calendar/Number time value.

private static double
toDateDouble(Object value, DateTimeContext dtc)

Returns an access date double converted from a java Date/Calendar/Number/Temporal time value.

public static double
private static long
toDateLong(Object value)

Returns: an appropriate Date long value for the given object

public static Object
toInternalValue(DataType dataType, Object value, DatabaseImpl db)

Converts the given value to the "internal" representation for the given data type.

pack-priv static Object
pack-priv static double
toLocalDateDouble(long time)

private static double
pack-priv static LocalDateTime
private Number
toNumber(Object value)

Returns: an appropriate Number representation of the given object.

private static Number
toNumber(Object value, DatabaseImpl db)

Returns: an appropriate Number representation of the given object.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

pack-priv byte[]
toUnscaledByteArray(BigDecimal decVal, int maxByteLen)

public Object
validate(Object obj)

Passes the given obj through the currently configured validator for this column and returns the result.

pack-priv String
private static String
withErrorContext(String msg, DatabaseImpl db, String tableName, String colName)

public ByteBuffer

Returns:

A buffer containing the bytes
write
(Object
Object to serialize
obj
,
int remainingRowLength)

Serialize an Object into a raw byte value for this column in little endian order

public ByteBuffer

Returns:

A buffer containing the bytes
write
(Object
Object to serialize
obj
,
int remainingRowLength, ByteOrder
Order in which to serialize
order
)

Serialize an Object into a raw byte value for this column

protected static void
protected static void
private void
writeCurrencyValue(ByteBuffer buffer, Object value)

Writes "Currency" values.

private void
writeDateValue(ByteBuffer buffer, Object value)

Writes a date value.

protected static void
protected static void
writeDefinitions(TableCreator creator, ByteBuffer
Buffer to write to
buffer
)

Writes the column definitions into a table definition buffer.

private static void
writeExtDateLong(ByteBuffer buffer, long val, int numChars)

Writes the given long value as the given number of ascii encoded characters.

private void
writeExtendedDateValue(ByteBuffer buffer, Object value)

Writes an "extended" date/time value.

protected ByteBuffer

Returns:

A buffer containing the bytes
writeFixedLengthField
(Object
Object to serialize
obj
,
ByteOrder
Order in which to serialize
order
)

Serialize an Object into a raw byte value for this column

protected ByteBuffer
private void
writeGUIDValue(ByteBuffer buffer, Object value)

Writes a GUID value.

private void
writeNumericValue(ByteBuffer buffer, Object value)

Writes a numeric value.

protected ByteBuffer
writeRealData(Object obj, int remainingRowLength, ByteOrder order)

private static void
writeSortOrder(ByteBuffer buffer, ColumnImpl.SortOrder sortOrder, JetFormat format)

Writes the sort order info to the given buffer at the current position.

public boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait