Changeset 1412
- Timestamp:
- 02/27/14 17:10:33 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-test-utils/src/main/java/de/ugoe/cs/autoquest/tasktrees/TaskTreeEncoder.java
r1294 r1412 29 29 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTaskInstance; 30 30 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 31 import de.ugoe.cs.autoquest.tasktrees.treeifc.IMarkingTemporalRelationship; 31 32 import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptional; 32 33 import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptionalInstance; … … 34 35 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelectionInstance; 35 36 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 37 import de.ugoe.cs.autoquest.tasktrees.treeifc.IStructuringTemporalRelationship; 36 38 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 37 39 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; … … 85 87 } 86 88 } 89 90 /** 91 * 92 */ 93 public void encode(ITask task) 94 throws FileNotFoundException 95 { 96 PrintStream out = null; 97 try { 98 out = new PrintStream(new FileOutputStream("task.txt")); 99 encode(task, out); 100 } 101 finally { 102 if (out != null) { 103 out.close(); 104 } 105 } 106 } 87 107 88 108 /** … … 109 129 public void encode(ITaskInstance taskInstance, PrintStream out) { 110 130 encode(taskInstance, out, "", 0); 131 } 132 133 /** 134 * 135 */ 136 public void encode(ITask task, PrintStream out) { 137 encode(task, out, "", 0); 111 138 } 112 139 … … 163 190 else if (taskInstance instanceof IOptionalInstance) { 164 191 encode(((IOptionalInstance) taskInstance).getChild(), out, indent + " ", i++); 192 } 193 194 if (task instanceof ITemporalRelationship) { 195 out.print(indent); 196 out.print("}"); 197 } 198 199 out.println(); 200 } 201 202 /** 203 * 204 */ 205 private void encode(ITask task, 206 PrintStream out, 207 String indent, 208 int index) 209 { 210 if (task instanceof ITemporalRelationship) { 211 if (index > 0) { 212 out.println(); 213 } 214 out.print(indent); 215 216 if (task instanceof ISequence) { 217 out.print("Sequence "); 218 } 219 else if (task instanceof ISelection) { 220 out.print("Selection "); 221 } 222 else if (task instanceof IIteration) { 223 out.print("Iteration "); 224 } 225 else if (task instanceof IOptional) { 226 out.print("Optional "); 227 } 228 229 out.print(task.getId()); 230 out.println(" {"); 231 } 232 else if (task instanceof IEventTask) { 233 out.print(indent); 234 out.print(task); 235 } 236 else { 237 fail("unknown type of task " + task); 238 } 239 240 int i = 0; 241 242 if (task instanceof IStructuringTemporalRelationship) { 243 for (ITask child : ((IStructuringTemporalRelationship) task).getChildren()) { 244 encode(child, out, indent + " ", i++); 245 } 246 } 247 else if (task instanceof IMarkingTemporalRelationship) { 248 encode(((IMarkingTemporalRelationship) task).getMarkedTask(), out, indent + " ", i++); 165 249 } 166 250
Note: See TracChangeset
for help on using the changeset viewer.