com.healthmarketscience.jackcess
Class Column

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

public class Column
extends Object
implements Comparable<Column>

Access database column definition

Author:
Tim McCune
Usage:
General: This class is general use.

Nested Class Summary
 class Column.AutoNumberGenerator
          Base class for the supported autonumber types.
static class Column.SortOrder
          Information about the sort order (collation) for a textual column.
 
Field Summary
static Object AUTO_NUMBER
          Meaningless placeholder object for inserting values in an autonumber column.
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
static byte FIXED_LEN_FLAG_MASK
          mask for the fixed len bit
static Column.SortOrder GENERAL_LEGACY_SORT_ORDER
          the "general" text sort order, legacy version (access 2000-2007)
static Column.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)
static Object KEEP_VALUE
          Meaningless placeholder object for updating rows which indicates that a given column should keep its existing value.
static byte UNKNOWN_FLAG_MASK
          mask for the unknown bit (possible "can be null"?)
 
Constructor Summary
Column()
           
Column(JetFormat format)
           
Column(Table table, ByteBuffer buffer, int offset, int displayIndex)
          Read a column definition in from a buffer
 
Method Summary
 int compareTo(Column other)
          Orders Columns by column number.
static short countNonLongVariableLength(List<Column> columns)
           
static short countVariableLength(List<Column> columns)
           
static String decodeUncompressedText(byte[] textBytes, Charset charset)
           
static ByteBuffer encodeUncompressedText(CharSequence text, Charset charset)
           
 Column.AutoNumberGenerator getAutoNumberGenerator()
          Returns the AutoNumberGenerator for this column if this is an autonumber column, null otherwise.
 int getColumnIndex()
           
 short getColumnNumber()
           
 ComplexColumnInfo<? extends ComplexValue> getComplexInfo()
          Returns extended functionality for "complex" columns.
 Database getDatabase()
           
 int getDisplayIndex()
           
 int getFixedDataOffset()
           
 JetFormat getFormat()
           
 short getLength()
           
 short getLengthInUnits()
           
 String getName()
           
 PageChannel getPageChannel()
           
 byte getPrecision()
           
 PropertyMap getProperties()
           
 Object getRowValue(Map<String,?> rowMap)
           
 Object getRowValue(Object[] rowArray)
           
 byte getScale()
           
 int getSQLType()
           
 Table getTable()
           
 short getTextCodePage()
           
 Column.SortOrder getTextSortOrder()
           
 DataType getType()
           
 int getVarLenTableIndex()
           
 Column 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 isCompressedUnicode()
           
 boolean isHyperlink()
          Returns whether or not this is a hyperlink column (only possible for columns of type MEMO).
 boolean isVariableLength()
           
 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
 void setAutoNumber(boolean autoNumber)
           
 void setColumnIndex(int newColumnIndex)
           
 void setColumnNumber(short newColumnNumber)
           
 void setCompressedUnicode(boolean newCompessedUnicode)
           
 void setFixedDataOffset(int newOffset)
           
 void setHyperlink(boolean hyperlink)
           
 void setLength(short length)
           
 void setLengthInUnits(short unitLength)
           
 void setName(String name)
           
 void setPrecision(byte newPrecision)
           
 Object setRowValue(Map<String,Object> rowMap, Object value)
           
 Object setRowValue(Object[] rowArray, Object value)
           
 void setScale(byte newScale)
           
 void setSQLType(int type)
           
 void setSQLType(int type, int lengthInUnits)
           
 void setTextSortOrder(Column.SortOrder newTextSortOrder)
           
 void setType(DataType type)
          Also sets the length and the variable length flag, inferred from the type.
 void setVariableLength(boolean variableLength)
           
 void setVarLenTableIndex(int idx)
           
 void setVersionHistoryColumn(Column versionHistoryCol)
           
static boolean toBooleanValue(Object obj)
          Interpret a boolean value (null == false)
static byte[] toByteArray(Object value)
           
static CharSequence toCharSequence(Object value)
           
 String toString()
           
 void validate(JetFormat format)
          Checks that this column definition is valid.
 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
 ByteBuffer writeFixedLengthField(Object obj, ByteOrder order)
          Serialize an Object into a raw byte value for this column
 ByteBuffer writeLongValue(byte[] value, int remainingRowLength)
          Write an LVAL column into a ByteBuffer inline if it fits, otherwise in other data page(s).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

AUTO_NUMBER

public static final Object AUTO_NUMBER
Meaningless placeholder object for inserting values in an autonumber column. it is not required that this value be used (any passed in value is ignored), but using this placeholder may make code more obvious.

Usage:
General: This field is general use.

KEEP_VALUE

public static final Object KEEP_VALUE
Meaningless placeholder object for updating rows which indicates that a given column should keep its existing value.

Usage:
General: This field is general use.

FIXED_LEN_FLAG_MASK

public static final byte FIXED_LEN_FLAG_MASK
mask for the fixed len bit

See Also:
Constant Field Values
Usage:
Advanced: This field is for advanced/internal use.

AUTO_NUMBER_FLAG_MASK

public static final byte AUTO_NUMBER_FLAG_MASK
mask for the auto number bit

See Also:
Constant Field Values
Usage:
Advanced: This field is for advanced/internal use.

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
Usage:
Advanced: This field is for advanced/internal use.

HYPERLINK_FLAG_MASK

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

See Also:
Constant Field Values
Usage:
Advanced: This field is for advanced/internal use.

UNKNOWN_FLAG_MASK

public static final byte UNKNOWN_FLAG_MASK
mask for the unknown bit (possible "can be null"?)

See Also:
Constant Field Values
Usage:
Advanced: This field is for advanced/internal use.

GENERAL_LEGACY_SORT_ORDER

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

Usage:
Intermediate: This field requires moderate API knowledge.

GENERAL_SORT_ORDER

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

Usage:
Intermediate: This field requires moderate API knowledge.
Constructor Detail

Column

public Column()
Usage:
General: This method is general use.

Column

public Column(JetFormat format)
Usage:
Advanced: This method is for advanced/internal use.

Column

public Column(Table table,
              ByteBuffer buffer,
              int offset,
              int displayIndex)
       throws IOException
Read 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
Usage:
Advanced: This method is for advanced/internal use.
Method Detail

getTable

public Table getTable()
Usage:
General: This method is general use.

getDatabase

public Database getDatabase()
Usage:
General: This method is general use.

getFormat

public JetFormat getFormat()
Usage:
Advanced: This method is for advanced/internal use.

getPageChannel

public PageChannel getPageChannel()
Usage:
Advanced: This method is for advanced/internal use.

getName

public String getName()
Usage:
General: This method is general use.

setName

public void setName(String name)
Usage:
Advanced: This method is for advanced/internal use.

isVariableLength

public boolean isVariableLength()
Usage:
Advanced: This method is for advanced/internal use.

setVariableLength

public void setVariableLength(boolean variableLength)
Usage:
Advanced: This method is for advanced/internal use.

isAutoNumber

public boolean isAutoNumber()
Usage:
General: This method is general use.

setAutoNumber

public void setAutoNumber(boolean autoNumber)
Usage:
General: This method is general use.

getColumnNumber

public short getColumnNumber()
Usage:
Advanced: This method is for advanced/internal use.

setColumnNumber

public void setColumnNumber(short newColumnNumber)
Usage:
Advanced: This method is for advanced/internal use.

getColumnIndex

public int getColumnIndex()
Usage:
Advanced: This method is for advanced/internal use.

setColumnIndex

public void setColumnIndex(int newColumnIndex)
Usage:
Advanced: This method is for advanced/internal use.

getDisplayIndex

public int getDisplayIndex()
Usage:
Advanced: This method is for advanced/internal use.

setType

public void setType(DataType type)
Also sets the length and the variable length flag, inferred from the type. For types with scale/precision, sets the scale and precision to default values.

Usage:
General: This method is general use.

getType

public DataType getType()
Usage:
General: This method is general use.

getSQLType

public int getSQLType()
               throws SQLException
Throws:
SQLException
Usage:
General: This method is general use.

setSQLType

public void setSQLType(int type)
                throws SQLException
Throws:
SQLException
Usage:
General: This method is general use.

setSQLType

public void setSQLType(int type,
                       int lengthInUnits)
                throws SQLException
Throws:
SQLException
Usage:
General: This method is general use.

isCompressedUnicode

public boolean isCompressedUnicode()
Usage:
General: This method is general use.

setCompressedUnicode

public void setCompressedUnicode(boolean newCompessedUnicode)
Usage:
General: This method is general use.

getPrecision

public byte getPrecision()
Usage:
General: This method is general use.

setPrecision

public void setPrecision(byte newPrecision)
Usage:
General: This method is general use.

getScale

public byte getScale()
Usage:
General: This method is general use.

setScale

public void setScale(byte newScale)
Usage:
General: This method is general use.

getTextSortOrder

public Column.SortOrder getTextSortOrder()
Usage:
Intermediate: This method requires moderate API knowledge.

setTextSortOrder

public void setTextSortOrder(Column.SortOrder newTextSortOrder)
Usage:
Advanced: This method is for advanced/internal use.

getTextCodePage

public short getTextCodePage()
Usage:
Intermediate: This method requires moderate API knowledge.

setLength

public void setLength(short length)
Usage:
General: This method is general use.

getLength

public short getLength()
Usage:
General: This method is general use.

setLengthInUnits

public void setLengthInUnits(short unitLength)
Usage:
General: This method is general use.

getLengthInUnits

public short getLengthInUnits()
Usage:
General: This method is general use.

setVarLenTableIndex

public void setVarLenTableIndex(int idx)
Usage:
Advanced: This method is for advanced/internal use.

getVarLenTableIndex

public int getVarLenTableIndex()
Usage:
Advanced: This method is for advanced/internal use.

setFixedDataOffset

public void setFixedDataOffset(int newOffset)
Usage:
Advanced: This method is for advanced/internal use.

getFixedDataOffset

public int getFixedDataOffset()
Usage:
Advanced: This method is for advanced/internal use.

isAppendOnly

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

Usage:
General: This method is general use.

getVersionHistoryColumn

public Column getVersionHistoryColumn()
Returns the column which tracks the version history for an "append only" column.

Usage:
Intermediate: This method requires moderate API knowledge.

setVersionHistoryColumn

public void setVersionHistoryColumn(Column versionHistoryCol)
Usage:
Advanced: This method is for advanced/internal use.

isHyperlink

public boolean isHyperlink()
Returns whether or not this is a hyperlink column (only possible for columns of type MEMO).

Usage:
General: This method is general use.

setHyperlink

public void setHyperlink(boolean hyperlink)
Usage:
General: This method is general use.

getComplexInfo

public ComplexColumnInfo<? extends ComplexValue> getComplexInfo()
Returns extended functionality for "complex" columns.

Usage:
General: This method is general use.

getAutoNumberGenerator

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

Usage:
Advanced: This method is for advanced/internal use.

getProperties

public PropertyMap getProperties()
                          throws IOException
Returns:
the properties for this column
Throws:
IOException
Usage:
General: This method is general use.

validate

public void validate(JetFormat format)
Checks that this column definition is valid.

Throws:
IllegalArgumentException - if this column definition is invalid.
Usage:
Advanced: This method is for advanced/internal use.

setRowValue

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

setRowValue

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

getRowValue

public Object getRowValue(Object[] rowArray)

getRowValue

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

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
Usage:
Advanced: This method is for advanced/internal use.

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
Usage:
Advanced: This method is for advanced/internal use.

writeLongValue

public ByteBuffer writeLongValue(byte[] value,
                                 int remainingRowLength)
                          throws IOException
Write an LVAL column into a ByteBuffer inline if it fits, otherwise in other data page(s).

Parameters:
value - Value of the LVAL column
Returns:
A buffer containing the LVAL definition and (possibly) the column value (unless written to other pages)
Throws:
IOException
Usage:
Advanced: This method is for advanced/internal use.

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
Usage:
Advanced: This method is for advanced/internal use.

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
Usage:
Advanced: This method is for advanced/internal use.

writeFixedLengthField

public 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
Usage:
Advanced: This method is for advanced/internal use.

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
Usage:
Advanced: This method is for advanced/internal use.

encodeUncompressedText

public static ByteBuffer encodeUncompressedText(CharSequence text,
                                                Charset charset)
Parameters:
text - Text to encode
charset - database charset
Returns:
A buffer with the text encoded
Usage:
Advanced: This method is for advanced/internal use.

compareTo

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

Specified by:
compareTo in interface Comparable<Column>
Usage:
General: This method is general use.

countVariableLength

public static short countVariableLength(List<Column> columns)
Parameters:
columns - A list of columns in a table definition
Returns:
The number of variable length columns found in the list
Usage:
Advanced: This method is for advanced/internal use.

countNonLongVariableLength

public static short countNonLongVariableLength(List<Column> columns)
Parameters:
columns - A list of columns in a table definition
Returns:
The number of variable length columns which are not long values found in the list
Usage:
Advanced: This method is for advanced/internal use.

toCharSequence

public static CharSequence toCharSequence(Object value)
                                   throws IOException
Returns:
an appropriate CharSequence representation of the given object.
Throws:
IOException
Usage:
Advanced: This method is for advanced/internal use.

toByteArray

public static byte[] toByteArray(Object value)
                          throws IOException
Returns:
an appropriate byte[] representation of the given object.
Throws:
IOException
Usage:
Advanced: This method is for advanced/internal use.

toBooleanValue

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

Usage:
Advanced: This method is for advanced/internal use.


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