Пример #1
0
 // find the next local match
 @Override
 public boolean matches() {
   // System.out.println(toString());
   // System.out.println(namesToNodes);
   // System.err.println("matches: " + myNode.reln);
   // this is necessary so that a negated/optional node matches only once
   if (finished) {
     // System.out.println(false);
     return false;
   }
   while (!finished) {
     if (matchChild()) {
       if (myNode.isNegated()) {
         // negated node only has to fail once
         finished = true;
         return false; // cannot be optional and negated
       } else {
         if (myNode.isOptional()) {
           finished = true;
         }
         // System.out.println(true);
         return true;
       }
     } else {
       goToNextNodeMatch();
     }
   }
   if (myNode.isNegated()) { // couldn't match my relation/pattern, so
     // succeeded!
     return true;
   } else { // couldn't match my relation/pattern, so failed!
     nextMatch = null;
     decommitVariableGroups();
     decommitNamedNodes();
     decommitNamedRelations();
     // didn't match, but return true anyway if optional
     return myNode.isOptional();
   }
 }