private boolean isRichText(Column c) throws IOException { if (c == null) { return false; } PropertyMap m = c.getProperties(); if (m == null) { return false; } if (c.getType() == null || ! c.getType().equals(DataType.MEMO)) { return false; } Object b = m.getValue(TEXT_FORMAT_KEY); if (b instanceof Byte) { if (((Byte)b).byteValue() == RICH_TEXT_FORMAT) { return true; } } return false; }
public int getFixedSize() { return getFixedSize(null); }
public static DataType fromSQLType(int sqlType) throws SQLException { return fromSQLType(sqlType, 0, null); }
if ( length < 3 ) { column.setType( DataType.BYTE ); length = DataType.BYTE.getFixedSize(); } else { if ( length < 5 ) { column.setType( DataType.INT ); length = DataType.INT.getFixedSize(); } else { column.setType( DataType.LONG ); length = DataType.LONG.getFixedSize(); case ValueMetaInterface.TYPE_NUMBER: column.setType( DataType.DOUBLE ); length = DataType.DOUBLE.getFixedSize(); break; case ValueMetaInterface.TYPE_DATE: column.setType( DataType.SHORT_DATE_TIME ); length = DataType.SHORT_DATE_TIME.getFixedSize(); break; case ValueMetaInterface.TYPE_STRING: if ( length < 255 ) { column.setType( DataType.TEXT ); length *= DataType.TEXT.getUnitSize(); } else { column.setType( DataType.MEMO ); length *= DataType.MEMO.getUnitSize(); case ValueMetaInterface.TYPE_BOOLEAN: column.setType( DataType.BOOLEAN );
public short getLength() { return ((_length != null) ? _length : (short)(!_type.isVariableLength() ? _type.getFixedSize() : _type.getDefaultSize())); }
public boolean isTrueVariableLength() { // some "var len" fields do not really have a variable length, // e.g. NUMERIC return (isVariableLength() && (getMinSize() != getMaxSize())); }
if(getType().isUnsupported()) { throw new IllegalArgumentException(withErrorContext( "Cannot create column with unsupported type " + getType())); if(!getType().isVariableLength()) { if(getLength() < getType().getFixedSize()) { throw new IllegalArgumentException(withErrorContext( "Invalid fixed length size " + getLength())); } else if(!getType().isLongValue()) { if(!getType().isValidSize(getLength())) { throw new IllegalArgumentException(withErrorContext( "Var length must be from " + getType().getMinSize() + " to " + getType().getMaxSize() + " inclusive, found " + getLength())); if(getType().getHasScalePrecision()) { if(!getType().isValidScale(getScale())) { throw new IllegalArgumentException(withErrorContext( "Scale must be from " + getType().getMinScale() + " to " + getType().getMaxScale() + " inclusive, found " + getScale())); if(!getType().isValidPrecision(getPrecision())) { throw new IllegalArgumentException(withErrorContext( "Precision must be from " + getType().getMinPrecision() + " to " + getType().getMaxPrecision() + " inclusive, found " + getPrecision())); if(!getType().mayBeAutoNumber()) { throw new IllegalArgumentException(withErrorContext(
dt = TypesMap.map2Jackcess(AccessType.valueOf(types[seq].toUpperCase(Locale.US))); cb.setType(dt); cb.setLengthInUnits((short) dt.getFixedSize()); dt = DataType.NUMERIC; } else { dt = DataType.fromSQLType( rs.getInt("DATA_TYPE"), length, if (length > 0 && dt.equals(DataType.TEXT)) { cb.setLengthInUnits(length);
public static String map2hsqldb(DataType _type) { if (JACKCESS_TO_HSQLDB_TYPES_MAP.containsKey(_type)) { return JACKCESS_TO_HSQLDB_TYPES_MAP.get(_type); } return _type.name(); }
/** * @usage _advanced_method_ */ protected ColumnImpl(TableImpl table, String name, DataType type, int colNumber, int fixedOffset, int varLenIndex) { _table = table; _name = name; _type = type; if(!_type.isVariableLength()) { _columnLength = (short)type.getFixedSize(); } else { _columnLength = (short)type.getMaxSize(); } _variableLength = type.isVariableLength(); _autoNumber = false; _calculated = false; _autoNumberGenerator = null; _columnNumber = (short)colNumber; _columnIndex = colNumber; _displayIndex = colNumber; _fixedDataOffset = fixedOffset; _varLenTableIndex = varLenIndex; }
int size = rtn.fromUnitSize(lengthInUnits, format); if(rtn.isVariableLength() && !rtn.isValidSize(size)) { (altRtn.isLongValue() || altRtn.isValidSize(size))) {
buffer.put(col.getType().getValue()); if(col.getType().isTextual()) { } else { if(col.getType().getHasScalePrecision() && !col.isCalculated()) { if(!col.getType().isLongValue()) { short length = col.getLength(); if(col.isCalculated()) { if(!col.getType().isVariableLength() || col.getType().getHasScalePrecision()) { length = CalculatedColumnUtil.CALC_FIXED_FIELD_LEN; } else {
if(totalOleLen > DataType.OLE.getMaxSize()) { throw new IllegalArgumentException("Content size of " + totalOleLen + " is too large for ole column");
public int getUnitSize(JetFormat format) { if((format != null) && isTextual()) { return format.SIZE_TEXT_FIELD_UNIT; } return _unitSize; }
@Override protected int calcMaxLengthInUnits() { // the byte "length" includes the calculated field overhead. remove // that to get the _actual_ data length (in units) return getType().toUnitSize(getType().getMaxSize() - CALC_EXTRA_DATA_LEN, getFormat()); }
public int toValidSize(int size) { return toValidRange(size, getMinSize(), getMaxSize()); }
public boolean isValidSize(int size) { return isWithinRange(size, getMinSize(), getMaxSize()); }
@FunctionType(functionName = "formulaToNumeric", argumentTypes = { AccessType.MEMO, AccessType.MEMO }, returnType = AccessType.DOUBLE) public static Double formulaToNumeric(String res, String datatype) { if (res == null) { return null; } try { DecimalFormatSymbols dfs = DecimalFormatSymbols.getInstance(); String sep = dfs.getDecimalSeparator() + ""; String gs = dfs.getGroupingSeparator() + ""; res = res.replaceAll(Pattern.quote(gs), ""); if (!sep.equalsIgnoreCase(".")) { res = res.replaceAll(Pattern.quote(sep), "."); } double d = val(res); DataType dt = DataType.valueOf(datatype); if (dt.equals(DataType.BYTE) || dt.equals(DataType.INT) || dt.equals(DataType.LONG)) { d = Math.rint(d + APPROX); } return d; } catch (Exception e) { return null; } }
throws IOException if(!isVariableLength() || !getType().isVariableLength()) { return writeFixedLengthField(obj, order); getType().getFixedSize(), order); writeNumericValue(buffer, obj); buffer.flip();