public SequenceIterator getAnother() throws XPathException { SequenceIterator newBase = base.getAnother(); MappingFunction newAction = action; if (newAction instanceof StatefulMappingFunction) { newAction = ((StatefulMappingFunction)newAction).getAnother(); } return new MappingIterator(newBase, newAction); }
/** * Get an iterator that returns the result of atomizing the sequence delivered by the supplied * iterator * @param base the supplied iterator, the input to atomization * @return an iterator that returns atomic values, the result of the atomization */ public static SequenceIterator getAtomizingIterator(SequenceIterator base) { if (base instanceof AxisIterator) { return new AxisAtomizingIterator((AxisIterator)base); } return new MappingIterator(base, AtomizingFunction.getInstance()); }
/** * Get an iterator that returns the result of atomizing the sequence delivered by the supplied * iterator * @param base the supplied iterator, the input to atomization * @return an iterator that returns atomic values, the result of the atomization */ public static SequenceIterator getAtomizingIterator(SequenceIterator base) { if (base instanceof AxisIterator) { return new AxisAtomizingIterator((AxisIterator)base); } return new MappingIterator(base, AtomizingFunction.getInstance()); }
public SequenceIterator getAnother() throws XPathException { SequenceIterator newBase = base.getAnother(); MappingFunction newAction = action instanceof StatefulMappingFunction ? ((StatefulMappingFunction)action).getAnother() : action; return new MappingIterator(newBase, newAction); }
/** * Get an iterator that returns the result of atomizing the sequence delivered by the supplied * iterator * @param base the supplied iterator, the input to atomization * @return an iterator that returns atomic values, the result of the atomization */ public static SequenceIterator getAtomizingIterator(SequenceIterator base) { if (base instanceof AxisIterator) { return new AxisAtomizingIterator((AxisIterator)base); } return new MappingIterator(base, AtomizingFunction.getInstance()); }
/** * Get the typed value of a given input string. This method assumes that the input value * is valid according to this SimpleType * @param value the string whose typed value is required * @param resolver namespace resolver for namespace-sensitive content * @param nameChecker name checker for XML-version sensitive content */ public SequenceIterator getTypedValue(CharSequence value, NamespaceResolver resolver, NameChecker nameChecker) throws ValidationException { UnfailingIterator iter = new StringTokenIterator(value.toString()); ListTypeMappingFunction map = new ListTypeMappingFunction(); map.resolver = resolver; map.atomicType = (AtomicType)getItemType(); map.nameChecker = nameChecker; return new MappingIterator(iter, map); }
/** * Get the typed value of a given input string. This method assumes that the input value * is valid according to this SimpleType * @param value the string whose typed value is required * @param resolver namespace resolver for namespace-sensitive content * @param nameChecker name checker for XML-version sensitive content */ public SequenceIterator getTypedValue(CharSequence value, NamespaceResolver resolver, NameChecker nameChecker) throws ValidationException { UnfailingIterator iter = new StringTokenIterator(value.toString()); ListTypeMappingFunction map = new ListTypeMappingFunction(); map.resolver = resolver; map.atomicType = (AtomicType)getItemType(); map.nameChecker = nameChecker; return new MappingIterator(iter, map); }
/** * Select nodes in a document using this PatternFinder. * @param doc the document node at the root of a tree * @param context the dynamic evaluation context * @return an iterator over the selected nodes in the document. */ public SequenceIterator selectNodes(DocumentInfo doc, final XPathContext context) throws XPathException { AxisIterator allElements = doc.iterateAxis(Axis.DESCENDANT, NodeKindTest.ELEMENT); MappingFunction atts = new MappingFunction() { public SequenceIterator map(Item item) { return new PrependIterator((NodeInfo)item, ((NodeInfo)item).iterateAxis(Axis.ATTRIBUTE)); } }; SequenceIterator allAttributes = new MappingIterator(allElements, atts); ItemMappingFunction test = new ItemMappingFunction() { public Item map(Item item) { if ((matches((NodeInfo)item))) { return item; } else { return null; } } }; return new ItemMappingIterator(allAttributes, test); }
public SequenceIterator iterate(XPathContext context) throws XPathException { SequenceIterator iter = new SortedTupleIterator(context, select.iterate(context), comparators); return new MappingIterator(iter, TupleUnwrapper.getInstance()); }
/** * Select nodes in a document using this PatternFinder. * @param doc the document node at the root of a tree * @param context the dynamic evaluation context * @return an iterator over the selected nodes in the document. */ public SequenceIterator selectNodes(DocumentInfo doc, final XPathContext context) throws XPathException { AxisIterator allElements = doc.iterateAxis(Axis.DESCENDANT, NodeKindTest.ELEMENT); MappingFunction atts = new MappingFunction() { public SequenceIterator map(Item item) { return new PrependIterator((NodeInfo)item, ((NodeInfo)item).iterateAxis(Axis.ATTRIBUTE)); } }; SequenceIterator allAttributes = new MappingIterator(allElements, atts); ItemMappingFunction test = new ItemMappingFunction() { public Item map(Item item) { if ((matches((NodeInfo)item))) { return item; } else { return null; } } }; return new ItemMappingIterator(allAttributes, test); }
public SequenceIterator iterate(XPathContext context) throws XPathException { SequenceIterator iter = new SortedTupleIterator(context, select.iterate(context), comparators); return new MappingIterator(iter, TupleUnwrapper.getInstance()); }
/** * Get the typed value of a given input string. This method assumes that the input value * is valid according to this SimpleType * * @param value the string whose typed value is required * @param resolver namespace resolver for namespace-sensitive content * @param rules the type conversion rules to be used */ /*@NotNull*/ public AtomicSequence getTypedValue(/*@NotNull*/ CharSequence value, NamespaceResolver resolver, ConversionRules rules) throws ValidationException { Whitespace.Tokenizer iter = new Whitespace.Tokenizer(value); ListTypeMappingFunction map = new ListTypeMappingFunction(); map.resolver = resolver; map.atomicType = (AtomicType) getItemType(); map.rules = rules; try { return new AtomicArray(new MappingIterator<>(iter, map)); } catch (XPathException err) { throw new ValidationException(err); // should not happen } }
/** * Get an iterator over the nodes that have an id equal to one of the values is a set of whitespace separated * strings * @param doc The document to be searched * @param idrefs an iterator over a set of strings each of which is a string containing * zero or more whitespace-separated ID values to be found in the document * @return an iterator over the nodes whose ID is one of the specified values * @throws XPathException */ public static SequenceIterator getIdMultiple(DocumentInfo doc, SequenceIterator idrefs) throws XPathException { IdMappingFunction map = new IdMappingFunction(); map.document = doc; SequenceIterator result = new MappingIterator(idrefs, map); return new DocumentOrderIterator(result, LocalOrderComparer.getInstance()); }
/** * Get an iterator over the nodes that have an id equal to one of the values is a set of whitespace separated * strings * @param doc The document to be searched * @param idrefs an iterator over a set of strings each of which is a string containing * zero or more whitespace-separated ID values to be found in the document * @return an iterator over the nodes whose ID is one of the specified values * @throws XPathException */ public static SequenceIterator getIdMultiple(DocumentInfo doc, SequenceIterator idrefs) throws XPathException { IdMappingFunction map = new IdMappingFunction(); map.document = doc; SequenceIterator result = new MappingIterator(idrefs, map); return new DocumentOrderIterator(result, LocalOrderComparer.getInstance()); }
/** * Get the typed value of a given input string. This method assumes that the input value * is valid according to this SimpleType * * @param value the string whose typed value is required * @param resolver namespace resolver for namespace-sensitive content * @param rules the type conversion rules to be used */ /*@NotNull*/ public AtomicSequence getTypedValue(/*@NotNull*/ CharSequence value, NamespaceResolver resolver, ConversionRules rules) throws ValidationException { Whitespace.Tokenizer iter = new Whitespace.Tokenizer(value); ListTypeMappingFunction map = new ListTypeMappingFunction(); map.resolver = resolver; map.atomicType = (AtomicType) getItemType(); map.rules = rules; try { return new AtomicArray(new MappingIterator<>(iter, map)); } catch (XPathException err) { throw new ValidationException(err); // should not happen } }
/** * Get an iterator over the nodes that have an id equal to one of the values is a set of whitespace separated * strings * @param doc The document to be searched * @param idrefs an iterator over a set of strings each of which is a string containing * zero or more whitespace-separated ID values to be found in the document * @return an iterator over the nodes whose ID is one of the specified values * @throws XPathException */ public static SequenceIterator getIdMultiple(DocumentInfo doc, SequenceIterator idrefs) throws XPathException { IdMappingFunction map = new IdMappingFunction(); map.document = doc; SequenceIterator result = new MappingIterator(idrefs, map); return new DocumentOrderIterator(result, LocalOrderComparer.getInstance()); }
/** * Get an iterator over the nodes that have an id equal to one of the values is a set of whitespace separated * strings * * @param doc The document to be searched * @param idrefs an iterator over a set of strings each of which is a string containing * zero or more whitespace-separated ID values to be found in the document * @param operation distinguishes id() and element-with-id() * @return an iterator over the nodes whose ID is one of the specified values * @throws XPathException if an error occurs */ public static SequenceIterator getIdMultiple( TreeInfo doc, SequenceIterator<?> idrefs, int operation) throws XPathException { IdMappingFunction map = new IdMappingFunction(); map.document = doc; map.operation = operation; SequenceIterator<?> result = new MappingIterator<>(idrefs, map); return new DocumentOrderIterator(result, LocalOrderComparer.getInstance()); }
/** * Get an iterator over the nodes that have an id equal to one of the values is a set of whitespace separated * strings * * @param doc The document to be searched * @param idrefs an iterator over a set of strings each of which is a string containing * zero or more whitespace-separated ID values to be found in the document * @param operation distinguishes id() and element-with-id() * @return an iterator over the nodes whose ID is one of the specified values * @throws XPathException if an error occurs */ public static SequenceIterator getIdMultiple( TreeInfo doc, SequenceIterator<?> idrefs, int operation) throws XPathException { IdMappingFunction map = new IdMappingFunction(); map.document = doc; map.operation = operation; SequenceIterator<?> result = new MappingIterator<>(idrefs, map); return new DocumentOrderIterator(result, LocalOrderComparer.getInstance()); }
/** * Iterate over the sequence of values */ public SequenceIterator iterate(XPathContext context) throws XPathException { // First create an iteration of the base sequence. // Then create a MappingIterator which applies a mapping function to each // item in the base sequence. The mapping function is essentially the "return" // expression, wrapped in a MappingAction object that is responsible also for // setting the range variable at each step. SequenceIterator base = sequence.iterate(context); int pslot = (positionVariable == null ? -1 : positionVariable.getLocalSlotNumber()); MappingFunction map = new MappingAction(context, getLocalSlotNumber(), pslot, action); return new MappingIterator(base, map); }
/** * Iterate over the sequence of values */ public SequenceIterator iterate(XPathContext context) throws XPathException { // First create an iteration of the base sequence. // Then create a MappingIterator which applies a mapping function to each // item in the base sequence. The mapping function is essentially the "return" // expression, wrapped in a MappingAction object that is responsible also for // setting the range variable at each step. SequenceIterator base = sequence.iterate(context); int pslot = (positionVariable == null ? -1 : positionVariable.getLocalSlotNumber()); MappingFunction map = new MappingAction(context, getLocalSlotNumber(), pslot, action); return new MappingIterator(base, map); }