/** * Create a new String value of the current class. * This method is meant to be overridden by subclasses. * * @param s the string * @return the value */ protected Value getNew(String s) { return ValueString.get(s); }
/** * Get or create a string value for the given string. * * @param s the string * @param treatEmptyStringsAsNull whether or not to treat empty strings as * NULL * @return the value */ public static Value get(String s, boolean treatEmptyStringsAsNull) { if (s.isEmpty()) { return treatEmptyStringsAsNull ? ValueNull.INSTANCE : EMPTY; } ValueString obj = new ValueString(StringUtils.cache(s)); if (s.length() > SysProperties.OBJECT_CACHE_MAX_PER_ELEMENT_SIZE) { return obj; } return Value.cache(obj); // this saves memory, but is really slow // return new ValueString(s.intern()); }
@Override public Value convertPrecision(long precision, boolean force) { if (precision == 0 || value.length() <= precision) { return this; } int p = MathUtils.convertLongToInt(precision); return getNew(value.substring(0, p)); }
buff.append(v.getString()).append(" FROM ").append(args[1].getPreparedSQL(session, parameters)); break;
buff.append(v.getString()).append(" FROM ").append(args[1].getSQL()); break;
/** * Get or create a string value for the given string. * * @param s the string * @return the value */ public static Value get(String s) { return get(s, false); }
public Value getTransactionId() { if (transaction == null) { return ValueNull.INSTANCE; } String strId = Long.toString(transaction.getId()); return ValueString.get(strId); }
private void add(String text) { Value[] row = {ValueString.get(text == null ? "" : text)}; result.addRow(row); }
private Prepared parseHelp() { StringBuilder buff = new StringBuilder( "SELECT * FROM INFORMATION_SCHEMA.HELP"); int i = 0; ArrayList<Value> paramValues = New.arrayList(); while (currentTokenType != END) { String s = currentToken; read(); if (i == 0) { buff.append(" WHERE "); } else { buff.append(" AND "); } i++; buff.append("UPPER(TOPIC) LIKE ?"); paramValues.add(ValueString.get("%" + s + "%")); } return prepare(session, buff.toString(), paramValues); }
private void add(ArrayList<Row> rows, String... strings) { Value[] values = new Value[strings.length]; for (int i = 0; i < strings.length; i++) { String s = strings[i]; Value v = (s == null) ? (Value) ValueNull.INSTANCE : ValueString.get(s); Column col = columns[i]; v = col.convert(v); values[i] = v; } Row row = new Row(values, 1); row.setKey(rows.size()); rows.add(row); }
/** * Updates a column in the current or insert row. * * @param columnIndex (1,2,...) * @param x the value * @throws SQLException if the result set is closed or not updatable */ @Override public void updateNString(int columnIndex, String x) throws SQLException { try { if (isDebugEnabled()) { debugCode("updateNString(" + columnIndex + ", " + quote(x) + ");"); } update(columnIndex, x == null ? ValueNull.INSTANCE : ValueString.get(x)); } catch (Exception e) { throw logAndConvert(e); } }
/** * Sets the value of a parameter. * * @param parameterIndex the parameter index (1, 2, ...) * @param x the value * @throws SQLException if this object is closed */ @Override public void setNString(int parameterIndex, String x) throws SQLException { try { if (isDebugEnabled()) { debugCode("setNString(" + parameterIndex + ", " + quote(x) + ");"); } Value v = x == null ? ValueNull.INSTANCE : ValueString.get(x); setParameter(parameterIndex, v); } catch (Exception e) { throw logAndConvert(e); } }
+ "INFORMATION_SCHEMA.TABLES " + "WHERE TABLE_SCHEMA=? ORDER BY TABLE_NAME"); paramValues.add(ValueString.get(schema)); } else if (readIf("COLUMNS")) { String tableName = readIdentifierWithSchema(); String schemaName = getSchema().getName(); paramValues.add(ValueString.get(tableName)); if (readIf("FROM")) { schemaName = readUniqueIdentifier(); + "WHERE C.TABLE_NAME=? AND C.TABLE_SCHEMA=? " + "ORDER BY C.ORDINAL_POSITION"); paramValues.add(ValueString.get(schemaName)); } else if (readIf("DATABASES") || readIf("SCHEMAS")) { + "PARTITIONER FROM INFORMATION_SCHEMA.PARTITIONS " + "WHERE OBJECT_NAME=? ORDER BY DATA_NODE"); paramValues.add(ValueString.get(tableName));
/** * Sets the value of a parameter. * * @param parameterIndex the parameter index (1, 2, ...) * @param x the value * @throws SQLException if this object is closed */ @Override public void setString(int parameterIndex, String x) throws SQLException { try { if (isDebugEnabled()) { debugCode("setString(" + parameterIndex + ", " + quote(x) + ");"); } Value v = x == null ? ValueNull.INSTANCE : ValueString.get(x); setParameter(parameterIndex, v); } catch (Exception e) { throw logAndConvert(e); } }
/** * Updates a column in the current or insert row. * * @param columnIndex (1,2,...) * @param x the value * @throws SQLException if the result set is closed or not updatable */ @Override public void updateString(int columnIndex, String x) throws SQLException { try { if (isDebugEnabled()) { debugCode("updateString(" + columnIndex + ", " + quote(x) + ");"); } update(columnIndex, x == null ? ValueNull.INSTANCE : ValueString.get(x)); } catch (Exception e) { throw logAndConvert(e); } }
private boolean checkIndex(Session session, String value, Value indexFrom, Value indexTo) { if (value == null || (indexFrom == null && indexTo == null)) { return true; } Database db = session.getDatabase(); Value v; if (database.getMode().lowerCaseIdentifiers) { v = ValueStringIgnoreCase.get(value); } else { v = ValueString.get(value); } if (indexFrom != null && db.compare(v, indexFrom) < 0) { return false; } if (indexTo != null && db.compare(v, indexTo) > 0) { return false; } return true; }
String s = rs.getString(columnIndex); v = (s == null) ? ValueNull.INSTANCE : ValueString.get(s); break;
if (maxMatch == patternLength) { filter.addIndexCondition(IndexCondition.get(Comparison.EQUAL, l, ValueExpression.get(ValueString.get(begin)))); } else { filter.addIndexCondition(IndexCondition.get( Comparison.BIGGER_EQUAL, l, ValueExpression.get(ValueString.get(begin)))); char next = begin.charAt(begin.length() - 1); filter.addIndexCondition(IndexCondition.get( Comparison.SMALLER, l, ValueExpression.get(ValueString.get(end)))); break;
/** * Updates a column in the current or insert row. * * @param columnLabel the column label * @param x the value * @throws SQLException if the result set is closed or not updatable */ @Override public void updateString(String columnLabel, String x) throws SQLException { try { if (isDebugEnabled()) { debugCode("updateString(" + quote(columnLabel) + ", " + quote(x) + ");"); } update(columnLabel, x == null ? ValueNull.INSTANCE : ValueString.get(x)); } catch (Exception e) { throw logAndConvert(e); } }
/** * Updates a column in the current or insert row. * * @param columnLabel the column label * @param x the value * @throws SQLException if the result set is closed or not updatable */ @Override public void updateNString(String columnLabel, String x) throws SQLException { try { if (isDebugEnabled()) { debugCode("updateNString(" + quote(columnLabel) + ", " + quote(x) + ");"); } update(columnLabel, x == null ? ValueNull.INSTANCE : ValueString.get(x)); } catch (Exception e) { throw logAndConvert(e); } }