001: /*
002: * BEGIN_HEADER - DO NOT EDIT
003: *
004: * The contents of this file are subject to the terms
005: * of the Common Development and Distribution License
006: * (the "License"). You may not use this file except
007: * in compliance with the License.
008: *
009: * You can obtain a copy of the license at
010: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011: * See the License for the specific language governing
012: * permissions and limitations under the License.
013: *
014: * When distributing Covered Code, include this CDDL
015: * HEADER in each file and include the License file at
016: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017: * If applicable add the following below this CDDL HEADER,
018: * with the fields enclosed by brackets "[]" replaced with
019: * your own identifying information: Portions Copyright
020: * [year] [name of copyright owner]
021: */
022:
023: /*
024: * @(#)EndpointStatus.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.jbi.binding.jms;
030:
031: /**
032: * Typesafe enumeration containing status values for a endpoint.
033: *
034: * @author Sun Microsystems inc.
035: */
036: public final class EndpointStatus {
037: /**
038: * Indicates that an endpoint has been deployed.
039: */
040: public static final EndpointStatus DEPLOYED = new EndpointStatus(
041: "DEPLOYED");
042: /**
043: * Indicates that an endpoint has been initialised.
044: */
045: public static final EndpointStatus INIT = new EndpointStatus("INIT");
046:
047: /**
048: * Indicates that an endpoint has been started.
049: */
050: public static final EndpointStatus STARTED = new EndpointStatus(
051: "STARTED");
052:
053: /**
054: * Indicates that an endpoint has been stopped.
055: */
056: public static final EndpointStatus STOPPED = new EndpointStatus(
057: "STOPPED");
058:
059: /**
060: * Indicates that an endpoint has been shutdown.
061: */
062: public static final EndpointStatus SHUTDOWN = new EndpointStatus(
063: "SHUTDOWN");
064:
065: /**
066: * String representation of status.
067: */
068: private String mStatus;
069:
070: /**
071: * Private constructor used to create a new EndpointStatus type.
072: *
073: * @param status value
074: */
075: private EndpointStatus(String status) {
076: mStatus = status;
077: }
078:
079: /**
080: * Equality test.
081: *
082: * @param status status object.
083: *
084: * @return boolean result of test.
085: */
086: public boolean equals(EndpointStatus status) {
087: return (mStatus.equals(status.mStatus));
088: }
089:
090: /**
091: * Returns string value of enumerated type.
092: *
093: * @return String representation of status value.
094: */
095: public String toString() {
096: return mStatus;
097: }
098:
099: /**
100: * Returns instance of EndpointStatus that corresponds to given string.
101: *
102: * @param status status string.
103: *
104: * @return EndpointStatus status object.
105: */
106: public static EndpointStatus valueOf(String status) {
107: EndpointStatus instance;
108:
109: //
110: // Convert symbolic name to object reference.
111: //
112: if (status.equals(SHUTDOWN.toString())) {
113: instance = SHUTDOWN;
114: } else if (status.equals(INIT.toString())) {
115: instance = INIT;
116: } else if (status.equals(STARTED.toString())) {
117: instance = STARTED;
118: } else if (status.equals(STOPPED.toString())) {
119: instance = STOPPED;
120: } else if (status.equals(DEPLOYED.toString())) {
121: instance = DEPLOYED;
122: } else {
123: //
124: // Someone has a problem.
125: //
126: throw new java.lang.IllegalArgumentException(status);
127: }
128:
129: return (instance);
130: }
131: }
|