Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Do Mai 10 2007 03:16:40 CEST
file stats: LOC: 171   Methods: 17
NCLOC: 110   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
DefaultModuleProperties.java 40,9% 61,4% 76,5% 59%
coverage coverage
 1    /* $Id: DefaultModuleProperties.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.bo.load;
 19   
 20    import java.net.URL;
 21   
 22    import org.qedeq.kernel.bo.module.LoadingState;
 23    import org.qedeq.kernel.bo.module.ModuleAddress;
 24    import org.qedeq.kernel.bo.module.ModuleProperties;
 25    import org.qedeq.kernel.bo.module.QedeqBo;
 26   
 27   
 28    /**
 29    * Represents a module and its states.
 30    *
 31    * @version $Revision: 1.1 $
 32    * @author Michael Meyling
 33    */
 34    public class DefaultModuleProperties implements ModuleProperties {
 35   
 36    /** Address and module specification. */
 37    private final ModuleAddress address;
 38   
 39    /** Completeness during loading from web. */
 40    private int loadingCompleteness;
 41   
 42    /** describes QEDEQ module loading state. */
 43    private LoadingState state;
 44   
 45    /** loaded QEDEQ module. */
 46    private QedeqBo module;
 47   
 48    /** failure exception. */
 49    private Exception exception;
 50   
 51   
 52    /**
 53    * Creates new module properties.
 54    *
 55    * @param address module address
 56    */
 57  17 public DefaultModuleProperties(final ModuleAddress address) {
 58  17 this.address = address;
 59  17 this.state = LoadingState.STATE_UNDEFINED;
 60  17 this.loadingCompleteness = 0;
 61    }
 62   
 63  0 public final boolean hasFailures() {
 64  0 return this.state.isFailure();
 65    }
 66   
 67  9 public final String getAddress() {
 68  9 if (address == null) {
 69  0 return "null";
 70    }
 71  9 return address.getAddress();
 72    }
 73   
 74  9 public final ModuleAddress getModuleAddress() {
 75  9 return address;
 76    }
 77   
 78  0 public final void setLoadingCompleteness(final int completeness) {
 79  0 this.loadingCompleteness = completeness;
 80    }
 81   
 82  31 public final void setLoadingProgressState(final LoadingState state) {
 83  31 if (state == LoadingState.STATE_LOADED) {
 84  0 throw new IllegalArgumentException(
 85    "this state could only be set by calling method setCheckedAndLoaded");
 86    }
 87  31 if (this.state == LoadingState.STATE_LOADED) {
 88  0 this.module = null;
 89    }
 90  31 if (state.isFailure()) {
 91  0 throw new IllegalArgumentException(
 92    "this is a failure state, call setLoadingFailureState");
 93    }
 94  31 this.exception = null;
 95  31 this.state = state;
 96    }
 97   
 98  7 public final void setLoadingFailureState(final LoadingState state, final Exception e) {
 99  7 if (!state.isFailure()) {
 100  0 throw new IllegalArgumentException(
 101    "this is no failure state, call setProgressState");
 102    }
 103  7 if (this.state == LoadingState.STATE_LOADED) {
 104  0 this.module = null;
 105    }
 106  7 this.state = state;
 107  7 this.exception = e;
 108    }
 109   
 110  63 public final LoadingState getLoadingState() {
 111  63 return this.state;
 112    }
 113   
 114  7 public final Exception getException() {
 115  7 return this.exception;
 116    }
 117   
 118  30 public final String getStateDescription() {
 119  30 if (this.state == LoadingState.STATE_LOADING_FROM_WEB) {
 120  0 return this.state.getText() + " (" + this.loadingCompleteness + "%)";
 121    } else {
 122  30 return this.state.getText();
 123    }
 124    }
 125   
 126  0 public final String getName() {
 127  0 if (address == null) {
 128  0 return "null";
 129    }
 130  0 return address.getName();
 131    }
 132   
 133  0 public final String getRuleVersion() {
 134  0 if (address == null || module == null || module.getHeader() == null
 135    || module.getHeader().getSpecification() == null
 136    || module.getHeader().getSpecification().getRuleVersion() == null) {
 137  0 return "null";
 138    }
 139  0 return module.getHeader().getSpecification().getRuleVersion();
 140    }
 141   
 142  48 public final URL getUrl() {
 143  48 if (address == null) {
 144  0 return null;
 145    }
 146  48 return address.getURL();
 147    }
 148   
 149  30 public final boolean isLoaded() {
 150  30 return (this.state == LoadingState.STATE_LOADED);
 151    }
 152   
 153  9 public final void setLoaded(final QedeqBo module) {
 154  9 this.state = LoadingState.STATE_LOADED;
 155  9 this.module = module;
 156    }
 157   
 158  13 public final QedeqBo getModule() {
 159  13 if (this.state != LoadingState.STATE_LOADED) {
 160  0 throw new IllegalStateException(
 161    "module could only be set if state is \"" + LoadingState.STATE_LOADED.getText()
 162    + "\"");
 163    }
 164  13 return this.module;
 165    }
 166   
 167  1 public final String toString() {
 168  1 return super.toString() + ":" + address + ";" + state;
 169    }
 170   
 171    }