Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Sa Jan 26 2008 14:11:34 CET
file stats: LOC: 145   Methods: 7
NCLOC: 62   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
LoadingState.java 50% 72,7% 71,4% 70%
coverage coverage
 1    /* $Id: LoadingState.java,v 1.3 2008/01/26 12:39:09 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.module;
 19   
 20   
 21    /**
 22    * Represents a module state. Every instance of this class is unique.
 23    *
 24    * @version $Revision: 1.3 $
 25    * @author Michael Meyling
 26    */
 27    public final class LoadingState {
 28   
 29    /** Undefined loading state. */
 30    public static final LoadingState STATE_UNDEFINED = new LoadingState(
 31    LoadingStateDescriptions.STATE_STRING_UNDEFINED, false,
 32    LoadingStateDescriptions.STATE_CODE_UNDEFINED);
 33   
 34    /** Trying to access web address. */
 35    public static final LoadingState STATE_LOCATING_WITHIN_WEB = new LoadingState(
 36    LoadingStateDescriptions.STATE_STRING_LOCATING_WITHIN_WEB, false,
 37    LoadingStateDescriptions.STATE_CODE_LOCATING_WITHIN_WEB);
 38   
 39    /** Try to access web address failed. */
 40    public static final LoadingState STATE_LOCATING_WITHIN_WEB_FAILED = new LoadingState(
 41    LoadingStateDescriptions.STATE_STRING_LOCATING_WITHIN_WEB_FAILED, true,
 42    LoadingStateDescriptions.STATE_CODE_LOCATING_WITHIN_WEB_FAILED);
 43   
 44    /** Loading from web address. */
 45    public static final LoadingState STATE_LOADING_FROM_WEB = new LoadingState(
 46    LoadingStateDescriptions.STATE_STRING_LOADING_FROM_WEB, false,
 47    LoadingStateDescriptions.STATE_CODE_LOADING_FROM_WEB);
 48   
 49    /** Loading from web address failed. */
 50    public static final LoadingState STATE_LOADING_FROM_WEB_FAILED = new LoadingState(
 51    LoadingStateDescriptions.STATE_STRING_LOADING_FROM_WEB_FAILED, true,
 52    LoadingStateDescriptions.STATE_CODE_LOADING_FROM_WEB_FAILED);
 53   
 54    /** Loading from local file buffer. */
 55    public static final LoadingState STATE_LOADING_FROM_BUFFER = new LoadingState(
 56    LoadingStateDescriptions.STATE_STRING_LOADING_FROM_BUFFER, false,
 57    LoadingStateDescriptions.STATE_CODE_LOADING_FROM_BUFFER);
 58   
 59    /** Loading from local file buffer failed. */
 60    public static final LoadingState STATE_LOADING_FROM_BUFFER_FAILED = new LoadingState(
 61    LoadingStateDescriptions.STATE_STRING_LOADING_FROM_BUFFER_FAILED, true,
 62    LoadingStateDescriptions.STATE_CODE_LOADING_FROM_BUFFER_FAILED);
 63   
 64    /** Loading into memory. */
 65    public static final LoadingState STATE_LOADING_INTO_MEMORY = new LoadingState(
 66    LoadingStateDescriptions.STATE_STRING_LOADING_INTO_MEMORY, false,
 67    LoadingStateDescriptions.STATE_CODE_LOADING_INTO_MEMORY);
 68   
 69    /** Loading into memory failed. */
 70    public static final LoadingState STATE_LOADING_INTO_MEMORY_FAILED = new LoadingState(
 71    LoadingStateDescriptions.STATE_STRING_LOADING_INTO_MEMORY_FAILED, true,
 72    LoadingStateDescriptions.STATE_CODE_LOADING_INTO_MEMORY_FAILED);
 73   
 74    /** Completely loaded. */
 75    public static final LoadingState STATE_LOADED = new LoadingState(
 76    LoadingStateDescriptions.STATE_STRING_LOADED, false,
 77    LoadingStateDescriptions.STATE_CODE_LOADED);
 78   
 79    /** meaning of this state. */
 80    private final String text;
 81   
 82    /** is this state a failure? */
 83    private final boolean failure;
 84   
 85    /** Code for state. */
 86    private final int code;
 87   
 88    /**
 89    * Creates new module state.
 90    *
 91    * @param text meaning of this state, <code>null</code> is not permitted.
 92    * @param failure is this a failure state?
 93    * @param code code of this state.
 94    * @throws IllegalArgumentException text == <code>null</code>
 95    */
 96  40 private LoadingState(final String text, final boolean failure, final int code) {
 97  40 this.text = text;
 98  40 if (this.text == null) {
 99  0 throw new IllegalArgumentException("text==null");
 100    }
 101  40 this.failure = failure;
 102  40 this.code = code;
 103    }
 104   
 105    /**
 106    * Get meaning of module state.
 107    *
 108    * @return meaning of module state.
 109    */
 110  1268 public String getText() {
 111  1268 return this.text;
 112    }
 113   
 114    /**
 115    * Is this a failure state?
 116    *
 117    * @return is this a failure state?
 118    */
 119  1688 public boolean isFailure() {
 120  1688 return this.failure;
 121    }
 122   
 123    /**
 124    * Get module state code.
 125    *
 126    * @return Module state.
 127    */
 128  494 public int getCode() {
 129  494 return this.code;
 130    }
 131   
 132  386 public String toString() {
 133  386 return this.text;
 134    }
 135   
 136  0 public int hashCode() {
 137  0 return this.text.hashCode();
 138    }
 139   
 140  0 public final boolean equals(final Object obj) {
 141    // every instance is unique
 142  0 return (this == obj);
 143    }
 144   
 145    }