public Object convert(Sequence<?> value, Class<?> targetClass, XPathContext context) throws XPathException { NumericValue nv = (NumericValue) value.head(); assert nv != null; return nv.getDoubleValue(); }
/** * Iterate over the value of the expression */ /*@NotNull*/ public SequenceIterator<?> iterate(XPathContext context) throws XPathException { return call(context, null).iterate(); }
public MapItem call(XPathContext context, Sequence[] arguments) throws XPathException { MapItem baseMap = (MapItem) arguments[0].head(); if (!(baseMap instanceof HashTrieMap)) { baseMap = HashTrieMap.copy(baseMap); } AtomicValue key = (AtomicValue) arguments[1].head(); GroundedValue<?> value = ((Sequence<?>)arguments[2]).materialize(); return baseMap.addEntry(key, value); } }
public static Sequence<?> toSequence(ArrayItem array) throws XPathException { List<GroundedValue<?>> results = new ArrayList<>(); for (Sequence<?> seq : array.members()) { results.add(seq.materialize()); } return new Chain(results); } }
public static ArrayItem append(ArrayItem array, Sequence<?> member) throws XPathException { List<GroundedValue<?>> list = new ArrayList<>(1); list.add(member.materialize()); SimpleArrayItem otherArray = new SimpleArrayItem(list); return array.concat(otherArray); }
private String toYesNoTypeString(Sequence<?> seqVal) throws XPathException { String s; boolean booleanValue = ((BooleanValue) seqVal.head()).getBooleanValue(); if (booleanValue) { s = "yes"; } else { s = "no"; } return s; }
/** * Get the value of this expression in a given context. * * @param context the XPathContext which contains the relevant variable bindings * @return the value of the variable, if it is defined * @throws net.sf.saxon.trans.XPathException if the variable is undefined */ /*@NotNull*/ public SequenceIterator<?> iterate(XPathContext context) throws XPathException { return evaluate(context).iterate(); }
@Override public ArrayItem call(XPathContext context, Sequence[] arguments) throws XPathException { ArrayItem array = (ArrayItem) arguments[0].head(); int index = checkSubscript((IntegerValue) arguments[1].head()) - 1; GroundedValue<?> newVal = ((Sequence<?>)arguments[2]).materialize(); return array.put(index, newVal); }
public static Sequence<?> toSequence(ArrayItem array) throws XPathException { List<GroundedValue<?>> results = new ArrayList<>(); for (Sequence<?> seq : array.members()) { results.add(seq.materialize()); } return new Chain(results); } }
/** * Call the function, returning the value as an item. This method will be used * only when the cardinality is zero or one. If the function is tail recursive, * it returns an Object representing the arguments to the next (recursive) call */ public Item evaluateItem(XPathContext c) throws XPathException { return callFunction(c).head(); }
/** * Evaluate the expression in a given context to return an iterator over a sequence */ /*@NotNull*/ public synchronized SequenceIterator<Item<?>> iterate() throws XPathException { makeSequence(); return (SequenceIterator<Item<?>>)sequence.iterate(); }
/** * Dynamic evaluation * @param context the dynamic evaluation context * @param arguments the values of the arguments, supplied as Sequences. * * @return true if the search token is present in the input * @throws XPathException if a dynamic error occurs */ public BooleanValue call(XPathContext context, Sequence[] arguments) throws XPathException { return BooleanValue.get( containsToken(arguments[0].iterate(), (StringValue) arguments[1].head(), getStringCollator())); }
@Override public ArrayItem call(XPathContext context, Sequence[] arguments) throws XPathException { ArrayItem array = (ArrayItem) arguments[0].head(); int index = checkSubscript((IntegerValue) arguments[1].head()) - 1; GroundedValue<?> newVal = ((Sequence<?>)arguments[2]).materialize(); return array.put(index, newVal); }
/** * Get the value of the range variable */ public Sequence<?> evaluateVariable(XPathContext context) throws XPathException { Sequence<?> actual = context.evaluateLocalVariable(slotNumber); if (!(actual instanceof GroundedValue || actual instanceof NodeInfo)) { actual = actual.materialize(); context.setLocalVariable(slotNumber, actual); } return actual; }
public Object convert(Sequence<?> value, Class<?> targetClass, XPathContext context) throws XPathException { IntegerValue iv = (IntegerValue) value.head(); assert iv != null; return (byte) iv.longValue(); }
/** * Iterate over the value of the expression */ /*@NotNull*/ public SequenceIterator<?> iterate(XPathContext context) throws XPathException { return call(context, null).iterate(); }
/** * Dynamic evaluation * @param context the dynamic evaluation context * @param arguments the values of the arguments, supplied as Sequences. * * @return true if the search token is present in the input * @throws XPathException if a dynamic error occurs */ public BooleanValue call(XPathContext context, Sequence[] arguments) throws XPathException { return BooleanValue.get( containsToken(arguments[0].iterate(), (StringValue) arguments[1].head(), getStringCollator())); }