001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package javax.enterprise.deploy.shared;
023:
024: /**
025: * An enumeration of deployment status action types.
026: *
027: * @author <a href="mailto:adrian@jboss.org">Adrian Brock</a>
028: * @version $Revision: 57196 $
029: */
030: public class ActionType {
031: // Constants -----------------------------------------------------
032:
033: /** The Execute integer value */
034: private static final int EXECUTE_INT = 0;
035: /** The Cancel integer value */
036: private static final int CANCEL_INT = 1;
037: /** The Stop integer value */
038: private static final int STOP_INT = 2;
039:
040: /** The action type for EXECUTE */
041: public static final ActionType EXECUTE = new ActionType(EXECUTE_INT);
042: /** The action type for CANCEL */
043: public static final ActionType CANCEL = new ActionType(CANCEL_INT);
044: /** The action type for STOP */
045: public static final ActionType STOP = new ActionType(STOP_INT);
046:
047: /** The action types */
048: private static final ActionType[] actionTypes = new ActionType[] {
049: EXECUTE, CANCEL, STOP };
050:
051: /** The action descriptions */
052: private static final String[] actionDescs = new String[] {
053: "Execute", "Cancel", "Stop" };
054:
055: // Attributes ----------------------------------------------------
056:
057: /** The value */
058: private int value;
059:
060: // Constructors --------------------------------------------------
061:
062: /**
063: * Create a new ActionType
064: *
065: * @param value the value
066: */
067: protected ActionType(int value) {
068: this .value = value;
069: }
070:
071: /**
072: * Get the value
073: *
074: * @return the value
075: */
076: public int getValue() {
077: return value;
078: }
079:
080: /**
081: * Get the string table for class action type
082: *
083: * [todo] check this?
084: * @return the string table
085: */
086: protected String[] getStringTable() {
087: return actionDescs;
088: }
089:
090: /**
091: * Get the enumerated values for module type
092: *
093: * @return the string table
094: */
095: protected ActionType[] getEnumValueTable() {
096: return actionTypes;
097: }
098:
099: /**
100: * Get the action type for an integer
101: *
102: * @param type the type
103: * @return the action type
104: */
105: public static ActionType getActionType(int type) {
106: if (type >= actionTypes.length)
107: return null;
108: return actionTypes[type];
109: }
110:
111: public String toString() {
112: return actionDescs[value];
113: }
114:
115: /**
116: * Return the offset of the first element
117: *
118: * @return the offset
119: */
120: protected int getOffset() {
121: return EXECUTE_INT;
122: }
123:
124: }
|