Search in sources :

Example 36 with JXPathContext

use of org.apache.commons.jxpath.JXPathContext in project freud by LMAX-Exchange.

the class AnnotationJdom method getAnnotationValueForElement.

private String getAnnotationValueForElement(final Element element) {
    final JXPathContext context = JXPathContext.newContext(element);
    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, '}');
        return sb.toString();
    }
}
Also used : JXPathContext(org.apache.commons.jxpath.JXPathContext) Element(org.jdom.Element)

Example 37 with JXPathContext

use of org.apache.commons.jxpath.JXPathContext in project freud by LMAX-Exchange.

the class MethodDeclarationJdom method getImplementation.

public CodeBlock getImplementation() {
    if (methodCodeBlock == null) {
        try {
            JXPathContext context = JXPathContext.newContext(methodDeclElement);
            Element codeBlockElement = (Element) context.selectSingleNode("/" + JavaSourceTokenType.BLOCK_SCOPE.getName());
            methodCodeBlock = CodeBlockJdom.createMethodImplementation(codeBlockElement, this, classDeclaration);
        } catch (JXPathException e) {
            return null;
        }
    }
    return methodCodeBlock;
}
Also used : JXPathContext(org.apache.commons.jxpath.JXPathContext) Element(org.jdom.Element) JXPathException(org.apache.commons.jxpath.JXPathException)

Aggregations

JXPathContext (org.apache.commons.jxpath.JXPathContext)37 Element (org.jdom.Element)12 JXPathException (org.apache.commons.jxpath.JXPathException)7 List (java.util.List)6 ArrayList (java.util.ArrayList)4 Document (org.w3c.dom.Document)4 Node (org.w3c.dom.Node)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 IOException (java.io.IOException)3 LinkedList (java.util.LinkedList)3 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)3 JXPathInvalidSyntaxException (org.apache.commons.jxpath.JXPathInvalidSyntaxException)3 Pointer (org.apache.commons.jxpath.Pointer)3 HttpResponse (org.apache.http.HttpResponse)3 StatusLine (org.apache.http.StatusLine)3 HttpClient (org.apache.http.client.HttpClient)3 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)3 DefaultHttpClient (org.apache.http.impl.client.DefaultHttpClient)3 Test (org.junit.Test)3 ModelJXPathContext (org.openforis.idm.model.expression.internal.ModelJXPathContext)3