Clover coverage report - ATP library for Java - 3.6.4-stable-060214
Coverage timestamp: Вт фев 14 2006 13:45:22 MSK
file stats: LOC: 235   Methods: 13
NCLOC: 112   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
TextGeneratorServer.java 0% 0% 0% 0%
coverage
 1    /*
 2    * Copyright (c) 2001-2004,
 3    * RedVerst Group, ISP RAS http://www.ispras.ru
 4    * All rights reserved.
 5    *
 6    * Redistribution and use in source and binary forms, with or without
 7    * modification, are permitted provided that the following conditions are met:
 8    *
 9    * 1. Redistributions of source code must retain the above copyright notice, this
 10    * list of conditions and the following disclaimer.
 11    *
 12    * 2. Redistributions in binary form must reproduce the above copyright notice,
 13    * this list of conditions and the following disclaimer in the documentation
 14    * and/or other materials provided with the distribution.
 15    *
 16    * 3. The names "ATP", "TreeDL", "RedVerst", "ISP RAS"
 17    * may not be used to endorse or promote products derived from this software
 18    * without specific prior written permission.
 19    *
 20    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 21    * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 22    * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 23    * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
 24    * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 25    * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 26    * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 27    * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 28    * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 29    * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 30    */
 31   
 32    package com.unitesk.atp.tree.generation;
 33   
 34    import java.util.Stack;
 35   
 36    import com.unitesk.atp.tree.Node;
 37    import com.unitesk.atp.text.generation.BasicGenerator;
 38    import com.unitesk.atp.text.filters.TextReceiver;
 39    import com.unitesk.atp.text.filters.LineSplitFilter;
 40    import com.unitesk.atp.text.filters.IndentFilter;
 41   
 42    /**
 43    * Text Generator Server implements {@link TextGenerator} functionality.
 44    *
 45    * @author <A href="mailto:demakov@ispras.ru">Alexey Demakov</A>
 46    * @version $Id: TextGeneratorServer.java,v 1.1 2004/10/09 06:28:48 all-x Exp $
 47    */
 48    public class TextGeneratorServer extends BasicGenerator implements TextGenerator
 49    {
 50    /**
 51    * Constructs Text Generator Server with the given client
 52    * and default indent step.
 53    *
 54    * @param client The client receiving results of text generation.
 55    */
 56  0 public TextGeneratorServer( TextReceiver client )
 57    {
 58  0 this( client, IndentFilter.DEFAULT_INDENT_STEP );
 59    }
 60   
 61    /**
 62    * Constructs Text Generator Server with the given client and indent step.
 63    *
 64    * @param client The client receiving results of text generation.
 65    * @param indentStep Indent step.
 66    */
 67  0 public TextGeneratorServer( TextReceiver client, int indentStep )
 68    {
 69  0 super( new LineSplitFilter( new IndentFilter( client, indentStep ) ) );
 70   
 71  0 lineSplitFilter = (LineSplitFilter)this.client;
 72  0 indentFilter = (IndentFilter)lineSplitFilter.getClient();
 73  0 out = client;
 74   
 75  0 setFunction( DEFAULT_NAME, new TreeDefaultFunction() );
 76    }
 77   
 78    /**
 79    * {@inheritDoc}
 80    */
 81  0 public void pushNode( Node node )
 82    {
 83  0 setVariable( DEFAULT_NAME, node );
 84  0 nodeStack.push( node );
 85    }
 86   
 87    /**
 88    * {@inheritDoc}
 89    */
 90  0 public Node getNode()
 91    {
 92   
 93  0 return (Node)nodeStack.peek();
 94    }
 95   
 96    /**
 97    * {@inheritDoc}
 98    */
 99  0 public void popNode()
 100    {
 101  0 nodeStack.pop();
 102   
 103  0 if( nodeStack.empty() )
 104    {
 105  0 setVariable( DEFAULT_NAME, null );
 106    } else {
 107  0 setVariable( DEFAULT_NAME, nodeStack.peek() );
 108    }
 109    }
 110   
 111    /**
 112    * {@inheritDoc}
 113    */
 114  0 public void pushIndent( int indent )
 115    {
 116  0 indentFilter.pushIndent( indent );
 117    }
 118   
 119    /**
 120    * {@inheritDoc}
 121    */
 122  0 public int getIndent()
 123    {
 124  0 return indentFilter.getIndent();
 125    }
 126   
 127    /**
 128    * {@inheritDoc}
 129    */
 130  0 public void incIndent()
 131    {
 132  0 indentFilter.pushIndent( indentFilter.getIndent()
 133    + indentFilter.getIndentStep()
 134    );
 135    }
 136   
 137    /**
 138    * {@inheritDoc}
 139    */
 140  0 public void decIndent()
 141    {
 142  0 indentFilter.pushIndent( indentFilter.getIndent()
 143    - indentFilter.getIndentStep()
 144    );
 145    }
 146   
 147    /**
 148    * {@inheritDoc}
 149    */
 150  0 public void popIndent()
 151    {
 152  0 indentFilter.popIndent();
 153    }
 154   
 155    /**
 156    * {@inheritDoc}
 157    */
 158  0 public void list( String index
 159    , int start
 160    , int end
 161    , String str
 162    , String separator
 163    )
 164    {
 165  0 int from;
 166  0 int to;
 167  0 int step;
 168   
 169  0 if( start < end )
 170    {
 171  0 from = start;
 172  0 to = end;
 173  0 step = 1;
 174    } else
 175  0 if( end < start )
 176    {
 177  0 from = start - 1;
 178  0 to = end - 1;
 179  0 step = -1;
 180    } else {
 181  0 return;
 182    }
 183  0 for( int i = from; i != to; i += step )
 184    {
 185  0 Object old_var = setVariable( index, new Integer( i ) );
 186   
 187  0 txt( str );
 188   
 189  0 if( i + step != to && separator != null )
 190    {
 191  0 txt( separator );
 192    }
 193   
 194  0 setVariable( index, old_var );
 195    }
 196    }
 197   
 198    /**
 199    * {@inheritDoc}
 200    */
 201  0 public void nl()
 202    {
 203  0 lineSplitFilter.nl();
 204    }
 205   
 206    /**
 207    * Print string as is, don't treat it as pattern and don't split lines.
 208    * This method is used for printing values of parameters.
 209    *
 210    * @param str The string to pass as is.
 211    */
 212  0 public void txtAsIs( String str )
 213    {
 214  0 indentFilter.txt( str );
 215    }
 216   
 217    /**
 218    * Line splitter.
 219    */
 220    protected LineSplitFilter lineSplitFilter;
 221    /**
 222    * Indent manager filter. Client of {@link #lineSplitFilter}
 223    */
 224    protected IndentFilter indentFilter;
 225    /**
 226    * Client receiving results of text generation.
 227    * Client of {@link #indentFilter}
 228    */
 229    protected TextReceiver out;
 230   
 231    /**
 232    * Stack of used nodes. The top element is current node.
 233    */
 234    private Stack/*Node*/ nodeStack = new Stack/*Node*/();
 235    }