Java Reference
In-Depth Information
protected void acceptChildren(ProcessComposite c)
{
Iterator i = c.getSubprocesses().iterator();
depth++;
while (i.hasNext())
{
((ProcessComponent) i.next()).accept(this);
}
depth--;
}
protected void printTag(String tag)
{
for (int i = 0; i < depth * INDENT_DEPTH; i++)
{
buf.append(" ");
}
buf.append(tag);
buf.append("\n");
}
}
A short program can now pretty-print a process flow:
package com.oozinoz.applications;
import com.oozinoz.process.*;
import com.oozinoz.dublin.*;
public class ShowPretty
{
public static void main(String[] args)
{
ProcessComponent p = ShellProcess.make();
PrettyVisitor v = new PrettyVisitor();
System.out.println(v.getPretty(p));
}
}
Running this program prints out:
Make an aerial shell
Build inner shell
Inspect
?Rework inner shell, or complete shell
Rework
Disassemble
Make an aerial shell
... Finish: Attach lift, insert fusing, wrap
The developers of the ProcessComponent hierarchy are well aware of the need to avoid
infinite loops while traversing process flows. As the PrettyVisitor class shows,
the developers of the visitor also have to be aware of the potential for cycles in process
components. It would help prevent errors if the ProcessComponent developers could
provide some support of cycle management as part of their support of V ISITOR .
Search WWH ::




Custom Search