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

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 FIXED_LEN_FLAG_MASK
          mask for the fixed len bit
static byte UNKNOWN_FLAG_MASK
          mask for the unknown bit
 
Constructor Summary
Column()
           
Column(JetFormat format)
           
Column(Table table, ByteBuffer buffer, int offset)
          Read a column definition in from a buffer
 
Method Summary
 int compareTo(Column other)
           
static short countNonLongVariableLength(List<Column> columns)
           
static short countVariableLength(List<Column> columns)
           
static String decodeUncompressedText(byte[] textBytes, JetFormat format)
           
static ByteBuffer encodeUncompressedText(CharSequence text, JetFormat format)
           
 int getColumnIndex()
           
 short getColumnNumber()
           
 int getFixedDataOffset()
           
 JetFormat getFormat()
           
 short getLength()
           
 short getLengthInUnits()
           
 String getName()
           
 PageChannel getPageChannel()
           
 byte getPrecision()
           
 byte getScale()
           
 int getSQLType()
           
 Table getTable()
           
 DataType getType()
           
 int getVarLenTableIndex()
           
 boolean isAutoNumber()
           
 boolean isCompressedUnicode()
           
 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 setFixedDataOffset(int newOffset)
           
 void setLength(short length)
           
 void setLengthInUnits(short unitLength)
           
 void setName(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(Object obj)
          Interpret a boolean value (null == false)
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.


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

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,
              ByteBuffer buffer,
              int offset)
       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
Method Detail

getTable

public Table getTable()

getFormat

public JetFormat getFormat()

getPageChannel

public PageChannel getPageChannel()

getName

public String getName()

setName

public void setName(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 SQLException
Throws:
SQLException

setSQLType

public void setSQLType(int type)
                throws SQLException
Throws:
SQLException

setSQLType

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

isCompressedUnicode

public boolean isCompressedUnicode()

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()

validate

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

Throws:
IllegalArgumentException - if this column definition is invalid.

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

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

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

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

toString

public String toString()
Overrides:
toString in class Object

decodeUncompressedText

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

encodeUncompressedText

public static ByteBuffer encodeUncompressedText(CharSequence text,
                                                JetFormat format)
Parameters:
text - Text to encode
format - relevant db format
Returns:
A buffer with the text encoded

compareTo

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

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

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

toCharSequence

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

toBooleanValue

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



Copyright ? 2005-2008 Health Market Science. All Rights Reserved.