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


Java CommonTree类代码示例

本文整理汇总了Java中org.antlr.runtime.tree.CommonTree的典型用法代码示例。如果您正苦于以下问题:Java CommonTree类的具体用法?Java CommonTree怎么用?Java CommonTree使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CommonTree类属于org.antlr.runtime.tree包,在下文中一共展示了CommonTree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convertNode

import org.antlr.runtime.tree.CommonTree; //导入依赖的package包/类
private static Object convertNode(CommonTree node, DatabaseDialect dialect) {
  	switch (node.getType()) {
	case SQLLexer.CREATE_TABLE: return convertCreateTable(node, dialect);
	case SQLLexer.DROP_TABLE: return convertDropTable(node);
	case SQLLexer.ALTER_TABLE: return convertAlterTable(node);
	case SQLLexer.CREATE_SEQUENCE: return convertCreateSequence(node);
	case SQLLexer.DROP_SEQUENCE: return convertDropSequence(node);
	case SQLLexer.CREATE_INDEX: return convertCreateIndex(node);
	case SQLLexer.COMMENT_TABLE: return convertTableComment(node);
	case SQLLexer.COMMENT_COLUMN: return convertColumnComment(node);
}
  	if (node.isNil()) {
  		List<Object> nodes = convertNodes(getChildNodes(node), dialect);
  		return nodes.toArray();
  	}
throw new ParseException("Unknown token type", "'" + node.getText() + "'");
  }
 
开发者ID:aravindc,项目名称:jdbacl,代码行数:18,代码来源:SQLParserUtil.java

示例2: betweenChecks

import org.antlr.runtime.tree.CommonTree; //导入依赖的package包/类
/**
 * Used by BetweenClauseTest, validates the clause
 * @param theQuery Query
 * @param propName String
 * @param firstValue String
 * @param secondValue String
 */
private void betweenChecks(Query theQuery, final String propName, final String firstValue, final String secondValue) {
    assertNotNull(theQuery);
    CommonTree tree = theQuery.getTree();
    assertNotNull(tree);
	assertEquals(WhereClauseParser.BETWEEN, tree.getType());
	assertEquals(WhereClauseParser.PROPERTYNAME, tree.getChild(0).getType());
	assertTrue(propName.equals(tree.getChild(0).getText()));
	assertEquals(WhereClauseParser.PROPERTYVALUE, tree.getChild(1).getType());
	assertEquals(WhereClauseParser.PROPERTYVALUE, tree.getChild(2).getType());
	QueryHelper.walk(theQuery, new WalkerCallbackAdapter(){
		@Override
		public void between(String property, String firstVal, String secondVal, boolean negated) {
			assertTrue("Property name should be "+propName,propName.equals(property));
			assertTrue("First value should be "+firstValue,firstValue.equals(firstVal));
			assertTrue("Second value should be "+secondValue,secondValue.equals(secondVal));
		}
		
	});
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:27,代码来源:WhereTests.java

示例3: convertColumnSpec

import org.antlr.runtime.tree.CommonTree; //导入依赖的package包/类
private static void convertColumnSpec(CommonTree node, DBTable table) {
String columnName = convertString(childAt(0, node));
String columnTypeName;
Integer size = null;
Integer fractionDigits = null;
int detailOffset = 2;
columnTypeName = convertString(childAt(1, node));
if (node.getChildCount() > 2 && childAt(2, node).getType() == SQLLexer.SIZE) {
	detailOffset++;
	CommonTree sizeNode = childAt(2, node);
	size = convertInteger(childAt(0, sizeNode));
	if (sizeNode.getChildCount() > 1) {
		CommonTree subNode2 = childAt(1, sizeNode);
		if (subNode2.getType() == SQLLexer.INT) {
			fractionDigits = convertInteger(subNode2);
		} else {
			// TODO v1.0 support (n BYTE) / (n CHAR)
		}
	}
}
DBColumn column = new DBColumn(columnName, table, DBDataType.getInstance(columnTypeName), size, fractionDigits);
table.addColumn(column);
   for (int i = detailOffset; i < node.getChildCount(); i++)
   	convertColumnDetail(childAt(i, node), column);
  }
 
开发者ID:aravindc,项目名称:jdbacl,代码行数:26,代码来源:SQLParserUtil.java

示例4: matchesChecks

import org.antlr.runtime.tree.CommonTree; //导入依赖的package包/类
/**
 * Used by the matchesClauseTest
 * @param theQuery Query
 * @param propName String
 * @param propVal String
 */
private void matchesChecks(Query theQuery, final String propName, final String propVal) {
    assertNotNull(theQuery);
    CommonTree tree = theQuery.getTree();
    assertNotNull(tree);
	assertEquals(WhereClauseParser.PROPERTYNAME, tree.getChild(0).getType());
	assertTrue(propName.equals(tree.getChild(0).getText()));
	assertEquals(WhereClauseParser.PROPERTYVALUE, tree.getChild(1).getType());
	QueryHelper.walk(theQuery, new WalkerCallbackAdapter(){
		@Override
		public void matches(String propertyName, String propertyValue, boolean negated) {
			assertTrue("Property name should be "+propName,propName.equals(propertyName));
			assertTrue("Property value should be "+propVal,propVal.equals(propertyValue));
		}
		
	});
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:23,代码来源:WhereTests.java

示例5: buildFTSTest

import org.antlr.runtime.tree.CommonTree; //导入依赖的package包/类
static private Constraint buildFTSTest(CommonTree argNode, QueryModelFactory factory, FunctionEvaluationContext functionEvaluationContext,
        Selector selector, Map<String, Column> columnMap, String defaultField)
{
    CommonTree testNode = argNode;
    switch (testNode.getType())
    {
    case CMIS_FTSParser.DISJUNCTION:
    case CMIS_FTSParser.CONJUNCTION:
        return buildFTSConnective(testNode, factory, functionEvaluationContext, selector, columnMap, defaultField);
    case CMIS_FTSParser.TERM:
        return buildTerm(testNode, factory, functionEvaluationContext, selector, columnMap);
    case CMIS_FTSParser.PHRASE:
        return buildPhrase(testNode, factory, functionEvaluationContext, selector, columnMap);
    default:
        throw new FTSQueryException("Unsupported FTS option " + testNode.getText());
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:18,代码来源:CMISFTSQueryParser.java

示例6: inChecks

import org.antlr.runtime.tree.CommonTree; //导入依赖的package包/类
/**
 * Use by the inClauseTest
 * @param theQuery Query
 * @param propName String
 * @param values String...
 */
private void inChecks(Query theQuery, final String propName, final String... values) {
    assertNotNull(theQuery);
    CommonTree tree = theQuery.getTree();
    assertNotNull(tree);
	assertEquals(WhereClauseParser.IN, tree.getType());
	assertEquals(WhereClauseParser.PROPERTYNAME, tree.getChild(0).getType());
	assertTrue(propName.equals(tree.getChild(0).getText()));
	QueryHelper.walk(theQuery, new WalkerCallbackAdapter(){
		@Override
		public void in(String property, boolean negated, String... propertyValues) {
			assertTrue("Property name should be "+propName,propName.equals(property));
			for (int i = 0; i < values.length; i++) {
				assertTrue("Value must match:"+values[i],values[i].equals(propertyValues[i]));				
			}
		}
		
	});
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:25,代码来源:WhereTests.java

示例7: recursivelyFixWindowFucntion

import org.antlr.runtime.tree.CommonTree; //导入依赖的package包/类
public static void recursivelyFixWindowFucntion(
    CommonTree srcTree) {
    if (srcTree.getChildCount() == 0) { return; }

    // process node
 String text = srcTree.getText();
 System.out.println("Currently processed node==> " + text);
    if (text.equals(PARTITION_BY)) {
        return;
    } else if (text.equals(ORDER_BY)) {
		if (srcTree.getChildCount() == 0) {
			if (srcTree.getParent() != null) {
				// found a matching node
				srcTree.getParent().deleteChild(srcTree.getChildIndex());
				srcTree.getParent().freshenParentAndChildIndexes();
			}
		}
        return;
    }

    // process children
    for (Tree t : children(srcTree)) {
        recursivelyFixWindowFucntion((CommonTree)t);
    }
}
 
开发者ID:ajoabraham,项目名称:hue,代码行数:26,代码来源:TreePatcher.java

示例8: findAggFuncRecursively

import org.antlr.runtime.tree.CommonTree; //导入依赖的package包/类
private static Boolean findAggFuncRecursively(
    CommonTree tree,
    List<String> aggregateFuncs) {
    Boolean ret = false;
    
    if (tree.getText().equals(FUNCTION_CALL)) {
        // function
        String funcName = tree.getChild(0).getChild(0).getText(); //FUNCTION_CALL->QNAME->xxx
        if (aggregateFuncs.contains(funcName.toLowerCase())) {
            return true;
        }
    }
    
    for (Tree t : children(tree)) {
        ret = findAggFuncRecursively((CommonTree)t, aggregateFuncs);
        if (ret == true) {
            return true;
        }
    }
    
    return false;
}
 
开发者ID:ajoabraham,项目名称:hue,代码行数:23,代码来源:TreePatcher.java

示例9: patchTreeByTreesGroupBy

import org.antlr.runtime.tree.CommonTree; //导入依赖的package包/类
public static void patchTreeByTreesGroupBy(CommonTree srcTree, CommonTree targetTree)
{
    //System.out.println("Text = " + srcTree.getText() +  " ChildCount = " + srcTree.getChildCount() + " Type = " + srcTree.getType());
    if (srcTree.getChildCount() == 0) {
        return;
    }

    // process node
	if (srcTree.getText().equals(QUERY_SPEC_NODE)) {
		// patch
		targetTree.setParent(srcTree);
		srcTree.addChild(targetTree);
		return;
	}

    // process children
    for (Tree t : children(srcTree)) {
        patchTreeByTreesGroupBy((CommonTree)t, targetTree);
    }

    return;
}
 
开发者ID:ajoabraham,项目名称:hue,代码行数:23,代码来源:TreePatcher.java

示例10: gatherTypes

import org.antlr.runtime.tree.CommonTree; //导入依赖的package包/类
private static void gatherTypes(CommonTree srcTree, Map<String, Integer> typesMap)
{
    if (srcTree.getChildCount() == 0) {
        return;
    }

    // process node
	if (!typesMap.containsKey(srcTree.getText())) {
		typesMap.put(srcTree.getText(), new Integer(srcTree.getType()));
	}

    // process children
    for (Tree subTree : children(srcTree)) {
        gatherTypes((CommonTree)subTree, typesMap);
    }

    return;
}
 
开发者ID:ajoabraham,项目名称:hue,代码行数:19,代码来源:TreePatcher.java

示例11: createGroupByNode

import org.antlr.runtime.tree.CommonTree; //导入依赖的package包/类
public static CommonTree createGroupByNode(List<String> names)
{
	CommonTree groupByNode = createGenericNode(GENERIC_NODE);
	groupByNode.token.setText(GROUP_BY_NODE);
	//groupByNode.token.setType(80);
	groupByNode.token.setType(findType(GROUP_BY_NODE));
	groupByNode.deleteChild(0);

	for (String name : names) {
		CommonTree genericNode = createGenericNode(name);
		genericNode.setParent(groupByNode);
		groupByNode.addChild(genericNode);
	}

	return groupByNode;
}
 
开发者ID:ajoabraham,项目名称:hue,代码行数:17,代码来源:TreePatcher.java

示例12: updateTreeByString

import org.antlr.runtime.tree.CommonTree; //导入依赖的package包/类
public static void updateTreeByString(CommonTree tree, String target, String goal) {
    if (tree.getChildCount() == 0) {
        // leaf
		if (tree.getText().equals(target)) {
			//modifyText(tree, goal+'.'+target);
			modifyText(tree, goal);
			//System.out.println("Found 1!!!");
		}
		return;
    }

    // process node
	if (tree.getText().equals(target)) {
		modifyText(tree, goal+'.'+target);
		//System.out.println("Found 2!!!");
	}

    // process children
    for (Tree t : children(tree)) {
        updateTreeByString((CommonTree)t, target, goal);
    }

    return;
}
 
开发者ID:ajoabraham,项目名称:hue,代码行数:25,代码来源:TreePatcher.java

示例13: printExpression

import org.antlr.runtime.tree.CommonTree; //导入依赖的package包/类
public static void printExpression(String sql)
{
    println(sql.trim());
    println("");

    System.out.println("EXP Printing CommonTree toString...");
    CommonTree tree = VeroSqlParser.parseExpression(sql);
    println(TreePrinter.treeToString(tree));
    println("");

    System.out.println("EXP Printing AST toString...");
    Expression expression = VeroSqlParser.createExpression(tree);
    println(expression.toString());
    println("");

    System.out.println("EXP Printing Format sql toString...");
    // TODO: support formatting all statement types
    println(FormatterFactory.getSqlFormatter().formatSql(expression));
    println("");

    println(repeat("=", 60));
    println("");
}
 
开发者ID:ajoabraham,项目名称:hue,代码行数:24,代码来源:TreePrinter.java

示例14: printStatement

import org.antlr.runtime.tree.CommonTree; //导入依赖的package包/类
public static void printStatement(String sql)
{
    println(sql.trim());
    println("");

    System.out.println("STATE Printing CommonTree toString...");
    CommonTree tree = VeroSqlParser.parseStatement(sql);
    println(TreePrinter.treeToString(tree));
    println("");

    System.out.println("STATE Printing AST toString...");
    Statement statement = VeroSqlParser.createStatement(tree);
    println(statement.toString());
    println("");

    System.out.println("STATE Printing Format sql toString...");
    // TODO: support formatting all statement types
    if (statement instanceof Query) {
        println(FormatterFactory.getSqlFormatter().formatSql(statement));
        println("");
    }

    println(repeat("=", 60));
    println("");
}
 
开发者ID:ajoabraham,项目名称:hue,代码行数:26,代码来源:TreePrinter.java

示例15: toQualName

import org.antlr.runtime.tree.CommonTree; //导入依赖的package包/类
/** Creates a qualified name tree by extending an existing one
 * with an additional fragment in front.
 * @param init token holding the additional level text
 * @param subTree the existing tree; may be {@code null}, in which case
 * the result is calculated using {@link #toQualName(Token,Token)} with first
 * argument {@code null}
 */
CommonTree toQualName(Token init, CtrlTree subTree) {
    CtrlTree result;
    if (subTree == null || this.namespace.hasErrors()) {
        result = toQualName(null, init);
    } else {
        Token subTop = subTree.getToken();
        QualName qualName = subTree.getQualName()
            .nest(getText(init));
        CommonToken top = new CommonToken(subTop.getType(), qualName.toString());
        top.setLine(init.getLine());
        top.setTokenIndex(init.getTokenIndex());
        result = new CtrlTree(top);
        result.setQualName(qualName);
        result.addChild(subTree.getChild(0));
    }
    return result;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:25,代码来源:CtrlHelper.java


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