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 commands.
026: *
027: * @author <a href="mailto:adrian@jboss.org">Adrian Brock</a>
028: * @version $Revision: 57196 $
029: */
030: public class CommandType {
031: // Constants -----------------------------------------------------
032:
033: /** The DISTRIBUTE integer value */
034: private static final int DISTRIBUTE_INT = 0;
035: /** The START integer value */
036: private static final int START_INT = 1;
037: /** The STOP integer value */
038: private static final int STOP_INT = 2;
039: /** The UNDEPLOY integer value */
040: private static final int UNDEPLOY_INT = 3;
041: /** The REDEPLOY integer value */
042: private static final int REDEPLOY_INT = 4;
043:
044: /** The command type for an DISTRIBUTE */
045: public static final CommandType DISTRIBUTE = new CommandType(
046: DISTRIBUTE_INT);
047: /** The command type for an START */
048: public static final CommandType START = new CommandType(START_INT);
049: /** The command type for an STOP */
050: public static final CommandType STOP = new CommandType(STOP_INT);
051: /** The command type for an UNDEPLOY */
052: public static final CommandType UNDEPLOY = new CommandType(
053: UNDEPLOY_INT);
054: /** The module type for an REDEPLOY */
055: public static final CommandType REDEPLOY = new CommandType(
056: REDEPLOY_INT);
057:
058: /** The command types */
059: private static final CommandType[] commandTypes = new CommandType[] {
060: DISTRIBUTE, START, STOP, UNDEPLOY, REDEPLOY };
061:
062: /** The command descriptions */
063: private static final String[] commandDescs = new String[] {
064: "Distribute", "Start", "Stop", "Undeploy", "Redeploy" };
065:
066: // Attributes ----------------------------------------------------
067:
068: /** The value */
069: private int value;
070:
071: /**
072: * Create a new CommandType
073: *
074: * @param value the value
075: */
076: protected CommandType(int value) {
077: this .value = value;
078: }
079:
080: // Public --------------------------------------------------------
081:
082: /**
083: * Get the value
084: *
085: * @return the value
086: */
087: public int getValue() {
088: return value;
089: }
090:
091: /**
092: * Get the string table for class command type
093: *
094: * [todo] check this?
095: * @return the string table
096: */
097: protected String[] getStringTable() {
098: return commandDescs;
099: }
100:
101: /**
102: * Get the enumerated values for module type
103: *
104: * @return the string table
105: */
106: protected CommandType[] getEnumValueTable() {
107: return commandTypes;
108: }
109:
110: /**
111: * Get the command type for an integer
112: *
113: * @param type the type
114: * @return the command type
115: */
116: public static CommandType getCommandType(int type) {
117: if (type >= commandTypes.length)
118: return null;
119: return commandTypes[type];
120: }
121:
122: public String toString() {
123: return commandDescs[value];
124: }
125:
126: /**
127: * Return the offset of the first element
128: *
129: * @return the offset
130: */
131: protected int getOffset() {
132: return DISTRIBUTE_INT;
133: }
134:
135: }
|