title: Java Parsing Oracle Explain Plan
body: <p>I wonder if there is any library that allows for parsing oracle's explain plan into a data structure. </p>
  
  <p>Given the following query:</p>
  
  <pre><code> select prod_category, avg(amount_sold)
   from sales s, products p
   where p.prod_id = s.prod_id
   group by prod_category;
  </code></pre>
  
  <p>explain plan may look something like the following:</p>
  
  <pre><code> ------------------------------------------
    Id   Operation              Name   
   ------------------------------------------
      0  SELECT STATEMENT              
      1   HASH GROUP BY                
      2    HASH JOIN                   
      3     TABLE ACCESS FULL   PRODUCTS
      4     PARTITION RANGE ALL        
      5      TABLE ACCESS FULL  SALES  
   ------------------------------------------
  </code></pre>
  
  <p>I want a parser that parses the plan into a data structure that allows visualizing and analyzing the plan like the following:</p>
  
  <pre><code>  SELECT STATEMENT
          |
       GROUP BY
          |
         JOIN
     _____|______
    |            |
   ACCESS     ACCESS
   (PRODUCTS) (SALES)
  </code></pre>
  
  <p>I have noticed that Oracle's <a href="http://www.oracle.com/technetwork/developer-tools/sql-developer/overview/index.html" rel="nofollow">SQLDeveloper</a> visualizes the plan. I am reluctant to manually parse the text, so I wonder if there is any library that would help with parsing the plan.</p>