Package org.apache.commons.jxpath

Examples of org.apache.commons.jxpath.JXPathContext.selectNodes()


            JXPathContext context = JXPathContext.newContext(classDeclElement);
            innerClassDeclarationByNameMap = new LinkedHashMap<String, ClassDeclaration>();
            for (JavaSourceTokenType tokenType : POSSIBLE_CLASS_DECLARATION_TYPES) {
                final String tokenName = tokenType.getName();
                List<Element> innerClassElementList =
                        context.selectNodes("/" + CLASS_TOP_LEVEL_SCOPE.getName() + "/" + tokenName);
                for (Element innerClassElement : innerClassElementList) {
                    ClassDeclaration innerClass = new ClassDeclarationJdom(innerClassElement, DeclarationType.valueOf(tokenName), this);
                    innerClassDeclarationByNameMap.put(innerClass.getName(), innerClass);
                }
            }
View Full Code Here


    public Map<String, List<MethodCall>> getMethodCallByMethodNameMap() {
        if (methodCallByMethodNameMap == null) {
            methodCallByMethodNameMap = new HashMap<String, List<MethodCall>>();
            JXPathContext context = JXPathContext.newContext(codeBlockElement);
            List<Element> methodCallElementList =
                    context.selectNodes("//" + JavaSourceTokenType.METHOD_CALL.getName());
            for (Element methodCallElement : methodCallElementList) {
                final MethodCall methodCall = new MethodCallJdom(methodCallElement);
                List<MethodCall> methodCallList = methodCallByMethodNameMap.get(methodCall.getMethodName());
                if (methodCallList == null) {
                    methodCallList = new LinkedList<MethodCall>();
View Full Code Here

                methodName = idAttr.getValue();
                instanceReferences = EMPTY_ARRAY;
            }
            else {
                JXPathContext context = JXPathContext.newContext(methodCallElement);
                final List<Element> identElementList = context.selectNodes("//" + JavaSourceTokenType.IDENT.getName());

                Collections.sort(identElementList, JdomTreePositionComparator.getInstance());

                final int methodNameIndex = identElementList.size() - 1;
                methodName = identElementList.get(methodNameIndex).getText();
View Full Code Here

        final Element expr = (Element) context.selectSingleNode("/" + JavaSourceTokenType.EXPR.name() + "/*");
        if (expr != null) {
            return expr.getText();
        }
        else {
            final List<Element> exprList = context.selectNodes("//" + JavaSourceTokenType.EXPR.name() + "/*");
            StringBuilder sb = new StringBuilder("{");
            for (Element item : exprList) {
                sb.append(item.getText()).append(",");
            }
            sb.setCharAt(sb.length() - 1, '}');
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    public static FuzzyXMLNode[] selectNodes(FuzzyXMLElement element,String xpath){
        JXPathContext ctx = JXPathContext.newContext(element);
        List<FuzzyXMLNode> list = ctx.selectNodes(xpath);
        return list.toArray(new FuzzyXMLNode[list.size()]);
    }
   
    public static Object getValue(FuzzyXMLElement element,String xpath){
        JXPathContext ctx = JXPathContext.newContext(element);
View Full Code Here

            return result;
        }
        else
        {
            JXPathContext context = createContext(root, key);
            List result = context.selectNodes(key);
            return (result != null) ? result : Collections.EMPTY_LIST;
        }
    }

    /**
 
View Full Code Here

        }
        Node root = ((Document) result.getNode()).getDocumentElement();
        JXPathContext ctx = JXPathContext.newContext(root);

        assertEquals("Wrong name of root element", "config", root.getNodeName());
        assertEquals("Wrong number of children of root", 1, ctx.selectNodes(
                "/*").size());
        assertEquals("Wrong number of tables", 2, ctx.selectNodes(
                "/tables/table").size());
        assertEquals("Wrong name of first table", "users", ctx
                .getValue("/tables/table[1]/name"));
View Full Code Here

        JXPathContext ctx = JXPathContext.newContext(root);

        assertEquals("Wrong name of root element", "config", root.getNodeName());
        assertEquals("Wrong number of children of root", 1, ctx.selectNodes(
                "/*").size());
        assertEquals("Wrong number of tables", 2, ctx.selectNodes(
                "/tables/table").size());
        assertEquals("Wrong name of first table", "users", ctx
                .getValue("/tables/table[1]/name"));
        assertEquals("Wrong number of fields in first table", 5, ctx
                .selectNodes("/tables/table[1]/fields/field").size());
View Full Code Here

                "/*").size());
        assertEquals("Wrong number of tables", 2, ctx.selectNodes(
                "/tables/table").size());
        assertEquals("Wrong name of first table", "users", ctx
                .getValue("/tables/table[1]/name"));
        assertEquals("Wrong number of fields in first table", 5, ctx
                .selectNodes("/tables/table[1]/fields/field").size());
        assertEquals("Wrong attribute value", "system", ctx
                .getValue("/tables/table[1]/@tableType"));
    }
}
View Full Code Here

        }
        Node root = ((Document) result.getNode()).getDocumentElement();
        JXPathContext ctx = JXPathContext.newContext(root);
       
        assertEquals("Wrong root name", rootName, root.getNodeName());
        assertEquals("Wrong number of children", 3, ctx.selectNodes("/*").size());

        check(ctx, "world/continents/continent", CONTINENTS);
        check(ctx, "world/greeting", new String[] { "Hello", "Salute" });
        check(ctx, "world/wish", "Peace");
        check(ctx, "application/mail/smtp", "smtp.mymail.org");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.