throw new IllegalArgumentException("invalid fixed length size");
}
} else if(!getType().isLongValue()) {
- if((getLength() < 0) || (getLength() > getType().getMaxSize())) {
+ if((getLength() < getType().getMinSize()) ||
+ (getLength() > getType().getMaxSize())) {
throw new IllegalArgumentException("var length out of range");
}
}
// this is an "inline" var length field
switch(getType()) {
+ case NUMERIC:
+ // don't ask me why numerics are "var length" columns...
+ ByteBuffer buffer = ByteBuffer.allocate(getLength());
+ System.out.println("BUZ NUMERIC " + getLength());
+ buffer.order(order);
+ writeNumericValue(buffer, obj);
+ buffer.flip();
+ System.out.println("BUZ NUMERIC rem " + buffer.remaining());
+ return buffer;
+
case TEXT:
CharSequence text = toCharSequence(obj);
int maxChars = getLength() / 2;
byte[] encodedData = encodeUncompressedText(text).array();
obj = encodedData;
break;
+
case BINARY:
// should already be "encoded"
break;
case MONEY:
writeCurrencyValue(buffer, obj);
break;
- case NUMERIC:
- writeNumericValue(buffer, obj);
- break;
case GUID:
writeGUIDValue(buffer, obj);
break;
FLOAT((byte) 0x06, Types.FLOAT, 4),
DOUBLE((byte) 0x07, Types.DOUBLE, 8),
SHORT_DATE_TIME((byte) 0x08, Types.TIMESTAMP, 8),
- BINARY((byte) 0x09, Types.BINARY, null, true, false, 255, 255),
- TEXT((byte) 0x0A, Types.VARCHAR, null, true, false, 50 * 2,
+ BINARY((byte) 0x09, Types.BINARY, null, true, false, 0, 255, 255),
+ TEXT((byte) 0x0A, Types.VARCHAR, null, true, false, 0, 50 * 2,
(int)JetFormat.TEXT_FIELD_MAX_LENGTH),
- OLE((byte) 0x0B, Types.LONGVARBINARY, null, true, true, null, 0xFFFFFF),
- MEMO((byte) 0x0C, Types.LONGVARCHAR, null, true, true, null, 0xFFFFFF),
+ OLE((byte) 0x0B, Types.LONGVARBINARY, null, true, true, 0, null, 0xFFFFFF),
+ MEMO((byte) 0x0C, Types.LONGVARCHAR, null, true, true, 0, null, 0xFFFFFF),
UNKNOWN_0D((byte) 0x0D),
GUID((byte) 0x0F, null, 16),
- NUMERIC((byte) 0x10, Types.NUMERIC, 17, false, false, null, null,
+ // for some reason numeric is "var len" even though it has a fixed size...
+ NUMERIC((byte) 0x10, Types.NUMERIC, null, true, false, 17, 17, 17,
true, 0, 0, 28, 1, 18, 28);
/** Map of SQL types to Access data types */
private byte _value;
/** Size in bytes of fixed length columns */
private Integer _fixedSize;
- /** default size for var length columns */
+ /** min in bytes size for var length columns */
+ private Integer _minSize;
+ /** default size in bytes for var length columns */
private Integer _defaultSize;
- /** Max size in bytes */
+ /** Max size in bytes for var length columns */
private Integer _maxSize;
/** SQL type equivalent, or null if none defined */
private Integer _sqlType;
}
private DataType(byte value, Integer sqlType, Integer fixedSize) {
- this(value, sqlType, fixedSize, false, false, null, null);
+ this(value, sqlType, fixedSize, false, false, null, null, null);
}
private DataType(byte value, Integer sqlType, Integer fixedSize,
boolean variableLength,
boolean longValue,
+ Integer minSize,
Integer defaultSize,
Integer maxSize) {
- this(value, sqlType, fixedSize, variableLength, longValue, defaultSize,
- maxSize, false, null, null, null, null, null, null);
+ this(value, sqlType, fixedSize, variableLength, longValue,
+ minSize, defaultSize, maxSize,
+ false, null, null, null, null, null, null);
}
private DataType(byte value, Integer sqlType, Integer fixedSize,
boolean variableLength,
boolean longValue,
+ Integer minSize,
Integer defaultSize,
Integer maxSize,
boolean hasScalePrecision,
_fixedSize = fixedSize;
_variableLength = variableLength;
_longValue = longValue;
+ _minSize = minSize;
_defaultSize = defaultSize;
_maxSize = maxSize;
_hasScalePrecision = hasScalePrecision;
}
}
+ public int getMinSize() {
+ return _minSize;
+ }
+
public int getDefaultSize() {
return _defaultSize;
}
throw new SQLException("Unsupported SQL type: " + sqlType);
}
}
-
+
}