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; }
private boolean typeGroup(DataType dt, DataType... gr) { for (DataType el : gr) { if (el.equals(dt)) { return true; } } return false; }
private String defaultValue4SQL(Object defaulT, DataType dt) throws SQLException, IOException { if (defaulT == null) { return null; } String default4SQL = SQLConverter.convertSQL(" " + defaulT.toString()).getSql(); if (default4SQL.trim().startsWith("=")) { default4SQL = default4SQL.trim().substring(1); } if (dt.equals(DataType.BOOLEAN) && ("=yes".equalsIgnoreCase(default4SQL) || "yes".equalsIgnoreCase(default4SQL))) { default4SQL = "true"; } if (dt.equals(DataType.BOOLEAN) && ("=no".equalsIgnoreCase(default4SQL) || "no".equalsIgnoreCase(default4SQL))) { default4SQL = "false"; } if ((dt.equals(DataType.MEMO) || dt.equals(DataType.TEXT)) && (!defaulT.toString().startsWith("\"") || !defaulT.toString().endsWith("\"")) ) { default4SQL = "'" + default4SQL.replaceAll("'", "''") + "'"; } return default4SQL; }
@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; } }
private static boolean hasAutoNumberColumn(Table t) { List<? extends Column> lc = t.getColumns(); for (Column cl : lc) { if (cl.isAutoNumber() || DataType.BOOLEAN.equals(cl.getType())) { return true; } } return false; }
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; }
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 BlobAction(Table _table, Object[] newValues) throws SQLException { this.table = _table; if (!BlobKey.hasPrimaryKey(_table)) { return; } Index pk = _table.getPrimaryKeyIndex(); HashSet<String> hsKey = new HashSet<String>(); for (Index.Column icl : pk.getColumns()) { hsKey.add(icl.getName()); } HashSet<String> hsBlob = new HashSet<String>(); int i = 0; HashMap<String, Object> keyMap = new HashMap<String, Object>(); for (Column cl : _table.getColumns()) { if (cl.getType().equals(DataType.OLE) && newValues[i] != null) { containsBlob = true; hsBlob.add(cl.getName()); } if (hsKey.contains(cl.getName())) { keyMap.put(cl.getName(), newValues[i]); } ++i; } for (String cln : hsBlob) { keys.add(new BlobKey(keyMap, table.getName(), cln)); } }
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; }
for (Column cli : t.getColumns()) { ColumnImpl cl = (ColumnImpl) cli; if (cli.getType().equals(DataType.COMPLEX_TYPE) && (newR[i] == null || "".equals(newR[i]))) { if (cli.getComplexInfo().getType().equals(ComplexDataType.ATTACHMENT)) { newR[i] = new JavaObjectData(new Attachment[0]); if (cl.getAutoNumberGenerator().getType().equals(DataType.LONG) && newR[i] != null) { AutoNumberManager.bump(cl, (Integer) newR[i]); if (cl.getAutoNumberGenerator().getType().equals(DataType.GUID)) { } else if (cl.getAutoNumberGenerator().getType().equals(DataType.LONG)) { int keyg = AutoNumberManager.getNext(cl); newR[i] = keyg; throw new RuntimeException("Cannot update autoincrement column"); } else if (cl.getAutoNumberGenerator().getType().equals(DataType.GUID)) { validateGUID(newR[i]); } else if (DataType.BOOLEAN.equals(cl.getType())) { if (newR[i] == null) { newR[i] = false;
if (default4SQL != null || cl.getType().equals(DataType.BOOLEAN)) { try { defObj = default4SQL == null && cl.getType().equals(DataType.BOOLEAN) ? Boolean.FALSE : defObj; ps = conn.getHSQLDBConnection().prepareStatement( SQLConverter.convertSQL("UPDATE " + tableName + " SET " + columnName + "=" + "?").getSql());
if (length > 0 && dt.equals(DataType.TEXT)) { cb.setLengthInUnits(length);
ColumnImpl cli = (ColumnImpl) cl; AutoNumberGenerator ang = cli.getAutoNumberGenerator(); if (ang.getType().equals(DataType.LONG)) { ctype = "COUNTER";