}
public Object evaluate(Context context) throws JaxenException
{
List contextNodeSet = new ArrayList();
Map unique = new IdentityHashMap();
contextNodeSet.addAll( context.getNodeSet() );
Object eachContextNode = null;
Iterator stepIter = getSteps().iterator();
Step eachStep = null;
List newNodeSet = new ArrayList();
int contextSize = 0;
OUTTER:
while ( stepIter.hasNext() )
{
eachStep = (Step) stepIter.next();
contextSize = contextNodeSet.size();
INNER:
for ( int i = 0 ; i < contextSize ; ++i )
{
eachContextNode = contextNodeSet.get( i );
Iterator axisNodeIter = eachStep.axisIterator( eachContextNode,
context.getContextSupport() );
if ( axisNodeIter == null )
{
continue INNER;
}
Object eachAxisNode = null;
List interimSet=new ArrayList();
while ( axisNodeIter.hasNext() )
{
eachAxisNode = axisNodeIter.next();
// System.err.println( "----> " + eachAxisNode + " // " + eachStep.matches( eachAxisNode, context.getContextSupport() ) );
if ( eachStep.matches( eachAxisNode,
context.getContextSupport() ) )
{
if ( ! unique.containsKey( eachAxisNode ) )
{
unique.put( eachAxisNode,
PRESENT );
interimSet.add( eachAxisNode );
}
}
}
List filtered = eachStep.getPredicateSet().evaluatePredicates(interimSet,context.getContextSupport() );
newNodeSet.addAll(filtered);
}
contextNodeSet.clear();
contextNodeSet.addAll( newNodeSet );
newNodeSet.clear();
unique.clear();
}
return contextNodeSet;
}