src/java/isac/util/interfaces/ICalcIterator.java
author mlang
Thu, 12 May 2005 18:19:58 +0200
changeset 2313 6be2c13f6199
parent 2312 cdcc19348255
child 2435 926013f3be28
permissions -rw-r--r--
java orignal again
     1 /*
     2  * Created on Sep 19, 2003
     3  */
     4 package isac.util.interfaces;
     5 
     6 import isac.util.formulae.Assumptions;
     7 import isac.util.formulae.CalcFormula;
     8 import isac.util.formulae.Position;
     9 import isac.util.tactics.Tactic;
    10 
    11 import java.rmi.Remote;
    12 import java.rmi.RemoteException;
    13 import java.util.Vector;
    14 
    15 /**
    16  * References a certain position in a CalcTree.
    17  * 
    18  * At such a Position there is (a) a Formula or a CalcHead (b) a Tactic which is
    19  * applicable to this Formula (Apply_Method is the only Tactic applicable to a
    20  * CalcHead) (c) an Assumption generated by application of this Tactic to this
    21  * Formula
    22  * Invariant: The Level changes at most +/- ONE when moveUp or moveDown.
    23  * 
    24  * a CalcIterator may be invalid,
    25  * 
    26  * @see isac.util.CalcChangedEvent#
    27  * 
    28  * Comments for the Dialog Guide # on 'applicable Tactic': if a Formula is also
    29  * a parent of some children (one LevelDown), there is also a 'DETAILED
    30  * applicable Tactic' generating the children. WN040920 presentation unclear #
    31  * on 'causal Tactic': this direction of investigation is opposite to the
    32  * applicablility of Tactics; investigating in this direction, for each Formula
    33  * the Tactic can befound which generated the Formula. The causal Tactic is
    34  * unique for each Formula, with the exception of Positions with moveLevelUp
    35  * (there is a 'DETAILED causal Tactic' analogously to 'DETAILED applicable
    36  * Tactic' at LevelDown)
    37  * 
    38  * @see isac.util.formulae.CalcElement
    39  * @see isac.bridge.CalcTree
    40  * @author Alan Krempler
    41  */
    42 public interface ICalcIterator extends Comparable, Cloneable, Remote {
    43 
    44     /**
    45      * get the marker 'Position' unique within a CalcTree (i.e. a CalcIterator)
    46      * 
    47      * @return Position
    48      */
    49     public Position getPosition() throws RemoteException;
    50 
    51     /**
    52      * Reference the first (root) element in the attached calculation tree.
    53      * 
    54      * @return Like all the moveXXX methods this returns true on success, false
    55      *         if there is no element to move to.
    56      */
    57     public boolean moveRoot() throws RemoteException;
    58 
    59     /**
    60      * Reference the next enclosing CalcHead element in the attached calculation
    61      * tree. This will be the subproblem being solved at the moment, or, if not
    62      * solving subproblems, the root problem of the calculation.
    63      * 
    64      * @return Like all the moveXXX methods this returns true on success, false
    65      *         if there is no element to move to.
    66      */
    67     public boolean moveCalcHead() throws RemoteException;
    68 
    69     /**
    70      * Reference the previous formula in the attached calculation tree.
    71      * 
    72      * @return Like all the moveXXX methods this returns true on success, false
    73      *         if there is no element to move to.
    74      */
    75     public boolean moveUp() throws RemoteException;
    76 
    77     /**
    78      * Reference the next formula in the attached calculation tree.
    79      * 
    80      * @return Like all the moveXXX methods this returns true on success, false
    81      *         if there is no element to move to.
    82      * 
    83      * moveRoot() plus moveDown() reaches all nodes in a CalcTree
    84      */
    85     public boolean moveDown() throws RemoteException;
    86 
    87     /**
    88      * Enter the next coarser level of refinement in the attached calculation
    89      * tree.
    90      * 
    91      * @return Like all the moveXXX methods this returns true on success, false
    92      *         if there is no element to move to.
    93      */
    94     public boolean moveLevelUp() throws RemoteException;
    95 
    96     /**
    97      * Enter the next more detailed level of refinement in the attached
    98      * calculation tree.
    99      * 
   100      * @return Like all the moveXXX methods this returns true on success, false
   101      *         if there is no element to move to.
   102      */
   103     public boolean moveLevelDown() throws RemoteException;
   104 
   105     /**
   106      * Reference the formula which resulted in the currently selected element of
   107      * the attached calculation tree.
   108      */
   109     public boolean moveFormula() throws RemoteException;
   110 
   111     /**
   112      * Ask whether this is the last Item, which is equivalent to whwther there
   113      * is another item where moveDown() could move to.
   114      * 
   115      * @return true, if moveDown() would not yield any new elements false, if
   116      *         moveDown() would move to another element WN040819 awaiting
   117      *         problems with parallel branches (OR, AND, etc.) in calcTree
   118      * @deprecated due to calcChangedEvent since 0512
   119      */
   120     public boolean isLast() throws RemoteException;
   121 
   122     /**
   123      * is the Iterator on a CalcHead or not
   124      */
   125     public boolean onCalcHead() throws RemoteException;
   126 
   127     /**
   128      * Use this to get the current element and check the type by calling
   129      * getType().
   130      * 
   131      * @return The currently referenced Element
   132      * @see #getType()
   133      * @deprecated due to getFormula, getTactic, getAssumption
   134      */
   135     public ICalcElement getElement() throws RemoteException;
   136 
   137     /**
   138      * @return Formula, which may also be a CalcHead !
   139      */
   140 
   141     public ICalcElement getFormula() throws RemoteException;
   142 
   143     /**
   144      * @return Tactic applicable to the formula under the Iterator
   145      */
   146     public Tactic getTactic() throws RemoteException;
   147 
   148     /**
   149      * Get a list of tactics applicable to the active formula.
   150      * 
   151      * @param scope
   152      *            WN0502 not yet impl. The filter parameter selects the scope of
   153      *            search for applicable tactics.
   154      * @return Vector with applicable tactics
   155      * @see #TACTICS_ALL
   156      * @see #TACTICS_CURRENT_THEORY
   157      * @see #TACTICS_CURRENT_METHOD
   158      */
   159     public Vector getApplicableTactics(int scope) throws RemoteException;
   160 
   161     /**
   162      * @return Assumptions generated by the Tactic applied to the formula, both
   163      *         under the same Iterator
   164      */
   165     public Assumptions getAssumptions() throws RemoteException;
   166 
   167     /**
   168      * @return Assumptions accumulated during calculation down to the formula
   169      *         under the Iterator ATTENTION: this returnvalue is also used by
   170      *         getAssumptions as long as getAccumulatedAssumptions does not
   171      *         include references to their _several_ sources -- i.e. change
   172      *         _this_ return, not that in getAssumptions !
   173      */
   174     public Assumptions getAccumulatedAssumptions() throws RemoteException;
   175 
   176     /**
   177      * The current level of nesting into subcalculations.
   178      * 
   179      * @return An int representing level of nesting (higher == more detailed)
   180      *         <p>
   181      *         Special values:
   182      *         <p>
   183      *         0: outmost level: only first and last step of calculation are on
   184      *         this level
   185      */
   186     public int getLevel() throws RemoteException;
   187 
   188     /**
   189      * Create a copy of this Iterator: the clone will point to the same formula
   190      * in the calcTree
   191      * 
   192      * @return a cloned Iterator
   193      */
   194     public Object clone();
   195 
   196     /**
   197      * for test-output
   198      * 
   199      * @return 'position', i.e. unique identifier in a CalcTree
   200      */
   201     public String toSMLString();
   202 
   203     //	/**
   204     //	 * Create a copy of this Iterator: the clone will point to the Position
   205     //	 * in the calcTree (Position may come from a formula in the worksheet)
   206     //	 *
   207     //	 * @return a cloned Iterator
   208     //	 */
   209     //	public ICalcIterator clone(Position p);
   210 
   211     //	/**
   212     //	 * @return the position unique within a calctree
   213     //	 * @see isac.uti.interfaces.ICalcIterator#clone(Position)
   214     //	 */
   215     //	public Position getSmlPos();
   216 }