/** @return true if the pattern matches the given node
*/
public boolean matches( Object node, Context context ) throws JaxenException
{
Navigator navigator = context.getNavigator();
/*
if ( isAbsolute() )
{
node = navigator.getDocumentNode( node );
}
*/
if (! nodeTest.matches(node, context) )
{
return false;
}
if (parentPattern != null)
{
Object parent = navigator.getParentNode( node );
if ( parent == null )
{
return false;
}
if ( ! parentPattern.matches( parent, context ) )
{
return false;
}
}
if (ancestorPattern != null) {
Object ancestor = navigator.getParentNode( node );
while (true)
{
if ( ancestorPattern.matches( ancestor, context ) )
{
break;
}
if ( ancestor == null )
{
return false;
}
if ( navigator.isDocument( ancestor ) )
{
return false;
}
ancestor = navigator.getParentNode( ancestor );
}
}
if (filters != null)
{