org.problets.domain.model.implement
Class Behavior

java.lang.Object
  extended by org.problets.domain.model.implement.Behavior

public class Behavior
extends java.lang.Object

Class meant to reduce the number of parameters passed among explainProcess() methods - encapsulates explanation, errors, output, dataTrace, controlTrace

Author:
Amruth Kumar

Constructor Summary
Behavior()
           
 
Method Summary
 void addDataTraceItem(AbstractVarModel dataObject, int lineNumber, java.lang.String template)
          Adds a new data trace item to the dataTrace vector and sets its previous tell if the item is an ask item
 java.util.Vector backupNarration()
          Backs up the narration so far, and returns a fresh narration vector for use by client
static java.util.Vector getCleanClone(java.util.Vector dataTrace)
          This method returns a clean clone of a given data trace.
 java.util.Vector getControlTrace()
          Returns a reference to the controlTrace
 java.util.Vector getDataTrace()
          Returns a reference to the dataTrace
 java.util.Vector getDataTraceCleanClone()
          Returns a clean clone of the dataTrace where ask items are blanked out.
 java.util.Vector getErrors()
          Returns a reference to the errors
 java.util.Vector getNarration()
          Returns a reference to the narration
 java.util.Vector getOutput()
          Returns a reference to the output
static void main(java.lang.String[] args)
           
 void print()
           
 java.util.Vector restoreNarration()
          Pops the top of the narration stack.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Behavior

public Behavior()
Method Detail

getNarration

public java.util.Vector getNarration()
Returns a reference to the narration


getErrors

public java.util.Vector getErrors()
Returns a reference to the errors


getOutput

public java.util.Vector getOutput()
Returns a reference to the output


getDataTrace

public java.util.Vector getDataTrace()
Returns a reference to the dataTrace


getDataTraceCleanClone

public java.util.Vector getDataTraceCleanClone()
Returns a clean clone of the dataTrace where ask items are blanked out. Rewritten to call the static method that follows public Vector getDataTraceCleanClone() { // First, make a clone of the datatrace vector int size = dataTrace.size(); Vector cloneVector = new Vector( size ); // Next, clone all the data trace items in the data trace vector // If any item is an ask item, set its previous tell to a tell item in the clone vector // (not the dataTrace vector!) DataTraceItem originalItem, clonedItem; for( int index = 0; index < size; index++ ) { // Make a clone of the element of data trace and add it to the clone vector originalItem = (DataTraceItem) dataTrace.elementAt( index ); clonedItem = (DataTraceItem) originalItem.clone(); cloneVector.addElement( clonedItem ); // If the item just added to the clone vector is an ask item, // set its previous tell to a TellItem on the clone vector, not dataTrace vector if( clonedItem.canEdit() ) { // Find its previous tell, by looking backwards from the location of the ask item TellItem previousTell = getPreviousTell( cloneVector, cloneVector.size() - 1 ); ((AskItem) clonedItem).setPreviousTell( previousTell ); } } // Reset every ask item to either it's previous tell or "" int itemCount = cloneVector.size(); for( int itemIndex = 0; itemIndex < itemCount; itemIndex++ ) ((DataTraceItem) cloneVector.elementAt( itemIndex )).reset(); // Return the copy of data trace return cloneVector; }


getCleanClone

public static java.util.Vector getCleanClone(java.util.Vector dataTrace)
This method returns a clean clone of a given data trace. It is exactly the same as getDataTraceCleanClone() except it cleans the data trace passed as parameter.


getControlTrace

public java.util.Vector getControlTrace()
Returns a reference to the controlTrace


addDataTraceItem

public void addDataTraceItem(AbstractVarModel dataObject,
                             int lineNumber,
                             java.lang.String template)
Adds a new data trace item to the dataTrace vector and sets its previous tell if the item is an ask item


backupNarration

public java.util.Vector backupNarration()
Backs up the narration so far, and returns a fresh narration vector for use by client


restoreNarration

public java.util.Vector restoreNarration()
Pops the top of the narration stack. Returns a reference to the new top-of-stack narration


print

public void print()

main

public static void main(java.lang.String[] args)