/* XmlDisplayer.java */
import java.util.ArrayList;
public class XmlDisplayer implements Visitor
{
private boolean terminal = true;
public Object visit(Rule_Clock rule)
{
if (!terminal) System.out.println();
System.out.print("<Clock>");
terminal = false;
visitRules(rule.rules);
if (!terminal) System.out.println();
System.out.print("</Clock>");
terminal = false;
return null;
}
public Object visit(Rule_Hours rule)
{
if (!terminal) System.out.println();
System.out.print("<Hours>");
terminal = false;
visitRules(rule.rules);
if (!terminal) System.out.println();
System.out.print("</Hours>");
terminal = false;
return null;
}
public Object visit(Rule_Minutes rule)
{
if (!terminal) System.out.println();
System.out.print("<Minutes>");
terminal = false;
visitRules(rule.rules);
if (!terminal) System.out.println();
System.out.print("</Minutes>");
terminal = false;
return null;
}
public Object visit(Rule_Seconds rule)
{
if (!terminal) System.out.println();
System.out.print("<Seconds>");
terminal = false;
visitRules(rule.rules);
if (!terminal) System.out.println();
System.out.print("</Seconds>");
terminal = false;
return null;
}
public Object visit(Rule_Separator rule)
{
if (!terminal) System.out.println();
System.out.print("<Separator>");
terminal = false;
visitRules(rule.rules);
if (!terminal) System.out.println();
System.out.print("</Separator>");
terminal = false;
return null;
}
public Object visit(Terminal_StringValue value)
{
System.out.print(value.spelling);
terminal = true;
return null;
}
public Object visit(Terminal_NumericValue value)
{
System.out.print(value.spelling);
terminal = true;
return null;
}
private Boolean visitRules(ArrayList<Rule> rules)
{
for (Rule rule : rules)
rule.accept(this);
return null;
}
}
/* eof */