}
else if (value instanceof EvalContext) {
// UnionContext will collect all values from the "value" context
// and treat the whole thing as a big collection.
context =
new UnionContext(
evalContext,
new EvalContext[] {(EvalContext) value });
}
else {
context = evalContext.getRootContext().getConstantContext(value);
}
if (firstMatch
&& isSimpleExpressionPath()
&& !(context instanceof NodeSetContext)) {
EvalContext ctx = context;
NodePointer ptr = (NodePointer) ctx.getSingleNodePointer();
if (ptr != null
&& (ptr.getIndex() == NodePointer.WHOLE_COLLECTION
|| predicates == null
|| predicates.length == 0)) {
return SimplePathInterpreter.interpretSimpleExpressionPath(
evalContext,
ptr,
predicates,
getSteps());
}
}
if (predicates != null) {
for (int j = 0; j < predicates.length; j++) {
if (j != 0) {
context = new UnionContext(context, new EvalContext[]{context});
}
context = new PredicateContext(context, predicates[j]);
}
}
return firstMatch ? (Object) getSingleNodePointerForSteps(context)