当前位置: 首页>>代码示例>>Java>>正文


Java StringValue类代码示例

本文整理汇总了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;
}
 
开发者ID:SerCeMan,项目名称:cjdb,代码行数:19,代码来源:QueryParserImpl.java

示例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());
}
 
开发者ID:kkmike999,项目名称:YuiHatano,代码行数:10,代码来源:KbSqlParser.java

示例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;
}
 
开发者ID:diennea,项目名称:herddb,代码行数:8,代码来源:SQLRecordPredicate.java

示例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());
    }
}
 
开发者ID:diennea,项目名称:herddb,代码行数:40,代码来源:SQLPlanner.java

示例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");
}
 
开发者ID:UBOdin,项目名称:jsqlparser,代码行数:32,代码来源:CCJSqlParser.java

示例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);

}
 
开发者ID:UBOdin,项目名称:jsqlparser,代码行数:15,代码来源:ReplaceTest.java

示例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);
}
 
开发者ID:UBOdin,项目名称:jsqlparser,代码行数:14,代码来源:ReplaceTest.java

示例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);
}
 
开发者ID:UBOdin,项目名称:jsqlparser,代码行数:15,代码来源:UpdateTest.java

示例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);

}
 
开发者ID:marat-gainullin,项目名称:platypus-js,代码行数:16,代码来源:ReplaceTest.java

示例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);
}
 
开发者ID:marat-gainullin,项目名称:platypus-js,代码行数:15,代码来源:ReplaceTest.java

示例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);
}
 
开发者ID:marat-gainullin,项目名称:platypus-js,代码行数:16,代码来源:UpdateTest.java

示例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;
}
 
开发者ID:sebastianoe,项目名称:s4j,代码行数:27,代码来源:Projector.java

示例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());
}
 
开发者ID:SerCeMan,项目名称:cjdb,代码行数:13,代码来源:QueryParserImpl.java

示例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;
}
 
开发者ID:Flipkart,项目名称:foxtrot,代码行数:10,代码来源:QueryUtils.java

示例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;
}
 
开发者ID:Flipkart,项目名称:foxtrot,代码行数:13,代码来源:QueryUtils.java


注:本文中的net.sf.jsqlparser.expression.StringValue类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。