com.healthmarketscience.jackcess.impl
Class ColumnImpl

java.lang.Object
  extended by com.healthmarketscience.jackcess.impl.ColumnImpl
All Implemented Interfaces:
Column, Comparable<ColumnImpl>

public class ColumnImpl
extends Object
implements Column, Comparable<ColumnImpl>

Access database column definition

Author:
Tim McCune

Nested Class Summary
 class ColumnImpl.AutoNumberGenerator
          Base class for the supported autonumber types.
static class ColumnImpl.SortOrder
          Information about the sort order (collation) for a textual column.
 
Field Summary
static byte AUTO_NUMBER_FLAG_MASK
          mask for the auto number bit
static byte AUTO_NUMBER_GUID_FLAG_MASK
          mask for the auto number guid bit
protected static byte COMPRESSED_UNICODE_EXT_FLAG_MASK
           
static byte FIXED_LEN_FLAG_MASK
          mask for the fixed len bit
static ColumnImpl.SortOrder GENERAL_LEGACY_SORT_ORDER
          the "general" text sort order, legacy version (access 2000-2007)
static ColumnImpl.SortOrder GENERAL_SORT_ORDER
          the "general" text sort order, latest version (access 2010+)
static byte HYPERLINK_FLAG_MASK
          mask for the hyperlink bit (on memo types)
protected static org.apache.commons.logging.Log LOG
           
static Object RETURN_ROW_ID
          Placeholder object for adding rows which indicates that the caller wants the RowId of the new row.
static byte UPDATABLE_FLAG_MASK
          mask for the "is updatable" field bit
 
Fields inherited from interface com.healthmarketscience.jackcess.Column
AUTO_NUMBER, KEEP_VALUE
 
Constructor Summary
protected ColumnImpl(TableImpl table, String name, DataType type, int colNumber, int fixedOffset, int varLenIndex)
           
 
Method Summary
protected static Object booleanToInteger(Object obj)
          Treat booleans as integers (C-style).
 int compareTo(ColumnImpl other)
          Orders Columns by column number.
static short countVariableLength(List<ColumnBuilder> columns)
           
static ColumnImpl create(TableImpl table, ByteBuffer buffer, int offset, String name, int displayIndex)
          Creates the appropriate ColumnImpl class and reads a column definition in from a buffer
static String decodeUncompressedText(byte[] textBytes, Charset charset)
           
static ByteBuffer encodeUncompressedText(CharSequence text, Charset charset)
           
 long fromDateDouble(double value)
          Returns a java long time value converted from an access date double.
 ColumnImpl.AutoNumberGenerator getAutoNumberGenerator()
          Returns the AutoNumberGenerator for this column if this is an autonumber column, null otherwise.
protected  Calendar getCalendar()
           
protected  Charset getCharset()
           
 int getColumnIndex()
           
 short getColumnNumber()
           
 ColumnValidator getColumnValidator()
          Gets currently configured ColumnValidator (always non-null).
 ComplexColumnInfo<? extends ComplexValue> getComplexInfo()
          Returns extended functionality for "complex" columns.
 DatabaseImpl getDatabase()
           
 int getDisplayIndex()
           
 int getFixedDataOffset()
           
 JetFormat getFormat()
           
 short getLength()
           
 short getLengthInUnits()
           
 String getName()
           
 int getOwnedPageCount()
          Returns the number of database pages owned by this column.
 PageChannel getPageChannel()
           
 byte getPrecision()
           
 PropertyMap getProperties()
           
 Object getRowValue(Map<String,?> rowMap)
           
 Object getRowValue(Object[] rowArray)
           
 byte getScale()
           
 int getSQLType()
           
 TableImpl getTable()
           
 short getTextCodePage()
           
 ColumnImpl.SortOrder getTextSortOrder()
           
 DataType getType()
           
 int getVarLenTableIndex()
           
 ColumnImpl getVersionHistoryColumn()
          Returns the column which tracks the version history for an "append only" column.
 boolean isAppendOnly()
          Whether or not this column is "append only" (its history is tracked by a separate version history column).
 boolean isAutoNumber()
           
 boolean isCalculated()
          Returns whether or not this is a calculated column.
 boolean isCompressedUnicode()
           
 boolean isHyperlink()
          Returns whether or not this is a hyperlink column (only possible for columns of type MEMO).
static boolean isRawData(Object value)
          Returns true if the given value is "raw" column data, false otherwise.
 boolean isVariableLength()
           
static com.healthmarketscience.jackcess.impl.ColumnImpl.RawData rawDataWrapper(byte[] bytes)
          Returns a wrapper for raw column data that can be written without understanding the data.
 Object read(byte[] data)
          Deserialize a raw byte value for this column into an Object
 Object read(byte[] data, ByteOrder order)
          Deserialize a raw byte value for this column into an Object
 Object readFromNullMask(boolean isNull)
           
 void setColumnIndex(int newColumnIndex)
           
 void setColumnValidator(ColumnValidator newValidator)
          Sets a new ColumnValidator.
 Object setRowValue(Map<String,Object> rowMap, Object value)
           
 Object setRowValue(Object[] rowArray, Object value)
           
 void setVersionHistoryColumn(ColumnImpl versionHistoryCol)
           
 boolean storeInNullMask()
           
static boolean toBooleanValue(Object obj)
          Interpret a boolean value (null == false)
static byte[] toByteArray(Object value)
           
static CharSequence toCharSequence(Object value)
           
 double toDateDouble(Object value)
          Returns an access date double converted from a java Date/Calendar/Number time value.
static Object toInternalValue(DataType dataType, Object value)
          Converts the given value to the "internal" representation for the given data type.
 String toString()
           
 Object validate(Object obj)
          Passes the given obj through the currently configured validator for this column and returns the result.
 ByteBuffer write(Object obj, int remainingRowLength)
          Serialize an Object into a raw byte value for this column in little endian order
 ByteBuffer write(Object obj, int remainingRowLength, ByteOrder order)
          Serialize an Object into a raw byte value for this column
protected static void writeColUsageMapDefinition(TableMutator creator, ColumnBuilder lvalCol, ByteBuffer buffer)
           
protected static void writeColUsageMapDefinitions(TableCreator creator, ByteBuffer buffer)
           
protected static void writeDefinition(TableMutator mutator, ColumnBuilder col, ByteBuffer buffer)
           
protected static void writeDefinitions(TableCreator creator, ByteBuffer buffer)
          Writes the column definitions into a table definition buffer.
protected  ByteBuffer writeFixedLengthField(Object obj, ByteBuffer buffer)
           
protected  ByteBuffer writeFixedLengthField(Object obj, ByteOrder order)
          Serialize an Object into a raw byte value for this column
protected  ByteBuffer writeRealData(Object obj, int remainingRowLength, ByteOrder order)
           
 boolean writeToNullMask(Object value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOG

protected static final org.apache.commons.logging.Log LOG

RETURN_ROW_ID

public static final Object RETURN_ROW_ID
Placeholder object for adding rows which indicates that the caller wants the RowId of the new row. Must be added as an extra value at the end of the row values array.

See Also:
TableImpl.asRowWithRowId(java.util.Map)

FIXED_LEN_FLAG_MASK

public static final byte FIXED_LEN_FLAG_MASK
mask for the fixed len bit

See Also:
Constant Field Values

AUTO_NUMBER_FLAG_MASK

public static final byte AUTO_NUMBER_FLAG_MASK
mask for the auto number bit

See Also:
Constant Field Values

AUTO_NUMBER_GUID_FLAG_MASK

public static final byte AUTO_NUMBER_GUID_FLAG_MASK
mask for the auto number guid bit

See Also:
Constant Field Values

HYPERLINK_FLAG_MASK

public static final byte HYPERLINK_FLAG_MASK
mask for the hyperlink bit (on memo types)

See Also:
Constant Field Values

UPDATABLE_FLAG_MASK

public static final byte UPDATABLE_FLAG_MASK
mask for the "is updatable" field bit

See Also:
Constant Field Values

COMPRESSED_UNICODE_EXT_FLAG_MASK

protected static final byte COMPRESSED_UNICODE_EXT_FLAG_MASK
See Also:
Constant Field Values

GENERAL_LEGACY_SORT_ORDER

public static final ColumnImpl.SortOrder GENERAL_LEGACY_SORT_ORDER
the "general" text sort order, legacy version (access 2000-2007)


GENERAL_SORT_ORDER

public static final ColumnImpl.SortOrder GENERAL_SORT_ORDER
the "general" text sort order, latest version (access 2010+)

Constructor Detail

ColumnImpl

protected ColumnImpl(TableImpl table,
                     String name,
                     DataType type,
                     int colNumber,
                     int fixedOffset,
                     int varLenIndex)
Method Detail

create

public static ColumnImpl create(TableImpl table,
                                ByteBuffer buffer,
                                int offset,
                                String name,
                                int displayIndex)
                         throws IOException
Creates the appropriate ColumnImpl class and reads a column definition in from a buffer

Parameters:
table - owning table
buffer - Buffer containing column definition
offset - Offset in the buffer at which the column definition starts
Throws:
IOException

getTable

public TableImpl getTable()
Specified by:
getTable in interface Column

getDatabase

public DatabaseImpl getDatabase()
Specified by:
getDatabase in interface Column

getFormat

public JetFormat getFormat()

getPageChannel

public PageChannel getPageChannel()

getName

public String getName()
Specified by:
getName in interface Column

isVariableLength

public boolean isVariableLength()
Specified by:
isVariableLength in interface Column

isAutoNumber

public boolean isAutoNumber()
Specified by:
isAutoNumber in interface Column

getColumnNumber

public short getColumnNumber()

getColumnIndex

public int getColumnIndex()
Specified by:
getColumnIndex in interface Column

setColumnIndex

public void setColumnIndex(int newColumnIndex)

getDisplayIndex

public int getDisplayIndex()

getType

public DataType getType()
Specified by:
getType in interface Column

getSQLType

public int getSQLType()
               throws SQLException
Specified by:
getSQLType in interface Column
Throws:
SQLException

isCompressedUnicode

public boolean isCompressedUnicode()
Specified by:
isCompressedUnicode in interface Column

getPrecision

public byte getPrecision()
Specified by:
getPrecision in interface Column

getScale

public byte getScale()
Specified by:
getScale in interface Column

getTextSortOrder

public ColumnImpl.SortOrder getTextSortOrder()

getTextCodePage

public short getTextCodePage()

getLength

public short getLength()
Specified by:
getLength in interface Column

getLengthInUnits

public short getLengthInUnits()
Specified by:
getLengthInUnits in interface Column

isCalculated

public boolean isCalculated()
Description copied from interface: Column
Returns whether or not this is a calculated column. Note that jackess won't interpret the calculation expression (but the field can be written directly).

Specified by:
isCalculated in interface Column

getVarLenTableIndex

public int getVarLenTableIndex()

getFixedDataOffset

public int getFixedDataOffset()

getCharset

protected Charset getCharset()

getCalendar

protected Calendar getCalendar()

isAppendOnly

public boolean isAppendOnly()
Description copied from interface: Column
Whether or not this column is "append only" (its history is tracked by a separate version history column).

Specified by:
isAppendOnly in interface Column

getVersionHistoryColumn

public ColumnImpl getVersionHistoryColumn()
Description copied from interface: Column
Returns the column which tracks the version history for an "append only" column.

Specified by:
getVersionHistoryColumn in interface Column

getOwnedPageCount

public int getOwnedPageCount()
Returns the number of database pages owned by this column.


setVersionHistoryColumn

public void setVersionHistoryColumn(ColumnImpl versionHistoryCol)

isHyperlink

public boolean isHyperlink()
Description copied from interface: Column
Returns whether or not this is a hyperlink column (only possible for columns of type MEMO).

Specified by:
isHyperlink in interface Column

getComplexInfo

public ComplexColumnInfo<? extends ComplexValue> getComplexInfo()
Description copied from interface: Column
Returns extended functionality for "complex" columns.

Specified by:
getComplexInfo in interface Column

getColumnValidator

public ColumnValidator getColumnValidator()
Description copied from interface: Column
Gets currently configured ColumnValidator (always non-null).

Specified by:
getColumnValidator in interface Column

setColumnValidator

public void setColumnValidator(ColumnValidator newValidator)
Description copied from interface: Column
Sets a new ColumnValidator. If null, resets to the value returned from the Database's ColumnValidatorFactory (if the factory returns null, then the default is used). Autonumber columns cannot have a validator instance other than the default.

Specified by:
setColumnValidator in interface Column

getAutoNumberGenerator

public ColumnImpl.AutoNumberGenerator getAutoNumberGenerator()
Returns the AutoNumberGenerator for this column if this is an autonumber column, null otherwise.


getProperties

public PropertyMap getProperties()
                          throws IOException
Specified by:
getProperties in interface Column
Returns:
the properties for this column
Throws:
IOException

setRowValue

public Object setRowValue(Object[] rowArray,
                          Object value)
Specified by:
setRowValue in interface Column

setRowValue

public Object setRowValue(Map<String,Object> rowMap,
                          Object value)
Specified by:
setRowValue in interface Column

getRowValue

public Object getRowValue(Object[] rowArray)
Specified by:
getRowValue in interface Column

getRowValue

public Object getRowValue(Map<String,?> rowMap)
Specified by:
getRowValue in interface Column

storeInNullMask

public boolean storeInNullMask()

writeToNullMask

public boolean writeToNullMask(Object value)

readFromNullMask

public Object readFromNullMask(boolean isNull)

read

public Object read(byte[] data)
            throws IOException
Deserialize a raw byte value for this column into an Object

Parameters:
data - The raw byte value
Returns:
The deserialized Object
Throws:
IOException

read

public Object read(byte[] data,
                   ByteOrder order)
            throws IOException
Deserialize a raw byte value for this column into an Object

Parameters:
data - The raw byte value
order - Byte order in which the raw value is stored
Returns:
The deserialized Object
Throws:
IOException

fromDateDouble

public long fromDateDouble(double value)
Returns a java long time value converted from an access date double.


toDateDouble

public double toDateDouble(Object value)
Returns an access date double converted from a java Date/Calendar/Number time value.


validate

public Object validate(Object obj)
                throws IOException
Passes the given obj through the currently configured validator for this column and returns the result.

Throws:
IOException

write

public ByteBuffer write(Object obj,
                        int remainingRowLength)
                 throws IOException
Serialize an Object into a raw byte value for this column in little endian order

Parameters:
obj - Object to serialize
Returns:
A buffer containing the bytes
Throws:
IOException

write

public ByteBuffer write(Object obj,
                        int remainingRowLength,
                        ByteOrder order)
                 throws IOException
Serialize an Object into a raw byte value for this column

Parameters:
obj - Object to serialize
order - Order in which to serialize
Returns:
A buffer containing the bytes
Throws:
IOException

writeRealData

protected ByteBuffer writeRealData(Object obj,
                                   int remainingRowLength,
                                   ByteOrder order)
                            throws IOException
Throws:
IOException

writeFixedLengthField

protected ByteBuffer writeFixedLengthField(Object obj,
                                           ByteOrder order)
                                    throws IOException
Serialize an Object into a raw byte value for this column

Parameters:
obj - Object to serialize
order - Order in which to serialize
Returns:
A buffer containing the bytes
Throws:
IOException

writeFixedLengthField

protected ByteBuffer writeFixedLengthField(Object obj,
                                           ByteBuffer buffer)
                                    throws IOException
Throws:
IOException

toString

public String toString()
Overrides:
toString in class Object

decodeUncompressedText

public static String decodeUncompressedText(byte[] textBytes,
                                            Charset charset)
Parameters:
textBytes - bytes of text to decode
charset - relevant charset
Returns:
the decoded string

encodeUncompressedText

public static ByteBuffer encodeUncompressedText(CharSequence text,
                                                Charset charset)
Parameters:
text - Text to encode
charset - database charset
Returns:
A buffer with the text encoded

compareTo

public int compareTo(ColumnImpl other)
Orders Columns by column number.

Specified by:
compareTo in interface Comparable<ColumnImpl>

countVariableLength

public static short countVariableLength(List<ColumnBuilder> columns)
Parameters:
columns - A list of columns in a table definition
Returns:
The number of variable length columns found in the list

toCharSequence

public static CharSequence toCharSequence(Object value)
                                   throws IOException
Returns:
an appropriate CharSequence representation of the given object.
Throws:
IOException

toByteArray

public static byte[] toByteArray(Object value)
                          throws IOException
Returns:
an appropriate byte[] representation of the given object.
Throws:
IOException

toBooleanValue

public static boolean toBooleanValue(Object obj)
Interpret a boolean value (null == false)


booleanToInteger

protected static Object booleanToInteger(Object obj)
Treat booleans as integers (C-style).


rawDataWrapper

public static com.healthmarketscience.jackcess.impl.ColumnImpl.RawData rawDataWrapper(byte[] bytes)
Returns a wrapper for raw column data that can be written without understanding the data. Useful for wrapping unparseable data for re-writing.


isRawData

public static boolean isRawData(Object value)
Returns true if the given value is "raw" column data, false otherwise.


writeDefinitions

protected static void writeDefinitions(TableCreator creator,
                                       ByteBuffer buffer)
                                throws IOException
Writes the column definitions into a table definition buffer.

Parameters:
buffer - Buffer to write to
Throws:
IOException

writeDefinition

protected static void writeDefinition(TableMutator mutator,
                                      ColumnBuilder col,
                                      ByteBuffer buffer)
                               throws IOException
Throws:
IOException

writeColUsageMapDefinitions

protected static void writeColUsageMapDefinitions(TableCreator creator,
                                                  ByteBuffer buffer)
                                           throws IOException
Throws:
IOException

writeColUsageMapDefinition

protected static void writeColUsageMapDefinition(TableMutator creator,
                                                 ColumnBuilder lvalCol,
                                                 ByteBuffer buffer)
                                          throws IOException
Throws:
IOException

toInternalValue

public static Object toInternalValue(DataType dataType,
                                     Object value)
                              throws IOException
Converts the given value to the "internal" representation for the given data type.

Throws:
IOException


Copyright © 2005-2017 Health Market Science. All Rights Reserved.