Clover Coverage Report
Coverage timestamp: Sa Aug 2 2008 13:56:27 CEST
../../../../img/srcFileCovDistChart8.png 47% of files have more coverage
11   159   8   1,57
2   71   0,73   7
7     1,14  
1    
 
  LoadingState       Line # 26 11 8 80% 0.8
 
  (43)
 
1    /* $Id: LoadingState.java,v 1.2 2008/05/15 21:27:48 m31 Exp $
2    *
3    * This file is part of the project "Hilbert II" - http://www.qedeq.org
4    *
5    * Copyright 2000-2008, 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.common;
19   
20    /**
21    * Represents a module state. Every instance of this class is unique.
22    *
23    * @version $Revision: 1.2 $
24    * @author Michael Meyling
25    */
 
26    public final class LoadingState {
27   
28    /** Undefined loading state. */
29    public static final LoadingState STATE_UNDEFINED = new LoadingState(
30    LoadingStateDescriptions.STATE_STRING_UNDEFINED, false,
31    LoadingStateDescriptions.STATE_CODE_UNDEFINED);
32   
33    /** Trying to access web address. */
34    public static final LoadingState STATE_LOCATING_WITHIN_WEB = new LoadingState(
35    LoadingStateDescriptions.STATE_STRING_LOCATING_WITHIN_WEB, false,
36    LoadingStateDescriptions.STATE_CODE_LOCATING_WITHIN_WEB);
37   
38    /** Try to access web address failed. */
39    public static final LoadingState STATE_LOCATING_WITHIN_WEB_FAILED = new LoadingState(
40    LoadingStateDescriptions.STATE_STRING_LOCATING_WITHIN_WEB_FAILED, true,
41    LoadingStateDescriptions.STATE_CODE_LOCATING_WITHIN_WEB_FAILED);
42   
43    /** Loading from web address. */
44    public static final LoadingState STATE_LOADING_FROM_WEB = new LoadingState(
45    LoadingStateDescriptions.STATE_STRING_LOADING_FROM_WEB, false,
46    LoadingStateDescriptions.STATE_CODE_LOADING_FROM_WEB);
47   
48    /** Loading from web address failed. */
49    public static final LoadingState STATE_LOADING_FROM_WEB_FAILED = new LoadingState(
50    LoadingStateDescriptions.STATE_STRING_LOADING_FROM_WEB_FAILED, true,
51    LoadingStateDescriptions.STATE_CODE_LOADING_FROM_WEB_FAILED);
52   
53    /** Loading from local file. */
54    public static final LoadingState STATE_LOADING_FROM_LOCAL_FILE = new LoadingState(
55    LoadingStateDescriptions.STATE_STRING_LOADING_FROM_LOCAL_FILE, false,
56    LoadingStateDescriptions.STATE_CODE_LOADING_FROM_LOCAL_FILE);
57   
58    /** Loading from web address failed. */
59    public static final LoadingState STATE_LOADING_FROM_LOCAL_FILE_FAILED = new LoadingState(
60    LoadingStateDescriptions.STATE_STRING_LOADING_FROM_WEB_FAILED, true,
61    LoadingStateDescriptions.STATE_CODE_LOADING_FROM_LOCAL_FILE_FAILED);
62   
63    /** Loading from local file buffer. */
64    public static final LoadingState STATE_LOADING_FROM_BUFFER = new LoadingState(
65    LoadingStateDescriptions.STATE_STRING_LOADING_FROM_BUFFER, false,
66    LoadingStateDescriptions.STATE_CODE_LOADING_FROM_BUFFER);
67   
68    /** Loading from local file buffer failed. */
69    public static final LoadingState STATE_LOADING_FROM_BUFFER_FAILED = new LoadingState(
70    LoadingStateDescriptions.STATE_STRING_LOADING_FROM_BUFFER_FAILED, true,
71    LoadingStateDescriptions.STATE_CODE_LOADING_FROM_BUFFER_FAILED);
72   
73    /** Loading into memory. */
74    public static final LoadingState STATE_LOADING_INTO_MEMORY = new LoadingState(
75    LoadingStateDescriptions.STATE_STRING_LOADING_INTO_MEMORY, false,
76    LoadingStateDescriptions.STATE_CODE_LOADING_INTO_MEMORY);
77   
78    /** Loading into memory failed. */
79    public static final LoadingState STATE_LOADING_INTO_MEMORY_FAILED = new LoadingState(
80    LoadingStateDescriptions.STATE_STRING_LOADING_INTO_MEMORY_FAILED, true,
81    LoadingStateDescriptions.STATE_CODE_LOADING_INTO_MEMORY_FAILED);
82   
83    /** Completely loaded. */
84    public static final LoadingState STATE_LOADED = new LoadingState(
85    LoadingStateDescriptions.STATE_STRING_LOADED, false,
86    LoadingStateDescriptions.STATE_CODE_LOADED);
87   
88    /** Deleted. */
89    public static final LoadingState STATE_DELETED = new LoadingState(
90    LoadingStateDescriptions.STATE_STRING_DELETED, false,
91    LoadingStateDescriptions.STATE_CODE_DELETED);
92   
93    /** meaning of this state. */
94    private final String text;
95   
96    /** is this state a failure? */
97    private final boolean failure;
98   
99    /** Code for state. */
100    private final int code;
101   
102    /**
103    * Creates new module state.
104    *
105    * @param text meaning of this state, <code>null</code> is not permitted.
106    * @param failure is this a failure state?
107    * @param code code of this state.
108    * @throws IllegalArgumentException text == <code>null</code>
109    */
 
110  104 toggle private LoadingState(final String text, final boolean failure, final int code) {
111  104 this.text = text;
112  104 if (this.text == null) {
113  0 throw new IllegalArgumentException("text==null");
114    }
115  104 this.failure = failure;
116  104 this.code = code;
117    }
118   
119    /**
120    * Get meaning of module state.
121    *
122    * @return meaning of module state.
123    */
 
124  341 toggle public String getText() {
125  341 return this.text;
126    }
127   
128    /**
129    * Is this a failure state?
130    *
131    * @return is this a failure state?
132    */
 
133  1270 toggle public boolean isFailure() {
134  1270 return this.failure;
135    }
136   
137    /**
138    * Get module state code.
139    *
140    * @return Module state.
141    */
 
142  250 toggle public int getCode() {
143  250 return this.code;
144    }
145   
 
146  3 toggle public String toString() {
147  3 return this.text;
148    }
149   
 
150  0 toggle public int hashCode() {
151  0 return this.text.hashCode();
152    }
153   
 
154  17 toggle public final boolean equals(final Object obj) {
155    // every instance is unique
156  17 return (this == obj);
157    }
158   
159    }