/**
* Walks an expression path (a path that starts with an expression)
*/
protected Object expressionPath(EvalContext evalContext, boolean firstMatch){
Object value = expression.compute(evalContext);
EvalContext context;
if (value instanceof InitialContext){
// This is an optimization. We can avoid iterating through a collection
// if the context bean is in fact one.
context = (InitialContext)value;
}
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 UnionContext)){
EvalContext ctx = context;
NodePointer ptr = (NodePointer)ctx.getSingleNodePointer();
if (ptr != null &&
(ptr.getIndex() == NodePointer.WHOLE_COLLECTION ||
predicates == null || predicates.length == 0)){
NodePointer pointer = SimplePathInterpreter.
interpretPredicates(evalContext, ptr, predicates);