private String getHsqldbColumnType(Column cl) throws IOException { String htype; DataType dtyp = cl.getType(); DataType rtyp = getReturnType(cl); boolean calcType = false; if (rtyp != null) { dtyp = rtyp; calcType = true; } if (dtyp.equals(DataType.TEXT)) { int ln = ff1997 ? cl.getLength() : cl.getLengthInUnits(); htype = "VARCHAR(" + ln + ")"; } else if (dtyp.equals(DataType.NUMERIC) && (cl.getScale() > 0 || calcType)) { if (calcType) { htype = "NUMERIC(100 ,4)"; } else { htype = "NUMERIC(" + (cl.getPrecision() > 0 ? cl.getPrecision() : 100) + "," + cl.getScale() + ")"; } } else if (dtyp.equals(DataType.FLOAT) && calcType) { htype = "NUMERIC(" + (cl.getPrecision() > 0 ? cl.getPrecision() : 100) + "," + 4 + ")"; } else { htype = TypesMap.map2hsqldb(dtyp); } return htype; }
/** * Sets all attributes except name from the given Column template (including * all column properties except GUID). */ public ColumnBuilder setFromColumn(Column template) throws IOException { DataType type = template.getType(); setType(type); setLength(template.getLength()); setAutoNumber(template.isAutoNumber()); if(type.getHasScalePrecision()) { setScale(template.getScale()); setPrecision(template.getPrecision()); } setCalculated(template.isCalculated()); setCompressedUnicode(template.isCompressedUnicode()); setHyperlink(template.isHyperlink()); if(template instanceof ColumnImpl) { setTextSortOrder(((ColumnImpl)template).getTextSortOrder()); } PropertyMap colProps = template.getProperties(); for(PropertyMap.Property colProp : colProps) { // copy everything but guid if(!PropertyMap.GUID_PROP.equalsIgnoreCase(colProp.getName())) { setProperty(colProp.getName(), colProp); } } return this; }