Update of /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/ejb/sessionjb
In directory sc8-pr-cvs1:/tmp/cvs-serv31457
Modified Files:
StudentRoleBean.java
Added Files:
TreeOperations.java
Log Message:
Refactoring - Move some code from StudentRole to TreeOperations - Now Student role dont need to now TreeElement
--- NEW FILE: TreeOperations.java ---
/**
*
* Copyright 2003 Ivan Frade
*
* This file is part of Prolix.
*
* Prolix is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Prolix is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Prolix; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
**/
package org.asturlinux.frade.prolix.ejb.sessionjb;
import org.asturlinux.frade.prolix.interpreter.interfaces.TreeElement;
public class TreeOperations
{
public boolean isSolution(TreeElement tree)
{
CheckSolutionVisitor visitor = new CheckSolutionVisitor();
LastNodeTraversor tt = new LastNodeTraversor();
tt.visit(tree,visitor);
return visitor.getIsSolution();
}
public boolean getCompletlyExplored(TreeElement tree)
{
return tree.isCompletlyExplored();
}
}
Index: StudentRoleBean.java
===================================================================
RCS file: /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/ejb/sessionjb/StudentRoleBean.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** StudentRoleBean.java 29 Aug 2003 18:39:45 -0000 1.7
--- StudentRoleBean.java 29 Aug 2003 20:33:40 -0000 1.8
***************
*** 185,200 ****
}
- CheckSolutionVisitor visitor = new CheckSolutionVisitor();
-
TreeElement treeResult;
! LastNodeTraversor tt = new LastNodeTraversor();
do
{
treeResult = _prologCtx.step();
- tt.visit(treeResult,visitor);
}
! while (!visitor.getIsSolution() && !treeResult.isCompletlyExplored());
! setLastSolution(treeResult.isCompletlyExplored());
TransformationControl tc = new TransformationControl();
return tc.transformToTreeXml(treeResult);
--- 185,199 ----
}
TreeElement treeResult;
! TreeOperations guardian = new TreeOperations();
!
do
{
treeResult = _prologCtx.step();
}
! while (!guardian.isSolution(treeResult)
! && !guardian.getCompletlyExplored(treeResult));
! setLastSolution(guardian.getCompletlyExplored(treeResult));
TransformationControl tc = new TransformationControl();
return tc.transformToTreeXml(treeResult);
***************
*** 219,227 ****
TreeElement treeResult = _prologCtx.step();
if (treeResult == null) //FIXME Can be possible?
setLastSolution(false);
else
! setLastSolution(treeResult.isCompletlyExplored());
// FIXME: cache results
--- 218,227 ----
TreeElement treeResult = _prologCtx.step();
+ TreeOperations to = new TreeOperations();
if (treeResult == null) //FIXME Can be possible?
setLastSolution(false);
else
! setLastSolution(to.getCompletlyExplored(treeResult));
// FIXME: cache results
|