import edu.neu.ccs.demeter.dj.*; class JKrauzeVisitor extends Visitor { // Display hyperslice: concern: object display static int _indent = 0; static String _newLine = ""; public void start(){ System.out.println(" start display "); } public void before(Object host){ if(!isTerm(host)) { System.out.print(_newLine + host.getClass().getName() + " {"); _newLine = ""; if(host instanceof java.util.Collection) { System.out.println(); //An extra indent is necessary because the local print needs //to know that is a new group _indent++; pIndent(); System.out.print(" "); } } else { System.out.print(host.getClass().getName() + " \"" + host + "\""); _newLine = "\n"; for(int i = 0; i < _indent; i++) { _newLine += " "; } _newLine += " "; //Same idea here since we reached a terminal _indent++; } _indent++; } public void after(Object host) { _indent--; System.out.print("}"); } public void before(Object source, String label, Object target){ System.out.println(); pIndent(); System.out.print("<" + label + "> "); } public void finish(){ System.out.println(); System.out.println(" finish display "); } public void pIndent(){ for(int i = 0; i < _indent; i++) { System.out.print(" "); } } public void addIndent(String ind) { for(int i = 0; i < _indent; i++) { ind += " "; } } public boolean isTerm(Object oTerm) { if( (oTerm instanceof Integer) || (oTerm instanceof String) ) { return true; } return false; } };