Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Do Mai 10 2007 03:16:40 CEST
file stats: LOC: 85   Methods: 7
NCLOC: 34   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
DefaultModuleEventListener.java - 0% 0% 0%
coverage
 1    /* $Id: DefaultModuleEventListener.java,v 1.1 2007/05/10 00:37:51 m31 Exp $
 2    *
 3    * This file is part of the project "Hilbert II" - http://www.qedeq.org
 4    *
 5    * Copyright 2000-2007, Michael Meyling <mime@qedeq.org>.
 6    *
 7    * "Hilbert II" is free software; you can redistribute
 8    * it and/or modify it under the terms of the GNU General Public
 9    * License as published by the Free Software Foundation; either
 10    * version 2 of the License, or (at your option) any later version.
 11    *
 12    * This program is distributed in the hope that it will be useful,
 13    * but WITHOUT ANY WARRANTY; without even the implied warranty of
 14    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 15    * GNU General Public License for more details.
 16    */
 17   
 18    package org.qedeq.kernel.log;
 19   
 20    import java.io.PrintStream;
 21    import java.util.Date;
 22    import java.text.SimpleDateFormat;
 23   
 24    import org.qedeq.kernel.bo.module.ModuleProperties;
 25   
 26    /**
 27    * Listener that writes events to a stream.
 28    *
 29    * @version $Revision: 1.1 $
 30    * @author Michael Meyling
 31    */
 32    public class DefaultModuleEventListener implements ModuleEventListener {
 33   
 34    /** Stream for output. */
 35    private PrintStream out = System.out;
 36   
 37    /** Timestamp format. */
 38    private static final SimpleDateFormat FORMATTER
 39    = new SimpleDateFormat("yyyy-MM-dd' 'HH:mm:ss,SSS");
 40   
 41    /**
 42    * Constructor.
 43    */
 44  0 public DefaultModuleEventListener() {
 45  0 this(System.out);
 46    }
 47   
 48    /**
 49    * Constructor.
 50    *
 51    * @param stream Print to this stream.
 52    */
 53  0 public DefaultModuleEventListener(final PrintStream stream) {
 54  0 this.out = stream;
 55    }
 56   
 57    /**
 58    * Set output stream.
 59    *
 60    * @param stream Output stream.
 61    */
 62  0 public final void setPrintStream(final PrintStream stream) {
 63  0 this.out = stream;
 64    }
 65   
 66  0 public void addModule(final ModuleProperties prop) {
 67  0 out.println(getTimestamp() + " Module added. "
 68    + prop.getStateDescription() + "\n\t" + prop.getAddress());
 69    }
 70   
 71  0 public void stateChanged(final ModuleProperties prop) {
 72  0 out.println(getTimestamp() + " Module state changed. "
 73    + prop.getStateDescription() + "\n\t" + prop.getAddress());
 74    }
 75   
 76  0 public void removeModule(final ModuleProperties prop) {
 77  0 out.println(getTimestamp() + " Module removed. "
 78    + prop.getStateDescription() + "\n\t" + prop.getAddress());
 79    }
 80   
 81  0 private static final String getTimestamp() {
 82  0 return FORMATTER.format(new Date()).toString();
 83    }
 84   
 85    }