}
private boolean pass(DataElement element, int i)
{
boolean pass = true;
DataElement currentElement = element;
for (; i < _matches.size(); ++i)
{
Match match = _matches.get(i);
if (match.name == null)
{
int d = 0;
while (d < match.minDistance)
{
if (currentElement.getParent() == null)
{
pass = false;
break;
}
currentElement = currentElement.getParent();
++d;
}
if (pass == false)
{
break;
}
if (i == (_matches.size() - 1))
{
while (d < match.maxDistance && currentElement.getParent() != null)
{
currentElement = currentElement.getParent();
++d;
}
}
else
{
Match nextMatch = _matches.get(i + 1);
int searchDistance = (match.maxDistance == Integer.MAX_VALUE ?
Integer.MAX_VALUE :
match.maxDistance - match.minDistance + 1);
boolean matched = false;
while (searchDistance > 0 && currentElement.getParent() != null)
{
if (matchName(nextMatch, currentElement.getName()))
{
boolean subPass = pass(currentElement.getParent(), i + 2);
if (subPass)
{
matched = true;
i = _matches.size();
while (currentElement.getParent() != null)
{
currentElement = currentElement.getParent();
}
break;
}
}
searchDistance--;
currentElement = currentElement.getParent();
}
if (matched == false)
{
pass = false;
break;
}
break;
}
}
else
{
if (currentElement.getParent() == null || matchName(match, currentElement.getName()) == false)
{
pass = false;
break;
}
currentElement = currentElement.getParent();
}
}
if (pass)
{
assert(i == _matches.size());
pass = (currentElement.getParent() == null);
}
return pass;
}