List of usage examples for org.apache.commons.jxpath JXPathContext newContext
public static JXPathContext newContext(Object contextBean)
From source file:com.technofovea.hl2parse.vdf.PropDataReader.java
public PropDataReader(VdfRoot rootNode) { root = rootNode; context = JXPathContext.newContext(root); JxPathUtil.addFunctions(context); }
From source file:com.technofovea.hl2parse.registry.ClientRegistry.java
public ClientRegistry(BlobFolder root) throws BlobParseFailure { this.root = root; ctx = JXPathContext.newContext(root); JxPathUtil.addFunctions(ctx); cdr = createCdr(); }
From source file:net.sf.ahtutils.report.jxpath.TestDataTypesJXpath.java
@Test public void test() { TestDataStructure structure = new TestDataStructure(); //structure.setIntegerValue(1); //structure.setLongValue(2); JXPathContext context = JXPathContext.newContext(structure); String queryInteger = "@integerValue"; String queryLong = "@longValue"; Iterator iteratorLong = context.iteratePointers(queryLong); while (iteratorLong.hasNext()) { Pointer pointerToItem = (Pointer) iteratorLong.next(); System.out.println("Got pointer: " + pointerToItem.getValue().getClass() + " with value = " + pointerToItem.getValue().toString()); }/*from ww w .j av a 2 s. c om*/ Iterator iteratorInteger = context.iteratePointers(queryInteger); while (iteratorInteger.hasNext()) { Pointer pointerToItem = (Pointer) iteratorInteger.next(); System.out.println("Got pointer: " + pointerToItem.getValue().getClass() + " with value = " + pointerToItem.getValue().toString()); } }
From source file:com.abien.patterns.business.lazy.JXPathTest.java
@Test public void lazyLoadOneToOne() { Object value = JXPathContext.newContext(master).getValue("/detail"); assertNotNull(value); }
From source file:com.yahoo.xpathproto.ImageHandler.java
@Override public List<Message.Builder> getRepeatedProtoBuilder(JXPathContext context, Context vars, Config.Entry entry) { List<Message.Builder> builders = new ArrayList(); Iterator iterator = context.iterate(entry.getPath()); while (iterator.hasNext()) { Object value = iterator.next(); builders.add(copyObjectToImageAsset(JXPathContext.newContext(value))); }/*from w w w . jav a 2 s .co m*/ return builders; }
From source file:com.abien.patterns.business.lazy.JXPathTest.java
@Test public void lazyLoadOneToMany() { Object value = JXPathContext.newContext(master).getValue("/details"); assertNotNull(value);//from ww w.ja v a2s .co m assertTrue(value instanceof List); }
From source file:blueprint.sdk.util.JXPathHelper.java
/** * @param xpath XPath to evaluate//ww w . j a v a 2 s . c o m * @param target target node * @return Pointer or null(not found) */ public static Node evaluateNode(String xpath, Node target) { return evaluateNode(xpath, JXPathContext.newContext(target)); }
From source file:com.technofovea.hl2parse.vdf.GameInfoReader.java
public GameInfoReader(VdfRoot rootNode, File sourceFile) { this.sourceFile = sourceFile; root = rootNode; context = JXPathContext.newContext(root); JxPathUtil.addFunctions(context); }
From source file:com.discursive.jccook.collections.predicate.XPathPredicate.java
public boolean evaluate(Object object) { boolean matches = false; JXPathContext context = JXPathContext.newContext(object); if (variables != null) { populateVariables(context);//from ww w. ja v a2 s .c o m } try { Object value = context.getValue(path); if (value != null) { matches = true; } } catch (JXPathException e) { // If this happens there is no match } return matches; }
From source file:net.pickapack.util.JaxenHelper.java
/** * Evaluate the specified expression under the specified object. * * @param <T> the type of the node * @param object the parent object/*from w w w . java2 s . co m*/ * @param expression the selection expression * @return the evaluation result under the specified object using the specified expression */ @SuppressWarnings("unchecked") public static <T> T evaluate(Object object, String expression) { return (T) JXPathContext.newContext(object).getValue(expression); }