Changeset 1294 for trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl
- Timestamp:
- 08/14/13 17:04:42 (11 years ago)
- Location:
- trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl
- Files:
-
- 5 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/EventTask.java
r1255 r1294 15 15 package de.ugoe.cs.autoquest.tasktrees.treeimpl; 16 16 17 import de.ugoe.cs.autoquest.eventcore.IEventTarget;18 import de.ugoe.cs.autoquest.eventcore.IEventType;19 17 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 20 18 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskVisitor; … … 39 37 /** 40 38 * <p> 41 * the type of the represented event 42 * </p> 43 */ 44 private IEventType eventType; 45 46 /** 47 * <p> 48 * the target of the represented event 49 * </p> 50 */ 51 private IEventTarget eventTarget; 52 53 /** 54 * <p> 55 * simple constructor initializing this task with an event type and an event target 39 * simple constructor initializing this task with a description for the represented events 56 40 * </p> 57 41 * 58 * @param eventType the type of the represented event 59 * @param eventTarget the target of the represented event 42 * @param description a description for the represented events 60 43 */ 61 EventTask(IEventType eventType, IEventTarget eventTarget) { 62 super.setDescription(eventType.toString() + " \u21D2 " + eventTarget); 63 this.eventType = eventType; 64 this.eventTarget = eventTarget; 65 } 66 67 /* (non-Javadoc) 68 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask#getEventType() 69 */ 70 @Override 71 public IEventType getEventType() { 72 return eventType; 73 } 74 75 /* (non-Javadoc) 76 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask#getEventTarget() 77 */ 78 @Override 79 public IEventTarget getEventTarget() { 80 return eventTarget; 44 EventTask(String description) { 45 super.setDescription(description); 81 46 } 82 47 -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/Task.java
r1215 r1294 15 15 package de.ugoe.cs.autoquest.tasktrees.treeimpl; 16 16 17 import java.util.Collection; 18 import java.util.Collections; 19 import java.util.HashSet; 20 17 21 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 22 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 18 23 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskVisitor; 19 24 … … 56 61 */ 57 62 private String description; 63 64 /** 65 * <p> 66 * the instances of this task 67 * </p> 68 */ 69 private Collection<ITaskInstance> instances = new HashSet<ITaskInstance>(); 58 70 59 71 /** … … 97 109 public String getDescription() { 98 110 return description; 111 } 112 113 /* (non-Javadoc) 114 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITask#getInstances() 115 */ 116 @Override 117 public Collection<ITaskInstance> getInstances() { 118 return Collections.unmodifiableCollection(instances); 99 119 } 100 120 … … 163 183 } 164 184 185 /** 186 * <p> 187 * internally used to add an instance to this task 188 * </p> 189 * 190 * @param instance the instance belonging to this task 191 */ 192 void addInstance(ITaskInstance instance) { 193 this.instances.add(instance); 194 } 195 165 196 /* (non-Javadoc) 166 197 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITask#accept(ITaskVisitor) -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskBuilder.java
r1216 r1294 17 17 import java.util.List; 18 18 19 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask;20 19 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 20 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIterationInstance; 21 21 import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptional; 22 import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptionalInstance; 22 23 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 24 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelectionInstance; 23 25 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequenceInstance; 24 27 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 25 28 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; … … 41 44 42 45 /* (non-Javadoc) 43 * @see ITaskBuilder#addChild(ITaskInstance,ITaskInstance) 44 */ 45 @Override 46 public void addChild(ITaskInstance parent, ITaskInstance child) throws IllegalArgumentException 47 { 48 if (!(parent instanceof TaskInstance)) { 49 throw new IllegalArgumentException 50 ("illegal type of task instance provided: " + parent.getClass()); 46 * @see ITaskBuilder#addChild(ISequenceInstance, ITaskInstance) 47 */ 48 @Override 49 public void addChild(ISequenceInstance instance, ITaskInstance child) 50 throws IllegalArgumentException 51 { 52 if (!(instance instanceof SequenceInstance)) { 53 throw new IllegalArgumentException 54 ("illegal type of sequence instance provided: " + instance.getClass()); 51 55 } 52 56 53 57 if (!(child instanceof TaskInstance)) { 54 58 throw new IllegalArgumentException 55 ("illegal type of task instance provided: " + parent.getClass()); 56 } 57 58 // check, that the correct number of children for the distinct types are added 59 ITask task = parent.getTask(); 60 61 if (task instanceof IEventTask) { 62 throw new IllegalArgumentException 63 ("can not add children to a task instance of an event task"); 64 } 65 else if (task instanceof ISelection) { 66 if (parent.getChildren().size() > 0) { 67 throw new IllegalArgumentException 68 ("the instance of a selection must have at most one child"); 59 ("illegal type of task instance provided: " + child.getClass()); 60 } 61 62 /*IStructuringTemporalRelationship parentTask = 63 (IStructuringTemporalRelationship) parent.getTask(); 64 65 for (ITask parentTaskChild : parentTask.getChildren()) { 66 if (parentTaskChild.equals(child.getTask())) { 67 foundChildTask = true; 68 break; 69 69 } 70 70 } 71 else if (task instanceof IOptional) { 72 if (parent.getChildren().size() > 1) { 73 throw new IllegalArgumentException 74 ("the instance of an optional must have at most one child"); 75 } 76 } 77 /*else if (task instanceof IIteration) { 78 for (ITaskInstance childInstance : parent.getChildren()) { 79 if (!childInstance.getTask().equals(child.getTask())) { 80 throw new IllegalArgumentException 81 ("all children of an instance of an iteration must have exactly the " + 82 "same type"); 83 } 84 } 85 } 86 87 boolean foundChildTask = false; 88 if (parent.getTask() instanceof IStructuringTemporalRelationship) { 89 IStructuringTemporalRelationship parentTask = 90 (IStructuringTemporalRelationship) parent.getTask(); 91 92 for (ITask parentTaskChild : parentTask.getChildren()) { 93 if (parentTaskChild.equals(child.getTask())) { 94 foundChildTask = true; 95 break; 96 } 97 } 98 } 99 else if (parent.getTask() instanceof IMarkingTemporalRelationship) { 100 IMarkingTemporalRelationship parentTask = 101 (IMarkingTemporalRelationship) parent.getTask(); 102 103 foundChildTask = parentTask.getMarkedTask() != null ? 104 parentTask.getMarkedTask().equals(child.getTask()) : false; 105 } 106 71 107 72 if (!foundChildTask) { 108 73 throw new IllegalArgumentException … … 111 76 }*/ 112 77 113 // finally, after all checks are positive, add the child 114 ((TaskInstance) parent).addChild(child); 78 ((SequenceInstance) instance).addChild(child); 79 } 80 81 /* (non-Javadoc) 82 * @see ITaskBuilder#addChild(ISequenceInstance, int, ITaskInstance) 83 */ 84 public void addChild(ISequenceInstance instance, int index, ITaskInstance child) 85 throws IllegalArgumentException 86 { 87 if (!(instance instanceof SequenceInstance)) { 88 throw new IllegalArgumentException 89 ("illegal type of sequence instance provided: " + instance.getClass()); 90 } 91 92 if (!(child instanceof TaskInstance)) { 93 throw new IllegalArgumentException 94 ("illegal type of task instance provided: " + child.getClass()); 95 } 96 97 /*IStructuringTemporalRelationship parentTask = 98 (IStructuringTemporalRelationship) parent.getTask(); 99 100 for (ITask parentTaskChild : parentTask.getChildren()) { 101 if (parentTaskChild.equals(child.getTask())) { 102 foundChildTask = true; 103 break; 104 } 105 } 106 107 if (!foundChildTask) { 108 throw new IllegalArgumentException 109 ("the task of the child instance to be added does not belong to the children " + 110 "of the task of the parent instance"); 111 }*/ 112 113 ((SequenceInstance) instance).addChild(index, child); 114 } 115 116 /* (non-Javadoc) 117 * @see ITaskBuilder#addChild(IIterationInstance, ITaskInstance) 118 */ 119 @Override 120 public void addChild(IIterationInstance instance, ITaskInstance child) 121 throws IllegalArgumentException 122 { 123 if (!(instance instanceof IterationInstance)) { 124 throw new IllegalArgumentException 125 ("illegal type of iteration instance provided: " + instance.getClass()); 126 } 127 128 if (!(child instanceof TaskInstance)) { 129 throw new IllegalArgumentException 130 ("illegal type of task instance provided: " + child.getClass()); 131 } 132 133 /*IStructuringTemporalRelationship parentTask = 134 (IStructuringTemporalRelationship) parent.getTask(); 135 136 IMarkingTemporalRelationship parentTask = 137 (IMarkingTemporalRelationship) parent.getTask(); 138 139 foundChildTask = parentTask.getMarkedTask() != null ? 140 parentTask.getMarkedTask().equals(child.getTask()) : false; 141 142 if (!foundChildTask) { 143 throw new IllegalArgumentException 144 ("the task of the child instance to be added does not belong to the children " + 145 "of the task of the parent instance"); 146 }*/ 147 148 ((IterationInstance) instance).addChild(child); 149 } 150 151 /* (non-Javadoc) 152 * @see ITaskBuilder#addChild(IIterationInstance, int, ITaskInstance) 153 */ 154 public void addChild(IIterationInstance instance, int index, ITaskInstance child) 155 throws IllegalArgumentException 156 { 157 if (!(instance instanceof IterationInstance)) { 158 throw new IllegalArgumentException 159 ("illegal type of iteration instance provided: " + instance.getClass()); 160 } 161 162 if (!(child instanceof TaskInstance)) { 163 throw new IllegalArgumentException 164 ("illegal type of task instance provided: " + child.getClass()); 165 } 166 167 /*IStructuringTemporalRelationship parentTask = 168 (IStructuringTemporalRelationship) parent.getTask(); 169 170 IMarkingTemporalRelationship parentTask = 171 (IMarkingTemporalRelationship) parent.getTask(); 172 173 foundChildTask = parentTask.getMarkedTask() != null ? 174 parentTask.getMarkedTask().equals(child.getTask()) : false; 175 176 if (!foundChildTask) { 177 throw new IllegalArgumentException 178 ("the task of the child instance to be added does not belong to the children " + 179 "of the task of the parent instance"); 180 }*/ 181 182 ((IterationInstance) instance).addChild(index, child); 183 } 184 185 /* (non-Javadoc) 186 * @see ITaskBuilder#setChild(ISelectionInstance, ITaskInstance) 187 */ 188 @Override 189 public void setChild(ISelectionInstance instance, ITaskInstance child) 190 throws IllegalArgumentException 191 { 192 if (!(instance instanceof SelectionInstance)) { 193 throw new IllegalArgumentException 194 ("illegal type of sequence instance provided: " + instance.getClass()); 195 } 196 197 if (!(child instanceof TaskInstance)) { 198 throw new IllegalArgumentException 199 ("illegal type of task instance provided: " + child.getClass()); 200 } 201 202 /*IStructuringTemporalRelationship parentTask = 203 (IStructuringTemporalRelationship) parent.getTask(); 204 205 for (ITask parentTaskChild : parentTask.getChildren()) { 206 if (parentTaskChild.equals(child.getTask())) { 207 foundChildTask = true; 208 break; 209 } 210 } 211 212 if (!foundChildTask) { 213 throw new IllegalArgumentException 214 ("the task of the child instance to be added does not belong to the children " + 215 "of the task of the parent instance"); 216 }*/ 217 218 ((SelectionInstance) instance).setChild(child); 219 } 220 221 /* (non-Javadoc) 222 * @see ITaskBuilder#setChild(IOptionalInstance, ITaskInstance) 223 */ 224 @Override 225 public void setChild(IOptionalInstance instance, ITaskInstance child) 226 throws IllegalArgumentException 227 { 228 if (!(instance instanceof OptionalInstance)) { 229 throw new IllegalArgumentException 230 ("illegal type of optional instance provided: " + instance.getClass()); 231 } 232 233 if (!(child instanceof TaskInstance)) { 234 throw new IllegalArgumentException 235 ("illegal type of task instance provided: " + child.getClass()); 236 } 237 238 /*IStructuringTemporalRelationship parentTask = 239 (IStructuringTemporalRelationship) parent.getTask(); 240 241 IMarkingTemporalRelationship parentTask = 242 (IMarkingTemporalRelationship) parent.getTask(); 243 244 foundChildTask = parentTask.getMarkedTask() != null ? 245 parentTask.getMarkedTask().equals(child.getTask()) : false; 246 247 if (!foundChildTask) { 248 throw new IllegalArgumentException 249 ("the task of the child instance to be added does not belong to the children " + 250 "of the task of the parent instance"); 251 }*/ 252 253 ((OptionalInstance) instance).setChild(child); 115 254 } 116 255 … … 134 273 135 274 /* (non-Javadoc) 275 * @see ITaskBuilder#addExecutedTask(IUserSession, int, ITaskInstance) 276 */ 277 public void addExecutedTask(IUserSession session, int index, ITaskInstance taskInstance) { 278 if (!(session instanceof UserSession)) { 279 throw new IllegalArgumentException 280 ("illegal type of session provided: " + session.getClass()); 281 } 282 283 if (!(taskInstance instanceof TaskInstance)) { 284 throw new IllegalArgumentException 285 ("illegal type of task instance provided: " + taskInstance.getClass()); 286 } 287 288 ((UserSession) session).addExecutedTask(index, taskInstance); 289 } 290 291 /* (non-Javadoc) 136 292 * @see ITaskBuilder#addTaskInstance(ITaskInstanceList, ITaskInstance) 137 293 */ 138 294 @Override 139 295 public void addTaskInstance(ITaskInstanceList taskInstanceList, ITaskInstance taskInstance) { 140 if (taskInstanceList instanceof TaskInstance) { 141 ((TaskInstance) taskInstanceList).addChild(taskInstance); 296 if (taskInstanceList instanceof SequenceInstance) { 297 addChild((SequenceInstance) taskInstanceList, taskInstance); 298 } 299 else if (taskInstanceList instanceof IterationInstance) { 300 addChild((IterationInstance) taskInstanceList, taskInstance); 142 301 } 143 302 else if (taskInstanceList instanceof UserSession) { 144 ((UserSession) taskInstanceList).addExecutedTask(taskInstance);303 addExecutedTask((UserSession) taskInstanceList, taskInstance); 145 304 } 146 305 else { … … 158 317 ITaskInstance taskInstance) 159 318 { 160 if (taskInstanceList instanceof TaskInstance) { 161 ((TaskInstance) taskInstanceList).addChild(index, taskInstance); 319 if (taskInstanceList instanceof SequenceInstance) { 320 addChild((SequenceInstance) taskInstanceList, index, taskInstance); 321 } 322 else if (taskInstanceList instanceof IterationInstance) { 323 addChild((IterationInstance) taskInstanceList, index, taskInstance); 162 324 } 163 325 else if (taskInstanceList instanceof UserSession) { 164 ((UserSession) taskInstanceList).addExecutedTask(index, taskInstance);326 addExecutedTask((UserSession) taskInstanceList, index, taskInstance); 165 327 } 166 328 else { … … 178 340 ITaskInstance taskInstance) 179 341 { 180 if (taskInstanceList instanceof TaskInstance) { 181 ((TaskInstance) taskInstanceList).removeChild(index); 182 ((TaskInstance) taskInstanceList).addChild(index, taskInstance); 183 } 184 else if (taskInstanceList instanceof UserSession) { 185 ((UserSession) taskInstanceList).removeExecutedTask(index); 186 ((UserSession) taskInstanceList).addExecutedTask(index, taskInstance); 187 } 188 else { 189 throw new IllegalArgumentException 190 ("illegal type of task instance list provided: " + taskInstanceList.getClass()); 191 } 342 removeTaskInstance(taskInstanceList, index); 343 addTaskInstance(taskInstanceList, index, taskInstance); 192 344 } 193 345 … … 334 486 @Override 335 487 public void removeTaskInstance(ITaskInstanceList taskInstanceList, int index) { 336 if (taskInstanceList instanceof TaskInstance) { 337 ((TaskInstance) taskInstanceList).removeChild(index); 488 if (taskInstanceList instanceof SequenceInstance) { 489 ((SequenceInstance) taskInstanceList).removeChild(index); 490 } 491 else if (taskInstanceList instanceof IterationInstance) { 492 ((IterationInstance) taskInstanceList).removeChild(index); 338 493 } 339 494 else if (taskInstanceList instanceof UserSession) { … … 369 524 } 370 525 371 /* (non-Javadoc)372 * @see ITaskBuilder#setDescription(ITask, java.lang.String)373 */374 @Override375 public void setDescription(ITask parent, String description) {376 if (!(parent instanceof Task)) {377 throw new IllegalArgumentException378 ("illegal type of task provided: " + parent.getClass());379 }380 381 ((Task) parent).setDescription(description);382 }383 384 526 /** 385 527 * <p> -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskFactory.java
r1216 r1294 17 17 import java.util.List; 18 18 19 import de.ugoe.cs.autoquest.eventcore.IEventTarget; 20 import de.ugoe.cs.autoquest.eventcore.IEventType; 19 import de.ugoe.cs.autoquest.eventcore.Event; 21 20 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 21 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTaskInstance; 22 22 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 23 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIterationInstance; 23 24 import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptional; 25 import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptionalInstance; 24 26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 27 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelectionInstance; 25 28 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 27 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 28 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList; 29 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequenceInstance; 29 30 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; 30 31 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory; … … 43 44 44 45 /* (non-Javadoc) 45 * @see ITaskFactory#createNewEventTask( IEventType, IEventTarget)46 * @see ITaskFactory#createNewEventTask(String) 46 47 */ 47 48 @Override 48 public IEventTask createNewEventTask( IEventType eventType, IEventTarget eventTarget) {49 return new EventTask( eventType, eventTarget);49 public IEventTask createNewEventTask(String description) { 50 return new EventTask(description); 50 51 } 51 52 … … 83 84 84 85 /* (non-Javadoc) 85 * @see ITaskFactory#createNewTaskInstance(I Task)86 * @see ITaskFactory#createNewTaskInstance(IEventTask, Event) 86 87 */ 87 88 @Override 88 public ITaskInstance createNewTaskInstance(ITask task) { 89 return new TaskInstance(task); 89 public IEventTaskInstance createNewTaskInstance(IEventTask task, Event event) { 90 if (!(task instanceof EventTask)) { 91 throw new IllegalArgumentException 92 ("illegal type of event task provided: " + task.getClass()); 93 } 94 95 EventTaskInstance instance = new EventTaskInstance(task, event); 96 ((EventTask) task).addInstance(instance); 97 98 return instance; 90 99 } 91 100 92 101 /* (non-Javadoc) 93 * @see ITaskFactory#createNewTaskInstance List()102 * @see ITaskFactory#createNewTaskInstance(ISequence) 94 103 */ 95 104 @Override 96 public ITaskInstanceList createNewTaskInstanceList() { 97 return new TaskInstance(new Sequence()); 105 public ISequenceInstance createNewTaskInstance(ISequence sequence) { 106 if (!(sequence instanceof Sequence)) { 107 throw new IllegalArgumentException 108 ("illegal type of sequence provided: " + sequence.getClass()); 109 } 110 111 SequenceInstance instance = new SequenceInstance(sequence); 112 ((Sequence) sequence).addInstance(instance); 113 114 return instance; 115 } 116 117 /* (non-Javadoc) 118 * @see ITaskFactory#createNewTaskInstance(IIteration) 119 */ 120 @Override 121 public IIterationInstance createNewTaskInstance(IIteration iteration) { 122 if (!(iteration instanceof Iteration)) { 123 throw new IllegalArgumentException 124 ("illegal type of iteration provided: " + iteration.getClass()); 125 } 126 127 IterationInstance instance = new IterationInstance(iteration); 128 ((Iteration) iteration).addInstance(instance); 129 130 return instance; 131 } 132 133 /* (non-Javadoc) 134 * @see ITaskFactory#createNewTaskInstance(IOptional) 135 */ 136 @Override 137 public IOptionalInstance createNewTaskInstance(IOptional optional) { 138 if (!(optional instanceof Optional)) { 139 throw new IllegalArgumentException 140 ("illegal type of optional provided: " + optional.getClass()); 141 } 142 143 OptionalInstance instance = new OptionalInstance(optional); 144 ((Optional) optional).addInstance(instance); 145 146 return instance; 147 } 148 149 /* (non-Javadoc) 150 * @see ITaskFactory#createNewTaskInstance(ISelection) 151 */ 152 @Override 153 public ISelectionInstance createNewTaskInstance(ISelection selection) { 154 if (!(selection instanceof Selection)) { 155 throw new IllegalArgumentException 156 ("illegal type of optional provided: " + selection.getClass()); 157 } 158 159 SelectionInstance instance = new SelectionInstance(selection); 160 ((Selection) selection).addInstance(instance); 161 162 return instance; 98 163 } 99 164 -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskInstance.java
r1255 r1294 14 14 15 15 package de.ugoe.cs.autoquest.tasktrees.treeimpl; 16 17 import java.util.Collections;18 import java.util.Iterator;19 import java.util.LinkedList;20 import java.util.List;21 16 22 17 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; … … 64 59 /** 65 60 * <p> 66 * the children of this task instance which are task instances, as well67 * </p>68 */69 private List<ITaskInstance> children;70 71 /**72 * <p>73 61 * instantiated the task instance with the task that is instantiated by the instance. It also 74 62 * assigns a unique id to the instance using {@link #getNewId()}. … … 102 90 public ITask getTask() { 103 91 return task; 104 }105 106 /* (non-Javadoc)107 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance#getChildren()108 */109 public synchronized List<ITaskInstance> getChildren() {110 if (children == null) {111 children = new LinkedList<ITaskInstance>();112 }113 114 return Collections.unmodifiableList(children);115 }116 117 /* (non-Javadoc)118 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList#get(int)119 */120 @Override121 public ITaskInstance get(int index) {122 if (children == null) {123 throw new IndexOutOfBoundsException(Integer.toString(index));124 }125 else {126 return children.get(index);127 }128 }129 130 /* (non-Javadoc)131 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList#size()132 */133 @Override134 public int size() {135 if (children == null) {136 return 0;137 }138 else {139 return children.size();140 }141 }142 143 /* (non-Javadoc)144 * @see java.lang.Iterable#iterator()145 */146 @Override147 public Iterator<ITaskInstance> iterator() {148 return getChildren().iterator();149 92 } 150 93 … … 203 146 try { 204 147 clone = (TaskInstance) super.clone(); 205 206 if (children != null) {207 clone.children = new LinkedList<ITaskInstance>();208 209 for (ITaskInstance child : children) {210 clone.children.add(child.clone());211 }212 }213 214 148 } 215 149 catch (CloneNotSupportedException e) { … … 219 153 220 154 return clone; 221 }222 223 /**224 * <p>225 * used to add a child to this task instance226 * </p>227 *228 * @param child the new child of this instance229 */230 synchronized void addChild(ITaskInstance child) {231 if (children == null) {232 children = new LinkedList<ITaskInstance>();233 }234 235 children.add(child);236 }237 238 /**239 * <p>240 * used to add a child to this task instance at a specific position241 * </p>242 *243 * @param index the position of the new child in the list of children244 * @param child the new child of this instance245 */246 synchronized void addChild(int index, ITaskInstance child) {247 if (children == null) {248 children = new LinkedList<ITaskInstance>();249 }250 251 children.add(index, child);252 }253 254 /**255 * <p>256 * removes a child from this task instance at a specific position257 * </p>258 *259 * @param index the position of the child to be removed260 *261 * @return the child remove from the children of this instance262 */263 synchronized ITaskInstance removeChild(int index) {264 if (children != null) {265 return children.remove(index);266 }267 else {268 throw new IllegalArgumentException269 ("this task instance does not have children that can be removed");270 }271 155 } 272 156
Note: See TracChangeset
for help on using the changeset viewer.