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: * @(#)ExchangeStatus.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package javax.jbi.messaging;
030:
031: /** Typesafe enumeration containing status values for a message exchange.
032: *
033: * @author JSR208 Expert Group
034: */
035: public final class ExchangeStatus {
036:
037: /** Indicates that an ME has not been processed to completion. */
038: public static final ExchangeStatus ACTIVE = new ExchangeStatus(
039: "Active");
040:
041: /** Indicates that an ME has terminated abnormally within the JBI
042: * environment.
043: */
044: public static final ExchangeStatus ERROR = new ExchangeStatus(
045: "Error");
046:
047: /** Indicates that an ME has been processed to completion.
048: */
049: public static final ExchangeStatus DONE = new ExchangeStatus("Done");
050:
051: /** String representation of status. */
052: private String mStatus;
053:
054: /** Private constructor used to create a new ExchangeStatus type.
055: * @param status value
056: */
057: private ExchangeStatus(String status) {
058: mStatus = status;
059: }
060:
061: /** Returns string value of enumerated type.
062: * @return String representation of status value.
063: */
064: public String toString() {
065: return mStatus;
066: }
067:
068: /** Equality test.
069: * @param status value to be compared for equality
070: * @return boolean result of test.
071:
072: public boolean equals(Object obj)
073: {
074: boolean isEqual = false;
075:
076: if (obj instanceof ExchangeStatus &&
077: mStatus.equals(((ExchangeStatus)obj).mStatus))
078: {
079: isEqual = true;
080: }
081:
082: return isEqual;
083: }
084: */
085:
086: /** Returns instance of ExchangeStatus that corresponds to given string.
087: * @param status string value of status
088: * @return ExchangeStatus
089: * @throws java.lang.IllegalArgumentException if string can't be translated
090: */
091: public static ExchangeStatus valueOf(String status) {
092: ExchangeStatus instance;
093:
094: //
095: // Convert symbolic name to object reference.
096: //
097: if (status.equals(DONE.toString())) {
098: instance = DONE;
099: } else if (status.equals(ERROR.toString())) {
100: instance = ERROR;
101: } else if (status.equals(ACTIVE.toString())) {
102: instance = ACTIVE;
103:
104: } else {
105: //
106: // Someone has a problem.
107: //
108: throw new java.lang.IllegalArgumentException(status);
109: }
110:
111: return (instance);
112: }
113:
114: /** Returns hash code value for this object.
115: * @return hash code value
116: */
117: public int hashCode() {
118: return mStatus.hashCode();
119: }
120: }
|