/** * 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 ValueString getNew(String s) { return ValueString.get(s); }
/** * Get or create a string value for the given string. * * @param s the string * @return the value */ public static ValueString get(String s) { if (s.length() == 0) { return EMPTY; } ValueString obj = new ValueString(StringUtils.cache(s)); if (s.length() > SysProperties.OBJECT_CACHE_MAX_PER_ELEMENT_SIZE) { return obj; } return (ValueString) 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].getSQL(isDistributed)); break;
private void add(String text) { Value[] row = { ValueString.get(text) }; result.addRow(row); } }
/** * 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()); }
public Value getTransactionId() { if (transaction == null) { return ValueNull.INSTANCE; } return ValueString.get(Long.toString(transaction.getTransactionId())); }
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); }
private StatementBase parseHelp() { StringBuilder buff = new StringBuilder("SELECT * FROM INFORMATION_SCHEMA.HELP"); int i = 0; ArrayList<Value> paramValues = Utils.newSmallArrayList(); 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); }
@Override public Value readValue(ByteBuffer buff, int tag) { int len; if (tag == STRING) { len = DataUtils.readVarInt(buff); if (len == 0) return ValueNull.INSTANCE; } else { len = tag - TAG_STRING_0_15; } return ValueString.get(DataUtils.readString(buff, len)); } };
public void setRecord(SearchRow r) { r.setValue(0, ValueInt.get(id)); r.setValue(1, ValueInt.get(objectType.value)); r.setValue(2, ValueString.get(sql)); }
/** * 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 ? (Value) 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 ? (Value) 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 ? (Value) ValueNull.INSTANCE : ValueString.get(x)); } catch (Exception e) { throw logAndConvert(e); } }
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(); + "IFNULL(COLUMN_DEFAULT, 'NULL') DEFAULT " + "FROM INFORMATION_SCHEMA.COLUMNS C " + "WHERE C.TABLE_NAME=? AND C.TABLE_SCHEMA=? " + "ORDER BY C.ORDINAL_POSITION"); paramValues.add(ValueString.get(schemaName));
/** * 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 ? (Value) ValueNull.INSTANCE : ValueString.get(x); setParameter(parameterIndex, v); } 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 ? (Value) ValueNull.INSTANCE : ValueString.get(x)); } catch (Exception e) { throw logAndConvert(e); } }
v = (s == null) ? (Value) ValueNull.INSTANCE : ValueString.get(s); break;