db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r984902 - in /db/derby/code/trunk/java/tools/org/apache/derby: impl/tools/planexporter/ impl/tools/planexporter/resources/ tools/
Date Thu, 12 Aug 2010 18:30:44 GMT
Author: kristwaa
Date: Thu Aug 12 18:30:43 2010
New Revision: 984902

URL: http://svn.apache.org/viewvc?rev=984902&view=rev
Log:
DERBY-4587: Add tools for improved analysis and understanding of query plans and execution statistics

Formatting changes:
 o moved class JavaDoc to after package and import statements
   (the ASF license header will be the first content of the files)
 o replaced tabs with spaces (1 tab = 4 spaces)
 o removed trailing whitespace

Patch file: DERBY-4587-tool-9.9-formatting.diff

Modified:
    db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/AccessDatabase.java
    db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/CreateHTMLFile.java
    db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/CreateXMLFile.java
    db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/TreeNode.java
    db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/resources/advancedViewXSL.xsl
    db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/resources/advancedViewXSL2.xsl
    db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/resources/vanilla_html.xsl
    db/derby/code/trunk/java/tools/org/apache/derby/tools/PlanExporter.java

Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/AccessDatabase.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/AccessDatabase.java?rev=984902&r1=984901&r2=984902&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/AccessDatabase.java (original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/AccessDatabase.java Thu Aug 12 18:30:43 2010
@@ -1,9 +1,3 @@
-/**
- * This class will perform the database connection establishment,
- * querying the database, shut downing the database.
- * Created under DERBY-4587-PlanExporter tool
- */
-
 package org.apache.derby.impl.tools.planexporter;
 
 import java.sql.Connection;
@@ -12,483 +6,488 @@ import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 
+/**
+ * This class will perform the database connection establishment,
+ * querying the database, shut downing the database.
+ * Created under DERBY-4587-PlanExporter tool
+ */
 public class AccessDatabase {
 
-	private Connection conn = null;
-	private Statement stmt = null;
-	private TreeNode[] data;
-	private String dbURL = null;
-	private String schema = null;
-	private String query = null;
-	/**
-	 * @param query the stmt_id to set
-	 */
-	public void setQuery(String query) {
-		this.query = query;
-	}
-
-	/**
-	 * @return the stmt_id
-	 */
-	public String getQuery() {
-		return query;
-	}
-	private int depth = 0;	
-	public int getDepth() {
-		return depth;
-	}
-	private String xmlDetails="";
-
-	//set of variables to identify values of XPlain tables
-	private static final int ID =0 ;
-	private static final int P_ID =1;
-	private static final int NODE_TYPE=2;
-	private static final int NO_OF_OPENS=3;
-	private static final int INPUT_ROWS=4;
-	private static final int RETURNED_ROWS=5;
-	private static final int VISITED_PAGES=6;
-	private static final int SCAN_QUALIFIERS=7;
-	private static final int NEXT_QUALIFIERS=8;
-	private static final int SCANNED_OBJECT=9;
-	private static final int SCAN_TYPE=10;
-	private static final int SORT_TYPE=11;
-	private static final int NO_OF_OUTPUT_ROWS_BY_SORTER=12;
-
-
-	/**
-	 * 
-	 * @param dburl
-	 * @param aSchema
-	 * @param aQuery
-	 */
-	public AccessDatabase(String dburl, String aSchema, String aQuery) {
-
-		dbURL = dburl;
-		schema = aSchema;
-		setQuery(aQuery);
-
-	}
-
-	/**
-	 * 
-	 * @param aConn
-	 * @param aSchema
-	 * @param aQuery
-	 *
-	 */
-	public AccessDatabase(Connection aConn, String aSchema, String aQuery) {
-
-		conn = aConn;
-		schema = aSchema;
-		setQuery(aQuery);
-
-	}
-
-	/**
-	 * 
-	 * @throws InstantiationException
-	 * @throws IllegalAccessException
-	 * @throws ClassNotFoundException
-	 * @throws SQLException 
-	 */
-	public void createConnection() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
-	{
-
-		if(dbURL.indexOf("://") != -1)
-			Class.forName("org.apache.derby.jdbc.ClientDriver").newInstance();
-
-		else
-			Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
-
-		//Get a connection
-		conn = DriverManager.getConnection(dbURL); 
-
-	}
-
-	/**
-	 * <p>
-	 * This method creates the queries such that after execution
-	 * of the query it will return XML data fragments.
-	 * </P>
-	 * @throws SQLException
-	 * */
-	public void createXMLFragment() throws SQLException{
-		createXMLData(
-				"select 'id=\"' ||RS_ID|| '\"' " +
-				"from "+schema+".SYSXPLAIN_RESULTSETS " +
-				"where STMT_ID = '"+getQuery()+"'", ID);
-
-		createXMLData(
-				"select PARENT_RS_ID "+
-				"from "+schema+".SYSXPLAIN_RESULTSETS " +
-				"where STMT_ID = '"+getQuery()+"'", P_ID);
-
-		createXMLData(
-				"select 'name=\"' ||OP_IDENTIFIER|| '\"' " +
-				"from "+schema+".SYSXPLAIN_RESULTSETS " +
-				"where STMT_ID = '"+getQuery()+"'", NODE_TYPE);
-
-		createXMLData(
-				"select 'no_opens=\"' " +
-				"|| TRIM(CHAR(NO_OPENS))|| '\"' " +
-				"from "+schema+".SYSXPLAIN_RESULTSETS " +
-				"where STMT_ID = '"+getQuery()+"'", NO_OF_OPENS);
-
-		createXMLData(
-				"select 'input_rows=\"' " +
-				"|| TRIM(CHAR(INPUT_ROWS))|| '\"' " +
-				"from "+schema+".SYSXPLAIN_RESULTSETS " +
-				"where STMT_ID = '"+getQuery()+"'", INPUT_ROWS);
-
-		createXMLData(
-				"select 'returned_rows=\"' " +
-				"|| TRIM(CHAR(RETURNED_ROWS))|| '\"' " +
-				"from "+schema+".SYSXPLAIN_RESULTSETS " +
-				"where STMT_ID = '"+getQuery()+"'", RETURNED_ROWS);
-
-		createXMLData(
-				"select 'visited_pages=\"'" +
-				"|| TRIM(CHAR(NO_VISITED_PAGES))|| '\"' " +
-				"from ("+schema+".SYSXPLAIN_SCAN_PROPS " +
-				"NATURAL RIGHT OUTER JOIN "+schema+".SYSXPLAIN_RESULTSETS) " +
-				"where STMT_ID = '"+getQuery()+"'", VISITED_PAGES);
-
-		createXMLData(
-				"select 'scan_qualifiers=\"'"+ 
-				"||SCAN_QUALIFIERS|| '\"' " +
-				"from ("+schema+".SYSXPLAIN_SCAN_PROPS " +
-				"NATURAL RIGHT OUTER JOIN "+schema+".SYSXPLAIN_RESULTSETS) " +
-				"where STMT_ID = '"+getQuery()+"'", SCAN_QUALIFIERS);
-
-		createXMLData(
-				"select 'next_qualifiers=\"'"+
-				"||NEXT_QUALIFIERS|| '\"' " +
-				"from ("+schema+".SYSXPLAIN_SCAN_PROPS " +
-				"NATURAL RIGHT OUTER JOIN "+schema+".SYSXPLAIN_RESULTSETS) " +
-				"where STMT_ID = '"+getQuery()+"'", NEXT_QUALIFIERS);
-
-		createXMLData(
-				"select 'scanned_object=\"'"+
-				"||SCAN_OBJECT_NAME|| '\"' " +
-				"from ("+schema+".SYSXPLAIN_SCAN_PROPS " +
-				"NATURAL RIGHT OUTER JOIN "+schema+".SYSXPLAIN_RESULTSETS) " +
-				"where STMT_ID = '"+getQuery()+"'", SCANNED_OBJECT);
-
-		createXMLData(
-				"select 'scan_type=\"'"+
-				"||TRIM(SCAN_TYPE)|| '\"' " +
-				"from ("+schema+".SYSXPLAIN_SCAN_PROPS " +
-				"NATURAL RIGHT OUTER JOIN "+schema+".SYSXPLAIN_RESULTSETS) " +
-				"where STMT_ID = '"+getQuery()+"'", SCAN_TYPE);
-
-		createXMLData(
-				"select 'sort_type=\"'"+
-				"||TRIM(SORT_TYPE)|| '\"' " +
-				"from ("+schema+".SYSXPLAIN_SORT_PROPS " +
-				"NATURAL RIGHT OUTER JOIN "+schema+".SYSXPLAIN_RESULTSETS) " +
-				"where STMT_ID = '"+getQuery()+"'", SORT_TYPE);
-
-		createXMLData(
-				"select 'sorter_output=\"'"+
-				"||TRIM(CHAR(NO_OUTPUT_ROWS))|| '\"' " +
-				"from ("+schema+".SYSXPLAIN_SORT_PROPS " +
-				"NATURAL RIGHT OUTER JOIN "+schema+".SYSXPLAIN_RESULTSETS) " +
-				"where STMT_ID = '"+getQuery()+"'", NO_OF_OUTPUT_ROWS_BY_SORTER);
-
-	}
-
-	/**
-	 * Generating the XML tree
-	 * @return all xml elements as a String
-	 */
-	public String getXmlString(){
-
-		for(int i=0;i<data.length;i++){
-			//assume only one root element for any query
-			if(data[i].getDepth()==0){//root element
-				xmlDetails += indent(1);
-				xmlDetails += data[i].toString();
-				getChildren(1, data[i].getId());
-				xmlDetails += indent(1)+"</node>\n";
-				break;
-			}
-		}
-		return xmlDetails;
-	}
-
-	/**
-	 * 
-	 * @param currentLevel level of the XML tree (0 based) of current node
-	 * @param id current node's stmt_id
-	 */
-	private void getChildren(int currentLevel,String id ){
-		if(currentLevel <= depth){
-			for(int i=0;i<data.length;i++){
-				if(data[i].getDepth()== currentLevel &&
-						(id.indexOf(data[i].getParent()) != -1))
-				{
-					xmlDetails += indent(currentLevel+1);
-					xmlDetails += data[i].toString();
-					getChildren(currentLevel+1, data[i].getId());
-					xmlDetails += indent(currentLevel+1)+"</node>\n";
-				}
-			}
-		}
-	}
-
-	/**
-	 * 
-	 * @param j indent needed
-	 * @return indent as a string
-	 */
-	public String indent(int j){
-		String str="";
-		for(int i=0;i<=j+1;i++)
-			str +="	";
-
-		return str;
-	}
-
-	/**
-	 * marking the depth of each element
-	 */
-	public void markTheDepth(){
-		int i=0;
-		while(data[i].getParent().indexOf("null")== -1)
-			i++;
-		data[i].setDepth(depth); //root
-		findChildren(i,depth);
-	}
-
-	/**
-	 * 
-	 * @param idx current element's index
-	 * @param dep current examining depth
-	 */
-	private void findChildren(int idx, int dep) {
-		if(dep>depth)
-			depth =dep;
-
-		for(int i=0;i<data.length;i++){
-
-			if(data[i].getParent().indexOf("null")== -1){ 
-				if((data[idx].getId()).indexOf(data[i].getParent()) != -1
-						&& i != idx)
-				{
-					data[i].setDepth(dep +1);
-					findChildren(i,dep+1);	 
-				}		
-			}
-		}
-	}
-
-
-	/**
-	 * 
-	 * @return whether the initialization is successful or not
-	 * @throws SQLException 
-	 */
-	public boolean initializeDataArray() throws SQLException{
-		if(noOfNodes()==0)
-			return false;
-		else{
-			data = new TreeNode[noOfNodes()];
-			for(int i=0; i<data.length;i++){
-				data[i] = new TreeNode();
-			}
-			return true;
-		}
-
-	}
-
-	/**
-	 * 
-	 * @param qry query to be executed
-	 * @throws SQLException 
-	 */
-	private void createXMLData(String qry, int x) throws SQLException{
-
-		stmt = conn.createStatement();
-		ResultSet results = stmt.executeQuery(qry);
-
-		int i=0;
-		while(results.next())
-		{
-			String text= results.getString(1);
-			if(text != null){
-				switch(x){
-				case ID: 
-					data[i].setId(text+" ");
-					break;
-				case P_ID:
-					data[i].setParent(text);
-					break;
-				case NODE_TYPE:
-					data[i].setNodeType(text+" ");
-					break;
-				case NO_OF_OPENS:
-					data[i].setNoOfOpens(text+" ");
-					break;
-				case INPUT_ROWS:
-					data[i].setInputRows(text+" ");
-					break;
-				case RETURNED_ROWS:
-					data[i].setReturnedRows(text+" ");
-					break;
-				case VISITED_PAGES:
-					data[i].setVisitedPages(text+" ");
-					break;	
-				case SCAN_QUALIFIERS:
-					data[i].setScanQualifiers(text+" ");
-					break;
-				case NEXT_QUALIFIERS:
-					data[i].setNextQualifiers(text+" ");
-					break;
-				case SCANNED_OBJECT:
-					data[i].setScannedObject(text+" ");
-					break;
-				case SCAN_TYPE:
-					data[i].setScanType(text+" ");
-					break;
-				case SORT_TYPE:
-					data[i].setSortType(text+" ");
-					break;
-				case NO_OF_OUTPUT_ROWS_BY_SORTER:
-					data[i].setSorterOutput(text+" ");
-					break;
-				}
-			}
-			else{
-				/*Other attributes are omitted from the xml document 
-				 * if they're null.
-				 * P_ID can be null at the root.
-				 * */
-				switch(x){
-				case P_ID:
-					data[i].setParent(text+"");
-					break;
-				}
-			}
-			i++;	 
-		}
-		results.close();
-		stmt.close();
-	}
-
-	/**
-	 * 
-	 * @return total # of nodes
-	 * @throws SQLException 
-	 */
-	private int noOfNodes() throws SQLException{
-
-		stmt = conn.createStatement();
-		ResultSet results = stmt.executeQuery(
-				"select count(*) from " +
-				""+schema+".SYSXPLAIN_RESULTSETS " +
-				"where STMT_ID = '"+getQuery()+"'");
-		results.next();
-		int no = results.getInt(1);
-		results.close();
-		stmt.close();
-		return no;
-	}
-
-
-	/**
-	 * 
-	 * @return the &lt;statement&gt; element
-	 * @throws SQLException 
-	 */
-	public String statement() throws SQLException{
-		stmt = conn.createStatement();
-		ResultSet results = stmt.executeQuery(
-				"select STMT_TEXT "+
-				"from "+schema+".SYSXPLAIN_STATEMENTS " +
-				"where STMT_ID = '"+getQuery()+"'");
-		results.next();
-		String statement = results.getString(1);
-		results.close();
-		stmt.close();
-		/*Removing possible less than and greater than characters
-		 * in a query statement with XML representation.*/
-		if(statement.indexOf('<')!= -1){
-			statement = replace(statement, "<","&lt;");
-		}
-		if(statement.indexOf('>')!= -1){
-			statement = replace(statement, ">","&gt;");
-		}
-		return "<statement>"+statement+"</statement>\n";
-	}
-
-	/**
-	 * 
-	 * @param stmt statement to be changed
-	 * @param expr string to be removed
-	 * @param replace string to be added
-	 * @return modified string
-	 */
-	private String replace(String stmt, String expr, String replace){
-		String[] part=stmt.split(expr);
-		String newStmt= part[0];
-		for(int i=1;i<part.length;i++){
-			newStmt += " "+replace+" "+part[i];
-		}
-
-		return newStmt;
-	}
-	
-	/**
-	 * 
-	 * @return XPLAIN_TIME of SYSXPLAIN_STATEMENTS
-	 * @throws SQLException
-	 */
-	public String time() throws SQLException{
-		stmt = conn.createStatement();
-		ResultSet results = stmt.executeQuery(
-				"select '<time>'||TRIM(CHAR(XPLAIN_TIME))||" +
-				"'</time>' from "+schema+".SYSXPLAIN_STATEMENTS " +
-				"where STMT_ID = '"+getQuery()+"'");
-		results.next();
-		String time = results.getString(1);
-		results.close();
-		stmt.close();
-		
-		return time;
-	}
-	
-	/**
-	 * 
-	 * @return stmt_id as a XML element
-	 */
-	public String stmtID(){
-		return "<stmt_id>"+getQuery()+"</stmt_id>";
-	}
-
-	/**
-	 * closing the connection to the database
-	 */
-	public void closeConnection()
-	{
-		try
-		{
-			if (stmt != null)
-			{
-				stmt.close();
-			}
-			if (conn != null)
-			{
-				conn.close();
-			}           
-		}
-		catch (SQLException sqlExcept){}
-	}
-
-	/**
-	 * 
-	 * @return data array of TreeNode Objects 
-	 */
-	public TreeNode[] getData() {
-		return data;
-	}
+    private Connection conn = null;
+    private Statement stmt = null;
+    private TreeNode[] data;
+    private String dbURL = null;
+    private String schema = null;
+    private String query = null;
+    /**
+     * @param query the stmt_id to set
+     */
+    public void setQuery(String query) {
+        this.query = query;
+    }
+
+    /**
+     * @return the stmt_id
+     */
+    public String getQuery() {
+        return query;
+    }
+    private int depth = 0;
+    public int getDepth() {
+        return depth;
+    }
+    private String xmlDetails="";
+
+    //set of variables to identify values of XPlain tables
+    private static final int ID =0 ;
+    private static final int P_ID =1;
+    private static final int NODE_TYPE=2;
+    private static final int NO_OF_OPENS=3;
+    private static final int INPUT_ROWS=4;
+    private static final int RETURNED_ROWS=5;
+    private static final int VISITED_PAGES=6;
+    private static final int SCAN_QUALIFIERS=7;
+    private static final int NEXT_QUALIFIERS=8;
+    private static final int SCANNED_OBJECT=9;
+    private static final int SCAN_TYPE=10;
+    private static final int SORT_TYPE=11;
+    private static final int NO_OF_OUTPUT_ROWS_BY_SORTER=12;
+
+
+    /**
+     *
+     * @param dburl
+     * @param aSchema
+     * @param aQuery
+     */
+    public AccessDatabase(String dburl, String aSchema, String aQuery) {
+
+        dbURL = dburl;
+        schema = aSchema;
+        setQuery(aQuery);
+
+    }
+
+    /**
+     *
+     * @param aConn
+     * @param aSchema
+     * @param aQuery
+     *
+     */
+    public AccessDatabase(Connection aConn, String aSchema, String aQuery) {
+
+        conn = aConn;
+        schema = aSchema;
+        setQuery(aQuery);
+
+    }
+
+    /**
+     *
+     * @throws InstantiationException
+     * @throws IllegalAccessException
+     * @throws ClassNotFoundException
+     * @throws SQLException
+     */
+    public void createConnection() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
+    {
+
+        if(dbURL.indexOf("://") != -1)
+            Class.forName("org.apache.derby.jdbc.ClientDriver").newInstance();
+
+        else
+            Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
+
+        //Get a connection
+        conn = DriverManager.getConnection(dbURL);
+
+    }
+
+    /**
+     * <p>
+     * This method creates the queries such that after execution
+     * of the query it will return XML data fragments.
+     * </P>
+     * @throws SQLException
+     * */
+    public void createXMLFragment() throws SQLException{
+        createXMLData(
+                "select 'id=\"' ||RS_ID|| '\"' " +
+                "from "+schema+".SYSXPLAIN_RESULTSETS " +
+                "where STMT_ID = '"+getQuery()+"'", ID);
+
+        createXMLData(
+                "select PARENT_RS_ID "+
+                "from "+schema+".SYSXPLAIN_RESULTSETS " +
+                "where STMT_ID = '"+getQuery()+"'", P_ID);
+
+        createXMLData(
+                "select 'name=\"' ||OP_IDENTIFIER|| '\"' " +
+                "from "+schema+".SYSXPLAIN_RESULTSETS " +
+                "where STMT_ID = '"+getQuery()+"'", NODE_TYPE);
+
+        createXMLData(
+                "select 'no_opens=\"' " +
+                "|| TRIM(CHAR(NO_OPENS))|| '\"' " +
+                "from "+schema+".SYSXPLAIN_RESULTSETS " +
+                "where STMT_ID = '"+getQuery()+"'", NO_OF_OPENS);
+
+        createXMLData(
+                "select 'input_rows=\"' " +
+                "|| TRIM(CHAR(INPUT_ROWS))|| '\"' " +
+                "from "+schema+".SYSXPLAIN_RESULTSETS " +
+                "where STMT_ID = '"+getQuery()+"'", INPUT_ROWS);
+
+        createXMLData(
+                "select 'returned_rows=\"' " +
+                "|| TRIM(CHAR(RETURNED_ROWS))|| '\"' " +
+                "from "+schema+".SYSXPLAIN_RESULTSETS " +
+                "where STMT_ID = '"+getQuery()+"'", RETURNED_ROWS);
+
+        createXMLData(
+                "select 'visited_pages=\"'" +
+                "|| TRIM(CHAR(NO_VISITED_PAGES))|| '\"' " +
+                "from ("+schema+".SYSXPLAIN_SCAN_PROPS " +
+                "NATURAL RIGHT OUTER JOIN "+schema+".SYSXPLAIN_RESULTSETS) " +
+                "where STMT_ID = '"+getQuery()+"'", VISITED_PAGES);
+
+        createXMLData(
+                "select 'scan_qualifiers=\"'"+
+                "||SCAN_QUALIFIERS|| '\"' " +
+                "from ("+schema+".SYSXPLAIN_SCAN_PROPS " +
+                "NATURAL RIGHT OUTER JOIN "+schema+".SYSXPLAIN_RESULTSETS) " +
+                "where STMT_ID = '"+getQuery()+"'", SCAN_QUALIFIERS);
+
+        createXMLData(
+                "select 'next_qualifiers=\"'"+
+                "||NEXT_QUALIFIERS|| '\"' " +
+                "from ("+schema+".SYSXPLAIN_SCAN_PROPS " +
+                "NATURAL RIGHT OUTER JOIN "+schema+".SYSXPLAIN_RESULTSETS) " +
+                "where STMT_ID = '"+getQuery()+"'", NEXT_QUALIFIERS);
+
+        createXMLData(
+                "select 'scanned_object=\"'"+
+                "||SCAN_OBJECT_NAME|| '\"' " +
+                "from ("+schema+".SYSXPLAIN_SCAN_PROPS " +
+                "NATURAL RIGHT OUTER JOIN "+schema+".SYSXPLAIN_RESULTSETS) " +
+                "where STMT_ID = '"+getQuery()+"'", SCANNED_OBJECT);
+
+        createXMLData(
+                "select 'scan_type=\"'"+
+                "||TRIM(SCAN_TYPE)|| '\"' " +
+                "from ("+schema+".SYSXPLAIN_SCAN_PROPS " +
+                "NATURAL RIGHT OUTER JOIN "+schema+".SYSXPLAIN_RESULTSETS) " +
+                "where STMT_ID = '"+getQuery()+"'", SCAN_TYPE);
+
+        createXMLData(
+                "select 'sort_type=\"'"+
+                "||TRIM(SORT_TYPE)|| '\"' " +
+                "from ("+schema+".SYSXPLAIN_SORT_PROPS " +
+                "NATURAL RIGHT OUTER JOIN "+schema+".SYSXPLAIN_RESULTSETS) " +
+                "where STMT_ID = '"+getQuery()+"'", SORT_TYPE);
+
+        createXMLData(
+                "select 'sorter_output=\"'"+
+                "||TRIM(CHAR(NO_OUTPUT_ROWS))|| '\"' " +
+                "from ("+schema+".SYSXPLAIN_SORT_PROPS " +
+                "NATURAL RIGHT OUTER JOIN "+schema+".SYSXPLAIN_RESULTSETS) " +
+                "where STMT_ID = '"+getQuery()+"'", NO_OF_OUTPUT_ROWS_BY_SORTER);
+
+    }
+
+    /**
+     * Generating the XML tree
+     * @return all xml elements as a String
+     */
+    public String getXmlString(){
+
+        for(int i=0;i<data.length;i++){
+            //assume only one root element for any query
+            if(data[i].getDepth()==0){//root element
+                xmlDetails += indent(1);
+                xmlDetails += data[i].toString();
+                getChildren(1, data[i].getId());
+                xmlDetails += indent(1)+"</node>\n";
+                break;
+            }
+        }
+        return xmlDetails;
+    }
+
+    /**
+     *
+     * @param currentLevel level of the XML tree (0 based) of current node
+     * @param id current node's stmt_id
+     */
+    private void getChildren(int currentLevel,String id ){
+        if(currentLevel <= depth){
+            for(int i=0;i<data.length;i++){
+                if(data[i].getDepth()== currentLevel &&
+                        (id.indexOf(data[i].getParent()) != -1))
+                {
+                    xmlDetails += indent(currentLevel+1);
+                    xmlDetails += data[i].toString();
+                    getChildren(currentLevel+1, data[i].getId());
+                    xmlDetails += indent(currentLevel+1)+"</node>\n";
+                }
+            }
+        }
+    }
+
+    /**
+     *
+     * @param j indent needed
+     * @return indent as a string
+     */
+    public String indent(int j){
+        String str="";
+        for(int i=0;i<=j+1;i++)
+            str +="    ";
+
+        return str;
+    }
+
+    /**
+     * marking the depth of each element
+     */
+    public void markTheDepth(){
+        int i=0;
+        while(data[i].getParent().indexOf("null")== -1)
+            i++;
+        data[i].setDepth(depth); //root
+        findChildren(i,depth);
+    }
+
+    /**
+     *
+     * @param idx current element's index
+     * @param dep current examining depth
+     */
+    private void findChildren(int idx, int dep) {
+        if(dep>depth)
+            depth =dep;
+
+        for(int i=0;i<data.length;i++){
+
+            if(data[i].getParent().indexOf("null")== -1){
+                if((data[idx].getId()).indexOf(data[i].getParent()) != -1
+                        && i != idx)
+                {
+                    data[i].setDepth(dep +1);
+                    findChildren(i,dep+1);
+                }
+            }
+        }
+    }
+
+
+    /**
+     *
+     * @return whether the initialization is successful or not
+     * @throws SQLException
+     */
+    public boolean initializeDataArray() throws SQLException{
+        if(noOfNodes()==0)
+            return false;
+        else{
+            data = new TreeNode[noOfNodes()];
+            for(int i=0; i<data.length;i++){
+                data[i] = new TreeNode();
+            }
+            return true;
+        }
+
+    }
+
+    /**
+     *
+     * @param qry query to be executed
+     * @throws SQLException
+     */
+    private void createXMLData(String qry, int x) throws SQLException{
+
+        stmt = conn.createStatement();
+        ResultSet results = stmt.executeQuery(qry);
+
+        int i=0;
+        while(results.next())
+        {
+            String text= results.getString(1);
+            if(text != null){
+                switch(x){
+                case ID:
+                    data[i].setId(text+" ");
+                    break;
+                case P_ID:
+                    data[i].setParent(text);
+                    break;
+                case NODE_TYPE:
+                    data[i].setNodeType(text+" ");
+                    break;
+                case NO_OF_OPENS:
+                    data[i].setNoOfOpens(text+" ");
+                    break;
+                case INPUT_ROWS:
+                    data[i].setInputRows(text+" ");
+                    break;
+                case RETURNED_ROWS:
+                    data[i].setReturnedRows(text+" ");
+                    break;
+                case VISITED_PAGES:
+                    data[i].setVisitedPages(text+" ");
+                    break;
+                case SCAN_QUALIFIERS:
+                    data[i].setScanQualifiers(text+" ");
+                    break;
+                case NEXT_QUALIFIERS:
+                    data[i].setNextQualifiers(text+" ");
+                    break;
+                case SCANNED_OBJECT:
+                    data[i].setScannedObject(text+" ");
+                    break;
+                case SCAN_TYPE:
+                    data[i].setScanType(text+" ");
+                    break;
+                case SORT_TYPE:
+                    data[i].setSortType(text+" ");
+                    break;
+                case NO_OF_OUTPUT_ROWS_BY_SORTER:
+                    data[i].setSorterOutput(text+" ");
+                    break;
+                }
+            }
+            else{
+                /*Other attributes are omitted from the xml document
+                 * if they're null.
+                 * P_ID can be null at the root.
+                 * */
+                switch(x){
+                case P_ID:
+                    data[i].setParent(text+"");
+                    break;
+                }
+            }
+            i++;
+        }
+        results.close();
+        stmt.close();
+    }
+
+    /**
+     *
+     * @return total # of nodes
+     * @throws SQLException
+     */
+    private int noOfNodes() throws SQLException{
+
+        stmt = conn.createStatement();
+        ResultSet results = stmt.executeQuery(
+                "select count(*) from " +
+                ""+schema+".SYSXPLAIN_RESULTSETS " +
+                "where STMT_ID = '"+getQuery()+"'");
+        results.next();
+        int no = results.getInt(1);
+        results.close();
+        stmt.close();
+        return no;
+    }
+
+
+    /**
+     *
+     * @return the &lt;statement&gt; element
+     * @throws SQLException
+     */
+    public String statement() throws SQLException{
+        stmt = conn.createStatement();
+        ResultSet results = stmt.executeQuery(
+                "select STMT_TEXT "+
+                "from "+schema+".SYSXPLAIN_STATEMENTS " +
+                "where STMT_ID = '"+getQuery()+"'");
+        results.next();
+        String statement = results.getString(1);
+        results.close();
+        stmt.close();
+        /*Removing possible less than and greater than characters
+         * in a query statement with XML representation.*/
+        if(statement.indexOf('<')!= -1){
+            statement = replace(statement, "<","&lt;");
+        }
+        if(statement.indexOf('>')!= -1){
+            statement = replace(statement, ">","&gt;");
+        }
+        return "<statement>"+statement+"</statement>\n";
+    }
+
+    /**
+     *
+     * @param stmt statement to be changed
+     * @param expr string to be removed
+     * @param replace string to be added
+     * @return modified string
+     */
+    private String replace(String stmt, String expr, String replace){
+        String[] part=stmt.split(expr);
+        String newStmt= part[0];
+        for(int i=1;i<part.length;i++){
+            newStmt += " "+replace+" "+part[i];
+        }
+
+        return newStmt;
+    }
+
+    /**
+     *
+     * @return XPLAIN_TIME of SYSXPLAIN_STATEMENTS
+     * @throws SQLException
+     */
+    public String time() throws SQLException{
+        stmt = conn.createStatement();
+        ResultSet results = stmt.executeQuery(
+                "select '<time>'||TRIM(CHAR(XPLAIN_TIME))||" +
+                "'</time>' from "+schema+".SYSXPLAIN_STATEMENTS " +
+                "where STMT_ID = '"+getQuery()+"'");
+        results.next();
+        String time = results.getString(1);
+        results.close();
+        stmt.close();
+
+        return time;
+    }
+
+    /**
+     *
+     * @return stmt_id as a XML element
+     */
+    public String stmtID(){
+        return "<stmt_id>"+getQuery()+"</stmt_id>";
+    }
+
+    /**
+     * closing the connection to the database
+     */
+    public void closeConnection()
+    {
+        try
+        {
+            if (stmt != null)
+            {
+                stmt.close();
+            }
+            if (conn != null)
+            {
+                conn.close();
+            }
+        }
+        catch (SQLException sqlExcept){}
+    }
+
+    /**
+     *
+     * @return data array of TreeNode Objects
+     */
+    public TreeNode[] getData() {
+        return data;
+    }
 }

Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/CreateHTMLFile.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/CreateHTMLFile.java?rev=984902&r1=984901&r2=984902&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/CreateHTMLFile.java (original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/CreateHTMLFile.java Thu Aug 12 18:30:43 2010
@@ -17,33 +17,33 @@ import java.net.URL;
  */
 public class CreateHTMLFile {
 
-	public void getHTML(String XMLFileName, String XSLSheetName, 
-			String HTMLFile, boolean def) throws Exception{
+    public void getHTML(String XMLFileName, String XSLSheetName,
+            String HTMLFile, boolean def) throws Exception{
 
-		if(!(HTMLFile.toUpperCase()).endsWith(".HTML"))
-			HTMLFile +=".html";
+        if(!(HTMLFile.toUpperCase()).endsWith(".HTML"))
+            HTMLFile +=".html";
 
-		TransformerFactory transFactory = TransformerFactory.newInstance();
-		Transformer transformer;
+        TransformerFactory transFactory = TransformerFactory.newInstance();
+        Transformer transformer;
 
-		if(def){
-			URL url=getClass().getResource(XSLSheetName); 
-			transformer = 
-				transFactory.newTransformer(new StreamSource(url.openStream()));
-		}
-		else{
-			File style=new File(XSLSheetName);
-			if(style.exists())
-				transformer = 
-					transFactory.newTransformer(new StreamSource(XSLSheetName));
-			else{
-				URL url=getClass().getResource("resources/vanilla_html.xsl"); 
-				transformer = 
-					transFactory.newTransformer(new StreamSource(url.openStream()));
-			}
-		}
+        if(def){
+            URL url=getClass().getResource(XSLSheetName);
+            transformer =
+                transFactory.newTransformer(new StreamSource(url.openStream()));
+        }
+        else{
+            File style=new File(XSLSheetName);
+            if(style.exists())
+                transformer =
+                    transFactory.newTransformer(new StreamSource(XSLSheetName));
+            else{
+                URL url=getClass().getResource("resources/vanilla_html.xsl");
+                transformer =
+                    transFactory.newTransformer(new StreamSource(url.openStream()));
+            }
+        }
 
-		transformer.transform(new StreamSource(XMLFileName),
-				new StreamResult(new FileOutputStream(HTMLFile)));
-	}
+        transformer.transform(new StreamSource(XMLFileName),
+                new StreamResult(new FileOutputStream(HTMLFile)));
+    }
 }

Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/CreateXMLFile.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/CreateXMLFile.java?rev=984902&r1=984901&r2=984902&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/CreateXMLFile.java (original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/CreateXMLFile.java Thu Aug 12 18:30:43 2010
@@ -1,10 +1,3 @@
-/**
- * This class is to create the final xml file, that will be used 
- * by the Graphical Query Explainer.
- * This is called from org.apache.derby.tools.PlanExporter.
- * 
- * */
-
 package org.apache.derby.impl.tools.planexporter;
 
 import java.io.BufferedOutputStream;
@@ -16,61 +9,65 @@ import java.security.AccessController;
 import java.security.PrivilegedActionException;
 import org.apache.derby.impl.tools.planexporter.AccessDatabase;
 
+/**
+ * This class is to create the final xml file, that will be used
+ * by the Graphical Query Explainer.
+ * This is called from org.apache.derby.tools.PlanExporter.
+ */
 public class CreateXMLFile {
 
-	AccessDatabase access;
+    AccessDatabase access;
 
-	public CreateXMLFile(AccessDatabase access) {
-		this.access = access;
-	}
-
-	/**
-	 * @param stmt statement executed
-	 * @param time time which the statement was executed 
-	 * @param data large xml data string array 
-	 * @param file_name name of the file to be written
-	 * @param xsl_sheet_name name of the style sheet
-	 * @throws PrivilegedActionException 
-	 * @throws IOException 
-	 * @throws PrivilegedActionException 
-	 * 
-	 */
-	public void writeTheXMLFile(String stmt, String time,
-			TreeNode[] data, final String file_name, String xsl_sheet_name) 
-	throws IOException, PrivilegedActionException {
-
-		String defaultXML = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
-		String embedXSL="";
-		if(xsl_sheet_name != null)
-			embedXSL ="<?xml-stylesheet type=\"text/xsl\" href=\""
-						+xsl_sheet_name+"\"?>\n";
-		String comment = "<!-- Apache Derby Query Explainer (DERBY-4587)-->\n";
-		String parentTagStart = "<plan>\n";
-		String parentTagEnd = "</plan>\n";
-		String childTagStart = "<details>\n";
-		String childTagEnd = "</details>\n";
-
-		DataOutputStream dos =
-			new DataOutputStream(
-					new BufferedOutputStream(
-							(OutputStream)AccessController.doPrivileged
-							(new java.security.PrivilegedExceptionAction(){
-								public Object run() throws IOException{
-									return new FileOutputStream(file_name);
-								}
-							})));
-
-		dos.write(defaultXML.getBytes());
-		dos.write(embedXSL.getBytes());
-		dos.write(comment.getBytes());
-		dos.write(parentTagStart.getBytes());
-		dos.write((access.indent(0)+stmt).getBytes());
-		dos.write((access.indent(0)+time).getBytes());
-		dos.write((access.indent(0)+access.stmtID()).getBytes());
-		dos.write((access.indent(0)+childTagStart).getBytes());
-		dos.write(access.getXmlString().getBytes());
-		dos.write((access.indent(0)+childTagEnd).getBytes());
-		dos.write(parentTagEnd.getBytes());
-		dos.close();
-	}
+    public CreateXMLFile(AccessDatabase access) {
+        this.access = access;
+    }
+
+    /**
+     * @param stmt statement executed
+     * @param time time which the statement was executed
+     * @param data large xml data string array
+     * @param file_name name of the file to be written
+     * @param xsl_sheet_name name of the style sheet
+     * @throws PrivilegedActionException
+     * @throws IOException
+     * @throws PrivilegedActionException
+     */
+    public void writeTheXMLFile(String stmt, String time,
+            TreeNode[] data, final String file_name, String xsl_sheet_name)
+    throws IOException, PrivilegedActionException {
+
+        String defaultXML = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
+        String embedXSL="";
+        if(xsl_sheet_name != null)
+            embedXSL ="<?xml-stylesheet type=\"text/xsl\" href=\""
+                        +xsl_sheet_name+"\"?>\n";
+        String comment = "<!-- Apache Derby Query Explainer (DERBY-4587)-->\n";
+        String parentTagStart = "<plan>\n";
+        String parentTagEnd = "</plan>\n";
+        String childTagStart = "<details>\n";
+        String childTagEnd = "</details>\n";
+
+        DataOutputStream dos =
+            new DataOutputStream(
+                    new BufferedOutputStream(
+                            (OutputStream)AccessController.doPrivileged
+                            (new java.security.PrivilegedExceptionAction(){
+                                public Object run() throws IOException{
+                                    return new FileOutputStream(file_name);
+                                }
+                            })));
+
+        dos.write(defaultXML.getBytes());
+        dos.write(embedXSL.getBytes());
+        dos.write(comment.getBytes());
+        dos.write(parentTagStart.getBytes());
+        dos.write((access.indent(0)+stmt).getBytes());
+        dos.write((access.indent(0)+time).getBytes());
+        dos.write((access.indent(0)+access.stmtID()).getBytes());
+        dos.write((access.indent(0)+childTagStart).getBytes());
+        dos.write(access.getXmlString().getBytes());
+        dos.write((access.indent(0)+childTagEnd).getBytes());
+        dos.write(parentTagEnd.getBytes());
+        dos.close();
+    }
 }

Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/TreeNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/TreeNode.java?rev=984902&r1=984901&r2=984902&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/TreeNode.java (original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/TreeNode.java Thu Aug 12 18:30:43 2010
@@ -1,215 +1,215 @@
+package org.apache.derby.impl.tools.planexporter;
+
 /**
  * This class is used by PlanExporter tool (DERBY-4587)
  * as a data structure to keep the values retrieved
  * after querying XPLAIN tables and few other properties
  * of a plan node in a query plan.
  */
-package org.apache.derby.impl.tools.planexporter;
-
 class TreeNode{
 
-	private String parentId = "";//PARENT_RS_ID
-	private String id = "";//RS_ID
-	private String nodeType = "";//OP_IDENTIFIER
-	private String noOfOpens = "";//NO_OPENS
-	private String inputRows = "";//INPUT_ROWS
-	private String returnedRows = "";//RETURNED_ROWS
-	private String visitedPages = "";//NO_VISITED_PAGES
-	private String scanQualifiers = "";//SCAN_QUALIFIERS
-	private String nextQualifiers = "";//NEXT_QUALIFIERS
-	private String scannedObject = "";//SCAN_OBJECT_NAME
-	private String scanType = "";//SCAN_TYPE
-	private String sortType = "";//SORT_TYPE
-	private String sorterOutput = "";//NO_OUTPUT_ROWS
-	private int depth ;
-
-
-	/**
-	 * @param id the id to set
-	 */
-	public void setId(String id) {
-		this.id = id;
-	}
-	/**
-	 * @return the id
-	 */
-	public String getId() {
-		return id;
-	}
-	/**
-	 * @param parentId the parentId to set
-	 */
-	public void setParent(String parentId) {
-		this.parentId = parentId;
-	}
-	/**
-	 * @return the parentId
-	 */
-	public String getParent() {
-		return parentId;
-	}
-	/**
-	 * @param nodeType the nodeType to set
-	 */
-	public void setNodeType(String nodeType) {
-		this.nodeType = nodeType;
-	}
-	/**
-	 * @return the nodeType
-	 */
-	public String getNodeType() {
-		return nodeType;
-	}
-	/**
-	 * @param noOfOpens the noOfOpens to set
-	 */
-	public void setNoOfOpens(String noOfOpens) {
-		this.noOfOpens = noOfOpens;
-	}
-	/**
-	 * @return the noOfOpens
-	 */
-	public String getNoOfOpens() {
-		return noOfOpens;
-	}
-	/**
-	 * @param inputRows the inputRows to set
-	 */
-	public void setInputRows(String inputRows) {
-		this.inputRows = inputRows;
-	}
-	/**
-	 * @return the inputRows
-	 */
-	public String getInputRows() {
-		return inputRows;
-	}
-	/**
-	 * @param returnedRows the returnedRows to set
-	 */
-	public void setReturnedRows(String returnedRows) {
-		this.returnedRows = returnedRows;
-	}
-	/**
-	 * @return the returnedRows
-	 */
-	public String getReturnedRows() {
-		return returnedRows;
-	}
-	/**
-	 * @param visitedPages the visitedPages to set
-	 */
-	public void setVisitedPages(String visitedPages) {
-		this.visitedPages = visitedPages;
-	}
-	/**
-	 * @return the visitedPages
-	 */
-	public String getVisitedPages() {
-		return visitedPages;
-	}
-	/**
-	 * @param depth the depth to set
-	 */
-	public void setDepth(int depth) {
-		this.depth = depth;
-	}
-	/**
-	 * @return the depth
-	 */
-	public int getDepth() {
-		return depth;
-	}
-	/**
-	 * @param scanQualifiers the scanQualifiers to set
-	 */
-	public void setScanQualifiers(String scanQualifiers) {
-		this.scanQualifiers = scanQualifiers;
-	}
-	/**
-	 * @return the scanQualifiers
-	 */
-	public String getScanQualifiers() {
-		return scanQualifiers;
-	}
-	/**
-	 * @param nextQualifiers the nextQualifiers to set
-	 */
-	public void setNextQualifiers(String nextQualifiers) {
-		this.nextQualifiers = nextQualifiers;
-	}
-	/**
-	 * @return the nextQualifiers
-	 */
-	public String getNextQualifiers() {
-		return nextQualifiers;
-	}
-	/**
-	 * @param scannedObject the scannedObject to set
-	 */
-	public void setScannedObject(String scannedObject) {
-		this.scannedObject = scannedObject;
-	}
-	/**
-	 * @return the scannedObject
-	 */
-	public String getScannedObject() {
-		return scannedObject;
-	}
-	/**
-	 * @param scanType the scanType to set
-	 */
-	public void setScanType(String scanType) {
-		this.scanType = scanType;
-	}
-	/**
-	 * @return the scanType
-	 */
-	public String getScanType() {
-		return scanType;
-	}
-	/**
-	 * @param sortType the sortType to set
-	 */
-	public void setSortType(String sortType) {
-		this.sortType = sortType;
-	}
-	/**
-	 * @return the sortType
-	 */
-	public String getSortType() {
-		return sortType;
-	}
-	/**
-	 * @param sorterOutput the sorterOutput to set
-	 */
-	public void setSorterOutput(String sorterOutput) {
-		this.sorterOutput = sorterOutput;
-	}
-	/**
-	 * @return the sorterOutput
-	 */
-	public String getSorterOutput() {
-		return sorterOutput;
-	}
-
-	/**
-	 * @return XML fragment for this TreeNode object
-	 */
-	public String toString(){
-		String details = "<node ";
-		details += getNodeType();
-		details += getInputRows();
-		details += getReturnedRows();
-		details += getNoOfOpens();
-		details += getVisitedPages();
-		details += getScanQualifiers();
-		details += getNextQualifiers();
-		details += getScannedObject();
-		details += getScanType();
-		details += getSortType();
-		details += getSorterOutput();
+    private String parentId = "";//PARENT_RS_ID
+    private String id = "";//RS_ID
+    private String nodeType = "";//OP_IDENTIFIER
+    private String noOfOpens = "";//NO_OPENS
+    private String inputRows = "";//INPUT_ROWS
+    private String returnedRows = "";//RETURNED_ROWS
+    private String visitedPages = "";//NO_VISITED_PAGES
+    private String scanQualifiers = "";//SCAN_QUALIFIERS
+    private String nextQualifiers = "";//NEXT_QUALIFIERS
+    private String scannedObject = "";//SCAN_OBJECT_NAME
+    private String scanType = "";//SCAN_TYPE
+    private String sortType = "";//SORT_TYPE
+    private String sorterOutput = "";//NO_OUTPUT_ROWS
+    private int depth ;
+
+
+    /**
+     * @param id the id to set
+     */
+    public void setId(String id) {
+        this.id = id;
+    }
+    /**
+     * @return the id
+     */
+    public String getId() {
+        return id;
+    }
+    /**
+     * @param parentId the parentId to set
+     */
+    public void setParent(String parentId) {
+        this.parentId = parentId;
+    }
+    /**
+     * @return the parentId
+     */
+    public String getParent() {
+        return parentId;
+    }
+    /**
+     * @param nodeType the nodeType to set
+     */
+    public void setNodeType(String nodeType) {
+        this.nodeType = nodeType;
+    }
+    /**
+     * @return the nodeType
+     */
+    public String getNodeType() {
+        return nodeType;
+    }
+    /**
+     * @param noOfOpens the noOfOpens to set
+     */
+    public void setNoOfOpens(String noOfOpens) {
+        this.noOfOpens = noOfOpens;
+    }
+    /**
+     * @return the noOfOpens
+     */
+    public String getNoOfOpens() {
+        return noOfOpens;
+    }
+    /**
+     * @param inputRows the inputRows to set
+     */
+    public void setInputRows(String inputRows) {
+        this.inputRows = inputRows;
+    }
+    /**
+     * @return the inputRows
+     */
+    public String getInputRows() {
+        return inputRows;
+    }
+    /**
+     * @param returnedRows the returnedRows to set
+     */
+    public void setReturnedRows(String returnedRows) {
+        this.returnedRows = returnedRows;
+    }
+    /**
+     * @return the returnedRows
+     */
+    public String getReturnedRows() {
+        return returnedRows;
+    }
+    /**
+     * @param visitedPages the visitedPages to set
+     */
+    public void setVisitedPages(String visitedPages) {
+        this.visitedPages = visitedPages;
+    }
+    /**
+     * @return the visitedPages
+     */
+    public String getVisitedPages() {
+        return visitedPages;
+    }
+    /**
+     * @param depth the depth to set
+     */
+    public void setDepth(int depth) {
+        this.depth = depth;
+    }
+    /**
+     * @return the depth
+     */
+    public int getDepth() {
+        return depth;
+    }
+    /**
+     * @param scanQualifiers the scanQualifiers to set
+     */
+    public void setScanQualifiers(String scanQualifiers) {
+        this.scanQualifiers = scanQualifiers;
+    }
+    /**
+     * @return the scanQualifiers
+     */
+    public String getScanQualifiers() {
+        return scanQualifiers;
+    }
+    /**
+     * @param nextQualifiers the nextQualifiers to set
+     */
+    public void setNextQualifiers(String nextQualifiers) {
+        this.nextQualifiers = nextQualifiers;
+    }
+    /**
+     * @return the nextQualifiers
+     */
+    public String getNextQualifiers() {
+        return nextQualifiers;
+    }
+    /**
+     * @param scannedObject the scannedObject to set
+     */
+    public void setScannedObject(String scannedObject) {
+        this.scannedObject = scannedObject;
+    }
+    /**
+     * @return the scannedObject
+     */
+    public String getScannedObject() {
+        return scannedObject;
+    }
+    /**
+     * @param scanType the scanType to set
+     */
+    public void setScanType(String scanType) {
+        this.scanType = scanType;
+    }
+    /**
+     * @return the scanType
+     */
+    public String getScanType() {
+        return scanType;
+    }
+    /**
+     * @param sortType the sortType to set
+     */
+    public void setSortType(String sortType) {
+        this.sortType = sortType;
+    }
+    /**
+     * @return the sortType
+     */
+    public String getSortType() {
+        return sortType;
+    }
+    /**
+     * @param sorterOutput the sorterOutput to set
+     */
+    public void setSorterOutput(String sorterOutput) {
+        this.sorterOutput = sorterOutput;
+    }
+    /**
+     * @return the sorterOutput
+     */
+    public String getSorterOutput() {
+        return sorterOutput;
+    }
+
+    /**
+     * @return XML fragment for this TreeNode object
+     */
+    public String toString(){
+        String details = "<node ";
+        details += getNodeType();
+        details += getInputRows();
+        details += getReturnedRows();
+        details += getNoOfOpens();
+        details += getVisitedPages();
+        details += getScanQualifiers();
+        details += getNextQualifiers();
+        details += getScannedObject();
+        details += getScanType();
+        details += getSortType();
+        details += getSorterOutput();
 
-		return details+">\n";
-	}
+        return details+">\n";
+    }
 }

Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/resources/advancedViewXSL.xsl
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/resources/advancedViewXSL.xsl?rev=984902&r1=984901&r2=984902&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/resources/advancedViewXSL.xsl (original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/resources/advancedViewXSL.xsl Thu Aug 12 18:30:43 2010
@@ -5,48 +5,48 @@
   <xsl:output method="html" indent="yes"
     doctype-public="-//W3C//DTD HTML 4.01//EN"
     doctype-system="http://www.w3.org/TR/html4/strict.dtd"/>
-    
+
   <xsl:strip-space elements="*"/>
- 
+
   <xsl:template match="/">
     <html>
       <head>
         <title>Derby Graphical Query Explainer</title>
         <style type="text/css">
-		H1,H2{text-align:center;}
-		ul{list-style-type: none;}
+        H1,H2{text-align:center;}
+        ul{list-style-type: none;}
         table.hide { display: none; }
-		table,td,th
-		{
-			border:2px solid black;
-			font-size:18px;
-			position:relative;
-			left:160px;
-		}
-		th
-		{
-			text-align:left;
-			background-color:#999933;
-			color:white;
-		}
-		td{text-align:center;}
-		span.expand, span.collapse
-		{
-			color:#3B5998;
-			font-size:20px;
-			position:relative;
-			left:150px;
-		}
-		span.plus, span.minus
-		{
-			color:#000000;
-			font-size:20px;
-		}
+        table,td,th
+        {
+            border:2px solid black;
+            font-size:18px;
+            position:relative;
+            left:160px;
+        }
+        th
+        {
+            text-align:left;
+            background-color:#999933;
+            color:white;
+        }
+        td{text-align:center;}
+        span.expand, span.collapse
+        {
+            color:#3B5998;
+            font-size:20px;
+            position:relative;
+            left:150px;
+        }
+        span.plus, span.minus
+        {
+            color:#000000;
+            font-size:20px;
+        }
         span.expand, span.collapse { cursor: pointer; }
         span.expand span.minus { display: none; }
         span.collapse span.plus { display: none }
         </style>
-		<script type="text/javascript">
+        <script type="text/javascript">
         <!--[CDATA[-->
         window.onload = function()
         {
@@ -57,7 +57,7 @@
             childUls[i].className = 'hide';
           }
         }
-        
+
         function toggle(el)
         {
           do
@@ -72,99 +72,99 @@
         </script>
       </head>
       <body>
-		<H1>Apache Derby</H1>
-		<H1>Graphical Query Explainer</H1>
-		<H2>Executed Date &amp; Time: <font color="#4E9258"> <xsl:value-of select="//time"/> </font></H2>
-		<H2>Query: <font color="#4E9258"> <xsl:value-of select="//statement"/> </font></H2>
-		<H2>STMT_ID: <font color="#4E9258"> <xsl:value-of select="//stmt_id"/> </font></H2>
-		<br></br>
-		<br></br>
+        <H1>Apache Derby</H1>
+        <H1>Graphical Query Explainer</H1>
+        <H2>Executed Date &amp; Time: <font color="#4E9258"> <xsl:value-of select="//time"/> </font></H2>
+        <H2>Query: <font color="#4E9258"> <xsl:value-of select="//statement"/> </font></H2>
+        <H2>STMT_ID: <font color="#4E9258"> <xsl:value-of select="//stmt_id"/> </font></H2>
+        <br></br>
+        <br></br>
         <xsl:apply-templates/>
       </body>
     </html>
   </xsl:template>
-  
+
   <xsl:template match="plan">
     <ul id="main-ul">
       <xsl:apply-templates select="details/node"/>
     </ul>
   </xsl:template>
-  
+
   <xsl:template match="node">
     <li>
       <span class="expand" onclick="toggle(this);">
         <span class="plus">+ </span>
         <span class="minus">- </span>
         <xsl:value-of select="@name"/>
-		<br></br>
+        <br></br>
       </span>
       <table frame="border" rules="all">
-		<xsl:if test="count(@input_rows)!=0">
-			<tr>
-			<xsl:apply-templates select="@input_rows"/>
-			</tr>
-		</xsl:if>
-		<xsl:if test="count(@returned_rows)!=0">
-			<tr>
-			<xsl:apply-templates select="@returned_rows"/>
-			</tr>
-		</xsl:if>
-		<xsl:if test="count(@no_opens)!=0">
-			<tr>
-			<xsl:apply-templates select="@no_opens"/>
-			</tr>
-		</xsl:if>
-		<xsl:if test="count(@visited_pages)!=0">
-			<tr>
-			<xsl:apply-templates select="@visited_pages"/>
-			</tr>
-		</xsl:if>
-		<xsl:if test="count(@scan_qualifiers)!=0">
-			<tr>
-			<xsl:apply-templates select="@scan_qualifiers"/>
-			</tr>
-		</xsl:if>
-		<xsl:if test="count(@next_qualifiers)!=0">
-			<tr>
-			<xsl:apply-templates select="@next_qualifiers"/>
-			</tr>
-		</xsl:if>
-		<xsl:if test="count(@scanned_object)!=0">
-			<tr>
-			<xsl:apply-templates select="@scanned_object"/>
-			</tr>
-		</xsl:if>
-		<xsl:if test="count(@scan_type)!=0">
-			<tr>
-			<xsl:apply-templates select="@scan_type"/>
-			</tr>
-		</xsl:if>
-		<xsl:if test="count(@sort_type)!=0">
-			<tr>
-			<xsl:apply-templates select="@sort_type"/>
-			</tr>
-		</xsl:if>
-		<xsl:if test="count(@sorter_output)!=0">
-			<tr>
-			<xsl:apply-templates select="@sorter_output"/>
-			</tr>
-		</xsl:if>
-		</table>
-		<br></br>
+        <xsl:if test="count(@input_rows)!=0">
+            <tr>
+            <xsl:apply-templates select="@input_rows"/>
+            </tr>
+        </xsl:if>
+        <xsl:if test="count(@returned_rows)!=0">
+            <tr>
+            <xsl:apply-templates select="@returned_rows"/>
+            </tr>
+        </xsl:if>
+        <xsl:if test="count(@no_opens)!=0">
+            <tr>
+            <xsl:apply-templates select="@no_opens"/>
+            </tr>
+        </xsl:if>
+        <xsl:if test="count(@visited_pages)!=0">
+            <tr>
+            <xsl:apply-templates select="@visited_pages"/>
+            </tr>
+        </xsl:if>
+        <xsl:if test="count(@scan_qualifiers)!=0">
+            <tr>
+            <xsl:apply-templates select="@scan_qualifiers"/>
+            </tr>
+        </xsl:if>
+        <xsl:if test="count(@next_qualifiers)!=0">
+            <tr>
+            <xsl:apply-templates select="@next_qualifiers"/>
+            </tr>
+        </xsl:if>
+        <xsl:if test="count(@scanned_object)!=0">
+            <tr>
+            <xsl:apply-templates select="@scanned_object"/>
+            </tr>
+        </xsl:if>
+        <xsl:if test="count(@scan_type)!=0">
+            <tr>
+            <xsl:apply-templates select="@scan_type"/>
+            </tr>
+        </xsl:if>
+        <xsl:if test="count(@sort_type)!=0">
+            <tr>
+            <xsl:apply-templates select="@sort_type"/>
+            </tr>
+        </xsl:if>
+        <xsl:if test="count(@sorter_output)!=0">
+            <tr>
+            <xsl:apply-templates select="@sorter_output"/>
+            </tr>
+        </xsl:if>
+        </table>
+        <br></br>
         <ul>
           <xsl:apply-templates select="node"/>
         </ul>
-      
+
     </li>
   </xsl:template>
-  
+
   <xsl:template match="node/@*">
-	<th align="left">
-		<xsl:value-of select="name()"/>
-	</th>		
-	<td>
-	<xsl:value-of select="."/>
-	</td>
+    <th align="left">
+        <xsl:value-of select="name()"/>
+    </th>
+    <td>
+    <xsl:value-of select="."/>
+    </td>
   </xsl:template>
 
 </xsl:stylesheet>

Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/resources/advancedViewXSL2.xsl
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/resources/advancedViewXSL2.xsl?rev=984902&r1=984901&r2=984902&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/resources/advancedViewXSL2.xsl (original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/resources/advancedViewXSL2.xsl Thu Aug 12 18:30:43 2010
@@ -5,48 +5,48 @@
   <xsl:output method="html" indent="yes"
     doctype-public="-//W3C//DTD HTML 4.01//EN"
     doctype-system="http://www.w3.org/TR/html4/strict.dtd"/>
-    
+
   <xsl:strip-space elements="*"/>
-  
+
   <xsl:template match="/">
     <html>
       <head>
         <title>Derby Graphical Query Explainer</title>
         <style type="text/css">
-		H1,H2{text-align:center;}
-		ul{list-style-type: none;}
+        H1,H2{text-align:center;}
+        ul{list-style-type: none;}
         table.hide { display: none; }
-		table,td,th
-		{
-			border:2px solid black;
-			font-size:18px;
-			position:relative;
-			left:160px;
-		}
-		th
-		{
-			text-align:left;
-			background-color:#999933;
-			color:white;
-		}
-		td,tr{text-align:center;}
-		span.expand, span.collapse
-		{
-			color:#3B5998;
-			font-size:20px;
-			position:relative;
-			left:150px;
-		}
-		span.plus, span.minus
-		{
-			color:#000000;
-			font-size:20px;
-		}
+        table,td,th
+        {
+            border:2px solid black;
+            font-size:18px;
+            position:relative;
+            left:160px;
+        }
+        th
+        {
+            text-align:left;
+            background-color:#999933;
+            color:white;
+        }
+        td,tr{text-align:center;}
+        span.expand, span.collapse
+        {
+            color:#3B5998;
+            font-size:20px;
+            position:relative;
+            left:150px;
+        }
+        span.plus, span.minus
+        {
+            color:#000000;
+            font-size:20px;
+        }
         span.expand, span.collapse { cursor: pointer; }
         span.expand span.minus { display: none; }
         span.collapse span.plus { display: none }
         </style>
-		<script type="text/javascript">
+        <script type="text/javascript">
         <!--[CDATA[-->
         window.onload = function()
         {
@@ -57,7 +57,7 @@
             childUls[i].className = 'hide';
           }
         }
-        
+
         function toggle(el)
         {
           do
@@ -68,118 +68,118 @@
           ul.className = ul.className === '' ? 'hide' : '';
           el.className = el.className === 'collapse' ? 'expand' : '';
         }
-		
-		function hide(el)
-		{
-			do
-			{
-				var ul = el.nextSibling;
-			}
-			while (ul.tagName.toLowerCase() !== 'table');
-			ul.className = ul.className === '' ? 'hide' : '';
-			el.className = el.className === 'expand' ? 'collapse' : '';
-		}
+
+        function hide(el)
+        {
+            do
+            {
+                var ul = el.nextSibling;
+            }
+            while (ul.tagName.toLowerCase() !== 'table');
+            ul.className = ul.className === '' ? 'hide' : '';
+            el.className = el.className === 'expand' ? 'collapse' : '';
+        }
        <!-- ]]-->
         </script>
       </head>
       <body>
-		<H1>Apache Derby</H1>
-		<H1>Graphical Query Explainer</H1>
-		<H2>Executed Date &amp; Time: <font color="#4E9258"> <xsl:value-of select="//time"/> </font></H2>
-		<H2>Query: <font color="#4E9258"> <xsl:value-of select="//statement"/> </font></H2>
-		<H2>STMT_ID: <font color="#4E9258"> <xsl:value-of select="//stmt_id"/> </font></H2>
-		<br></br>
-		<br></br>
+        <H1>Apache Derby</H1>
+        <H1>Graphical Query Explainer</H1>
+        <H2>Executed Date &amp; Time: <font color="#4E9258"> <xsl:value-of select="//time"/> </font></H2>
+        <H2>Query: <font color="#4E9258"> <xsl:value-of select="//statement"/> </font></H2>
+        <H2>STMT_ID: <font color="#4E9258"> <xsl:value-of select="//stmt_id"/> </font></H2>
+        <br></br>
+        <br></br>
         <xsl:apply-templates/>
       </body>
     </html>
   </xsl:template>
-  
+
   <xsl:template match="plan">
      <ul id="main-ul">
       <xsl:apply-templates select="details/node">
-		<xsl:with-param name="i" select="0"/>
-	</xsl:apply-templates>
+        <xsl:with-param name="i" select="0"/>
+    </xsl:apply-templates>
     </ul>
   </xsl:template>
-  
+
   <xsl:template match="node">
   <xsl:param name="i"/>
     <li>
       <span class="collapse" onmouseover="toggle(this);" onmouseout="hide(this);">
-		 <xsl:if test="$i!=0">
-			|_
-		</xsl:if> 
+         <xsl:if test="$i!=0">
+            |_
+        </xsl:if>
         <xsl:value-of select="@name"/>
-		<br></br>
+        <br></br>
       </span>
       <table frame="border" rules="all">
-		<xsl:if test="count(@input_rows)!=0">
-			<tr>
-			<xsl:apply-templates select="@input_rows"/>
-			</tr>
-		</xsl:if>
-		<xsl:if test="count(@returned_rows)!=0">
-			<tr>
-			<xsl:apply-templates select="@returned_rows"/>
-			</tr>
-		</xsl:if>
-		<xsl:if test="count(@no_opens)!=0">
-			<tr>
-			<xsl:apply-templates select="@no_opens"/>
-			</tr>
-		</xsl:if>
-		<xsl:if test="count(@visited_pages)!=0">
-			<tr>
-			<xsl:apply-templates select="@visited_pages"/>
-			</tr>
-		</xsl:if>
-		<xsl:if test="count(@scan_qualifiers)!=0">
-			<tr>
-			<xsl:apply-templates select="@scan_qualifiers"/>
-			</tr>
-		</xsl:if>
-		<xsl:if test="count(@next_qualifiers)!=0">
-			<tr>
-			<xsl:apply-templates select="@next_qualifiers"/>
-			</tr>
-		</xsl:if>
-		<xsl:if test="count(@scanned_object)!=0">
-			<tr>
-			<xsl:apply-templates select="@scanned_object"/>
-			</tr>
-		</xsl:if>
-		<xsl:if test="count(@scan_type)!=0">
-			<tr>
-			<xsl:apply-templates select="@scan_type"/>
-			</tr>
-		</xsl:if>
-		<xsl:if test="count(@sort_type)!=0">
-			<tr>
-			<xsl:apply-templates select="@sort_type"/>
-			</tr>
-		</xsl:if>
-		<xsl:if test="count(@sorter_output)!=0">
-			<tr>
-			<xsl:apply-templates select="@sorter_output"/>
-			</tr>
-		</xsl:if>
-		</table>
-		<br></br>
+        <xsl:if test="count(@input_rows)!=0">
+            <tr>
+            <xsl:apply-templates select="@input_rows"/>
+            </tr>
+        </xsl:if>
+        <xsl:if test="count(@returned_rows)!=0">
+            <tr>
+            <xsl:apply-templates select="@returned_rows"/>
+            </tr>
+        </xsl:if>
+        <xsl:if test="count(@no_opens)!=0">
+            <tr>
+            <xsl:apply-templates select="@no_opens"/>
+            </tr>
+        </xsl:if>
+        <xsl:if test="count(@visited_pages)!=0">
+            <tr>
+            <xsl:apply-templates select="@visited_pages"/>
+            </tr>
+        </xsl:if>
+        <xsl:if test="count(@scan_qualifiers)!=0">
+            <tr>
+            <xsl:apply-templates select="@scan_qualifiers"/>
+            </tr>
+        </xsl:if>
+        <xsl:if test="count(@next_qualifiers)!=0">
+            <tr>
+            <xsl:apply-templates select="@next_qualifiers"/>
+            </tr>
+        </xsl:if>
+        <xsl:if test="count(@scanned_object)!=0">
+            <tr>
+            <xsl:apply-templates select="@scanned_object"/>
+            </tr>
+        </xsl:if>
+        <xsl:if test="count(@scan_type)!=0">
+            <tr>
+            <xsl:apply-templates select="@scan_type"/>
+            </tr>
+        </xsl:if>
+        <xsl:if test="count(@sort_type)!=0">
+            <tr>
+            <xsl:apply-templates select="@sort_type"/>
+            </tr>
+        </xsl:if>
+        <xsl:if test="count(@sorter_output)!=0">
+            <tr>
+            <xsl:apply-templates select="@sorter_output"/>
+            </tr>
+        </xsl:if>
+        </table>
+        <br></br>
         <ul>
           <xsl:apply-templates select="node"/>
         </ul>
-      
+
     </li>
   </xsl:template>
-  
+
   <xsl:template match="node/@*">
-	<th align="left">
-		<xsl:value-of select="name()"/>
-	</th>		
-	<td>
-	<xsl:value-of select="."/>
-	</td>
+    <th align="left">
+        <xsl:value-of select="name()"/>
+    </th>
+    <td>
+    <xsl:value-of select="."/>
+    </td>
   </xsl:template>
 
 </xsl:stylesheet>

Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/resources/vanilla_html.xsl
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/resources/vanilla_html.xsl?rev=984902&r1=984901&r2=984902&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/resources/vanilla_html.xsl (original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/planexporter/resources/vanilla_html.xsl Thu Aug 12 18:30:43 2010
@@ -1,79 +1,79 @@
 <xsl:stylesheet
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0">
-  
+
   <xsl:output method="html" indent="yes"
     doctype-public="-//W3C//DTD HTML 4.01//EN"
     doctype-system="http://www.w3.org/TR/html4/strict.dtd"/>
-  
+
   <xsl:output method="html" indent="yes"/>
-  
+
   <xsl:template match="/">
     <html>
       <head>
         <title>Derby Graphical Query Explainer</title>
       </head>
       <body>
-		<IMG SRC="derby-logo.png" ALIGN="left"/> 
-		<center><H1>Apache Derby</H1></center>
-		<center><H1>Graphical Query Explainer</H1></center>
-		<center><H2>Executed Date &amp; Time: <font color="#4E9258"> <xsl:value-of select="//time"/> </font></H2></center>
-		<center><H2>Query: <font color="#4E9258"> <xsl:value-of select="//statement"/> </font></H2></center>
-		<center><H2>STMT_ID: <font color="#4E9258"> <xsl:value-of select="//stmt_id"/> </font></H2></center>
+        <IMG SRC="derby-logo.png" ALIGN="left"/>
+        <center><H1>Apache Derby</H1></center>
+        <center><H1>Graphical Query Explainer</H1></center>
+        <center><H2>Executed Date &amp; Time: <font color="#4E9258"> <xsl:value-of select="//time"/> </font></H2></center>
+        <center><H2>Query: <font color="#4E9258"> <xsl:value-of select="//statement"/> </font></H2></center>
+        <center><H2>STMT_ID: <font color="#4E9258"> <xsl:value-of select="//stmt_id"/> </font></H2></center>
         <xsl:apply-templates select="plan/details/node"/>
       </body>
     </html>
   </xsl:template>
-  
+
   <xsl:template match="node">
     <ul>
-		<br/>
+        <br/>
         <h3><font face="verdana" color="#E56717"><xsl:value-of select="@name"/></font></h3>
-        
-		<table frame="border" rules="all">
-		<xsl:if test="count(@input_rows)!=0">
-			<tr>
-			<xsl:apply-templates select="@input_rows"/>
-			</tr>
-		</xsl:if>
-			<tr>
-			<xsl:apply-templates select="@returned_rows"/>
-			</tr>
-			<tr>
-			<xsl:apply-templates select="@no_opens"/>
-			</tr>
-			<tr>
-			<xsl:apply-templates select="@visited_pages"/>
-			</tr>
-			<tr>
-			<xsl:apply-templates select="@scan_qualifiers"/>
-			</tr>
-			<tr>
-			<xsl:apply-templates select="@next_qualifiers"/>
-			</tr>
-			<tr>
-			<xsl:apply-templates select="@scanned_object"/>
-			</tr>
-			<tr>
-			<xsl:apply-templates select="@scan_type"/>
-			</tr>
-			<tr>
-			<xsl:apply-templates select="@sort_type"/>
-			</tr>
-			<tr>
-			<xsl:apply-templates select="@sorter_output"/>
-			</tr>
-		</table>
+
+        <table frame="border" rules="all">
+        <xsl:if test="count(@input_rows)!=0">
+            <tr>
+            <xsl:apply-templates select="@input_rows"/>
+            </tr>
+        </xsl:if>
+            <tr>
+            <xsl:apply-templates select="@returned_rows"/>
+            </tr>
+            <tr>
+            <xsl:apply-templates select="@no_opens"/>
+            </tr>
+            <tr>
+            <xsl:apply-templates select="@visited_pages"/>
+            </tr>
+            <tr>
+            <xsl:apply-templates select="@scan_qualifiers"/>
+            </tr>
+            <tr>
+            <xsl:apply-templates select="@next_qualifiers"/>
+            </tr>
+            <tr>
+            <xsl:apply-templates select="@scanned_object"/>
+            </tr>
+            <tr>
+            <xsl:apply-templates select="@scan_type"/>
+            </tr>
+            <tr>
+            <xsl:apply-templates select="@sort_type"/>
+            </tr>
+            <tr>
+            <xsl:apply-templates select="@sorter_output"/>
+            </tr>
+        </table>
         <xsl:apply-templates select="node"/>
     </ul>
   </xsl:template>
-  
+
   <xsl:template match="node/@*">
-	<th align="left">
-		<xsl:value-of select="name()"/>
-	</th>		
-	<td>
-		<xsl:value-of select="."/>
-	</td>
+    <th align="left">
+        <xsl:value-of select="name()"/>
+    </th>
+    <td>
+        <xsl:value-of select="."/>
+    </td>
   </xsl:template>
 </xsl:stylesheet>

Modified: db/derby/code/trunk/java/tools/org/apache/derby/tools/PlanExporter.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/tools/PlanExporter.java?rev=984902&r1=984901&r2=984902&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/tools/PlanExporter.java (original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/tools/PlanExporter.java Thu Aug 12 18:30:43 2010
@@ -1,7 +1,3 @@
-/**
- * This class is the main entry point to the tool Graphical Query Explainer.
- * 
- */
 package org.apache.derby.tools;
 
 import java.io.File;
@@ -10,269 +6,272 @@ import org.apache.derby.impl.tools.plane
 import org.apache.derby.impl.tools.planexporter.CreateHTMLFile;
 import org.apache.derby.impl.tools.planexporter.CreateXMLFile;
 
+/**
+ * This class is the main entry point to the tool Graphical Query Explainer.
+ */
 public class PlanExporter {
 
-	private static String dbURL = null; //connection URL
-	private static String xslStyleSheetName ="resources/vanilla_html.xsl";//default xsl
-	private static final int XML=1;
-	private static final int HTML=2;
-	private static final int XSL=3;
-
-	/**
-	 * @param args 
-	 * 1) database URL eg: jdbc:derby:myDB ---------
-	 * 2) database schema -----------------------------
-	 * 3) statement ID (36 characters) ----------------
-	 * and user specified arguments.
-	 */
-	public static void main(String[] args) {
-
-		try{
-			if(args.length>4 && args.length<10 ){
-				dbURL = args[0];
-
-				AccessDatabase access = new AccessDatabase(dbURL, args[1], args[2]);
-				access.createConnection();
-				if(access.initializeDataArray()){
-					access.createXMLFragment();
-					access.markTheDepth();
-					String stmt=access.statement();
-					String time=access.time();
-					access.closeConnection();
-					
-					//advanced XSL feature
-					//possible occurrences are
-					//-adv -xml {path} -xsl {path} or
-					//-adv -xsl {path} -xml {path}
-					if(args.length==8 && 
-						args[3].equalsIgnoreCase("-adv")){
-						int opt1=selectArg(args[4]);
-						int opt2=selectArg(args[6]);
-						if(opt1==1 && opt2==3){
-							if(args[7].toUpperCase().endsWith(".XSL"))
-								generateXML(access,args[5],stmt,time,args[7]);
-							else
-								generateXML(access,args[5],stmt,time,args[7]+".xsl");
-						}
-						else if(opt1==3 && opt2==1){
-							if(args[5].toUpperCase().endsWith(".XSL"))
-								generateXML(access,args[7],stmt,time,args[5]);
-							else
-								generateXML(access,args[7],stmt,time,args[5]+".xsl");
-						}
-						else
-							printHelp();
-					}
-					//possible occurrences are -xml {path} or -html {path} 
-					else if(args.length==5){
-						int opt=selectArg(args[3]);
-						if(opt==0 || opt==3)
-							printHelp();
-						else if(opt==1)
-							generateXML(access,args[4],stmt,time,null);
-						else{
-							generateXML(access,"temp.xml",stmt,time,null);
-							generateHTML("temp.xml",args[4],xslStyleSheetName,true);
-							deleteFile("temp.xml");
-						}
-					}
-					//possible occurrences are
-					//-xml {path} and -html {path}
-					//-html {path} and -xml {path}
-					//-html {path} and -xsl {path}
-					//-xsl {path} and -html {path}
-					else if(args.length==7){
-						int opt1=selectArg(args[3]);
-						int opt2=selectArg(args[5]);
-						if(opt1==0 || opt2==0)
-							printHelp();
-						else if(opt1==1 && opt2==2){
-							generateXML(access,args[4],stmt,time,null);
-							generateHTML(args[4],args[6],xslStyleSheetName,true);
-						}
-						else if(opt1==2 && opt2==1){
-							generateXML(access,args[6],stmt,time,null);
-							generateHTML(args[6],args[4],xslStyleSheetName,true);
-						}
-						else if(opt1==2 && opt2==3){
-							generateXML(access,"temp.xml",stmt,time,null);
-							generateHTML("temp.xml",args[4],args[6],false);
-							deleteFile("temp.xml");
-						}
-						else if(opt1==3 && opt2==2){
-							generateXML(access,"temp.xml",stmt,time,null);
-							generateHTML("temp.xml",args[6],args[4],false);
-							deleteFile("temp.xml");
-						}
-						else
-							printHelp();
-					}
-					//possible occurrences are
-					//-xml {path} and -html {path} and -xsl {path}
-					//-html {path} and -xsl {path} and -xml {path}
-					//-xsl {path} and -xml {path} and -html {path}
-					//-xml {path} and -xsl {path} and -html {path}
-					//-html {path} and -xml {path} and -xsl {path}
-					//-xsl {path} and -html {path} and -xml {path}
-					else if(args.length==9){
-						int opt1=selectArg(args[3]);
-						int opt2=selectArg(args[5]);
-						int opt3=selectArg(args[7]);
-						if(opt1==0 || opt2==0 || opt3==0)
-							printHelp();
-						else if(opt1==1 && opt2==2 && opt3==3){
-							generateXML(access,args[4],stmt,time,null);
-							generateHTML(args[4],args[6],args[8],false);
-						}
-						else if(opt1==2 && opt2==3 && opt3==1){
-							generateXML(access,args[8],stmt,time,null);
-							generateHTML(args[8],args[4],args[6],false);
-						}
-						else if(opt1==3 && opt2==1 && opt3==2){
-							generateXML(access,args[6],stmt,time,null);
-							generateHTML(args[6],args[8],args[4],false);
-						}
-						else if(opt1==1 && opt2==3 && opt3==2){
-							generateXML(access,args[4],stmt,time,null);
-							generateHTML(args[4],args[8],args[6],false);
-						}
-						else if(opt1==2 && opt2==1 && opt3==3){
-							generateXML(access,args[6],stmt,time,null);
-							generateHTML(args[6],args[4],args[8],false);
-						}
-						else if(opt1==3 && opt2==2 && opt3==1){
-							generateXML(access,args[8],stmt,time,null);
-							generateHTML(args[8],args[6],args[4],false);
-						}
-						else
-							printHelp();
-					}	
-					else
-						printHelp();
-				}
-				else{
-					System.out.println(
-							"====================================================\n" +
-							"--- An Error Occured: No Statistics has Captured ---\n" +
-							"-- Possible reasons: 							   --\n" +
-							"-- 1) The statement executed is a DDL statement.  --\n" +
-							"-- Statistics will not capture for DDL statements --\n" +
-							"-- by the Derby.                                  --\n" +
-							"-- 2) The statement ID entered is incorrect.	   --\n" +
-							"====================================================\n"
-					);
-				}
-			}
-			else
-				printHelp();
-			
-		}catch(Exception ex){
-			ex.printStackTrace();
-		}
-	}	
-
-	/**
-	 * Reading the user's option
-	 * @param arg user's option
-	 * @return the argument type
-	 */
-	private static int selectArg(String arg){
-		if(arg.equalsIgnoreCase("-xml"))
-			return XML;
-		else if(arg.equalsIgnoreCase("-html"))
-			return HTML;
-		else if(arg.equalsIgnoreCase("-xsl"))
-			return XSL;
-		else
-			return 0;
-	}
-
-	/**
-	 * 
-	 * @param access instance of AccessDatabase class
-	 * @param arg path of XML
-	 * @param stmt statement executed
-	 * @param time time which the statement was executed
-	 * @param xsl name of the style sheet
-	 * @throws Exception
-	 */
-	private static void generateXML(AccessDatabase access, 
-			String arg, String stmt, String time, String xsl) throws Exception{
-		CreateXMLFile xmlFile = new CreateXMLFile(access);
-
-		if(arg.toUpperCase().endsWith(".XML")){
-			xmlFile.writeTheXMLFile(stmt, time,
-					access.getData(),  
-					arg, xsl);
-		}
-		else{
-			xmlFile.writeTheXMLFile(stmt, time,
-					access.getData(),  
-					arg.concat(".xml"),
-					xsl);
-		}
-	}
-
-	/**
-	 * 
-	 * @param arg path to xml
-	 * @param path path of HTML
-	 * @param style path to xsl
-	 * @param def whether the default xsl or not
-	 * @throws Exception
-	 */
-	private static void generateHTML(String arg, String path, 
-			String style, boolean def) throws Exception{
-		CreateHTMLFile htmlFile = new CreateHTMLFile();
-
-		if(arg.toUpperCase().endsWith(".XML")){
-			htmlFile.getHTML(arg, style, path, def);
-		}
-		else{
-			htmlFile.getHTML(arg.concat(".xml"), style, path, def);
-		}
-	}
-
-	private static void printHelp(){
-		System.out.println
-		(
-				"================================================\n" +
-				"-------------- PlanExporter Tool ---------------\n" +
-				"--   You can pass 5 arguments (minimum), or   --\n" +
-				"--       7 arguments or 8 arguments or        --\n" +
-				"-----------  9 arguments (maximum)  ------------\n" +
-				"--         separated by a space.              --\n" +
-				"---------------Mandatory Arguments--------------\n" +
-				"1) database URL --------------------------------\n" +
-				"2) database schema -----------------------------\n" +
-				"3) statement ID (36 characters) ----------------\n" +
-				"---------------Optional Arguments---------------\n" +
-				"-----------Choose at least one option-----------\n" +
-				"a) -xml {pathToXML} or -html {pathToHTML} ------\n" +
-				"b) -xml {pathToXML} -html {pathToHTML} ---------\n" +
-				"c) -xsl {pathToXSL} -html {pathToHTML} ---------\n" +
-				"d) -xml {pathToXML} -xsl {pathToXSL} -----------\n" +
-				"      -html {pathToHTML} -----------------------\n" +
-				"e) -adv -xml {pathToXML} -xsl {pathToXSL} ------\n" +
-				"================================================\n"
-		);
-	}
-
-	private static void deleteFile(final String fileName) 
-	{
-		AccessController.doPrivileged
-		(new java.security.PrivilegedAction() {
-
-			public Object run() {
-				File delFile = new File(fileName);
-				if (!delFile.exists())
-					return null;
-				delFile.delete();
-				return null;
-			}
-		}
-		);
+    private static String dbURL = null; //connection URL
+    private static String xslStyleSheetName ="resources/vanilla_html.xsl";//default xsl
+    private static final int XML=1;
+    private static final int HTML=2;
+    private static final int XSL=3;
+
+    /**
+     * @param args
+     * 1) database URL eg: jdbc:derby:myDB ---------
+     * 2) database schema -----------------------------
+     * 3) statement ID (36 characters) ----------------
+     * and user specified arguments.
+     */
+    public static void main(String[] args) {
+
+        try{
+            if(args.length>4 && args.length<10 ){
+                dbURL = args[0];
+
+                AccessDatabase access = new AccessDatabase(dbURL, args[1], args[2]);
+                access.createConnection();
+                if(access.initializeDataArray()){
+                    access.createXMLFragment();
+                    access.markTheDepth();
+                    String stmt=access.statement();
+                    String time=access.time();
+                    access.closeConnection();
+
+                    //advanced XSL feature
+                    //possible occurrences are
+                    //-adv -xml {path} -xsl {path} or
+                    //-adv -xsl {path} -xml {path}
+                    if(args.length==8 &&
+                        args[3].equalsIgnoreCase("-adv")){
+                        int opt1=selectArg(args[4]);
+                        int opt2=selectArg(args[6]);
+                        if(opt1==1 && opt2==3){
+                            if(args[7].toUpperCase().endsWith(".XSL"))
+                                generateXML(access,args[5],stmt,time,args[7]);
+                            else
+                                generateXML(access,args[5],stmt,time,args[7]+".xsl");
+                        }
+                        else if(opt1==3 && opt2==1){
+                            if(args[5].toUpperCase().endsWith(".XSL"))
+                                generateXML(access,args[7],stmt,time,args[5]);
+                            else
+                                generateXML(access,args[7],stmt,time,args[5]+".xsl");
+                        }
+                        else
+                            printHelp();
+                    }
+                    //possible occurrences are -xml {path} or -html {path}
+                    else if(args.length==5){
+                        int opt=selectArg(args[3]);
+                        if(opt==0 || opt==3)
+                            printHelp();
+                        else if(opt==1)
+                            generateXML(access,args[4],stmt,time,null);
+                        else{
+                            generateXML(access,"temp.xml",stmt,time,null);
+                            generateHTML("temp.xml",args[4],xslStyleSheetName,true);
+                            deleteFile("temp.xml");
+                        }
+                    }
+                    //possible occurrences are
+                    //-xml {path} and -html {path}
+                    //-html {path} and -xml {path}
+                    //-html {path} and -xsl {path}
+                    //-xsl {path} and -html {path}
+                    else if(args.length==7){
+                        int opt1=selectArg(args[3]);
+                        int opt2=selectArg(args[5]);
+                        if(opt1==0 || opt2==0)
+                            printHelp();
+                        else if(opt1==1 && opt2==2){
+                            generateXML(access,args[4],stmt,time,null);
+                            generateHTML(args[4],args[6],xslStyleSheetName,true);
+                        }
+                        else if(opt1==2 && opt2==1){
+                            generateXML(access,args[6],stmt,time,null);
+                            generateHTML(args[6],args[4],xslStyleSheetName,true);
+                        }
+                        else if(opt1==2 && opt2==3){
+                            generateXML(access,"temp.xml",stmt,time,null);
+                            generateHTML("temp.xml",args[4],args[6],false);
+                            deleteFile("temp.xml");
+                        }
+                        else if(opt1==3 && opt2==2){
+                            generateXML(access,"temp.xml",stmt,time,null);
+                            generateHTML("temp.xml",args[6],args[4],false);
+                            deleteFile("temp.xml");
+                        }
+                        else
+                            printHelp();
+                    }
+                    //possible occurrences are
+                    //-xml {path} and -html {path} and -xsl {path}
+                    //-html {path} and -xsl {path} and -xml {path}
+                    //-xsl {path} and -xml {path} and -html {path}
+                    //-xml {path} and -xsl {path} and -html {path}
+                    //-html {path} and -xml {path} and -xsl {path}
+                    //-xsl {path} and -html {path} and -xml {path}
+                    else if(args.length==9){
+                        int opt1=selectArg(args[3]);
+                        int opt2=selectArg(args[5]);
+                        int opt3=selectArg(args[7]);
+                        if(opt1==0 || opt2==0 || opt3==0)
+                            printHelp();
+                        else if(opt1==1 && opt2==2 && opt3==3){
+                            generateXML(access,args[4],stmt,time,null);
+                            generateHTML(args[4],args[6],args[8],false);
+                        }
+                        else if(opt1==2 && opt2==3 && opt3==1){
+                            generateXML(access,args[8],stmt,time,null);
+                            generateHTML(args[8],args[4],args[6],false);
+                        }
+                        else if(opt1==3 && opt2==1 && opt3==2){
+                            generateXML(access,args[6],stmt,time,null);
+                            generateHTML(args[6],args[8],args[4],false);
+                        }
+                        else if(opt1==1 && opt2==3 && opt3==2){
+                            generateXML(access,args[4],stmt,time,null);
+                            generateHTML(args[4],args[8],args[6],false);
+                        }
+                        else if(opt1==2 && opt2==1 && opt3==3){
+                            generateXML(access,args[6],stmt,time,null);
+                            generateHTML(args[6],args[4],args[8],false);
+                        }
+                        else if(opt1==3 && opt2==2 && opt3==1){
+                            generateXML(access,args[8],stmt,time,null);
+                            generateHTML(args[8],args[6],args[4],false);
+                        }
+                        else
+                            printHelp();
+                    }
+                    else
+                        printHelp();
+                }
+                else{
+                    System.out.println(
+                            "====================================================\n" +
+                            "--- An Error Occured: No Statistics has Captured ---\n" +
+                            "-- Possible reasons:                                --\n" +
+                            "-- 1) The statement executed is a DDL statement.  --\n" +
+                            "-- Statistics will not capture for DDL statements --\n" +
+                            "-- by the Derby.                                  --\n" +
+                            "-- 2) The statement ID entered is incorrect.       --\n" +
+                            "====================================================\n"
+                    );
+                }
+            }
+            else
+                printHelp();
+
+        }catch(Exception ex){
+            ex.printStackTrace();
+        }
+    }
+
+    /**
+     * Reading the user's option
+     * @param arg user's option
+     * @return the argument type
+     */
+    private static int selectArg(String arg){
+        if(arg.equalsIgnoreCase("-xml"))
+            return XML;
+        else if(arg.equalsIgnoreCase("-html"))
+            return HTML;
+        else if(arg.equalsIgnoreCase("-xsl"))
+            return XSL;
+        else
+            return 0;
+    }
+
+    /**
+     *
+     * @param access instance of AccessDatabase class
+     * @param arg path of XML
+     * @param stmt statement executed
+     * @param time time which the statement was executed
+     * @param xsl name of the style sheet
+     * @throws Exception
+     */
+    private static void generateXML(AccessDatabase access,
+            String arg, String stmt, String time, String xsl) throws Exception{
+        CreateXMLFile xmlFile = new CreateXMLFile(access);
+
+        if(arg.toUpperCase().endsWith(".XML")){
+            xmlFile.writeTheXMLFile(stmt, time,
+                    access.getData(),
+                    arg, xsl);
+        }
+        else{
+            xmlFile.writeTheXMLFile(stmt, time,
+                    access.getData(),
+                    arg.concat(".xml"),
+                    xsl);
+        }
+    }
+
+    /**
+     *
+     * @param arg path to xml
+     * @param path path of HTML
+     * @param style path to xsl
+     * @param def whether the default xsl or not
+     * @throws Exception
+     */
+    private static void generateHTML(String arg, String path,
+            String style, boolean def) throws Exception{
+        CreateHTMLFile htmlFile = new CreateHTMLFile();
+
+        if(arg.toUpperCase().endsWith(".XML")){
+            htmlFile.getHTML(arg, style, path, def);
+        }
+        else{
+            htmlFile.getHTML(arg.concat(".xml"), style, path, def);
+        }
+    }
+
+    private static void printHelp(){
+        System.out.println
+        (
+                "================================================\n" +
+                "-------------- PlanExporter Tool ---------------\n" +
+                "--   You can pass 5 arguments (minimum), or   --\n" +
+                "--       7 arguments or 8 arguments or        --\n" +
+                "-----------  9 arguments (maximum)  ------------\n" +
+                "--         separated by a space.              --\n" +
+                "---------------Mandatory Arguments--------------\n" +
+                "1) database URL --------------------------------\n" +
+                "2) database schema -----------------------------\n" +
+                "3) statement ID (36 characters) ----------------\n" +
+                "---------------Optional Arguments---------------\n" +
+                "-----------Choose at least one option-----------\n" +
+                "a) -xml {pathToXML} or -html {pathToHTML} ------\n" +
+                "b) -xml {pathToXML} -html {pathToHTML} ---------\n" +
+                "c) -xsl {pathToXSL} -html {pathToHTML} ---------\n" +
+                "d) -xml {pathToXML} -xsl {pathToXSL} -----------\n" +
+                "      -html {pathToHTML} -----------------------\n" +
+                "e) -adv -xml {pathToXML} -xsl {pathToXSL} ------\n" +
+                "================================================\n"
+        );
+    }
+
+    private static void deleteFile(final String fileName)
+    {
+        AccessController.doPrivileged
+        (new java.security.PrivilegedAction() {
+
+            public Object run() {
+                File delFile = new File(fileName);
+                if (!delFile.exists())
+                    return null;
+                delFile.delete();
+                return null;
+            }
+        }
+        );
 
-	}
+    }
 
 }



Mime
View raw message