Clover coverage report - DNA Site - 1.1
Coverage timestamp: Sun May 2 2004 15:33:21 BST
file stats: LOC: 91   Methods: 5
NCLOC: 35   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
AbstractLogEnabled.java 100% 100% 100% 100%
coverage
 1   
 /*
 2   
  * Copyright (C) The DNA Group. All rights reserved.
 3   
  *
 4   
  * This software is published under the terms of the DNA
 5   
  * Software License version 1.1, a copy of which has been included
 6   
  * with this distribution in the LICENSE.txt file.
 7   
  */
 8   
 package org.codehaus.dna;
 9   
 
 10   
 /**
 11   
  * Abstract utility class that components can extend to
 12   
  * make it easy to implement logging.
 13   
  *
 14   
  * @version $Revision: 1.2 $ $Date: 2004/05/01 09:51:48 $
 15   
  */
 16   
 public abstract class AbstractLogEnabled
 17   
     implements LogEnabled
 18   
 {
 19   
     /**
 20   
      * The components logger.
 21   
      */
 22   
     private Logger m_logger;
 23   
 
 24   
     /**
 25   
      * Set the components logger.
 26   
      *
 27   
      * @param logger the logger
 28   
      */
 29  28
     public void enableLogging( final Logger logger )
 30   
     {
 31  28
         m_logger = logger;
 32   
     }
 33   
 
 34   
     /**
 35   
      * Return the components logger.
 36   
      *
 37   
      * @return the components logger.
 38   
      */
 39  32
     protected final Logger getLogger()
 40   
     {
 41  32
         return m_logger;
 42   
     }
 43   
 
 44   
     /**
 45   
      * Utility method to setup specified object
 46   
      * with current components logger.
 47   
      *
 48   
      * @param object the object
 49   
      */
 50  8
     protected final void setupLogger( final Object object )
 51   
     {
 52  8
         setupLogger( object, getLogger() );
 53   
     }
 54   
 
 55   
     /**
 56   
      * Utility method to setup specified object
 57   
      * with a child logger of components current
 58   
      * logger with specified name.
 59   
      *
 60   
      * @param object the object
 61   
      * @param name the name of child logger
 62   
      */
 63  8
     protected final void setupLogger( final Object object,
 64   
                                       final String name )
 65   
     {
 66  8
         if( null == name )
 67   
         {
 68  4
             throw new NullPointerException( "name" );
 69   
         }
 70  4
         final Logger childLogger = getLogger().getChildLogger( name );
 71  4
         setupLogger( object, childLogger );
 72   
     }
 73   
 
 74   
     /**
 75   
      * Internal implementation method to setup object
 76   
      * with specified logger. If the object implements
 77   
      * {@link LogEnabled} it will be supplied with logger
 78   
      * via the {@link LogEnabled} interface.
 79   
      *
 80   
      * @param object the object
 81   
      * @param logger the logger
 82   
      */
 83  12
     private final void setupLogger( final Object object, final Logger logger )
 84   
     {
 85  12
         if( object instanceof LogEnabled )
 86   
         {
 87  8
             ( (LogEnabled)object ).enableLogging( logger );
 88   
         }
 89   
     }
 90   
 }
 91