本文整理汇总了Java中net.sf.jsqlparser.expression.LongValue类的典型用法代码示例。如果您正苦于以下问题:Java LongValue类的具体用法?Java LongValue怎么用?Java LongValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LongValue类属于net.sf.jsqlparser.expression包,在下文中一共展示了LongValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import net.sf.jsqlparser.expression.LongValue; //导入依赖的package包/类
@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);
}
}
示例2: countSelectItem
import net.sf.jsqlparser.expression.LongValue; //导入依赖的package包/类
/**
* 获取jsqlparser中count的SelectItem
*
* @return
*/
private static List<SelectItem> countSelectItem() {
if (CollectionUtils.isNotEmpty(countSelectItem)) {
return countSelectItem;
}
Function function = new Function();
function.setName("COUNT");
List<Expression> expressions = new ArrayList<>();
LongValue longValue = new LongValue(1);
ExpressionList expressionList = new ExpressionList();
expressions.add(longValue);
expressionList.setExpressions(expressions);
function.setParameters(expressionList);
countSelectItem = new ArrayList<>();
SelectExpressionItem selectExpressionItem = new SelectExpressionItem(function);
countSelectItem.add(selectExpressionItem);
return countSelectItem;
}
示例3: setUp
import net.sf.jsqlparser.expression.LongValue; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
tenantSqlParser = new TenantSqlParser();
tenantSqlParser.setTenantHandler(new TenantHandler() {
@Override
public Expression getTenantId() {
return new LongValue(1000L);
}
@Override
public String getTenantIdColumn() {
return "tenant_id";
}
@Override
public boolean doTableFilter(String tableName) {
return "user".equals(tableName);
}
});
}
示例4: parseExpression
import net.sf.jsqlparser.expression.LongValue; //导入依赖的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;
}
示例5: parseToValue
import net.sf.jsqlparser.expression.LongValue; //导入依赖的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());
}
示例6: isConstant
import net.sf.jsqlparser.expression.LongValue; //导入依赖的package包/类
static boolean isConstant(Expression exp) {
return exp instanceof StringValue
|| exp instanceof LongValue
|| exp instanceof NullValue
|| exp instanceof TimestampValue
|| exp instanceof JdbcParameter;
}
示例7: resolveValue
import net.sf.jsqlparser.expression.LongValue; //导入依赖的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());
}
}
示例8: countSelectItem
import net.sf.jsqlparser.expression.LongValue; //导入依赖的package包/类
/**
* <p>
* 获取jsqlparser中count的SelectItem
* </p>
*/
private static List<SelectItem> countSelectItem() {
Function function = new Function();
function.setName("COUNT");
List<Expression> expressions = new ArrayList<>();
LongValue longValue = new LongValue(1);
ExpressionList expressionList = new ExpressionList();
expressions.add(longValue);
expressionList.setExpressions(expressions);
function.setParameters(expressionList);
List<SelectItem> selectItems = new ArrayList<>();
SelectExpressionItem selectExpressionItem = new SelectExpressionItem(function);
selectItems.add(selectExpressionItem);
return selectItems;
}
示例9: visit
import net.sf.jsqlparser.expression.LongValue; //导入依赖的package包/类
@Override
public void visit(LongValue longValue) {
this.getBuffer().append("?");
long value = longValue.getValue();
if(context.isNegative()) {
value = -value;
}
values.add(value);
}
示例10: countSelectItem
import net.sf.jsqlparser.expression.LongValue; //导入依赖的package包/类
/**
* 获取jsqlparser中count的SelectItem
*
* @return
*/
private static List<SelectItem> countSelectItem() {
if (CollectionUtils.isNotEmpty(countSelectItem)) {
return countSelectItem;
}
Function function = new Function();
function.setName("COUNT");
List<Expression> expressions = new ArrayList<Expression>();
LongValue longValue = new LongValue(0);
ExpressionList expressionList = new ExpressionList();
expressions.add(longValue);
expressionList.setExpressions(expressions);
function.setParameters(expressionList);
countSelectItem = new ArrayList<SelectItem>();
SelectExpressionItem selectExpressionItem = new SelectExpressionItem(function);
countSelectItem.add(selectExpressionItem);
return countSelectItem;
}
示例11: testReplaceSyntax1
import net.sf.jsqlparser.expression.LongValue; //导入依赖的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);
}
示例12: testReplaceSyntax2
import net.sf.jsqlparser.expression.LongValue; //导入依赖的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);
}
示例13: testUpdate
import net.sf.jsqlparser.expression.LongValue; //导入依赖的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);
}
示例14: testReplaceSyntax1
import net.sf.jsqlparser.expression.LongValue; //导入依赖的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);
}
示例15: testReplaceSyntax2
import net.sf.jsqlparser.expression.LongValue; //导入依赖的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);
}