Clover coverage report - Drools - 2.0-rc2
Coverage timestamp: Wed May 11 2005 07:12:26 BST
file stats: LOC: 225   Methods: 13
NCLOC: 164   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ReteooPrintDumpVisitor.java 0% 0% 0% 0%
coverage
 1    package org.drools.reteoo;
 2   
 3    /*
 4    * $Id: ReteooPrintDumpVisitor.java,v 1.11 2005/02/02 00:23:22 mproctor Exp $
 5    *
 6    * Copyright 2004-2004 (C) The Werken Company. All Rights Reserved.
 7    *
 8    * Redistribution and use of this software and associated documentation
 9    * ("Software"), with or without modification, are permitted provided that the
 10    * following conditions are met:
 11    *
 12    * 1. Redistributions of source code must retain copyright statements and
 13    * notices. Redistributions must also contain a copy of this document.
 14    *
 15    * 2. Redistributions in binary form must reproduce the above copyright notice,
 16    * this list of conditions and the following disclaimer in the documentation
 17    * and/or other materials provided with the distribution.
 18    *
 19    * 3. The name "drools" must not be used to endorse or promote products derived
 20    * from this Software without prior written permission of The Werken Company.
 21    * For written permission, please contact bob@werken.com.
 22    *
 23    * 4. Products derived from this Software may not be called "drools" nor may
 24    * "drools" appear in their names without prior written permission of The Werken
 25    * Company. "drools" is a trademark of The Werken Company.
 26    *
 27    * 5. Due credit should be given to The Werken Company. (http://werken.com/)
 28    *
 29    * THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS''
 30    * AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 31    * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 32    * ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE
 33    * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 34    * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 35    * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 36    * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 37    * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 38    * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 39    * POSSIBILITY OF SUCH DAMAGE.
 40    *
 41    */
 42   
 43    import java.io.PrintStream;
 44    import java.util.Iterator;
 45   
 46    import org.drools.RuleBase;
 47    import org.drools.rule.Declaration;
 48   
 49    public class ReteooPrintDumpVisitor extends ReflectiveVisitor
 50    {
 51    private PrintStream out;
 52   
 53    private StringBuffer buffer;
 54   
 55    private int depth;
 56   
 57    private String indent;
 58   
 59  0 public ReteooPrintDumpVisitor(PrintStream out)
 60    {
 61  0 this.out = out;
 62  0 this.indent = " ";
 63    }
 64   
 65  0 public ReteooPrintDumpVisitor(PrintStream out,
 66    String indent)
 67    {
 68  0 this.out = out;
 69  0 this.indent = indent;
 70    }
 71   
 72  0 public void visitRuleBase(RuleBase ruleBase)
 73    {
 74  0 buffer = new StringBuffer( );
 75  0 visit( ((RuleBaseImpl) ruleBase).getRete( ) );
 76  0 out.println( buffer.toString( ) );
 77    }
 78   
 79  0 public void visitRete(Rete rete)
 80    {
 81  0 buffer.append( "Rete" );
 82  0 buffer.append( newline );
 83  0 buffer.append( "----" );
 84  0 buffer.append( newline );
 85  0 Iterator it = rete.getObjectTypeNodeIterator( );
 86  0 int scopedDepth = depth;
 87  0 depth++;
 88  0 while ( it.hasNext( ) )
 89    {
 90  0 visit( it.next( ) );
 91    }
 92  0 depth = scopedDepth;
 93    }
 94   
 95  0 public void visitObjectTypeNode(ObjectTypeNode objectTypeNode)
 96    {
 97  0 String indent = getIndent( depth );
 98  0 buffer.append( indent ).append( "ObjectTypeNode" );
 99  0 buffer.append( newline );
 100  0 buffer.append( indent ).append( "--------------" );
 101  0 buffer.append( newline );
 102  0 buffer.append( indent ).append( "objectType: " + objectTypeNode.getObjectType( ).toString( ) );
 103  0 buffer.append( newline );
 104  0 Iterator it = objectTypeNode.getParameterNodeIterator( );
 105  0 int scopedDepth = depth;
 106  0 depth++;
 107  0 while ( it.hasNext( ) )
 108    {
 109  0 visit( it.next( ) );
 110    }
 111  0 depth = scopedDepth;
 112    }
 113   
 114  0 public void visitParameterNode(ParameterNode parameterNode)
 115    {
 116  0 String indent = getIndent( depth );
 117  0 buffer.append( indent ).append( "ParameterNode" );
 118  0 buffer.append( newline );
 119  0 buffer.append( indent ).append( "-------------" );
 120  0 buffer.append( newline );
 121  0 int scopedDepth = depth;
 122  0 depth++;
 123  0 visit( parameterNode.getDeclaration( ) );
 124  0 buffer.append( indent ).append( "tupleSink:" );
 125  0 buffer.append( newline );
 126   
 127  0 Iterator it = parameterNode.getTupleSinks( ).iterator( );
 128  0 depth++;
 129  0 while ( it.hasNext() )
 130    {
 131  0 visit( it.next() );
 132    }
 133  0 depth = scopedDepth;
 134    }
 135   
 136  0 public void visitDeclaration(Declaration declaration)
 137    {
 138  0 String indent = getIndent( depth );
 139  0 buffer.append( indent ).append( "Declaration" );
 140  0 buffer.append( newline );
 141  0 buffer.append( indent ).append( "-----------" );
 142  0 buffer.append( newline );
 143  0 buffer.append( indent ).append( "identifier: " );
 144  0 buffer.append( declaration.getIdentifier( ) );
 145  0 buffer.append( newline );
 146  0 buffer.append( indent ).append( "objectType: " );
 147  0 buffer.append( declaration.getObjectType( ) );
 148  0 buffer.append( newline );
 149    }
 150   
 151  0 public void visitConditionNode(ConditionNode conditionNode)
 152    {
 153  0 String indent = getIndent( depth );
 154  0 buffer.append( indent ).append( "ConditionNode" );
 155  0 buffer.append( newline );
 156  0 buffer.append( indent ).append( "-------------" );
 157  0 buffer.append( newline );
 158  0 buffer.append( indent ).append( "condition: " );
 159  0 buffer.append( conditionNode.toString( ) );
 160  0 buffer.append( newline );
 161  0 buffer.append( indent ).append( "tupleSink:" );
 162  0 buffer.append( newline );
 163  0 int scopedDepth = depth;
 164  0 Iterator it = conditionNode.getTupleSinks( ).iterator( );
 165  0 depth++;
 166  0 while ( it.hasNext() )
 167    {
 168  0 visit( it.next() );
 169    }
 170  0 depth = scopedDepth;
 171    }
 172   
 173  0 public void visitJoinNodeInput(JoinNodeInput joinNodeInput)
 174    {
 175  0 String indent = getIndent( depth );
 176  0 buffer.append( indent ).append( "JoinNodeInput" );
 177  0 buffer.append( newline );
 178  0 buffer.append( indent ).append( "-------------" );
 179  0 buffer.append( newline );
 180  0 buffer.append( indent ).append( joinNodeInput.toString( ) );
 181  0 buffer.append( newline );
 182  0 int scopedDepth = depth;
 183  0 Iterator it = joinNodeInput.getJoinNode( ).getTupleSinks( ).iterator( );
 184  0 depth++;
 185  0 while ( it.hasNext() )
 186    {
 187  0 visit( it.next() );
 188    }
 189  0 depth = scopedDepth;
 190   
 191    }
 192   
 193  0 public void visitTerminalNode(TerminalNode terminalNode)
 194    {
 195  0 String indent = getIndent( depth );
 196  0 buffer.append( indent ).append( "TerminalNode" );
 197  0 buffer.append( newline );
 198  0 buffer.append( indent ).append( "-------------" );
 199  0 buffer.append( newline );
 200  0 buffer.append( indent ).append( terminalNode.toString( ) );
 201  0 buffer.append( newline );
 202    }
 203   
 204  0 public void visitObject(Object object)
 205    {
 206  0 buffer.append( "no visitor implementation for : " + object.getClass( ) + " : " + object );
 207  0 buffer.append( newline );
 208    }
 209   
 210  0 public void visitNull()
 211    {
 212  0 buffer.append( "unable to visit null objects" );
 213  0 buffer.append( newline );
 214    }
 215   
 216  0 private String getIndent(int depth)
 217    {
 218  0 StringBuffer indentBuffer = new StringBuffer( );
 219  0 for ( int i = 0; i < depth; i++ )
 220    {
 221  0 indentBuffer.append( indent );
 222    }
 223  0 return indentBuffer.toString( );
 224    }
 225    }