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


Java CommonTree.getChildCount方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: buildDisjunction

import org.antlr.runtime.tree.CommonTree; //导入方法依赖的package包/类
/**
 * @param orNode CommonTree
 * @param factory QueryModelFactory
 * @param functionEvaluationContext FunctionEvaluationContext
 * @param selectors Map<String, Selector>
 * @param columnMap HashMap<String, Column>
 * @return Constraint
 */
private Constraint buildDisjunction(CommonTree orNode, QueryModelFactory factory,
        FunctionEvaluationContext functionEvaluationContext, Map<String, Selector> selectors,
        HashMap<String, Column> columnMap)
{
    List<Constraint> constraints = new ArrayList<Constraint>(orNode.getChildCount());
    for (int i = 0; i < orNode.getChildCount(); i++)
    {
        CommonTree andNode = (CommonTree) orNode.getChild(i);
        Constraint constraint = buildConjunction(andNode, factory, functionEvaluationContext, selectors, columnMap);
        constraints.add(constraint);
    }
    if (constraints.size() == 1)
    {
        return constraints.get(0);
    } else
    {
        return factory.createDisjunction(constraints);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:28,代码来源:CMISQueryParser.java

示例7: buildConjunction

import org.antlr.runtime.tree.CommonTree; //导入方法依赖的package包/类
/**
 * @param andNode CommonTree
 * @param factory QueryModelFactory
 * @param functionEvaluationContext FunctionEvaluationContext
 * @param selectors Map<String, Selector>
 * @param columnMap HashMap<String, Column>
 * @return Constraint
 */
private Constraint buildConjunction(CommonTree andNode, QueryModelFactory factory,
        FunctionEvaluationContext functionEvaluationContext, Map<String, Selector> selectors,
        HashMap<String, Column> columnMap)
{
    List<Constraint> constraints = new ArrayList<Constraint>(andNode.getChildCount());
    for (int i = 0; i < andNode.getChildCount(); i++)
    {
        CommonTree notNode = (CommonTree) andNode.getChild(i);
        Constraint constraint = buildNegation(notNode, factory, functionEvaluationContext, selectors, columnMap);
        constraints.add(constraint);
    }
    if (constraints.size() == 1 && constraints.get(0).getOccur() != Occur.EXCLUDE)
    {
        return constraints.get(0);
    } else
    {
        return factory.createConjunction(constraints);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:28,代码来源:CMISQueryParser.java

示例8: convertSub

import org.antlr.runtime.tree.CommonTree; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static Expression<?> convertSub(CommonTree node) {
	if (node.getChildCount() == 1) {
		return new UnaryMinusExpression<Object>(convertExpressionNode(childAt(0, node)));
	} else {
		SubtractionExpression result = new SubtractionExpression();
		for (CommonTree child : getChildNodes(node))
			result.addTerm(convertExpressionNode(child));
		return result;
	}
}
 
开发者ID:aravindc,项目名称:jdbacl,代码行数:12,代码来源:SQLParserUtil.java

示例9: printTree

import org.antlr.runtime.tree.CommonTree; //导入方法依赖的package包/类
private static void printTree(CommonTree t, int indent) {		
	if ( t != null ) {
		indent(indent);
		System.out.println(t.toString());
		for (int i = 0; i < t.getChildCount(); i++ ) {
			printTree((CommonTree)t.getChild(i), indent+1);
		}
	}
}
 
开发者ID:amritbhat786,项目名称:DocIT,代码行数:10,代码来源:Parsing.java

示例10: recursivelyPatchWindowFunction

import org.antlr.runtime.tree.CommonTree; //导入方法依赖的package包/类
private static void recursivelyPatchWindowFunction(
   	CommonTree srcTree,
   	List<String> partitionByToRemove,
   	List<String> orderByToRemove) {
       if (srcTree.getChildCount() == 0) { return; }

       // process node
       if (srcTree.getText().equals(PARTITION_BY)) {
           treeRemoveItem(srcTree, QNAME, partitionByToRemove);
           if (srcTree.getChildCount() == 0) {
               if (srcTree.getParent() != null) {
   				srcTree.getParent().deleteChild(srcTree.getChildIndex());
   				srcTree.getParent().freshenParentAndChildIndexes();
               }
           }
           return;
       } else if (srcTree.getText().equals(ORDER_BY)) {
           // 20150311 ToDo: need to apply partition_by solution but order by has asc/desc to string...
           treeRemoveItem(srcTree, ORDER_BY_ITEM, orderByToRemove);
           if (srcTree.getChildCount() == 0) {
               if (srcTree.getParent() != null) {
   				srcTree.getParent().deleteChild(srcTree.getChildIndex());
   				srcTree.getParent().freshenParentAndChildIndexes();
               }
           }
           return;
       }

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

示例11: patchTreeByTree

import org.antlr.runtime.tree.CommonTree; //导入方法依赖的package包/类
public static void patchTreeByTree(CommonTree srcTree, String target, CommonTree goalTree)
{
    if (srcTree.getChildCount() == 0) {
        // leaf
		//System.out.println("leaf " + srcTree.getToken().getText());
		if (srcTree.getToken().getText().equals(target)) {
			srcTree.deleteChild(0);
			srcTree.addChild(goalTree);
			System.out.println("Found 1!!!");
		}
		return;
    }

    // process node
    System.out.println("node " + srcTree.getToken().getText());
    if (srcTree.getToken().getText().equals(target)) {
		srcTree.deleteChild(0);
		srcTree.addChild(goalTree);
		//System.out.println("Found 2!!!");
    }

    // process children
    for (Tree t : children(srcTree)) {
        patchTreeByTree((CommonTree)t, target, goalTree);
    }

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

示例12: isAutoPhrasable

import org.antlr.runtime.tree.CommonTree; //导入方法依赖的package包/类
private static boolean isAutoPhrasable(CommonTree node, boolean defaultConjunction) {
	if((node.getType() == FTSParser.CONJUNCTION) && (node.getChildCount() > 1))
	{
		int simpleTermCount = 0;
		for (Object current : node.getChildren())
		{
			CommonTree child = (CommonTree) current;
			if((child.getType() ==  FTSParser.MANDATORY) || (child.getType() ==  FTSParser.DEFAULT))
			{
				if(child.getChildCount() > 0)
				{
					CommonTree item = (CommonTree)child.getChild(0);
					if((item.getType() == FTSParser.TERM) && (item.getChildCount() == 1))
					{
						simpleTermCount++;
					}
				}
			}
			else
			{
				return false;
			}
		}
		return simpleTermCount > 1;
	}

	return false;

}
 
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:30,代码来源:FTSQueryParser.java

示例13: setBoost

import org.antlr.runtime.tree.CommonTree; //导入方法依赖的package包/类
static private void setBoost(Constraint constraint, CommonTree subNode)
{
    for (int i = 0, l = subNode.getChildCount(); i < l; i++)
    {
        CommonTree child = (CommonTree) subNode.getChild(i);
        if (child.getType() == FTSParser.BOOST)
        {
            String boostString = child.getChild(0).getText();
            float boost = Float.parseFloat(boostString);
            constraint.setBoost(boost);
            return;
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:15,代码来源:FTSQueryParser.java

示例14: isStarWithNoField

import org.antlr.runtime.tree.CommonTree; //导入方法依赖的package包/类
private static boolean isStarWithNoField(CommonTree testNode)
{
    if (testNode.getType() == FTSParser.TERM && testNode.getChildCount() == 1)
    {
        CommonTree child = (CommonTree) testNode.getChild(0);
        if (child.getType() == FTSParser.STAR)
        {
            return true;
        }
    }
    return false;
}
 
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:13,代码来源:FTSQueryParser.java

示例15: findFieldReference

import org.antlr.runtime.tree.CommonTree; //导入方法依赖的package包/类
static private CommonTree findFieldReference(CommonTree node)
{
    for (int i = 0, l = node.getChildCount(); i < l; i++)
    {
        CommonTree child = (CommonTree) node.getChild(i);
        if (child.getType() == FTSParser.FIELD_REF)
        {
            return child;
        }
    }
    return null;
}
 
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:13,代码来源:FTSQueryParser.java


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