本文整理汇总了Java中net.sf.jsqlparser.expression.StringValue类的典型用法代码示例。如果您正苦于以下问题:Java StringValue类的具体用法?Java StringValue怎么用?Java StringValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StringValue类属于net.sf.jsqlparser.expression包,在下文中一共展示了StringValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseExpression
import net.sf.jsqlparser.expression.StringValue; //导入依赖的package包/类
private ru.cjdb.sql.expressions.Expression parseExpression(Expression expr, String... tableNames) {
if (expr instanceof LongValue) {
return new ValueExpression(((LongValue) expr).getStringValue());
}
if (expr instanceof StringValue) {
return new ValueExpression(((StringValue) expr).getValue());
}
if (expr instanceof Column) {
String columnName = ((Column) expr).getColumnName();
ru.cjdb.scheme.dto.Column column = asList(tableNames).stream()
.flatMap(name -> metainfoService.getTable(name).getColumns().stream())
.filter(col -> col.getName().equals(columnName))
.findAny()
.orElseThrow(() -> new SqlParseException("Column " + columnName + " not found!"));
return new ColumnValueExpr(columnName, column.getType());
}
return null;
}
示例2: parseToValue
import net.sf.jsqlparser.expression.StringValue; //导入依赖的package包/类
private static Expression parseToValue(Object arg) {
if (arg instanceof Long || arg instanceof Integer) {
return new LongValue(arg.toString());
} else if (arg instanceof Double || arg instanceof Float) {
return new DoubleValue(arg.toString());
}
return new StringValue(arg.toString());
}
示例3: isConstant
import net.sf.jsqlparser.expression.StringValue; //导入依赖的package包/类
static boolean isConstant(Expression exp) {
return exp instanceof StringValue
|| exp instanceof LongValue
|| exp instanceof NullValue
|| exp instanceof TimestampValue
|| exp instanceof JdbcParameter;
}
示例4: resolveValue
import net.sf.jsqlparser.expression.StringValue; //导入依赖的package包/类
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 ((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());
}
}
示例5: LikeExpression
import net.sf.jsqlparser.expression.StringValue; //导入依赖的package包/类
final public Expression LikeExpression() throws ParseException {
LikeExpression result = new LikeExpression();
Expression leftExpression = null;
Expression rightExpression = null;
leftExpression = SimpleExpression();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case K_NOT:
jj_consume_token(K_NOT);
result.setNot(true);
break;
default:
jj_la1[89] = jj_gen;
;
}
jj_consume_token(K_LIKE);
rightExpression = SimpleExpression();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case K_ESCAPE:
jj_consume_token(K_ESCAPE);
token = jj_consume_token(S_CHAR_LITERAL);
result.setEscape((StringValue.parseEscaped(token.image)).getValue());
break;
default:
jj_la1[90] = jj_gen;
;
}
result.setLeftExpression(leftExpression);
result.setRightExpression(rightExpression);
{if (true) return result;}
throw new Error("Missing return statement in function");
}
示例6: testReplaceSyntax1
import net.sf.jsqlparser.expression.StringValue; //导入依赖的package包/类
public void testReplaceSyntax1() throws JSQLParserException {
String statement = "REPLACE mytable SET col1='as', col2=?, col3=565";
Replace replace = (Replace) parserManager.parse(new StringReader(statement));
assertEquals("mytable", replace.getTable().getName());
assertEquals(3, replace.getColumns().size());
assertEquals("col1", ((Column) replace.getColumns().get(0)).getColumnName());
assertEquals("col2", ((Column) replace.getColumns().get(1)).getColumnName());
assertEquals("col3", ((Column) replace.getColumns().get(2)).getColumnName());
assertEquals("as", ((StringValue)replace.getExpressions().get(0)).getValue());
assertTrue(replace.getExpressions().get(1) instanceof JdbcParameter);
assertEquals(565, ((LongValue)replace.getExpressions().get(2)).getValue());
assertEquals(statement, ""+replace);
}
示例7: testReplaceSyntax2
import net.sf.jsqlparser.expression.StringValue; //导入依赖的package包/类
public void testReplaceSyntax2() throws JSQLParserException {
String statement = "REPLACE mytable (col1, col2, col3) VALUES ('as', ?, 565)";
Replace replace = (Replace) parserManager.parse(new StringReader(statement));
assertEquals("mytable", replace.getTable().getName());
assertEquals(3, replace.getColumns().size());
assertEquals("col1", ((Column) replace.getColumns().get(0)).getColumnName());
assertEquals("col2", ((Column) replace.getColumns().get(1)).getColumnName());
assertEquals("col3", ((Column) replace.getColumns().get(2)).getColumnName());
assertEquals("as", ((StringValue) ((ExpressionList)replace.getItemsList()).getExpressions().get(0)).getValue());
assertTrue(((ExpressionList)replace.getItemsList()).getExpressions().get(1) instanceof JdbcParameter);
assertEquals(565, ((LongValue) ((ExpressionList)replace.getItemsList()).getExpressions().get(2)).getValue());
assertEquals(statement, ""+replace);
}
示例8: testUpdate
import net.sf.jsqlparser.expression.StringValue; //导入依赖的package包/类
public void testUpdate() throws JSQLParserException {
String statement = "UPDATE mytable set col1='as', col2=?, col3=565 Where o >= 3";
Update update = (Update) parserManager.parse(new StringReader(statement));
assertEquals("mytable", update.getTable().getName());
assertEquals(3, update.getColumns().size());
assertEquals("col1", ((Column) update.getColumns().get(0)).getColumnName());
assertEquals("col2", ((Column) update.getColumns().get(1)).getColumnName());
assertEquals("col3", ((Column) update.getColumns().get(2)).getColumnName());
assertEquals("as", ((StringValue) update.getExpressions().get(0)).getValue());
assertTrue(update.getExpressions().get(1) instanceof JdbcParameter);
assertEquals(565, ((LongValue) update.getExpressions().get(2)).getValue());
assertTrue(update.getWhere() instanceof GreaterThanEquals);
}
示例9: testReplaceSyntax1
import net.sf.jsqlparser.expression.StringValue; //导入依赖的package包/类
@Test
public void testReplaceSyntax1() throws JSQLParserException {
String statement = "REPLACE mytable SET col1='as', col2=?, col3=565";
Replace replace = (Replace) parserManager.parse(new StringReader(statement));
assertEquals("mytable", replace.getTable().getName());
assertEquals(3, replace.getColumns().size());
assertEquals("col1", ((Column) replace.getColumns().get(0)).getColumnName());
assertEquals("col2", ((Column) replace.getColumns().get(1)).getColumnName());
assertEquals("col3", ((Column) replace.getColumns().get(2)).getColumnName());
assertEquals("as", ((StringValue) replace.getExpressions().get(0)).getValue());
assertTrue(replace.getExpressions().get(1) instanceof JdbcParameter);
assertEquals(565, ((LongValue) replace.getExpressions().get(2)).getValue());
assertEquals(statement, "" + replace);
}
示例10: testReplaceSyntax2
import net.sf.jsqlparser.expression.StringValue; //导入依赖的package包/类
@Test
public void testReplaceSyntax2() throws JSQLParserException {
String statement = "REPLACE mytable (col1, col2, col3) VALUES ('as', ?, 565)";
Replace replace = (Replace) parserManager.parse(new StringReader(statement));
assertEquals("mytable", replace.getTable().getName());
assertEquals(3, replace.getColumns().size());
assertEquals("col1", ((Column) replace.getColumns().get(0)).getColumnName());
assertEquals("col2", ((Column) replace.getColumns().get(1)).getColumnName());
assertEquals("col3", ((Column) replace.getColumns().get(2)).getColumnName());
assertEquals("as", ((StringValue) ((ExpressionList) replace.getItemsList()).getExpressions().get(0)).getValue());
assertTrue(((ExpressionList) replace.getItemsList()).getExpressions().get(1) instanceof JdbcParameter);
assertEquals(565, ((LongValue) ((ExpressionList) replace.getItemsList()).getExpressions().get(2)).getValue());
assertEquals(statement, "" + replace);
}
示例11: testUpdate
import net.sf.jsqlparser.expression.StringValue; //导入依赖的package包/类
@Test
public void testUpdate() throws JSQLParserException {
String statement = "UPDATE mytable set col1='as', col2=?, col3=565 Where o >= 3";
Update update = (Update) parserManager.parse(new StringReader(statement));
assertEquals("mytable", update.getTable().getName());
assertEquals(3, update.getColumns().size());
assertEquals("col1", ((Column) update.getColumns().get(0)).getColumnName());
assertEquals("col2", ((Column) update.getColumns().get(1)).getColumnName());
assertEquals("col3", ((Column) update.getColumns().get(2)).getColumnName());
assertEquals("as", ((StringValue) update.getExpressions().get(0)).getValue());
assertTrue(update.getExpressions().get(1) instanceof JdbcParameter);
assertEquals(565, ((LongValue) update.getExpressions().get(2)).getValue());
assertTrue(update.getWhere() instanceof GreaterThanEquals);
}
示例12: getInstance
import net.sf.jsqlparser.expression.StringValue; //导入依赖的package包/类
public static Projector getInstance(Expression expression, String alias, QueryTypeExtractor queryTypeExtractor) {
Projector instance = null;
if (expression instanceof net.sf.jsqlparser.schema.Column) {
instance = new ColumnProjector((net.sf.jsqlparser.schema.Column) expression, alias, queryTypeExtractor);
} else if (expression instanceof Function) {
instance = new FunctionProjector((Function) expression, alias, queryTypeExtractor);
} else if (expression instanceof BinaryExpression) {
instance = new BinaryExpressionProjector((BinaryExpression) expression, alias, queryTypeExtractor);
} else if (expression instanceof LongValue) {
instance = new LongProjector(expression, alias, queryTypeExtractor);
} else if (expression instanceof StringValue) {
instance = new StringProjector(expression, alias, queryTypeExtractor);
} else if (expression instanceof DoubleValue) {
instance = new DoubleProjector(expression, alias, queryTypeExtractor);
} else if (expression instanceof Parenthesis) {
instance = new ParenthesisProjector((Parenthesis) expression, queryTypeExtractor);
} else if (expression instanceof JdbcParameter) {
instance = new JdbcParameterProjector(queryTypeExtractor);
} else if (expression instanceof SubSelect) {
instance = new SubSelectProjector((SubSelect) expression, alias, queryTypeExtractor);
} else {
throw new RuntimeException("Not supported");
}
return instance;
}
示例13: getValue
import net.sf.jsqlparser.expression.StringValue; //导入依赖的package包/类
private Object getValue(Expression expr) {
if (expr instanceof LongValue) {
return (int)((LongValue) expr).getValue();
}
if(expr instanceof DoubleValue) {
return ((DoubleValue) expr).getValue();
}
if(expr instanceof StringValue) {
return ((StringValue) expr).getValue();
}
throw new SqlParseException("Unknown value type " + expr.getClass());
}
示例14: expressionToString
import net.sf.jsqlparser.expression.StringValue; //导入依赖的package包/类
public static String expressionToString(Expression expression) {
if(expression instanceof Column) {
return ((Column)expression).getFullyQualifiedName();
}
if(expression instanceof StringValue) {
return ((StringValue)expression).getValue();
}
return null;
}
示例15: expressionToNumber
import net.sf.jsqlparser.expression.StringValue; //导入依赖的package包/类
public static Number expressionToNumber(Expression expression) {
if(expression instanceof StringValue) {
return Long.valueOf(((StringValue) expression).getValue());
}
if(expression instanceof LongValue) {
return ((LongValue)expression).getValue();
}
if(expression instanceof DoubleValue) {
return ((DoubleValue)expression).getValue();
}
return null;
}