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: * @(#)MessageStatus.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.monitoring;
030:
031: /**
032: * Typesafe enumeration containing status values for a message .
033: *
034: * @author Sun Microsystems, Inc.
035: */
036: public final class MessageStatus {
037: /**
038: * Indicates that an ME has not been processed to completion.
039: */
040: public static final MessageStatus PROCESSING = new MessageStatus(
041: "PROCESSING");
042:
043: /**
044: * Indicates that an ME has terminated abnormally within the JBI
045: * environment.
046: */
047: public static final MessageStatus INQUEUE = new MessageStatus(
048: "INQUEUE");
049:
050: /**
051: * Indicates that an ME has been processed to completion.
052: */
053: public static final MessageStatus ERROR = new MessageStatus("ERROR");
054:
055: /**
056: *
057: */
058: /**
059: *
060: */
061:
062: /**
063: *
064: */
065: public static final MessageStatus COMPLETED = new MessageStatus(
066: "COMPLETED");
067:
068: /**
069: * String representation of status.
070: */
071: private String mStatus;
072:
073: /**
074: * Private constructor used to create a new MessageStatus type.
075: *
076: * @param status value
077: */
078: private MessageStatus(String status) {
079: mStatus = status;
080: }
081:
082: /**
083: * Equality test.
084: *
085: * @param status
086: *
087: * @return boolean result of test.
088: */
089: public boolean equals(MessageStatus status) {
090: return (mStatus.equals(status.mStatus));
091: }
092:
093: /**
094: * Returns string value of enumerated type.
095: *
096: * @return String representation of status value.
097: */
098: public String toString() {
099: return mStatus;
100: }
101:
102: /**
103: * Returns instance of MessageStatus that corresponds to given string.
104: *
105: * @param status
106: *
107: * @return MessageStatus
108: *
109: * @throws java.lang.IllegalArgumentException if string can't be translated
110: */
111: public static MessageStatus valueOf(String status) {
112: MessageStatus instance;
113:
114: //
115: // Convert symbolic name to object reference.
116: //
117: if (status.equals(COMPLETED.toString())) {
118: instance = COMPLETED;
119: } else if (status.equals(ERROR.toString())) {
120: instance = ERROR;
121: } else if (status.equals(INQUEUE.toString())) {
122: instance = INQUEUE;
123: } else if (status.equals(PROCESSING.toString())) {
124: instance = PROCESSING;
125: } else {
126: //
127: // Someone has a problem.
128: //
129: throw new java.lang.IllegalArgumentException(status);
130: }
131:
132: return (instance);
133: }
134: }
|