本文整理汇总了Java中net.sf.jsqlparser.statement.Statement.accept方法的典型用法代码示例。如果您正苦于以下问题:Java Statement.accept方法的具体用法?Java Statement.accept怎么用?Java Statement.accept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.jsqlparser.statement.Statement
的用法示例。
在下文中一共展示了Statement.accept方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: modifyTableNames
import net.sf.jsqlparser.statement.Statement; //导入方法依赖的package包/类
public static String modifyTableNames(String sql,TableRenamer tableRenamer)
{
if(sql == null)
{
throw new IllegalArgumentException("sql is null");
}
Statement statement = null;
try
{
statement = CCJSqlParserUtil.parse(sql);
}
catch (JSQLParserException e)
{
throw new IllegalArgumentException("Error when parsing sql:[" + sql+"]",e);
}
TableRenameVisitor tableRenameVisitor=new TableRenameVisitor(tableRenamer);
statement.accept(tableRenameVisitor);
return statement.toString();
}
示例2: testMysqlQuote
import net.sf.jsqlparser.statement.Statement; //导入方法依赖的package包/类
public void testMysqlQuote() throws JSQLParserException {
String statement = "SELECT `a.OWNERLASTNAME`, `OWNERFIRSTNAME` "
+"FROM `ANTIQUEOWNERS` AS a, ANTIQUES AS b "
+"WHERE b.BUYERID = a.OWNERID AND b.ITEM = 'Chair'";
Statement parsed = parserManager.parse(new StringReader(statement));
StatementDeParser deParser=new StatementDeParser(new StringBuffer());
parsed.accept(deParser);
assertEquals(statement, parsed.toString());
assertEquals(statement, deParser.getBuffer().toString());
}
示例3: testConcat
import net.sf.jsqlparser.statement.Statement; //导入方法依赖的package包/类
public void testConcat() throws JSQLParserException {
String statement = "SELECT a || b || c + 4 FROM t";
Statement parsed = parserManager.parse(new StringReader(statement));
StatementDeParser deParser=new StatementDeParser(new StringBuffer());
parsed.accept(deParser);
assertEquals(statement, parsed.toString());
assertEquals(statement, deParser.getBuffer().toString());
}
示例4: testMatches
import net.sf.jsqlparser.statement.Statement; //导入方法依赖的package包/类
public void testMatches() throws JSQLParserException {
String statement = "SELECT * FROM team WHERE team.search_column @@ to_tsquery('new & york & yankees')";
Statement parsed = parserManager.parse(new StringReader(statement));
StatementDeParser deParser=new StatementDeParser(new StringBuffer());
parsed.accept(deParser);
assertEquals(statement, parsed.toString());
assertEquals(statement, deParser.getBuffer().toString());
}
示例5: testGroupByExpression
import net.sf.jsqlparser.statement.Statement; //导入方法依赖的package包/类
public void testGroupByExpression() throws JSQLParserException {
String statement =
"SELECT col1, col2, col1 + col2, sum(col8)" +
" FROM table1 " +
"GROUP BY col1, col2, col1 + col2";
Statement parsed = parserManager.parse(new StringReader(statement));
StatementDeParser deParser=new StatementDeParser(new StringBuffer());
parsed.accept(deParser);
assertEquals(statement, parsed.toString());
assertEquals(statement, deParser.getBuffer().toString());
}
示例6: testBitwise
import net.sf.jsqlparser.statement.Statement; //导入方法依赖的package包/类
public void testBitwise() throws JSQLParserException {
String statement =
"SELECT col1 & 32, col2 ^ col1, col1 | col2" +
" FROM table1";
Statement parsed = parserManager.parse(new StringReader(statement));
StatementDeParser deParser=new StatementDeParser(new StringBuffer());
parsed.accept(deParser);
assertEquals(statement, parsed.toString());
assertEquals(statement, deParser.getBuffer().toString());
}
示例7: testMysqlQuote
import net.sf.jsqlparser.statement.Statement; //导入方法依赖的package包/类
@Test
public void testMysqlQuote() throws JSQLParserException {
String statement = "SELECT `a.OWNERLASTNAME`, `OWNERFIRSTNAME` "
+ "FROM `ANTIQUEOWNERS` AS a, ANTIQUES AS b "
+ "WHERE b.BUYERID = a.OWNERID AND b.ITEM = 'Chair'";
Statement parsed = parserManager.parse(new StringReader(statement));
StatementDeParser deParser = new StatementDeParser(new StringBuilder());
parsed.accept(deParser);
assertEquals(statement, parsed.toString());
assertEquals(statement.toLowerCase(), deParser.getBuffer().toString().replaceAll("[\r\n]+", "").toLowerCase());
}
示例8: testConcat
import net.sf.jsqlparser.statement.Statement; //导入方法依赖的package包/类
@Test
public void testConcat() throws JSQLParserException {
String statement = "SELECT a || b || c + 4 FROM t";
Statement parsed = parserManager.parse(new StringReader(statement));
StatementDeParser deParser = new StatementDeParser(new StringBuilder());
parsed.accept(deParser);
assertEquals(statement, parsed.toString());
assertEquals(statement.toLowerCase(), deParser.getBuffer().toString().replaceAll("[\r\n]+", "").toLowerCase());
}
示例9: testMatches
import net.sf.jsqlparser.statement.Statement; //导入方法依赖的package包/类
@Test
public void testMatches() throws JSQLParserException {
String statement = "SELECT * FROM team WHERE team.search_column @@ to_tsquery('new & york & yankees')";
Statement parsed = parserManager.parse(new StringReader(statement));
StatementDeParser deParser = new StatementDeParser(new StringBuilder());
parsed.accept(deParser);
assertEquals(statement, parsed.toString());
assertEquals(statement.toLowerCase(), deParser.getBuffer().toString().replaceAll("[\r\n]+", "").toLowerCase());
}
示例10: testGroupByExpression
import net.sf.jsqlparser.statement.Statement; //导入方法依赖的package包/类
@Test
public void testGroupByExpression() throws JSQLParserException {
String statement =
"SELECT col1, col2, col1 + col2, sum(col8)"
+ " FROM table1 "
+ "GROUP BY col1, col2, col1 + col2";
Statement parsed = parserManager.parse(new StringReader(statement));
StatementDeParser deParser = new StatementDeParser(new StringBuilder());
parsed.accept(deParser);
assertEquals(statement, parsed.toString());
assertEquals(statement.toLowerCase(), deParser.getBuffer().toString().replaceAll("[\r\n]+", "").toLowerCase());
}
示例11: testBitwise
import net.sf.jsqlparser.statement.Statement; //导入方法依赖的package包/类
@Test
public void testBitwise() throws JSQLParserException {
String statement =
"SELECT col1 & 32, col2 ^ col1, col1 | col2"
+ " FROM table1";
Statement parsed = parserManager.parse(new StringReader(statement));
StatementDeParser deParser = new StatementDeParser(new StringBuilder());
parsed.accept(deParser);
assertEquals(statement, parsed.toString());
assertEquals(statement.toLowerCase(), deParser.getBuffer().toString().replaceAll("[\r\n]+", "").toLowerCase());
}
示例12: revert
import net.sf.jsqlparser.statement.Statement; //导入方法依赖的package包/类
protected String revert(Statement statement) {
StatementDeParser deParser = new StatementDeParser(new StringBuilder());
statement.accept(deParser);
return deParser.getBuffer().toString();
}
示例13: execute
import net.sf.jsqlparser.statement.Statement; //导入方法依赖的package包/类
public FindIterable<Document> execute(String SQL) throws JSQLParserException {
Statement statement = CCJSqlParserUtil.parse(SQL);
SQLVisitor visitor = new SQLVisitor();
statement.accept(visitor);
Query noQuery = visitor.getNoQuery();
if (logger.isDebugEnabled() && outputQuery) {
logger.debug(noQuery);
}
ArrayList<String> tables = Lists.newArrayList(noQuery.getTables().getTableNames());
MongoCollection<Document> collection = db.getCollection(tables.get(0));
QueryWhere where = noQuery.getWhere();
QueryColumn columns = noQuery.getColumns();
return collection.find(where.getFilter()).projection(columns.getColumns(tables.get(0)));
}
示例14: getTableList
import net.sf.jsqlparser.statement.Statement; //导入方法依赖的package包/类
/**
* Main entry for this Tool class. A list of found tables is returned.
*
* @param delete
* @return
*/
public List<String> getTableList(Statement statement) {
init();
statement.accept(this);
return tables;
}
示例15: doDeParse
import net.sf.jsqlparser.statement.Statement; //导入方法依赖的package包/类
/**
* 将Statement反解析为sql
*
* @param statement
* @return
*/
protected String doDeParse(Statement statement) {
StatementDeParser deParser = new StatementDeParser(new StringBuilder());
statement.accept(deParser);
return deParser.getBuffer().toString();
}