Elexis API documentation
Version 2.1.6 as of December 11 2011

com.healthmarketscience.jackcess
Class Column

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

public class Column
extends java.lang.Object
implements java.lang.Comparable<Column>

Access database column definition

Author:
Tim McCune

Nested Class Summary
 class Column.AutoNumberGenerator
          Base class for the supported autonumber types.
 
Field Summary
static java.lang.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.
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 java.lang.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
 
Constructor Summary
Column()
           
Column(JetFormat format)
           
Column(Table table, java.nio.ByteBuffer buffer, int offset)
          Read a column definition in from a buffer
 
Method Summary
 int compareTo(Column other)
           
static short countNonLongVariableLength(java.util.List<Column> columns)
           
static short countVariableLength(java.util.List<Column> columns)
           
static java.lang.String decodeUncompressedText(byte[] textBytes, java.nio.charset.Charset charset)
           
static java.nio.ByteBuffer encodeUncompressedText(java.lang.CharSequence text, java.nio.charset.Charset charset)
           
 Column.AutoNumberGenerator getAutoNumberGenerator()
          Returns the AutoNumberGenerator for this column if this is an autonumber column, null otherwise.
 int getColumnIndex()
           
 short getColumnNumber()
           
 int getFixedDataOffset()
           
 JetFormat getFormat()
           
 short getLength()
           
 short getLengthInUnits()
           
 java.lang.String getName()
           
 PageChannel getPageChannel()
           
 byte getPrecision()
           
 byte getScale()
           
 int getSQLType()
           
 Table getTable()
           
 DataType getType()
           
 int getVarLenTableIndex()
           
 boolean isAutoNumber()
           
 boolean isCompressedUnicode()
           
 boolean isVariableLength()
           
 java.lang.Object read(byte[] data)
          Deserialize a raw byte value for this column into an Object
 java.lang.Object read(byte[] data, java.nio.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 setLength(short length)
           
 void setLengthInUnits(short unitLength)
           
 void setName(java.lang.String name)
           
 void setPrecision(byte newPrecision)
           
 void setScale(byte newScale)
           
 void setSQLType(int type)
           
 void setSQLType(int type, int lengthInUnits)
           
 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)
           
static boolean toBooleanValue(java.lang.Object obj)
          Interpret a boolean value (null == false)
static byte[] toByteArray(java.lang.Object value)
           
static java.lang.CharSequence toCharSequence(java.lang.Object value)
           
 java.lang.String toString()
           
 void validate(JetFormat format)
          Checks that this column definition is valid.
 java.nio.ByteBuffer write(java.lang.Object obj, int remainingRowLength)
          Serialize an Object into a raw byte value for this column in little endian order
 java.nio.ByteBuffer write(java.lang.Object obj, int remainingRowLength, java.nio.ByteOrder order)
          Serialize an Object into a raw byte value for this column
 java.nio.ByteBuffer writeFixedLengthField(java.lang.Object obj, java.nio.ByteOrder order)
          Serialize an Object into a raw byte value for this column
 java.nio.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 java.lang.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.


KEEP_VALUE

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


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

UNKNOWN_FLAG_MASK

public static final byte UNKNOWN_FLAG_MASK
mask for the unknown bit

See Also:
Constant Field Values
Constructor Detail

Column

public Column()

Column

public Column(JetFormat format)

Column

public Column(Table table,
              java.nio.ByteBuffer buffer,
              int offset)
       throws java.io.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:
java.io.IOException
Method Detail

getTable

public Table getTable()

getFormat

public JetFormat getFormat()

getPageChannel

public PageChannel getPageChannel()

getName

public java.lang.String getName()

setName

public void setName(java.lang.String name)

isVariableLength

public boolean isVariableLength()

setVariableLength

public void setVariableLength(boolean variableLength)

isAutoNumber

public boolean isAutoNumber()

setAutoNumber

public void setAutoNumber(boolean autoNumber)

getColumnNumber

public short getColumnNumber()

setColumnNumber

public void setColumnNumber(short newColumnNumber)

getColumnIndex

public int getColumnIndex()

setColumnIndex

public void setColumnIndex(int newColumnIndex)

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.


getType

public DataType getType()

getSQLType

public int getSQLType()
               throws java.sql.SQLException
Throws:
java.sql.SQLException

setSQLType

public void setSQLType(int type)
                throws java.sql.SQLException
Throws:
java.sql.SQLException

setSQLType

public void setSQLType(int type,
                       int lengthInUnits)
                throws java.sql.SQLException
Throws:
java.sql.SQLException

isCompressedUnicode

public boolean isCompressedUnicode()

setCompressedUnicode

public void setCompressedUnicode(boolean newCompessedUnicode)

getPrecision

public byte getPrecision()

setPrecision

public void setPrecision(byte newPrecision)

getScale

public byte getScale()

setScale

public void setScale(byte newScale)

setLength

public void setLength(short length)

getLength

public short getLength()

setLengthInUnits

public void setLengthInUnits(short unitLength)

getLengthInUnits

public short getLengthInUnits()

setVarLenTableIndex

public void setVarLenTableIndex(int idx)

getVarLenTableIndex

public int getVarLenTableIndex()

setFixedDataOffset

public void setFixedDataOffset(int newOffset)

getFixedDataOffset

public int getFixedDataOffset()

getAutoNumberGenerator

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


validate

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

Throws:
java.lang.IllegalArgumentException - if this column definition is invalid.

read

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

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

read

public java.lang.Object read(byte[] data,
                             java.nio.ByteOrder order)
                      throws java.io.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:
java.io.IOException

writeLongValue

public java.nio.ByteBuffer writeLongValue(byte[] value,
                                          int remainingRowLength)
                                   throws java.io.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:
java.io.IOException

write

public java.nio.ByteBuffer write(java.lang.Object obj,
                                 int remainingRowLength)
                          throws java.io.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:
java.io.IOException

write

public java.nio.ByteBuffer write(java.lang.Object obj,
                                 int remainingRowLength,
                                 java.nio.ByteOrder order)
                          throws java.io.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:
java.io.IOException

writeFixedLengthField

public java.nio.ByteBuffer writeFixedLengthField(java.lang.Object obj,
                                                 java.nio.ByteOrder order)
                                          throws java.io.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:
java.io.IOException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

decodeUncompressedText

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

encodeUncompressedText

public static java.nio.ByteBuffer encodeUncompressedText(java.lang.CharSequence text,
                                                         java.nio.charset.Charset charset)
Parameters:
text - Text to encode
db - relevant db
Returns:
A buffer with the text encoded

compareTo

public int compareTo(Column other)
Specified by:
compareTo in interface java.lang.Comparable<Column>

countVariableLength

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

countNonLongVariableLength

public static short countNonLongVariableLength(java.util.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

toCharSequence

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

toByteArray

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

toBooleanValue

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


Elexis API documentation
Version 2.1.6 as of December 11 2011

Copyright 2005-2011 by Gerry Weirich, Elexis