Clover Coverage Report
Coverage timestamp: Sat Sep 18 2010 04:09:52 UTC
../../../../img/srcFileCovDistChart8.png 50% of files have more coverage
11   141   8   1.57
2   71   0.73   7
7     1.14  
1    
 
  LoadingState       Line # 23 11 8 80% 0.8
 
  (58)
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2010, Michael Meyling <mime@qedeq.org>.
4    *
5    * "Hilbert II" is free software; you can redistribute
6    * it and/or modify it under the terms of the GNU General Public
7    * License as published by the Free Software Foundation; either
8    * version 2 of the License, or (at your option) any later version.
9    *
10    * This program is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13    * GNU General Public License for more details.
14    */
15   
16    package org.qedeq.kernel.common;
17   
18    /**
19    * Represents a module state. Every instance of this class is unique.
20    *
21    * @author Michael Meyling
22    */
 
23    public final class LoadingState implements State {
24   
25    /** Undefined loading state. */
26    public static final LoadingState STATE_UNDEFINED = new LoadingState(
27    LoadingStateDescriptions.STATE_STRING_UNDEFINED, false,
28    LoadingStateDescriptions.STATE_CODE_UNDEFINED);
29   
30    /** Trying to access web address. */
31    public static final LoadingState STATE_LOCATING_WITHIN_WEB = new LoadingState(
32    LoadingStateDescriptions.STATE_STRING_LOCATING_WITHIN_WEB, false,
33    LoadingStateDescriptions.STATE_CODE_LOCATING_WITHIN_WEB);
34   
35    /** Try to access web address failed. */
36    public static final LoadingState STATE_LOCATING_WITHIN_WEB_FAILED = new LoadingState(
37    LoadingStateDescriptions.STATE_STRING_LOCATING_WITHIN_WEB_FAILED, true,
38    LoadingStateDescriptions.STATE_CODE_LOCATING_WITHIN_WEB_FAILED);
39   
40    /** Loading from web address. */
41    public static final LoadingState STATE_LOADING_FROM_WEB = new LoadingState(
42    LoadingStateDescriptions.STATE_STRING_LOADING_FROM_WEB, false,
43    LoadingStateDescriptions.STATE_CODE_LOADING_FROM_WEB);
44   
45    /** Loading from web address failed. */
46    public static final LoadingState STATE_LOADING_FROM_WEB_FAILED = new LoadingState(
47    LoadingStateDescriptions.STATE_STRING_LOADING_FROM_WEB_FAILED, true,
48    LoadingStateDescriptions.STATE_CODE_LOADING_FROM_WEB_FAILED);
49   
50    /** Loading from local file. */
51    public static final LoadingState STATE_LOADING_FROM_LOCAL_FILE = new LoadingState(
52    LoadingStateDescriptions.STATE_STRING_LOADING_FROM_LOCAL_FILE, false,
53    LoadingStateDescriptions.STATE_CODE_LOADING_FROM_LOCAL_FILE);
54   
55    /** Loading from web address failed. */
56    public static final LoadingState STATE_LOADING_FROM_LOCAL_FILE_FAILED = new LoadingState(
57    LoadingStateDescriptions.STATE_STRING_LOADING_FROM_WEB_FAILED, true,
58    LoadingStateDescriptions.STATE_CODE_LOADING_FROM_LOCAL_FILE_FAILED);
59   
60    /** Loading from local file buffer. */
61    public static final LoadingState STATE_LOADING_FROM_BUFFER = new LoadingState(
62    LoadingStateDescriptions.STATE_STRING_LOADING_FROM_BUFFER, false,
63    LoadingStateDescriptions.STATE_CODE_LOADING_FROM_BUFFER);
64   
65    /** Loading from local file buffer failed. */
66    public static final LoadingState STATE_LOADING_FROM_BUFFER_FAILED = new LoadingState(
67    LoadingStateDescriptions.STATE_STRING_LOADING_FROM_BUFFER_FAILED, true,
68    LoadingStateDescriptions.STATE_CODE_LOADING_FROM_BUFFER_FAILED);
69   
70    /** Loading into memory. */
71    public static final LoadingState STATE_LOADING_INTO_MEMORY = new LoadingState(
72    LoadingStateDescriptions.STATE_STRING_LOADING_INTO_MEMORY, false,
73    LoadingStateDescriptions.STATE_CODE_LOADING_INTO_MEMORY);
74   
75    /** Loading into memory failed. */
76    public static final LoadingState STATE_LOADING_INTO_MEMORY_FAILED = new LoadingState(
77    LoadingStateDescriptions.STATE_STRING_LOADING_INTO_MEMORY_FAILED, true,
78    LoadingStateDescriptions.STATE_CODE_LOADING_INTO_MEMORY_FAILED);
79   
80    /** Completely loaded. */
81    public static final LoadingState STATE_LOADED = new LoadingState(
82    LoadingStateDescriptions.STATE_STRING_LOADED, false,
83    LoadingStateDescriptions.STATE_CODE_LOADED);
84   
85    /** Deleted. */
86    public static final LoadingState STATE_DELETED = new LoadingState(
87    LoadingStateDescriptions.STATE_STRING_DELETED, false,
88    LoadingStateDescriptions.STATE_CODE_DELETED);
89   
90    /** meaning of this state. */
91    private final String text;
92   
93    /** is this state a failure? */
94    private final boolean failure;
95   
96    /** Code for state. */
97    private final int code;
98   
99    /**
100    * Creates new module state.
101    *
102    * @param text meaning of this state, <code>null</code> is not permitted.
103    * @param failure is this a failure state?
104    * @param code code of this state.
105    * @throws IllegalArgumentException text == <code>null</code>
106    */
 
107  143 toggle private LoadingState(final String text, final boolean failure, final int code) {
108  143 this.text = text;
109  143 if (this.text == null) {
110  0 throw new IllegalArgumentException("text==null");
111    }
112  143 this.failure = failure;
113  143 this.code = code;
114    }
115   
 
116  456 toggle public String getText() {
117  456 return this.text;
118    }
119   
 
120  1604 toggle public boolean isFailure() {
121  1604 return this.failure;
122    }
123   
 
124  330 toggle public int getCode() {
125  330 return this.code;
126    }
127   
 
128  3 toggle public String toString() {
129  3 return this.text;
130    }
131   
 
132  0 toggle public int hashCode() {
133  0 return this.text.hashCode();
134    }
135   
 
136  17 toggle public final boolean equals(final Object obj) {
137    // every instance is unique
138  17 return (this == obj);
139    }
140   
141    }