src/java/isac/bridge/CalcIterator.java
changeset 3881 72f0be16d83b
parent 3767 a93ffa479634
child 3928 d38196e9b162
equal deleted inserted replaced
3880:0b0dc38b1106 3881:72f0be16d83b
    34  * 
    34  * 
    35  * @author Richard Gradischnegg
    35  * @author Richard Gradischnegg
    36  */
    36  */
    37 public class CalcIterator implements ICalcIterator, Serializable {
    37 public class CalcIterator implements ICalcIterator, Serializable {
    38 
    38 
    39 	
    39     private static final Logger logger = Logger.getLogger(CalcIterator.class
       
    40             .getName());
       
    41 
    40     private CalcTree calc_tree_;
    42     private CalcTree calc_tree_;
    41 
    43 
    42     private int calc_tree_id_;//from SML + mapped by
    44     private int calc_tree_id_;// from SML + mapped by
    43     
    45 
    44     private static final long serialVersionUID = 36493649573845958L;
    46     private static final long serialVersionUID = 36493649573845958L;
    45 
    47 
    46     // smlCalcIDtoJavaCalcID(int);
    48     // smlCalcIDtoJavaCalcID(int);
    47 
    49 
    48     //iterator_id_ from SML TODO.WN041116 drop with new Iterator, which is NOT
    50     // iterator_id_ from SML TODO.WN041116 drop with new Iterator, which is NOT
    49     // stored in sml-kernel any more
    51     // stored in sml-kernel any more
    50     private int iterator_id_;
    52     private int iterator_id_;
    51 
    53 
    52     //WN041209 i.e. + SML: make 'Iterator n 1' implicit to 'CalcTree n' ?
    54     // WN041209 i.e. + SML: make 'Iterator n 1' implicit to 'CalcTree n' ?
    53 
    55 
    54     private Position sml_pos_;//unique within the sml calctree
    56     private Position sml_pos_;// unique within the sml calctree
    55 
       
    56     static Logger logger_ = Logger.getLogger(CalcIterator.class.getName());
       
    57 
    57 
    58     /**
    58     /**
    59      * Construct a new calculation element iterator object attached to the
    59      * Construct a new calculation element iterator object attached to the
    60      * passed calculation tree
    60      * passed calculation tree
    61      * 
    61      * 
    62      * @param calcTree
    62      * @param calcTree
    63      *            calculation tree
    63      *            calculation tree
    64      */
    64      */
    65     protected CalcIterator(CalcTree calcTree) {
    65     protected CalcIterator(CalcTree calcTree) {
    66         logger_.debug("CalcIterator(new Position)");
    66         if (logger.isDebugEnabled())
       
    67             logger.debug("CalcIterator(new Position)");
    67         this.setSmlPos(new Position());
    68         this.setSmlPos(new Position());
    68         this.calc_tree_ = calcTree;
    69         this.calc_tree_ = calcTree;
    69         this.calc_tree_id_ = calcTree.getId();
    70         this.calc_tree_id_ = calcTree.getId();
    70         //		try {
    71         // try {
    71         //			this.iterator_id_ = calcTree.getMathEngine().iterator(calc_tree_id_);
    72         // this.iterator_id_ = calcTree.getMathEngine().iterator(calc_tree_id_);
    72         //		} catch (RemoteException e) {
    73         // } catch (RemoteException e) {
    73         //		
    74         //		
    74         //			e.printStackTrace();
    75         // e.printStackTrace();
    75         //	    }
    76         // }
    76         this.iterator_id_ = 4711;//this selects for changing the CalcTree
    77         this.iterator_id_ = 4711;// this selects for changing the CalcTree
    77     }
    78     }
    78 
    79 
    79     /**
    80     /**
    80      * Construct a new calculation element iterator object attached to the
    81      * Construct a new calculation element iterator object attached to the
    81      * passed calculation tree with initial position (fetched from a formula on
    82      * passed calculation tree with initial position (fetched from a formula on
    83      * 
    84      * 
    84      * @param calcTree
    85      * @param calcTree
    85      *            calculation tree
    86      *            calculation tree
    86      */
    87      */
    87     public CalcIterator(CalcTree calcTree, Position sml_pos) {
    88     public CalcIterator(CalcTree calcTree, Position sml_pos) {
    88         logger_.debug("CalcIterator(" + sml_pos.toSMLString() + ")");
    89         if (logger.isDebugEnabled())
       
    90             logger.debug("CalcIterator(" + sml_pos.toSMLString() + ")");
    89         this.setSmlPos(sml_pos);
    91         this.setSmlPos(sml_pos);
    90         this.calc_tree_ = calcTree;
    92         this.calc_tree_ = calcTree;
    91         this.calc_tree_id_ = calcTree.getId();
    93         this.calc_tree_id_ = calcTree.getId();
    92         this.iterator_id_ = 4711;//this is calculated by the KE without state
    94         this.iterator_id_ = 4711;// this is calculated by the KE without
    93         //		try {
    95                                     // state
    94         //			this.iterator_id_ = calcTree.getMathEngine().iterator(calc_tree_id_);
    96         // try {
    95         //		} catch (RemoteException e) {
    97         // this.iterator_id_ = calcTree.getMathEngine().iterator(calc_tree_id_);
       
    98         // } catch (RemoteException e) {
    96         //			
    99         //			
    97         //			e.printStackTrace();
   100         // e.printStackTrace();
    98         //		}
   101         // }
    99     }
   102     }
   100 
   103 
   101     /**
   104     /**
   102      * Turn this iterator into a HotSpot iterator i.e. use it to move the active
   105      * Turn this iterator into a HotSpot iterator i.e. use it to move the active
   103      * Formula. This operation is not reversible.
   106      * Formula. This operation is not reversible.
   114      * 
   117      * 
   115      * @return Like all the moveXXX methods this returns true on success, false
   118      * @return Like all the moveXXX methods this returns true on success, false
   116      *         if there is no element to move to.
   119      *         if there is no element to move to.
   117      */
   120      */
   118     public boolean moveRoot() {
   121     public boolean moveRoot() {
   119         logger_.fatal("  DG->BR: moveRoot()");
   122         if (logger.isInfoEnabled())
   120         try {
   123             logger.info("  DG->BR: moveRoot()");
   121             //WN041208 return
   124         try {
       
   125             // WN041208 return
   122             // calc_tree_.getMathEngine().moveRoot(calc_tree_id_,
   126             // calc_tree_.getMathEngine().moveRoot(calc_tree_id_,
   123             // iterator_id_);
   127             // iterator_id_);
   124             Position p = calc_tree_.getMathEngine().moveRoot(calc_tree_id_,
   128             Position p = calc_tree_.getMathEngine().moveRoot(calc_tree_id_,
   125                     iterator_id_);
   129                     iterator_id_);
   126             if (p == null) {
   130             if (p == null) {
   127                 logger_.fatal("  DG<-BR: moveRoot() <- false NULL###");
   131                 if (logger.isInfoEnabled())
       
   132                     logger.info("  DG<-BR: moveRoot() <- false NULL###");
   128                 return false;
   133                 return false;
   129             } else {
   134             } else {
   130                 this.setSmlPos(p);
   135                 this.setSmlPos(p);
   131                 logger_.fatal("  DG<-BR: moveRoot() <- true");
   136                 if (logger.isInfoEnabled())
       
   137                     logger.info("  DG<-BR: moveRoot() <- true");
   132                 return true;
   138                 return true;
   133             }
   139             }
   134         } catch (RemoteException e) {
   140         } catch (RemoteException e) {
   135 
   141 
   136             e.printStackTrace();
   142             e.printStackTrace();
   137         }
   143         }
   138         logger_.fatal("  DG<-BR: moveRoot() <- false RemoteException###");
   144         if (logger.isInfoEnabled())
       
   145             logger.info("  DG<-BR: moveRoot() <- false RemoteException###");
   139         return false;
   146         return false;
   140     }
   147     }
   141 
   148 
   142     /**
   149     /**
   143      * Reference the previous formula in the attached calculation tree.
   150      * Reference the previous formula in the attached calculation tree.
   144      * 
   151      * 
   145      * @return Like all the moveXXX methods this returns true on success, false
   152      * @return Like all the moveXXX methods this returns true on success, false
   146      *         if there is no element to move to.
   153      *         if there is no element to move to.
   147      */
   154      */
   148     public boolean moveUp() {
   155     public boolean moveUp() {
   149         logger_.fatal("  DG->BR: moveUp()");
   156         if (logger.isInfoEnabled())
   150         try {
   157             logger.info("  DG->BR: moveUp()");
   151             //WN041208 return calc_tree_.getMathEngine().moveUp(calc_tree_id_,
   158         try {
       
   159             // WN041208 return calc_tree_.getMathEngine().moveUp(calc_tree_id_,
   152             // iterator_id_, sml_pos_);
   160             // iterator_id_, sml_pos_);
   153             Position p = calc_tree_.getMathEngine().moveUp(calc_tree_id_,
   161             Position p = calc_tree_.getMathEngine().moveUp(calc_tree_id_,
   154                     iterator_id_, sml_pos_);
   162                     iterator_id_, sml_pos_);
   155             if (p == null) {
   163             if (p == null) {
   156                 logger_.fatal("  DG<-BR: moveUp() <- false NULL###");
   164                 if (logger.isInfoEnabled())
       
   165                     logger.info("  DG<-BR: moveUp() <- false NULL###");
   157                 return false;
   166                 return false;
   158             } else {
   167             } else {
   159                 this.setSmlPos(p);
   168                 this.setSmlPos(p);
   160                 logger_.fatal("  DG<-BR: moveUp() <- true");
   169                 if (logger.isInfoEnabled())
       
   170                     logger.info("  DG<-BR: moveUp() <- true");
   161                 return true;
   171                 return true;
   162             }
   172             }
   163         } catch (RemoteException e) {
   173         } catch (RemoteException e) {
   164 
   174 
   165             e.printStackTrace();
   175             e.printStackTrace();
   166         }
   176         }
   167         logger_.fatal("  DG<-BR: moveUp() <- false RemoteException###");
   177         if (logger.isInfoEnabled())
       
   178             logger.info("  DG<-BR: moveUp() <- false RemoteException###");
   168         return false;
   179         return false;
   169     }
   180     }
   170 
   181 
   171     /**
   182     /**
   172      * Reference the next formula in the attached calculation tree.
   183      * Reference the next formula in the attached calculation tree.
   173      * 
   184      * 
   174      * @return Like all the moveXXX methods this returns true on success, false
   185      * @return Like all the moveXXX methods this returns true on success, false
   175      *         if there is no element to move to.
   186      *         if there is no element to move to.
   176      */
   187      */
   177     public boolean moveDown() {
   188     public boolean moveDown() {
   178         logger_.fatal("  DG->BR: moveDown()");
   189         if (logger.isInfoEnabled())
   179         try {
   190             logger.info("  DG->BR: moveDown()");
   180             //WN041208 return
   191         try {
       
   192             // WN041208 return
   181             // calc_tree_.getMathEngine().moveDown(calc_tree_id_,
   193             // calc_tree_.getMathEngine().moveDown(calc_tree_id_,
   182             // iterator_id_, sml_pos_);
   194             // iterator_id_, sml_pos_);
   183             Position p = calc_tree_.getMathEngine().moveDown(calc_tree_id_,
   195             Position p = calc_tree_.getMathEngine().moveDown(calc_tree_id_,
   184                     iterator_id_, sml_pos_);
   196                     iterator_id_, sml_pos_);
   185             if (p == null) {
   197             if (p == null) {
   186                 logger_.fatal("  DG<-BR: moveDown() <- false NULL###");
   198                 if (logger.isInfoEnabled())
       
   199                     logger.info("  DG<-BR: moveDown() <- false NULL###");
   187                 return false;
   200                 return false;
   188             } else {
   201             } else {
   189                 this.setSmlPos(p);
   202                 this.setSmlPos(p);
   190                 logger_.fatal("  DG<-BR: moveDown() <- true");
   203                 if (logger.isInfoEnabled())
       
   204                     logger.info("  DG<-BR: moveDown() <- true");
   191                 return true;
   205                 return true;
   192             }
   206             }
   193         } catch (RemoteException e) {
   207         } catch (RemoteException e) {
   194 
   208 
   195             e.printStackTrace();
   209             e.printStackTrace();
   196         }
   210         }
   197         logger_.fatal("  DG<-BR: moveDown() <- false RemoteException###");
   211         if (logger.isInfoEnabled())
       
   212             logger.info("  DG<-BR: moveDown() <- false RemoteException###");
   198         return false;
   213         return false;
   199     }
   214     }
   200 
   215 
   201     /**
   216     /**
   202      * Enter the next coarser level of refinement in the attached calculation
   217      * Enter the next coarser level of refinement in the attached calculation
   204      * 
   219      * 
   205      * @return Like all the moveXXX methods this returns true on success, false
   220      * @return Like all the moveXXX methods this returns true on success, false
   206      *         if there is no element to move to.
   221      *         if there is no element to move to.
   207      */
   222      */
   208     public boolean moveLevelUp() {
   223     public boolean moveLevelUp() {
   209         logger_.fatal("  DG->BR: moveLevelUp()");
   224         if (logger.isInfoEnabled())
   210         try {
   225             logger.info("  DG->BR: moveLevelUp()");
   211             //WN041208 return
   226         try {
       
   227             // WN041208 return
   212             // calc_tree_.getMathEngine().moveLevelUp(calc_tree_id_,
   228             // calc_tree_.getMathEngine().moveLevelUp(calc_tree_id_,
   213             // iterator_id_,
   229             // iterator_id_,
   214             // sml_pos_);
   230             // sml_pos_);
   215             Position p = calc_tree_.getMathEngine().moveLevelUp(calc_tree_id_,
   231             Position p = calc_tree_.getMathEngine().moveLevelUp(calc_tree_id_,
   216                     iterator_id_, sml_pos_);
   232                     iterator_id_, sml_pos_);
   217             if (p == null) {
   233             if (p == null) {
   218                 logger_.fatal("  DG<-BR: moveLevelUp() <- false NULL###");
   234                 if (logger.isInfoEnabled())
       
   235                     logger.info("  DG<-BR: moveLevelUp() <- false NULL###");
   219                 return false;
   236                 return false;
   220             } else {
   237             } else {
   221                 this.setSmlPos(p);
   238                 this.setSmlPos(p);
   222                 logger_.fatal("  DG<-BR: moveLevelUp() <- true");
   239                 if (logger.isInfoEnabled())
       
   240                     logger.info("  DG<-BR: moveLevelUp() <- true");
   223                 return true;
   241                 return true;
   224             }
   242             }
   225         } catch (RemoteException e) {
   243         } catch (RemoteException e) {
   226 
   244 
   227             e.printStackTrace();
   245             e.printStackTrace();
   228         }
   246         }
   229         logger_.fatal("  DG<-BR: moveLevelUp() <- false RemoteException###");
   247         if (logger.isInfoEnabled())
       
   248             logger.info("  DG<-BR: moveLevelUp() <- false RemoteException###");
   230         return false;
   249         return false;
   231     }
   250     }
   232 
   251 
   233     /**
   252     /**
   234      * Enter the next more detailed level of refinement in the attached
   253      * Enter the next more detailed level of refinement in the attached
   236      * 
   255      * 
   237      * @return Like all the moveXXX methods this returns true on success, false
   256      * @return Like all the moveXXX methods this returns true on success, false
   238      *         if there is no element to move to.
   257      *         if there is no element to move to.
   239      */
   258      */
   240     public boolean moveLevelDown() {
   259     public boolean moveLevelDown() {
   241         logger_.fatal("  DG->BR: moveLevelDown()");
   260         if (logger.isInfoEnabled())
   242         try {
   261             logger.info("  DG->BR: moveLevelDown()");
   243             //WN041208 return
   262         try {
       
   263             // WN041208 return
   244             // calc_tree_.getMathEngine().moveLevelDown(calc_tree_id_,
   264             // calc_tree_.getMathEngine().moveLevelDown(calc_tree_id_,
   245             // iterator_id_, sml_pos_);
   265             // iterator_id_, sml_pos_);
   246             Position p = calc_tree_.getMathEngine().moveLevelDown(
   266             Position p = calc_tree_.getMathEngine().moveLevelDown(
   247                     calc_tree_id_, iterator_id_, sml_pos_);
   267                     calc_tree_id_, iterator_id_, sml_pos_);
   248             if (p == null) {
   268             if (p == null) {
   249                 logger_.fatal("  DG<-BR: moveLevelDown() <- false NULL###");
   269                 if (logger.isInfoEnabled())
       
   270                     logger.info("  DG<-BR: moveLevelDown() <- false NULL###");
   250                 return false;
   271                 return false;
   251             } else {
   272             } else {
   252                 this.setSmlPos(p);
   273                 this.setSmlPos(p);
   253                 logger_.fatal("  DG<-BR: moveLevelDown() <- true");
   274                 if (logger.isInfoEnabled())
       
   275                     logger.info("  DG<-BR: moveLevelDown() <- true");
   254                 return true;
   276                 return true;
   255             }
   277             }
   256         } catch (RemoteException e) {
   278         } catch (RemoteException e) {
   257 
   279 
   258             e.printStackTrace();
   280             e.printStackTrace();
   259         }
   281         }
   260         logger_.fatal("  DG<-BR: moveLevelDown() <- false RemoteException###");
   282         if (logger.isInfoEnabled())
       
   283             logger.info("  DG<-BR: moveLevelDown() <- false RemoteException###");
   261         return false;
   284         return false;
   262     }
   285     }
   263 
   286 
   264     /**
   287     /**
   265      * Reference the calc_head_ that belongs to the currently selected item
   288      * Reference the calc_head_ that belongs to the currently selected item
   266      */
   289      */
   267     public boolean moveCalcHead() {
   290     public boolean moveCalcHead() {
   268         logger_.fatal("  DG->BR: moveCalcHead()");
   291         if (logger.isInfoEnabled())
   269         try {
   292             logger.info("  DG->BR: moveCalcHead()");
   270             //WN041208return
   293         try {
       
   294             // WN041208return
   271             // calc_tree_.getMathEngine().moveCalcHead(calc_tree_id_,
   295             // calc_tree_.getMathEngine().moveCalcHead(calc_tree_id_,
   272             // iterator_id_, sml_pos_);
   296             // iterator_id_, sml_pos_);
   273             Position p = calc_tree_.getMathEngine().moveCalcHead(calc_tree_id_,
   297             Position p = calc_tree_.getMathEngine().moveCalcHead(calc_tree_id_,
   274                     iterator_id_, sml_pos_);
   298                     iterator_id_, sml_pos_);
   275             if (p == null) {
   299             if (p == null) {
   276                 logger_.fatal("  DG<-BR: moveCalcHead() <- false NULL###");
   300                 if (logger.isInfoEnabled())
       
   301                     logger.info("  DG<-BR: moveCalcHead() <- false NULL###");
   277                 return false;
   302                 return false;
   278             } else {
   303             } else {
   279                 this.setSmlPos(p);
   304                 this.setSmlPos(p);
   280                 logger_.fatal("  DG<-BR: moveCalcHead() <- true");
   305                 if (logger.isInfoEnabled())
       
   306                     logger.info("  DG<-BR: moveCalcHead() <- true");
   281                 return true;
   307                 return true;
   282             }
   308             }
   283         } catch (RemoteException e) {
   309         } catch (RemoteException e) {
   284 
   310 
   285             e.printStackTrace();
   311             e.printStackTrace();
   286         }
   312         }
   287         logger_.fatal("  DG<-BR: moveCalcHead() <- false RemoteException###");
   313         if (logger.isInfoEnabled())
       
   314             logger.info("  DG<-BR: moveCalcHead() <- false RemoteException###");
   288         return false;
   315         return false;
   289     }
   316     }
   290 
   317 
   291     /**
   318     /**
   292      * Reference the tactic which resulted in the currently selected element of
   319      * Reference the tactic which resulted in the currently selected element of
   382      * @see isac.interfaces.IToCalc#getFormulaeFromTo(isac.interfaces.ICalcIterator,
   409      * @see isac.interfaces.IToCalc#getFormulaeFromTo(isac.interfaces.ICalcIterator,
   383      *      isac.interfaces.ICalcIterator, java.lang.Integer, boolean)
   410      *      isac.interfaces.ICalcIterator, java.lang.Integer, boolean)
   384      */
   411      */
   385     public Vector getFormulaeFromTo(ICalcIterator iterator_to, Integer level,
   412     public Vector getFormulaeFromTo(ICalcIterator iterator_to, Integer level,
   386             boolean result_includes_tactics) throws RemoteException {
   413             boolean result_includes_tactics) throws RemoteException {
   387         logger_.fatal("  DG->BR: getFormulaeFromTo(" + this.toSMLString()
   414         if (logger.isInfoEnabled())
   388                 + ", " + iterator_to.toSMLString() + level + ")");
   415             logger.info("  DG->BR: getFormulaeFromTo(" + this.toSMLString() + ", "
       
   416                 + iterator_to.toSMLString() + level + ")");
   389         try {
   417         try {
   390             return calc_tree_.getMathEngine().getFormulaeFromTo(calc_tree_id_,
   418             return calc_tree_.getMathEngine().getFormulaeFromTo(calc_tree_id_,
   391                     this, iterator_to, level, result_includes_tactics);
   419                     this, iterator_to, level, result_includes_tactics);
   392         } catch (RemoteException e) {
   420         } catch (RemoteException e) {
   393             e.printStackTrace();
   421             e.printStackTrace();
   405      *             (clone,moveActiveFormula)
   433      *             (clone,moveActiveFormula)
   406      */
   434      */
   407     void moveTo(CalcIterator calcIterator) {
   435     void moveTo(CalcIterator calcIterator) {
   408         this.moveRoot();
   436         this.moveRoot();
   409         Position otherPos = calcIterator.getPosition();
   437         Position otherPos = calcIterator.getPosition();
   410         //System.out.println(this.getPosition().toSMLString());
   438         // System.out.println(this.getPosition().toSMLString());
   411         //System.out.println(calcIterator.getPosition().toSMLString());
   439         // System.out.println(calcIterator.getPosition().toSMLString());
   412         while (!this.isOnPosition(otherPos)) {
   440         while (!this.isOnPosition(otherPos)) {
   413             if (!this.moveDown())
   441             if (!this.moveDown())
   414                 return;
   442                 return;
   415             //System.out.println("clone:
   443             // System.out.println("clone:
   416             // this=="+this.getPosition().toSMLString());
   444             // this=="+this.getPosition().toSMLString());
   417             //System.out.println("clone:other=="+calcIterator.getPosition().toSMLString());
   445             // System.out.println("clone:other=="+calcIterator.getPosition().toSMLString());
   418         }
   446         }
   419     }
   447     }
   420 
   448 
   421     // get the Position of the current element in the CalcTree
   449     // get the Position of the current element in the CalcTree
   422     public Position getPosition() {//TODO.WN041208 getSmlPos
   450     public Position getPosition() {// TODO.WN041208 getSmlPos
   423         logger_.error("  DG<>BR: getPosition() <--" + sml_pos_.toSMLString());
   451         if (logger.isInfoEnabled())
       
   452             logger.info("  DG<>BR: getPosition() <--" + sml_pos_.toSMLString());
   424         return sml_pos_;
   453         return sml_pos_;
   425         //		Position thisPos = null;
   454         // Position thisPos = null;
   426         //		ICalcElement ce = this.getElement();
   455         // ICalcElement ce = this.getElement();
   427         //		if (ce instanceof CalcHead) {
   456         // if (ce instanceof CalcHead) {
   428         //			thisPos = ((CalcHead) ce).getPosition();
   457         // thisPos = ((CalcHead) ce).getPosition();
   429         //		} else if (ce instanceof Formula) {
   458         // } else if (ce instanceof Formula) {
   430         //			thisPos = ((Formula) ce).getPosition();
   459         // thisPos = ((Formula) ce).getPosition();
   431         //		}
   460         // }
   432         //		return thisPos;
   461         // return thisPos;
   433     }
   462     }
   434 
   463 
   435     private void setSmlPos(Position p) {
   464     private void setSmlPos(Position p) {
   436         this.sml_pos_ = p;
   465         this.sml_pos_ = p;
   437     }
   466     }
   454      * Clone this iterator. The result is a second, different iterator
   483      * Clone this iterator. The result is a second, different iterator
   455      * referencing the same item as this iterator
   484      * referencing the same item as this iterator
   456      * 
   485      * 
   457      * @see isac.wsdialog.ICalcIterator#clone()
   486      * @see isac.wsdialog.ICalcIterator#clone()
   458      */
   487      */
   459     public Object clone() {
   488     public ICalcIterator cloneIterator() {
   460         logger_.debug("CalcIterator.clone() <-" + sml_pos_.toSMLString());
   489         if (logger.isDebugEnabled())
       
   490             logger.debug("CalcIterator.clone() <-" + sml_pos_.toSMLString());
   461         CalcIterator clone = (CalcIterator) calc_tree_.iterator();
   491         CalcIterator clone = (CalcIterator) calc_tree_.iterator();
   462         clone.setSmlPos(sml_pos_);
   492         clone.setSmlPos(sml_pos_);
   463         return clone;
   493         return clone;
   464     }
   494     }
   465 
   495 
   471      *         <p>
   501      *         <p>
   472      *         0 if the second iterator references the same item
   502      *         0 if the second iterator references the same item
   473      *         <p>
   503      *         <p>
   474      *         -1 otherwise
   504      *         -1 otherwise
   475      * @see java.lang.Comparable#compareTo(java.lang.Object)
   505      * @see java.lang.Comparable#compareTo(java.lang.Object)
   476      *  
   506      * 
   477      */
   507      */
   478     public int compareTo(Object o) {
   508     public int compareToIterator(ICalcIterator o) {
   479         int comp = this.sml_pos_.compareTo(((CalcIterator) o).sml_pos_);
   509         int comp = this.sml_pos_.compareTo(((CalcIterator) o).sml_pos_);
   480         logger_.fatal("  DG<>BR: compareTo() <- " + comp);
   510         if (logger.isInfoEnabled())
       
   511             logger.info("  DG<>BR: compareTo() <- " + comp);
   481         return comp;
   512         return comp;
   482     }
   513     }
   483 
   514 
   484     public boolean equals(Object o) {
   515     public boolean equals(Object o) {
   485         return (this.compareTo(o) == 0);
   516         return (this.compareToIterator((ICalcIterator) o) == 0);
   486     }
   517     }
   487 
   518 
   488     //    public int hashCode() {
   519     // public int hashCode() {
   489     //        return getPosition().toSMLString().hashCode();
   520     // return getPosition().toSMLString().hashCode();
   490     //    }
   521     // }
   491 
   522 
   492     public int getIteratorID() {
   523     public int getIteratorID() {
   493         return iterator_id_;
   524         return iterator_id_;
   494     }
   525     }
   495 
   526 
   496     /*
   527     /*
   497      * (non-Javadoc)
   528      * (non-Javadoc)
   498      * 
   529      * 
   499      * @see isac.interfaces.ICalcIterator#isLast()
   530      * @see isac.interfaces.ICalcIterator#isLast()
   500      * @deprecated since CalcChangedEvent.last_generated_formula
   531      * @deprecated since CalcChanged.last_generated_formula
   501      */
   532      */
   502     public boolean isLast() {
   533     public boolean isLast() {
   503         // TODO: implement
   534         // TODO: implement
   504         return true;
   535         return true;
   505     }
   536     }
   542      * get the formula-part at a CalcIterator-position this can be either a
   573      * get the formula-part at a CalcIterator-position this can be either a
   543      * Formula or a CalcHead
   574      * Formula or a CalcHead
   544      * 
   575      * 
   545      */
   576      */
   546     public ICalcElement getFormula() {
   577     public ICalcElement getFormula() {
   547         logger_.fatal("  DG->BR: getFormula()");
   578         if (logger.isInfoEnabled())
       
   579             logger.info("  DG->BR: getFormula()");
   548         ICalcElement fch = null;
   580         ICalcElement fch = null;
   549         try {
   581         try {
   550             fch = calc_tree_.getMathEngine()
   582             fch = calc_tree_.getMathEngine()
   551                     .getElement(calc_tree_id_, sml_pos_);
   583                     .getElement(calc_tree_id_, sml_pos_);
   552         } catch (RemoteException e) {
   584         } catch (RemoteException e) {
   553 
   585 
   554             e.printStackTrace();
   586             e.printStackTrace();
   555         }
   587         }
   556         logger_.fatal("  DG<-BR: getFormula <- formula=" + fch.toSMLString());
   588         if (logger.isInfoEnabled())
       
   589             logger.info("  DG<-BR: getFormula <- formula=" + fch.toSMLString());
   557         return fch;
   590         return fch;
   558     }
   591     }
   559 
   592 
   560     /**
   593     /**
   561      * @see isac.interfaces.ICalcIterator#getTactic()
   594      * @see isac.interfaces.ICalcIterator#getTactic()
   562      */
   595      */
   563     public Tactic getTactic() { //WN050217 kopiert von getFormula
   596     public Tactic getTactic() { // WN050217 kopiert von getFormula
   564         // !!!!!!!!!!!!!!!!!
   597         // !!!!!!!!!!!!!!!!!
   565         logger_.fatal("  DG->BR: getTactic()");
   598         if (logger.isInfoEnabled())
       
   599             logger.info("  DG->BR: getTactic()");
   566         Tactic tac = null;
   600         Tactic tac = null;
   567         try {
   601         try {
   568             tac = calc_tree_.getMathEngine().getTactic(calc_tree_id_, sml_pos_);
   602             tac = calc_tree_.getMathEngine().getTactic(calc_tree_id_, sml_pos_);
   569         } catch (RemoteException e) {
   603         } catch (RemoteException e) {
   570             e.printStackTrace();
   604             e.printStackTrace();
   571         }
   605         }
   572         
   606 
   573         if( tac != null )
   607         if (tac != null)
   574         	logger_.fatal("  DG<-BR: getTactic <-" + tac.toSMLString());
   608             if (logger.isInfoEnabled())
   575         
   609                 logger.info("  DG<-BR: getTactic <-" + tac.toSMLString());
       
   610 
   576         return tac;
   611         return tac;
   577     }
   612     }
   578 
   613 
   579     /**
   614     /**
   580      * @see isac.interfaces.ICalcIterator#getApplicableTactics()
   615      * @see isac.interfaces.ICalcIterator#getApplicableTactics()
   581      */
   616      */
   582     public Vector getApplicableTactics(int scope) throws RemoteException {
   617     public Vector getApplicableTactics(int scope) throws RemoteException {
   583         logger_.fatal("  DG->BR: getApplicableTactics()");
   618         if (logger.isInfoEnabled())
       
   619             logger.info("  DG->BR: getApplicableTactics()");
   584         Vector tacs = null;
   620         Vector tacs = null;
   585         try {
   621         try {
   586             tacs = calc_tree_.getMathEngine().getApplicableTactics(
   622             tacs = calc_tree_.getMathEngine().getApplicableTactics(
   587                     calc_tree_id_, scope, sml_pos_);
   623                     calc_tree_id_, scope, sml_pos_);
   588         } catch (RemoteException e) {
   624         } catch (RemoteException e) {
   589 
   625 
   590             e.printStackTrace();
   626             e.printStackTrace();
   591         }
   627         }
   592         logger_.fatal("  DG<-BR: getApplicableTactics()");
   628         if (logger.isInfoEnabled())
       
   629             logger.info("  DG<-BR: getApplicableTactics()");
   593         return tacs;
   630         return tacs;
   594     }
   631     }
   595 
   632 
   596     /**
   633     /**
   597      * get the Assumptions generated by the Tactic applied to the Formula at a
   634      * get the Assumptions generated by the Tactic applied to the Formula at a
   598      * CalcIterator-position
   635      * CalcIterator-position
   599      * 
   636      * 
   600      * @see isac.interfaces.ICalcIterator#getAssumptions()
   637      * @see isac.interfaces.ICalcIterator#getAssumptions()
   601      */
   638      */
   602     public Assumptions getAssumptions() {
   639     public Assumptions getAssumptions() {
   603         logger_.fatal("  DG->BR: getAssumptions()");
   640         if (logger.isInfoEnabled())
       
   641             logger.info("  DG->BR: getAssumptions()");
   604         Assumptions asms = null;
   642         Assumptions asms = null;
   605         try {
   643         try {
   606             asms = calc_tree_.getMathEngine().getAssumptions(calc_tree_id_,
   644             asms = calc_tree_.getMathEngine().getAssumptions(calc_tree_id_,
   607                     sml_pos_);
   645                     sml_pos_);
   608         } catch (RemoteException e) {
   646         } catch (RemoteException e) {
   609             e.printStackTrace();
   647             e.printStackTrace();
   610         }
   648         }
   611         logger_.fatal("  DG<-BR: getAssumption() <- " + asms.toSMLString());
   649         if (logger.isInfoEnabled())
       
   650             logger.info("  DG<-BR: getAssumption() <- " + asms.toSMLString());
   612         return asms;
   651         return asms;
   613     }
   652     }
   614 
   653 
   615     /**
   654     /**
   616      * @see isac.interfaces.ICalcIterator#getAccumulatedAssumptions()
   655      * @see isac.interfaces.ICalcIterator#getAccumulatedAssumptions()
   621             asms = calc_tree_.getMathEngine().getAccumulatedAssumptions(
   660             asms = calc_tree_.getMathEngine().getAccumulatedAssumptions(
   622                     calc_tree_id_, sml_pos_);
   661                     calc_tree_id_, sml_pos_);
   623         } catch (RemoteException e) {
   662         } catch (RemoteException e) {
   624             e.printStackTrace();
   663             e.printStackTrace();
   625         }
   664         }
   626         logger_.fatal("  DG<-BR: getAssumption() <- " + asms.toSMLString());
   665         if (logger.isInfoEnabled())
       
   666             logger.info("  DG<-BR: getAssumption() <- " + asms.toSMLString());
   627         return asms;
   667         return asms;
   628     }
   668     }
   629 
   669 
   630     /**
   670     /**
   631      * @see isac.interfaces.ICalcIterator#tryMatch()
   671      * @see isac.interfaces.ICalcIterator#tryMatch()
   635         try {
   675         try {
   636             m = calc_tree_.getMathEngine().initMatchProblem(calc_tree_id_);
   676             m = calc_tree_.getMathEngine().initMatchProblem(calc_tree_id_);
   637         } catch (RemoteException e) {
   677         } catch (RemoteException e) {
   638             e.printStackTrace();
   678             e.printStackTrace();
   639         }
   679         }
   640         logger_.fatal("  DG<-BR: tryMatchProblem() <- " + m.toString());
   680         if (logger.isInfoEnabled())
       
   681             logger.info("  DG<-BR: tryMatchProblem() <- " + m.toString());
   641         return m;
   682         return m;
   642     }
   683     }
   643 
   684 
   644     /**
   685     /**
   645      * @see isac.interfaces.ICalcIterator#tryMatch()
   686      * @see isac.interfaces.ICalcIterator#tryMatch()
   650             m = calc_tree_.getMathEngine().tryMatchProblem(calc_tree_id_,
   691             m = calc_tree_.getMathEngine().tryMatchProblem(calc_tree_id_,
   651                     problemID);
   692                     problemID);
   652         } catch (RemoteException e) {
   693         } catch (RemoteException e) {
   653             e.printStackTrace();
   694             e.printStackTrace();
   654         }
   695         }
   655         logger_.fatal("  DG<-BR: tryMatchProblem() <- " + m.toString());
   696         if (logger.isInfoEnabled())
       
   697             logger.info("  DG<-BR: tryMatchProblem() <- " + m.toString());
   656         return m;
   698         return m;
   657     }
   699     }
   658 
   700 
   659     /**
   701     /**
   660      * @see isac.interfaces.ICalcIterator#tryRefine()
   702      * @see isac.interfaces.ICalcIterator#tryRefine()
   665             m = calc_tree_.getMathEngine().tryRefineProblem(calc_tree_id_,
   707             m = calc_tree_.getMathEngine().tryRefineProblem(calc_tree_id_,
   666                     problemID);
   708                     problemID);
   667         } catch (RemoteException e) {
   709         } catch (RemoteException e) {
   668             e.printStackTrace();
   710             e.printStackTrace();
   669         }
   711         }
   670         logger_.fatal("  DG<-BR: tryRefineProblem() <- " + m.toString());
   712         if (logger.isInfoEnabled())
       
   713             logger.info("  DG<-BR: tryRefineProblem() <- " + m.toString());
   671         return m;
   714         return m;
   672     }
   715     }
   673 
   716 
   674     /**
   717     /**
   675      * @see isac.interfaces.ICalcIterator#tryMatchMethod(HierarchyKey)
   718      * @see isac.interfaces.ICalcIterator#tryMatchMethod(HierarchyKey)
   679         try {
   722         try {
   680             m = calc_tree_.getMathEngine().initMatchMethod(calc_tree_id_);
   723             m = calc_tree_.getMathEngine().initMatchMethod(calc_tree_id_);
   681         } catch (RemoteException e) {
   724         } catch (RemoteException e) {
   682             e.printStackTrace();
   725             e.printStackTrace();
   683         }
   726         }
   684         logger_.fatal("  DG<-BR: initMatchMethod() <- " + m.toString());
   727         if (logger.isInfoEnabled())
       
   728             logger.info("  DG<-BR: initMatchMethod() <- " + m.toString());
   685         return m;
   729         return m;
   686     }
   730     }
   687 
   731 
   688     /**
   732     /**
   689      * @see isac.interfaces.ICalcIterator#tryMatchMethod(HierarchyKey)
   733      * @see isac.interfaces.ICalcIterator#tryMatchMethod(HierarchyKey)
   694             m = calc_tree_.getMathEngine().tryMatchMethod(calc_tree_id_,
   738             m = calc_tree_.getMathEngine().tryMatchMethod(calc_tree_id_,
   695                     methodID);
   739                     methodID);
   696         } catch (RemoteException e) {
   740         } catch (RemoteException e) {
   697             e.printStackTrace();
   741             e.printStackTrace();
   698         }
   742         }
   699         logger_.fatal("  DG<-BR: tryMatchMethod() <- " + m.toString());
   743         if (logger.isInfoEnabled())
       
   744             logger.info("  DG<-BR: tryMatchMethod() <- " + m.toString());
   700         return m;
   745         return m;
   701     }
   746     }
   702     
   747 
   703     public Context initContext( ContextType type ) throws RemoteException {
   748     public Context initContext(ContextType type) throws RemoteException {
   704     	Context context = calc_tree_.getMathEngine().initContext( calc_tree_id_, type, sml_pos_ );
   749         Context context = calc_tree_.getMathEngine().initContext(calc_tree_id_,
   705     	return context;
   750                 type, sml_pos_);
   706     }
   751         return context;
   707 
   752     }
   708     public Context checkContext( Context context2check ) throws RemoteException {
   753 
   709     	Context context = calc_tree_.getMathEngine().checkContext( calc_tree_id_, context2check, sml_pos_ );
   754     public Context checkContext(Context context2check) throws RemoteException {
   710     	return context;
   755         Context context = calc_tree_.getMathEngine().checkContext(
   711     }
   756                 calc_tree_id_, context2check, sml_pos_);
   712     
   757         return context;
   713     public Context refineProblem( Context context2refine ) throws RemoteException {
   758     }
   714     	Context context = calc_tree_.getMathEngine().refineProblem( calc_tree_id_, context2refine, sml_pos_ );
   759 
   715     	return context;
   760     public Context refineProblem(Context context2refine) throws RemoteException {
   716     }
   761         Context context = calc_tree_.getMathEngine().refineProblem(
   717     
   762                 calc_tree_id_, context2refine, sml_pos_);
   718     public CalcHead setContext( ContextProblem context2set ) throws RemoteException {
   763         return context;
   719     	return calc_tree_.setContext( calc_tree_id_, context2set, sml_pos_ );
   764     }
   720     }
   765 
   721     public CalcHead setContext( ContextMethod context2set ) throws RemoteException {
   766     public CalcHead setContext(ContextProblem context2set)
   722     	return calc_tree_.setContext( calc_tree_id_, context2set, sml_pos_ );
   767             throws RemoteException {
   723     }
   768         return calc_tree_.setContext(calc_tree_id_, context2set, sml_pos_);
   724     public void setContext( ContextTheory context2set ) throws RemoteException {
   769     }
   725     	calc_tree_.setContext( calc_tree_id_, context2set, sml_pos_ );
   770 
   726     }
   771     public CalcHead setContext(ContextMethod context2set)
   727     
   772             throws RemoteException {
       
   773         return calc_tree_.setContext(calc_tree_id_, context2set, sml_pos_);
       
   774     }
       
   775 
       
   776     public void setContext(ContextTheory context2set) throws RemoteException {
       
   777         calc_tree_.setContext(calc_tree_id_, context2set, sml_pos_);
       
   778     }
       
   779 
   728     public String toSMLString() {
   780     public String toSMLString() {
   729         if (sml_pos_ == null)
   781         if (sml_pos_ == null)
   730             return "([],Und)";
   782             return "([],Und)";
   731         else
   783         else
   732             return sml_pos_.toSMLString();
   784             return sml_pos_.toSMLString();