/** * 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); }
private void add(String text) { Value[] row = { ValueString.get(text) }; result.addRow(row); } }
public Value getTransactionId() { if (transaction == null) { return ValueNull.INSTANCE; } return ValueString.get(Long.toString(transaction.getTransactionId())); }
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); }
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); }
@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); } }
/** * 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); } }
/** * 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 ? (Value) ValueNull.INSTANCE : ValueString.get(x)); } catch (Exception e) { throw logAndConvert(e); } }
private boolean checkIndex(ServerSession session, String value, Value indexFrom, Value indexTo) { if (value == null || (indexFrom == null && indexTo == null)) { return true; } Database db = session.getDatabase(); if (database.getMode().lowerCaseIdentifiers) { Value v = ValueStringIgnoreCase.get(value); if (indexFrom.equals(indexTo) && db.compare(v, indexFrom) != 0) { return false; } } else { Value 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; }
/** * INTERNAL */ public int getQueryTimeout() throws SQLException { try { debugCodeCall("getQueryTimeout"); if (queryTimeoutCache == -1) { checkClosed(); getQueryTimeout = prepareCommand("SELECT VALUE FROM INFORMATION_SCHEMA.SETTINGS WHERE NAME=?", getQueryTimeout); getQueryTimeout.getParameters().get(0).setValue(ValueString.get("QUERY_TIMEOUT"), false); Result result = getQueryTimeout.executeQuery(0, false); result.next(); int queryTimeout = result.currentRow()[0].getInt(); result.close(); if (queryTimeout != 0) { // round to the next second, otherwise 999 millis would return 0 seconds queryTimeout = (queryTimeout + 999) / 1000; } queryTimeoutCache = queryTimeout; } return queryTimeoutCache; } catch (Exception e) { throw logAndConvert(e); } }
private Expression readWildcardOrSequenceValue(String schema, String objectName) { if (readIf("*")) { return new Wildcard(schema, objectName); } if (schema == null) { schema = session.getCurrentSchemaName(); } if (readIf("NEXTVAL")) { Sequence sequence = findSequence(schema, objectName); if (sequence != null) { return new SequenceValue(sequence); } } else if (readIf("CURRVAL")) { Sequence sequence = findSequence(schema, objectName); if (sequence != null) { Function function = Function.getFunction(database, "CURRVAL"); function.setParameter(0, ValueExpression.get(ValueString.get(sequence.getSchema().getName()))); function.setParameter(1, ValueExpression.get(ValueString.get(sequence.getName()))); function.doneWithParameters(); return function; } } return null; }
v = ValueString.get(buff.toString());
Value value = ValueString.get(patternString); Expression expr = ValueExpression.get(value); return new Comparison(session, Comparison.EQUAL, left, expr).optimize(session);
private CreateUser parseCreateUser() { CreateUser command = new CreateUser(session); command.setIfNotExists(readIfNotExists()); command.setUserName(readUniqueIdentifier()); command.setComment(readCommentIf()); if (readIf("PASSWORD")) { command.setPassword(readExpression()); } else if (readIf("SALT")) { command.setSalt(readExpression()); read("HASH"); command.setHash(readExpression()); } else if (readIf("IDENTIFIED")) { read("BY"); // uppercase if not quoted command.setPassword(ValueExpression.get(ValueString.get(readColumnIdentifier()))); } else { throw getSyntaxError(); } if (readIf("ADMIN")) { command.setAdmin(true); } return command; }