private static JXPathContext initialiseContext(NamespaceSupport ns, Document doc) { JXPathContext context = JXPathContext.newContext(doc); addNamespaces(ns, context); context.setLenient(true); return context; }
public Object get(Object object, String xpath, Class target) throws IllegalArgumentException { JXPathContext context = JXPathContext.newContext(object); context.setLenient(true); Object value = context.getValue(xpath); return value; }
/** * Creates a new {@code JXPathContext} based on the passed in arguments. * * @param root the root node * @param handler the node handler * @param <T> the type of the nodes to be handled * @return the newly created context */ public <T> JXPathContext createContext(final T root, final NodeHandler<T> handler) { final JXPathContext context = JXPathContext.newContext(ConfigurationNodePointerFactory .wrapNode(root, handler)); context.setLenient(true); return context; } }
protected boolean stream(ElementHandler handler) { // create an xpath context from the root element // TODO: cache the context, should work just the same // JXPathIntrospector.registerDynamicClass(ElementHandlerImpl.class, // ElementHandlerPropertyHandler.class); JXPathIntrospector.registerDynamicClass(NodeImpl.class, NodePropertyHandler.class); // ElementHandler rootHandler = // ((DocumentHandler) handlers.firstElement()).getDocumentElementHandler(); Node root = ((DocumentHandler) handlers.firstElement()).getParseNode(); JXPathContext jxpContext = JXPathContextFactory.newInstance().newContext(null, root); jxpContext.setLenient(true); Iterator itr = jxpContext.iterate(xpath); while (itr.hasNext()) { Object obj = itr.next(); if (handler.getParseNode().equals(obj)) { return true; } } return false; } }
private void applyLeniency(JXPathContext jxpc) { if (this.commonAtts.leniency != null) { jxpc.setLenient(this.commonAtts.leniency.booleanValue()); } }
/** * Creates the {@code JXPathContext} used for executing a query. This * method will create a new context and ensure that it is correctly * initialized. * * @param root the configuration root node * @param key the key to be queried * @return the new context */ protected JXPathContext createContext(ConfigurationNode root, String key) { JXPathContext context = JXPathContext.newContext(root); context.setLenient(true); return context; }
JXPathContext context(Object object) { JXPathContext context = JXPathContextFactory.newInstance().newContext(null, object); context.setLenient(true); return context; } }
@Override public boolean apply(@Nullable String input) { JXPathContext context = JXPathContext.newContext(input); context.setLenient(true); return Objects.equal(context.getValue(valueXpath), context.getValue(inputXpath)); }
@Override public boolean apply(Object input) { JXPathContext jxpath = JXPathContext.newContext(input); // We should allow non-existing path, and let predicate handle it. jxpath.setLenient(true); Pointer pointer = jxpath.getPointer(xpath); return pointer != null && !(pointer instanceof NullPointer); }
JXPathContext context( Object object ) { JXPathContext context = JXPathContextFactory.newInstance().newContext( null, object ); context.setLenient( true ); return context; }
public Object get(Object object, String xpath, Class target) throws IllegalArgumentException { JXPathContext context = JXPathContext.newContext(object); context.setLenient(true); Object value = context.getValue(xpath); return value; }
private static JXPathContext initialiseContext(NamespaceSupport ns, Document doc) { JXPathContext context = JXPathContext.newContext(doc); addNamespaces(ns, context); context.setLenient(true); return context; }
/** * Gets value of object using xpath expression. * * @param object source object * @param index xpath expression * @return obtained value */ public static Object getXPathIndexedValue(Object object, String index) { JXPathContext context = JXPathContext.newContext(object); context.setLenient(true); return context.getValue(index); }
/** * Gets value of object using xpath expression. * * @param object source object * @param index xpath expression * @return obtained value */ public static Object getXPathIndexedValue(Object object, String index) { JXPathContext context = JXPathContext.newContext(object); context.setLenient(true); return context.getValue(index); }
JXPathContext context(Object object) { JXPathContext context = JXPathContextFactory.newInstance().newContext(null, object); context.setLenient(true); return context; } }
@SuppressWarnings("unchecked") @Override public boolean apply(Object input) { JXPathContext jxpath = JXPathContext.newContext(input); // We should allow non-existing path, and let predicate handle it. jxpath.setLenient(true); Object value = jxpath.getValue(xpath); return predicate.apply(value); }
/** * Gets a JXPath context for selecting and creating JSON nodes and values * * @return a JXPath context */ private JXPathContext getJXPath() { if (jxPath == null) { jxPath = JXPathContext.newContext(rootNode); jxPath.setFactory(new JsonMapFactory()); jxPath.setLenient(true); } return jxPath; }
public JXPathContext newContext(Object ctxObject) { JXPathContext context = JXPathContext.newContext(ctxObject); TypeUtils.setTypeConverter(new MyTypeConverter()); context.setFunctions(functionLibrary.getConverterFunctions()); context.setLenient(this.lenient); return context; }
/** access the jxpath context object for this object (lazily initialized) * @modified NWW - renamed, to avoid using 'get*' naming convention - otherwise * is accessed when traversing the tree, which leads to recursion and out of memory errors.*/ public final synchronized JXPathContext accessJXPathContext() { if (cxt == null) { this.cxt = JXPathContext.newContext(this); this.cxt.setLenient(true); FunctionLibrary lib = new FunctionLibrary(); this.cxt.setFunctions(lib); lib.addFunctions(new ClassFunctions(BaseBean.Fns.class,"fn")); } return cxt; } /** add a new funciton library to the xpath interpreter */
private JXPathContext getContext(ObjectModel objectModel) { // This could be made more efficient by caching the // JXPathContext within the Context object. JXPathContext jxobjectModel = JXPathContext.newContext(objectModel.get(ObjectModel.CONTEXTBEAN)); jxobjectModel.setVariables(new VariableAdapter(objectModel)); jxobjectModel.setLenient(this.lenient); jxobjectModel.setNamespaceContextPointer(new NamespacesTablePointer((NamespacesTable)objectModel.get(ObjectModel.NAMESPACE))); return jxobjectModel; }