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

public final Enum DataType

extends Enum<DataType>
Class Inheritance
Imports
io.github.spannm.jackcess.Database.FileFormat, io.github.spannm.jackcess.impl.DatabaseImpl, .JetFormat, .SqlHelper, java.io.IOException, java.math.BigDecimal, .BigInteger, java.sql.Types, java.time.LocalDateTime, java.util.Arrays, .Date, .HashMap, .Map, java.util.stream.Collectors

Supported access data types.
Author
Tim McCune

Field Summary

Modifier and TypeField and Description
private static final Map<Integer, DataType>
ALT_SQL_TYPES

Alternate map of SQL types to Access data types

public static final DataType
BIG_BINARY

A fixed length binary column longer than the 255 byte BINARY, which the engine calls "BigBinary".

public static final DataType
BIG_INT

Corresponds to a java Long.

public static final DataType
BINARY

Corresponds to a java byte[] of max length 255 bytes.

public static final DataType
BOOLEAN

Corresponds to a java Boolean.

public static final DataType
BYTE

Corresponds to a java Byte.

public static final DataType
COMPLEX_TYPE

Complex type corresponds to a special LONG autonumber field which is the key for a secondary table which holds the "real" data.

private static final Map<Byte, DataType>
private final int
defaultPrecision

the default precision value

private final int
defaultScale

the default scale value

private final int
defaultSize

default size in bytes for var length columns

public static final DataType
DOUBLE

Corresponds to a java Double.

public static final DataType
EXT_DATE_TIME

Corresponds to a java LocalDateTime (with 7 digits of nanosecond precision).

private final Integer
fixedSize

Size in bytes of fixed length columns

public static final DataType
FLOAT

Corresponds to a java Float.

public static final DataType
GUID

Corresponds to a java String with the pattern "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}", also known as a "Replication ID" in Access.

private final boolean
hasScalePrecision

does this field have scale/precision

public static final DataType
INT

Corresponds to a java Short.

public static final DataType
LONG

Corresponds to a java Integer.

private final boolean
longValue

is this a long value field

private final int
maxPrecision

max precision value

private final int
maxScale

max scale value

private final int
maxSize

Max size in bytes for var length columns

public static final DataType
MEMO

Corresponds to a java String of max length 8388607 chars.

private final int
minPrecision

min precision value

private final int
minScale

min scale value

private final int
minSize

min in bytes size for var length columns

public static final DataType
MONEY

Corresponds to a java BigDecimal with at most 4 decimal places.

public static final DataType
NUMERIC

Corresponds to a java BigDecimal.

public static final DataType
OLE

Corresponds to a java byte[] of max length 16777215 bytes.

public static final DataType
SHORT_DATE_TIME

Corresponds to a java Date or LocalDateTime.

private static final Map<Integer, DataType[]>
SQL_TYPES

Map of SQL types to Access data types

private final Integer
sqlType

SQL type equivalent, or null if none defined

public static final DataType
TEXT

Corresponds to a java String of max length 255 chars.

private final String
typeName

display name of this type

private final int
unitSize

the number of bytes per "unit" for this data type

public static final DataType
UNSUPPORTED_FIXEDLEN

Dummy type for a fixed length type which is not currently supported.

public static final DataType
UNSUPPORTED_VARLEN

Placeholder type for a variable length type which is not currently supported.

private final byte
value

Internal Access value

private final boolean
variableLength

is this a variable length field

Constructor Summary

AccessConstructor and Description
private
DataType(byte value, String typeName, Integer sqlType, Integer fixedSize)

private
DataType(byte value, String typeName, Integer sqlType, Integer fixedSize, boolean variableLength, boolean longValue, int minSize, int defaultSize, int maxSize, int unitSize)

private
DataType(byte value, String typeName, Integer sqlType, Integer fixedSize, boolean variableLength, boolean longValue, int minSize, int defaultSize, int maxSize, boolean hasScalePrecision, int minScale, int defaultScale, int maxScale, int minPrecision, int defaultPrecision, int maxPrecision, int unitSize)

Method Summary

Modifier and TypeMethod and Description
private static void
addNewSqlType(String typeName, DataType type, DataType altType)

Adds mappings for a sql type which was added after jdk 1.5 (using reflection).

public static DataType
fromByte(byte b)

public static DataType
fromSQLType(int sqlType)

public static DataType
fromSQLType(int sqlType, int lengthInUnits)

public static DataType
fromSQLType(int sqlType, int lengthInUnits, Database.FileFormat fileFormat)

public int
fromUnitSize(int size)

public int
fromUnitSize(int size, JetFormat format)

public int
public int
public int
public int
public int
getFixedSize(Short colLength)

public boolean
public int
public int
public int
public int
public int
public int
public int
public String
public static String
getTypeName(short value)

public int
public int
public byte
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
isValidPrecision(int precision)

public boolean
isValidScale(int scale)

public boolean
isValidSize(int size)

public boolean
private static boolean
isWithinRange(int value, int minValue, int maxValue)

public boolean
public int
toUnitSize(int size)

public int
toUnitSize(int size, JetFormat format)

public int
toValidPrecision(int precision)

private static int
toValidRange(int value, int minValue, int maxValue)

public int
toValidScale(int scale)

public int
toValidSize(int size)

public static DataType
public static DataType[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ALT_SQL_TYPESback to summary
private static final Map<Integer, DataType> ALT_SQL_TYPES

Alternate map of SQL types to Access data types

BIG_BINARYback to summary
public static final DataType BIG_BINARY

A fixed length binary column longer than the 255 byte BINARY, which the engine calls "BigBinary". Only the Data column of MSysAccessObjects uses it, which holds the forms, reports and VBA of the database. Jet4 only, since Jet3 used BINARY for that column and the ACE engine dropped the table. Handled like a fixed length BINARY/OLE.

BIG_INTback to summary
public static final DataType BIG_INT

Corresponds to a java Long. Accepts any Number (using Number#longValue), Boolean as 1 or 0, any Object converted to a String and parsed as Double, or null. Equivalent to SQL Types#BIGINT.

BINARYback to summary
public static final DataType BINARY

Corresponds to a java byte[] of max length 255 bytes. Accepts a byte[], or null. Equivalent to SQL Types#BINARY, Types#VARBINARY.

BOOLEANback to summary
public static final DataType BOOLEAN

Corresponds to a java Boolean. Accepts Boolean or null (which is considered false). Equivalent to SQL Types#BOOLEAN.

BYTEback to summary
public static final DataType BYTE

Corresponds to a java Byte. Accepts any Number (using Number#byteValue), Boolean as 1 or 0, any Object converted to a String and parsed as Double, or null. Equivalent to SQL Types#TINYINT, Types#BIT.

COMPLEX_TYPEback to summary
public static final DataType COMPLEX_TYPE

Complex type corresponds to a special LONG autonumber field which is the key for a secondary table which holds the "real" data.

DATA_TYPES_BY_VALUEback to summary
private static final Map<Byte, DataType> DATA_TYPES_BY_VALUE
defaultPrecisionback to summary
private final int defaultPrecision

the default precision value

defaultScaleback to summary
private final int defaultScale

the default scale value

defaultSizeback to summary
private final int defaultSize

default size in bytes for var length columns

DOUBLEback to summary
public static final DataType DOUBLE

Corresponds to a java Double. Accepts any Number (using Number#doubleValue), Boolean as 1 or 0, any Object converted to a String and parsed as Double, or null. Equivalent to SQL Types#DOUBLE, Types#REAL.

EXT_DATE_TIMEback to summary
public static final DataType EXT_DATE_TIME

Corresponds to a java LocalDateTime (with 7 digits of nanosecond precision). Accepts a Date, LocalDateTime (or related types), any Number (using Number#longValue), or null. Equivalent to SQL Types#TIMESTAMP, Types#DATE, Types#TIME.

fixedSizeback to summary
private final Integer fixedSize

Size in bytes of fixed length columns

FLOATback to summary
public static final DataType FLOAT

Corresponds to a java Float. Accepts any Number (using Number#floatValue), Boolean as 1 or 0, any Object converted to a String and parsed as Double, or null. Equivalent to SQL Types#FLOAT.

GUIDback to summary
public static final DataType GUID

Corresponds to a java String with the pattern "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}", also known as a "Replication ID" in Access. Accepts any Object converted to a String matching this pattern (surrounding "{}" are optional, so java.util.UUIDs are supported), or null.

hasScalePrecisionback to summary
private final boolean hasScalePrecision

does this field have scale/precision

INTback to summary
public static final DataType INT

Corresponds to a java Short. Accepts any Number (using Number#shortValue), Boolean as 1 or 0, any Object converted to a String and parsed as Double, or null. Equivalent to SQL Types#SMALLINT.

LONGback to summary
public static final DataType LONG

Corresponds to a java Integer. Accepts any Number (using Number#intValue), Boolean as 1 or 0, any Object converted to a String and parsed as Double, or null. Equivalent to SQL Types#INTEGER, Types#BIGINT.

longValueback to summary
private final boolean longValue

is this a long value field

maxPrecisionback to summary
private final int maxPrecision

max precision value

maxScaleback to summary
private final int maxScale

max scale value

maxSizeback to summary
private final int maxSize

Max size in bytes for var length columns

MEMOback to summary
public static final DataType MEMO

Corresponds to a java String of max length 8388607 chars. Accepts any CharSequence, any Object converted to a String , or null. Equivalent to SQL Types#LONGVARCHAR, Types#CLOB.

minPrecisionback to summary
private final int minPrecision

min precision value

minScaleback to summary
private final int minScale

min scale value

minSizeback to summary
private final int minSize

min in bytes size for var length columns

MONEYback to summary
public static final DataType MONEY

Corresponds to a java BigDecimal with at most 4 decimal places. Accepts any Number (using Number#doubleValue), a BigInteger, a BigDecimal (with at most 4 decimal places), Boolean as 1 or 0, any Object converted to a String and parsed as BigDecimal, or null. Equivalent to SQL Types#DECIMAL.

NUMERICback to summary
public static final DataType NUMERIC

Corresponds to a java BigDecimal. Accepts any Number (using Number#doubleValue), a BigInteger, a BigDecimal, Boolean as 1 or 0, any Object converted to a String and parsed as BigDecimal, or null. Equivalent to SQL Types#NUMERIC.

OLEback to summary
public static final DataType OLE

Corresponds to a java byte[] of max length 16777215 bytes. Accepts a byte[], or null. Equivalent to SQL Types#LONGVARBINARY, Types#BLOB.

SHORT_DATE_TIMEback to summary
public static final DataType SHORT_DATE_TIME

Corresponds to a java Date or LocalDateTime. Accepts a Date, LocalDateTime (or related types), any Number (using Number#longValue), or null. Equivalent to SQL Types#TIMESTAMP, Types#DATE, Types#TIME.

SQL_TYPESback to summary
private static final Map<Integer, DataType[]> SQL_TYPES

Map of SQL types to Access data types

sqlTypeback to summary
private final Integer sqlType

SQL type equivalent, or null if none defined

TEXTback to summary
public static final DataType TEXT

Corresponds to a java String of max length 255 chars. Accepts any CharSequence, any Object converted to a String , or null. Equivalent to SQL Types#VARCHAR, Types#CHAR.

typeNameback to summary
private final String typeName

display name of this type

unitSizeback to summary
private final int unitSize

the number of bytes per "unit" for this data type

UNSUPPORTED_FIXEDLENback to summary
public static final DataType UNSUPPORTED_FIXEDLEN

Dummy type for a fixed length type which is not currently supported. Handled like a fixed length BINARY.

UNSUPPORTED_VARLENback to summary
public static final DataType UNSUPPORTED_VARLEN

Placeholder type for a variable length type which is not currently supported. Handled like BINARY.

valueback to summary
private final byte value

Internal Access value

variableLengthback to summary
private final boolean variableLength

is this a variable length field

Constructor Detail

DataTypeback to summary
private DataType(byte value, String typeName, Integer sqlType, Integer fixedSize)
DataTypeback to summary
private DataType(byte value, String typeName, Integer sqlType, Integer fixedSize, boolean variableLength, boolean longValue, int minSize, int defaultSize, int maxSize, int unitSize)
DataTypeback to summary
private DataType(byte value, String typeName, Integer sqlType, Integer fixedSize, boolean variableLength, boolean longValue, int minSize, int defaultSize, int maxSize, boolean hasScalePrecision, int minScale, int defaultScale, int maxScale, int minPrecision, int defaultPrecision, int maxPrecision, int unitSize)

Method Detail

addNewSqlTypeback to summary
private static void addNewSqlType(String typeName, DataType type, DataType altType)

Adds mappings for a sql type which was added after jdk 1.5 (using reflection).

fromByteback to summary
public static DataType fromByte(byte b) throws IOException
fromSQLTypeback to summary
public static DataType fromSQLType(int sqlType) throws IOException
fromSQLTypeback to summary
public static DataType fromSQLType(int sqlType, int lengthInUnits) throws IOException
fromSQLTypeback to summary
public static DataType fromSQLType(int sqlType, int lengthInUnits, Database.FileFormat fileFormat) throws IOException
fromUnitSizeback to summary
public int fromUnitSize(int size)
fromUnitSizeback to summary
public int fromUnitSize(int size, JetFormat format)
getDefaultPrecisionback to summary
public int getDefaultPrecision()
getDefaultScaleback to summary
public int getDefaultScale()
getDefaultSizeback to summary
public int getDefaultSize()
getFixedSizeback to summary
public int getFixedSize()
getFixedSizeback to summary
public int getFixedSize(Short colLength)
getHasScalePrecisionback to summary
public boolean getHasScalePrecision()
getMaxPrecisionback to summary
public int getMaxPrecision()
getMaxScaleback to summary
public int getMaxScale()
getMaxSizeback to summary
public int getMaxSize()
getMinPrecisionback to summary
public int getMinPrecision()
getMinScaleback to summary
public int getMinScale()
getMinSizeback to summary
public int getMinSize()
getSQLTypeback to summary
public int getSQLType() throws IOException
getTypeNameback to summary
public String getTypeName()
getTypeNameback to summary
public static String getTypeName(short value)
getUnitSizeback to summary
public int getUnitSize()
getUnitSizeback to summary
public int getUnitSize(JetFormat format)
getValueback to summary
public byte getValue()
isLongValueback to summary
public boolean isLongValue()
isMultipleAutoNumberAllowedback to summary
public boolean isMultipleAutoNumberAllowed()
isSupportedback to summary
public boolean isSupported()
isTextualback to summary
public boolean isTextual()
isTrueVariableLengthback to summary
public boolean isTrueVariableLength()
isValidPrecisionback to summary
public boolean isValidPrecision(int precision)
isValidScaleback to summary
public boolean isValidScale(int scale)
isValidSizeback to summary
public boolean isValidSize(int size)
isVariableLengthback to summary
public boolean isVariableLength()
isWithinRangeback to summary
private static boolean isWithinRange(int value, int minValue, int maxValue)
mayBeAutoNumberback to summary
public boolean mayBeAutoNumber()
toUnitSizeback to summary
public int toUnitSize(int size)
toUnitSizeback to summary
public int toUnitSize(int size, JetFormat format)
toValidPrecisionback to summary
public int toValidPrecision(int precision)
toValidRangeback to summary
private static int toValidRange(int value, int minValue, int maxValue)
toValidScaleback to summary
public int toValidScale(int scale)
toValidSizeback to summary
public int toValidSize(int size)
valueOfback to summary
public static DataType valueOf(String name)
valuesback to summary
public static DataType[] values()