Clover coverage report - ATP library for Java - 3.6.4-stable-060214
Coverage timestamp: Вт фев 14 2006 13:45:22 MSK
file stats: LOC: 191   Methods: 17
NCLOC: 86   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
NullMessageBox.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.messages;
 33   
 34    /**
 35    * The message box that discards all messages but counts them.
 36    *
 37    * @author <A href="mailto:demakov@ispras.ru">Alexey Demakov</A>
 38    * @version $Id: NullMessageBox.java,v 1.3 2004/10/12 08:23:12 all-x Exp $
 39    */
 40    public class NullMessageBox implements MessageBox
 41    {
 42    /**
 43    * Creates message box with default {@link MessageStringManager string manager}.
 44    *
 45    * @see #NullMessageBox(MessageStringManager)
 46    */
 47  0 public NullMessageBox()
 48    {
 49    }
 50   
 51    /**
 52    * Creates message box with the specified {@link MessageStringManager string manager}.
 53    *
 54    * @param sm The specified string manager.
 55    */
 56  0 public NullMessageBox( MessageStringManager sm )
 57    {
 58  0 if( sm == null ) throw new NullPointerException( "sm" );
 59  0 this.sm = sm;
 60    }
 61   
 62    /**
 63    * {@inheritDoc}
 64    */
 65  0 public synchronized void fatal( Message message )
 66    {
 67  0 error( message );
 68  0 status();
 69    }
 70   
 71    /**
 72    * {@inheritDoc}
 73    */
 74  0 public synchronized void error( Message message )
 75    {
 76  0 context.setMessage( message );
 77  0 context.setLevel( ErrorMessageLevel.level);
 78  0 error_count++;
 79  0 errorStr( sm.getString( context ) );
 80    }
 81   
 82    /**
 83    * {@inheritDoc}
 84    */
 85  0 public synchronized void warning( Message message )
 86    {
 87  0 context.setMessage( message );
 88  0 context.setLevel( WarningMessageLevel.level );
 89  0 warning_count++;
 90  0 warningStr( sm.getString( context ) );
 91    }
 92   
 93    /**
 94    * {@inheritDoc}
 95    */
 96  0 public synchronized void info( Message message )
 97    {
 98  0 context.setMessage( message );
 99  0 context.setLevel( InfoMessageLevel.level );
 100  0 info_count++;
 101  0 infoStr( sm.getString( context ) );
 102    }
 103   
 104    /**
 105    * {@inheritDoc}
 106    */
 107  0 public synchronized void info( String message )
 108    {
 109  0 info_count++;
 110  0 infoStr( message );
 111    }
 112   
 113    /**
 114    * {@inheritDoc}
 115    */
 116  0 public int getErrorCount()
 117    {
 118  0 return error_count;
 119    }
 120   
 121    /**
 122    * {@inheritDoc}
 123    */
 124  0 public int getWarningCount()
 125    {
 126  0 return warning_count;
 127    }
 128   
 129    /**
 130    * {@inheritDoc}
 131    */
 132  0 public int getInfoCount()
 133    {
 134  0 return info_count;
 135    }
 136   
 137    /**
 138    * {@inheritDoc}
 139    */
 140  0 public void statistics()
 141    {
 142  0 info( new MessageBoxStatisticsMessage() );
 143    }
 144   
 145    /**
 146    * {@inheritDoc}
 147    */
 148  0 public void status()
 149    {
 150  0 if( getErrorCount() > 0 )
 151    {
 152  0 statistics();
 153  0 stop( 1 );
 154    }
 155    }
 156   
 157    /**
 158    * {@inheritDoc}
 159    */
 160  0 public void stop( int code )
 161    {
 162  0 throw new FatalErrorException( code );
 163    }
 164   
 165    /**
 166    * {@inheritDoc}
 167    */
 168  0 public MessageStringManager getStringManager() { return sm; }
 169   
 170  0 protected synchronized void errorStr( String message )
 171    {
 172    // NullMessageBox does nothing
 173    }
 174   
 175  0 protected synchronized void warningStr( String message )
 176    {
 177    // NullMessageBox does nothing
 178    }
 179   
 180  0 protected synchronized void infoStr( String message )
 181    {
 182    // NullMessageBox does nothing
 183    }
 184   
 185    protected MessageContext context = new MessageContext( this );
 186    protected MessageStringManager sm = new MessageStringManager();
 187   
 188    private int error_count;
 189    private int warning_count;
 190    private int info_count;
 191    }