Changeset 467


Ignore:
Timestamp:
07/25/12 11:58:00 (12 years ago)
Author:
pharms
Message:

corrected implementation of clone

Location:
trunk/quest-core-tasktrees/src/main/java/de/ugoe/cs/quest/tasktrees/treeimpl
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/quest-core-tasktrees/src/main/java/de/ugoe/cs/quest/tasktrees/treeimpl/InteractionTaskImpl.java

    r451 r467  
    9898  //----------------------------------------------------------------------------------------------- 
    9999  @Override 
    100   public TaskTreeNode clone() 
     100  public InteractionTaskImpl clone() 
    101101  { 
    102     return new InteractionTaskImpl(mGUIElement, mInteraction); 
     102    // GUI element and interaction are unchangeable and do not need to be cloned 
     103    return (InteractionTaskImpl) super.clone(); 
    103104  } 
    104105 
  • trunk/quest-core-tasktrees/src/main/java/de/ugoe/cs/quest/tasktrees/treeimpl/IterationImpl.java

    r439 r467  
    6767  //----------------------------------------------------------------------------------------------- 
    6868  @Override 
    69   public TaskTreeNode clone() 
     69  public IterationImpl clone() 
    7070  { 
    71     IterationImpl clone = new IterationImpl(); 
    72     clone.setDescription(super.getDescription()); 
    73      
    74     if (super.getChildren().size() > 0) 
    75     { 
    76       clone.setChild(super.getChildren().get(0)); 
    77     } 
    78     return clone; 
     71    return (IterationImpl) super.clone(); 
    7972  } 
    8073 
  • trunk/quest-core-tasktrees/src/main/java/de/ugoe/cs/quest/tasktrees/treeimpl/SelectionImpl.java

    r439 r467  
    99 
    1010import de.ugoe.cs.quest.tasktrees.treeifc.Selection; 
    11 import de.ugoe.cs.quest.tasktrees.treeifc.TaskTreeNode; 
    1211 
    1312//------------------------------------------------------------------------------------------------- 
     
    4039  //----------------------------------------------------------------------------------------------- 
    4140  @Override 
    42   public TaskTreeNode clone() 
     41  public SelectionImpl clone() 
    4342  { 
    44     SelectionImpl clone = new SelectionImpl(); 
    45     clone.setDescription(super.getDescription()); 
    46      
    47     for (TaskTreeNode child : getChildren()) 
    48     { 
    49       clone.addChild(child); 
    50     } 
    51      
    52     return clone; 
     43    return (SelectionImpl) super.clone(); 
    5344  } 
    5445 
  • trunk/quest-core-tasktrees/src/main/java/de/ugoe/cs/quest/tasktrees/treeimpl/SequenceImpl.java

    r439 r467  
    99 
    1010import de.ugoe.cs.quest.tasktrees.treeifc.Sequence; 
    11 import de.ugoe.cs.quest.tasktrees.treeifc.TaskTreeNode; 
    1211 
    1312//------------------------------------------------------------------------------------------------- 
     
    5352  public SequenceImpl clone() 
    5453  { 
    55     SequenceImpl clone = new SequenceImpl(); 
    56     clone.setDescription(super.getDescription()); 
    57      
    58     for (TaskTreeNode child : getChildren()) 
    59     { 
    60       clone.addChild(child); 
    61     } 
    62      
    63     return clone; 
     54    return (SequenceImpl) super.clone(); 
    6455  } 
    6556 
  • trunk/quest-core-tasktrees/src/main/java/de/ugoe/cs/quest/tasktrees/treeimpl/TaskTreeImpl.java

    r439 r467  
    101101  } 
    102102 
     103  //----------------------------------------------------------------------------------------------- 
     104  /* (non-Javadoc) 
     105   * @see java.lang.Object#clone() 
     106   */ 
     107  //----------------------------------------------------------------------------------------------- 
     108  @Override 
     109  public TaskTreeImpl clone() 
     110  { 
     111    TaskTreeImpl clone = null; 
     112    try 
     113    { 
     114      clone = (TaskTreeImpl) super.clone(); 
     115       
     116      clone.mRootNode = mRootNode.clone(); 
     117       
     118      // the clone will create the task map itself, when it is first retrieved 
     119      clone.mTaskMap = null; 
     120       
     121    } 
     122    catch (CloneNotSupportedException e) 
     123    { 
     124      // this should never happen. Therefore simply dump the exception 
     125      e.printStackTrace(); 
     126    } 
     127     
     128    return clone; 
     129  } 
     130 
    103131} 
  • trunk/quest-core-tasktrees/src/main/java/de/ugoe/cs/quest/tasktrees/treeimpl/TaskTreeNodeImpl.java

    r465 r467  
    2323 */ 
    2424//------------------------------------------------------------------------------------------------- 
    25 public abstract class TaskTreeNodeImpl implements TaskTreeNode 
     25public class TaskTreeNodeImpl implements TaskTreeNode 
    2626{ 
    2727  /** */ 
     
    282282  //----------------------------------------------------------------------------------------------- 
    283283  @Override 
    284   public abstract TaskTreeNode clone(); 
     284  public TaskTreeNode clone() 
     285  { 
     286    TaskTreeNodeImpl clone = null; 
     287    try 
     288    { 
     289      clone = (TaskTreeNodeImpl) super.clone(); 
     290       
     291      clone.mChildren = new ArrayList<TaskTreeNode>(); 
     292       
     293      for (TaskTreeNode child : mChildren) 
     294      { 
     295        clone.mChildren.add(child.clone()); 
     296      } 
     297       
     298    } 
     299    catch (CloneNotSupportedException e) 
     300    { 
     301      // this should never happen. Therefore simply dump the exception 
     302      e.printStackTrace(); 
     303    } 
     304     
     305    return clone; 
     306  } 
    285307 
    286308} 
  • trunk/quest-core-tasktrees/src/main/java/de/ugoe/cs/quest/tasktrees/treeimpl/TextInputInteractionTaskImpl.java

    r451 r467  
    1010import de.ugoe.cs.quest.eventcore.guimodel.GUIElement; 
    1111import de.ugoe.cs.quest.eventcore.userinteraction.TextInput; 
    12 import de.ugoe.cs.quest.tasktrees.treeifc.TaskTreeNode; 
    1312import de.ugoe.cs.quest.tasktrees.treeifc.TextInputInteractionTask; 
    1413 
     
    4847  public TextInputInteractionTaskImpl clone() 
    4948  { 
    50     TextInputInteractionTaskImpl clone = new TextInputInteractionTaskImpl(super.getGUIElement()); 
    51     clone.setDescription(super.getDescription()); 
    52     clone.setEnteredText(this.getEnteredText()); 
    53      
    54     for (TaskTreeNode child : getChildren()) 
    55     { 
    56       clone.addChild(child); 
    57     } 
    58      
    59     return clone; 
     49    // entered text is unchangeable and does not need to be cloned 
     50    return (TextInputInteractionTaskImpl) super.clone(); 
    6051  } 
    6152 
Note: See TracChangeset for help on using the changeset viewer.