use of org.apache.commons.jxpath.JXPathContext in project freud by LMAX-Exchange.
the class MethodCallJdom method getMethodName.
@SuppressWarnings("unchecked")
public String getMethodName() {
if (methodName == null) {
final Attribute idAttr = methodCallElement.getAttribute(JdomTreeAdaptor.ID_ATTR);
if (idAttr != null) {
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();
instanceReferences = new String[methodNameIndex];
for (int i = 0, size = instanceReferences.length; i < size; i++) {
instanceReferences[i] = identElementList.get(i).getText();
}
}
}
return methodName;
}
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;
}
use of org.apache.commons.jxpath.JXPathContext in project opennms by OpenNMS.
the class JsonCollectorArrayIT method testXpath.
@Test
@SuppressWarnings("unchecked")
public void testXpath() throws Exception {
JSONObject json = MockDocumentBuilder.getJSONDocument();
JXPathContext context = JXPathContext.newContext(json);
Iterator<Pointer> itr = context.iteratePointers("/elements[4]/it");
Assert.assertTrue(itr.hasNext());
Assert.assertEquals(itr.next().getValue(), "works");
Assert.assertFalse(itr.hasNext());
}
use of org.apache.commons.jxpath.JXPathContext in project galley by Commonjava.
the class JXPathUtils method newContext.
public static JXPathContext newContext(final Node node) {
final JXPathContext ctx = JXPathContext.newContext(node);
ctx.setLenient(true);
ctx.setFunctions(new ClassFunctions(ResolveFunctions.class, "ext"));
return ctx;
}
Aggregations