net.sf.jsqlparser.expression.SignedExpression Java Examples
The following examples show how to use
net.sf.jsqlparser.expression.SignedExpression.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractSpannerExpressionVisitorAdapter.java From spanner-jdbc with MIT License | 6 votes |
@Override public void visit(SignedExpression value) { Expression underlyingValue = value.getExpression(); if (underlyingValue instanceof DoubleValue) { DoubleValue doubleValue = (DoubleValue) underlyingValue; doubleValue .setValue(value.getSign() == '-' ? -doubleValue.getValue() : doubleValue.getValue()); visit(doubleValue); } else if (underlyingValue instanceof LongValue) { LongValue longValue = (LongValue) underlyingValue; longValue.setValue(value.getSign() == '-' ? -longValue.getValue() : longValue.getValue()); visit(longValue); } else { super.visit(value); } }
Example #2
Source File: SqlUtils.java From sql-to-mongo-db-query-converter with Apache License 2.0 | 6 votes |
public static Object getValue(Expression incomingExpression, Expression otherSide, FieldType defaultFieldType, Map<String, FieldType> fieldNameToFieldTypeMapping) throws ParseException { FieldType fieldType = otherSide !=null ? firstNonNull(fieldNameToFieldTypeMapping.get(getStringValue(otherSide)), defaultFieldType) : FieldType.UNKNOWN; if (LongValue.class.isInstance(incomingExpression)) { return normalizeValue((((LongValue)incomingExpression).getValue()),fieldType); } else if (SignedExpression.class.isInstance(incomingExpression)) { return normalizeValue((((SignedExpression)incomingExpression).toString()),fieldType); } else if (StringValue.class.isInstance(incomingExpression)) { return normalizeValue((((StringValue)incomingExpression).getValue()),fieldType); } else if (Column.class.isInstance(incomingExpression)) { return normalizeValue(getStringValue(incomingExpression),fieldType); } else { throw new ParseException("can not parseNaturalLanguageDate: " + incomingExpression.toString()); } }
Example #3
Source File: CTEToNestedQueryConverter.java From quetzal with Eclipse Public License 2.0 | 5 votes |
@Override public void visit(SignedExpression signedExpression) { clear(); boolean prevIsTopVal = isTopLevel; isTopLevel = false; signedExpression.getExpression().accept(this); isTopLevel = prevIsTopVal; defaultTopLevelProcessing(signedExpression); }
Example #4
Source File: ExpressionVisitorImpl.java From DataPermissionHelper with Apache License 2.0 | 4 votes |
@Override public void visit(SignedExpression signedExpression) { signedExpression.accept(new ExpressionVisitorImpl()); }
Example #5
Source File: DDLSQLPlanner.java From herddb with Apache License 2.0 | 4 votes |
private static Object resolveValue(Expression expression, boolean allowColumn) throws StatementExecutionException { if (expression instanceof JdbcParameter) { throw new StatementExecutionException("jdbcparameter expression not usable in this query"); } else if (allowColumn && expression instanceof net.sf.jsqlparser.schema.Column) { // this is only for supporting back ticks in DDL return fixMySqlBackTicks(((net.sf.jsqlparser.schema.Column) expression).getColumnName()); } else if (expression instanceof StringValue) { return ((StringValue) expression).getValue(); } else if (expression instanceof LongValue) { return ((LongValue) expression).getValue(); } else if (expression instanceof TimestampValue) { return ((TimestampValue) expression).getValue(); } else if (expression instanceof SignedExpression) { SignedExpression se = (SignedExpression) expression; switch (se.getSign()) { case '+': { return resolveValue(se.getExpression(), allowColumn); } case '-': { Object value = resolveValue(se.getExpression(), allowColumn); if (value == null) { return null; } if (value instanceof Integer) { return -1L * ((Integer) value); } else if (value instanceof Long) { return -1L * ((Long) value); } else { throw new StatementExecutionException( "unsupported value type " + expression.getClass() + " with sign " + se.getSign() + " on value " + value + " of type " + value. getClass()); } } default: throw new StatementExecutionException( "unsupported value type " + expression.getClass() + " with sign " + se.getSign()); } } else { throw new StatementExecutionException("unsupported value type " + expression.getClass()); } }