/** * Create a new UnionContext. * @param parentContext parent context * @param contexts child contexts */ public UnionContext(EvalContext parentContext, EvalContext[] contexts) { super(parentContext, new BasicNodeSet()); this.contexts = contexts; }
/** * Remove a pointer from this NodeSet. * @param pointer to remove */ public void remove(Pointer pointer) { if (pointers.remove(pointer)) { clearCacheLists(); } }
public NodeSet getNodeSetByKey(JXPathContext context, String key, Object value) { Pointer pointer = delegate.getPointerByKey(context, key, InfoSetUtil.stringValue(value)); BasicNodeSet result = new BasicNodeSet(); result.add(pointer); return result; }
@SuppressWarnings("rawtypes") @Override public Object convert(Object object, final Class toType) { if (object instanceof BasicNodeSet && ((BasicNodeSet) object).getValues().isEmpty()) { throw new JXPathNotFoundException("Could not find path in source"); } else { return super.convert(object, toType); } } }
public boolean setPosition(int position) { if (!prepared) { prepared = true; BasicNodeSet nodeSet = (BasicNodeSet) getNodeSet(); ArrayList pointers = new ArrayList(); for (int i = 0; i < contexts.length; i++) { EvalContext ctx = (EvalContext) contexts[i]; while (ctx.nextSet()) { while (ctx.nextNode()) { NodePointer ptr = ctx.getCurrentNodePointer(); if (!pointers.contains(ptr)) { pointers.add(ptr); } } } } sortPointers(pointers); for (Iterator it = pointers.iterator(); it.hasNext();) { nodeSet.add((Pointer) it.next()); } } return super.setPosition(position); } }
/** * Returns the list of all Pointers in this context for all positions * of the parent contexts. If there was an ongoing iteration over * this context, the method should not be called. * @return NodeSet */ public NodeSet getNodeSet() { if (position != 0) { throw new JXPathException( "Simultaneous operations: " + "should not request pointer list while " + "iterating over an EvalContext"); } BasicNodeSet set = new BasicNodeSet(); while (nextSet()) { while (nextNode()) { set.add((Pointer) getCurrentNodePointer().clone()); } } return set; }
return new NodeSetContext(context, new BasicNodeSet()); NodeSet nodeSet = jxpathContext.getNodeSetByKey(key, value); if (ec != null && ec.hasNext()) { BasicNodeSet accum = new BasicNodeSet(); accum.add(nodeSet); while (ec.hasNext()) { value = ((NodePointer) ec.next()).getValue(); accum.add(jxpathContext.getNodeSetByKey(key, value));
public static NodeSet getCustomers(String query){ List<Customer> l=getCustomersFromMyDatabase(query); BasicNodeSet bns=new BasicNodeSet(); putCustomersIntoNodeSet(bns,l); return bns; }
/** * Add a pointer to this NodeSet. * @param pointer to add */ public void add(Pointer pointer) { if (pointers.add(pointer)) { clearCacheLists(); } }
/** * Add the specified NodeSet to this NodeSet. * @param nodeSet to add */ public void add(NodeSet nodeSet) { if (pointers.addAll(nodeSet.getPointers())) { clearCacheLists(); } }