/** * Print the full tree of commands with indentation - useful for debugging * @return String String representation of command tree */ public String printCommandTree() { StringBuffer str = new StringBuffer(); printCommandTree(str, 0); return str.toString(); }
/** * Print the full tree of commands with indentation - useful for debugging * @return String String representation of command tree */ public String printCommandTree() { StringBuffer str = new StringBuffer(); printCommandTree(str, 0); return str.toString(); }
/** * Print the full tree of commands with indentation - useful for debugging * @return String String representation of command tree */ public String printCommandTree() { StringBuffer str = new StringBuffer(); printCommandTree(str, 0); return str.toString(); }
/** * Helper method to print command tree at given tab level * @param str String buffer to add command sub tree to * @param tabLevel Number of tabs to print this command at */ protected void printCommandTree(StringBuffer str, int tabLevel) { // Add tabs for(int i=0; i<tabLevel; i++) { str.append("\t"); //$NON-NLS-1$ } // Add this command str.append(toString()); str.append("\n"); //$NON-NLS-1$ // Add children recursively tabLevel++; for (Command subCommand : CommandCollectorVisitor.getCommands(this)) { subCommand.printCommandTree(str, tabLevel); } }
/** * Helper method to print command tree at given tab level * @param str String buffer to add command sub tree to * @param tabLevel Number of tabs to print this command at */ protected void printCommandTree(StringBuffer str, int tabLevel) { // Add tabs for(int i=0; i<tabLevel; i++) { str.append("\t"); //$NON-NLS-1$ } // Add this command str.append(toString()); str.append("\n"); //$NON-NLS-1$ // Add children recursively tabLevel++; for (Command subCommand : CommandCollectorVisitor.getCommands(this)) { subCommand.printCommandTree(str, tabLevel); } }
/** * Helper method to print command tree at given tab level * @param str String buffer to add command sub tree to * @param tabLevel Number of tabs to print this command at */ protected void printCommandTree(StringBuffer str, int tabLevel) { // Add tabs for(int i=0; i<tabLevel; i++) { str.append("\t"); //$NON-NLS-1$ } // Add this command str.append(toString()); str.append("\n"); //$NON-NLS-1$ // Add children recursively tabLevel++; for (Command subCommand : CommandCollectorVisitor.getCommands(this)) { subCommand.printCommandTree(str, tabLevel); } }
@Test public void testImplicitTempInsertWithNoColumns() { StringBuffer proc = new StringBuffer("CREATE VIRTUAL PROCEDURE") //$NON-NLS-1$ .append("\nBEGIN") //$NON-NLS-1$ .append("\n create local temporary table #matt (x integer);") //$NON-NLS-1$ .append("\n insert into #matt values (1);") //$NON-NLS-1$ .append("\nEND"); //$NON-NLS-1$ Command cmd = helpResolve(proc.toString()); String sExpected = "BEGIN\nCREATE LOCAL TEMPORARY TABLE #matt (x integer);\nINSERT INTO #matt (x) VALUES (1);\nEND\n\tCREATE LOCAL TEMPORARY TABLE #matt (x integer)\n\tINSERT INTO #matt (x) VALUES (1)\n"; //$NON-NLS-1$ String sActual = cmd.printCommandTree(); assertEquals( sExpected, sActual ); }