import brs.*; /** * Computes a String representation of a BiTree in in-order traversal. * Has extra new line characters when left and/or right subtrees are empty. * These new line characters can ge best handled by helper visitors. * @author D.X. Nguyen - Copyright 2001 - All Rights Reserved */ public class DictToString implements IVisitor { public static final DictToString Singleton = new DictToString(); private DictToString() { } public Object emptyCase(BiTree host, Object inp) { return ""; } public Object nonEmptyCase(BiTree host, Object inp) { return host.getLeftSubTree().execute(this, null) + "\n" + host.getRootDat().toString() + "\n" + host.getRightSubTree().execute(this, null); } }