|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| StateType.java | - | 76,9% | 57,1% | 70% |
|
||||||||||||||
| 1 |
/*
|
|
| 2 |
* EJTools, the Enterprise Java Tools
|
|
| 3 |
*
|
|
| 4 |
* Distributable under LGPL license.
|
|
| 5 |
* See terms of license at www.gnu.org.
|
|
| 6 |
*/
|
|
| 7 |
package javax.enterprise.deploy.shared;
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
/**
|
|
| 11 |
* Class StateTypes defines enumeration values for the DeploymentStatus object.
|
|
| 12 |
*
|
|
| 13 |
* @author Laurent Etiemble
|
|
| 14 |
* @version $Revision: 1.1 $
|
|
| 15 |
* @since 1.0
|
|
| 16 |
*/
|
|
| 17 |
public class StateType |
|
| 18 |
{
|
|
| 19 |
/** Index value */
|
|
| 20 |
private int value; |
|
| 21 |
|
|
| 22 |
/** The action operation has completed normally. */
|
|
| 23 |
public final static StateType COMPLETED; |
|
| 24 |
/** The action operation has failed. */
|
|
| 25 |
public final static StateType FAILED; |
|
| 26 |
/** The DeploymentManager is running in disconnected mode. */
|
|
| 27 |
public final static StateType RELEASED; |
|
| 28 |
/** The action operation is running normally. */
|
|
| 29 |
public final static StateType RUNNING; |
|
| 30 |
|
|
| 31 |
/** Internal table for string values */
|
|
| 32 |
private final static String[] stringTable; |
|
| 33 |
/** Internal table for values */
|
|
| 34 |
private final static StateType[] valueTable; |
|
| 35 |
|
|
| 36 |
|
|
| 37 |
/**
|
|
| 38 |
* Construct a new enumeration value with the given integer value.
|
|
| 39 |
*
|
|
| 40 |
* @param value Integer value
|
|
| 41 |
*/
|
|
| 42 | 32 |
protected StateType(int value) |
| 43 |
{
|
|
| 44 | 32 |
this.value = value;
|
| 45 |
} |
|
| 46 |
|
|
| 47 |
|
|
| 48 |
/**
|
|
| 49 |
* Returns this enumeration value's integer value.
|
|
| 50 |
*
|
|
| 51 |
* @return the value
|
|
| 52 |
*/
|
|
| 53 | 32 |
public int getValue() |
| 54 |
{
|
|
| 55 | 32 |
return this.value; |
| 56 |
} |
|
| 57 |
|
|
| 58 |
|
|
| 59 |
/**
|
|
| 60 |
* Return the string name of this StateType or the integer value if outside the
|
|
| 61 |
* bounds of the table.
|
|
| 62 |
*
|
|
| 63 |
* @return The String representation
|
|
| 64 |
*/
|
|
| 65 | 32 |
public String toString()
|
| 66 |
{
|
|
| 67 | 32 |
return stringTable[value];
|
| 68 |
} |
|
| 69 |
|
|
| 70 |
|
|
| 71 |
/**
|
|
| 72 |
* Returns the enumeration value table for class StateType
|
|
| 73 |
*
|
|
| 74 |
* @return Enumeration table of the values
|
|
| 75 |
*/
|
|
| 76 | 0 |
protected StateType[] getEnumValueTable()
|
| 77 |
{
|
|
| 78 | 0 |
return valueTable;
|
| 79 |
} |
|
| 80 |
|
|
| 81 |
|
|
| 82 |
/**
|
|
| 83 |
* Returns the lowest integer value used by this enumeration value's enumeration
|
|
| 84 |
* class. <p>
|
|
| 85 |
*
|
|
| 86 |
* The default implementation returns 0.</p>
|
|
| 87 |
*
|
|
| 88 |
* @return the offset of the lowest enumeration value.
|
|
| 89 |
*/
|
|
| 90 | 0 |
protected int getOffset() |
| 91 |
{
|
|
| 92 | 0 |
return 0;
|
| 93 |
} |
|
| 94 |
|
|
| 95 |
|
|
| 96 |
/**
|
|
| 97 |
* Returns the string table for class StateType
|
|
| 98 |
*
|
|
| 99 |
* @return The String representation table values
|
|
| 100 |
*/
|
|
| 101 | 0 |
protected String[] getStringTable()
|
| 102 |
{
|
|
| 103 | 0 |
return stringTable;
|
| 104 |
} |
|
| 105 |
|
|
| 106 |
|
|
| 107 |
/**
|
|
| 108 |
* Return an object of the specified value.
|
|
| 109 |
*
|
|
| 110 |
* @param value a designator for the object.
|
|
| 111 |
* @return The corresponding StateType
|
|
| 112 |
*/
|
|
| 113 | 32 |
public static StateType getModuleType(int value) |
| 114 |
{
|
|
| 115 | 32 |
return valueTable[value];
|
| 116 |
} |
|
| 117 |
|
|
| 118 |
/** Static block to initialize constants and to fill arrays. */
|
|
| 119 |
static
|
|
| 120 |
{
|
|
| 121 | 8 |
RUNNING = new StateType(0);
|
| 122 | 8 |
COMPLETED = new StateType(1);
|
| 123 | 8 |
FAILED = new StateType(2);
|
| 124 | 8 |
RELEASED = new StateType(3);
|
| 125 |
|
|
| 126 | 8 |
valueTable = (new StateType[]{RUNNING, COMPLETED, FAILED, RELEASED});
|
| 127 | 8 |
stringTable = new String[]{"running", "completed", "failed", "released"}; |
| 128 |
} |
|
| 129 |
} |
|
| 130 |
|
|
||||||||||