class IntersectionProofNode extends ProofNode { private SolutionListener watcher = new IntersectionMonitor(); private int numOfParts; IntersectionProofNode(Intersection re) { super(re); numOfParts = re.numOfParts(); } void backwardProcess() { super.backwardProcess(); Iterator it = (Intersection)roleExp.getParts(); while (it.hasNext()) { EntityExpression re = (EntityExpression)it.next(); ProofNode node = addBackwardNode(firstRole); node.backwardMgr.addListener(watcher); } } class IntersectionMonitor implements SolutionListener { // Maps a solution to a counter, no source is needed private HashMap solutions; public void solutionAdded(ProofNode s, ProofSolution r) { debugInfo("Solution added: "+roleExp+"; "+s.roleExp+"; "+r); if (! solutions.containsKey(r)) { // first piece solutions.put(r, new Integer(1)); } else { int n = ((Integer)solutions.get(r)).intValue(); n ++; solutions.put(r, new Integer(n)); if (n == numOfParts) { // all pieces are found backwardMgr.solutionAdded(IntersectionProofNode.this, r); } } } } /* forwardProcess has nothing special void forwardProcess() { super.forwardProcess(); } */ } // End of class IntersectionProofNode