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: * @(#)Link.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.jbi.messaging;
030:
031: /** Typesafe enumeration containing link types.
032: *
033: * @author JSR208 Expert Group
034: */
035: public final class Link {
036: /** Indicates that the provided service endpoint must be routed according
037: * to standard normalized message routing rules.
038: */
039: public static final Link STANDARD = new Link("standard");
040:
041: /** Indicates that the provided service endpoint name must match a service
042: * provider’s service endpoint name; indirect connections are not allowed.
043: */
044: public static final Link HARD = new Link("hard");
045:
046: /** Indicates that the provided service endpoint must not match a service
047: * provider’s service endpoint name; rather, it must match an indirect
048: * connection name.
049: */
050: public static final Link SOFT = new Link("soft");
051:
052: /** String representation of link. */
053: private String mLink;
054:
055: /** Private constructor used to create a new Link type.
056: * @param status value
057: */
058: private Link(String link) {
059: mLink = link;
060: }
061:
062: /** Returns string value of enumerated type.
063: * @return String representation of status value.
064: */
065: public String toString() {
066: return mLink;
067: }
068:
069: /** Equality test.
070: * @param status value to be compared for equality
071: * @return boolean result of test.
072: */
073: public boolean equals(Link link) {
074: return (mLink.equals(link.mLink));
075: }
076:
077: /** Returns instance of Link that corresponds to given string.
078: * @param status string value of status
079: * @return ExchangeStatus
080: * @throws java.lang.IllegalArgumentException if string can't be translated
081: */
082: public static Link valueOf(String link) {
083: Link instance;
084:
085: //
086: // Convert symbolic name to object reference.
087: //
088: if (link.equalsIgnoreCase(HARD.toString())) {
089: instance = HARD;
090: } else if (link.equalsIgnoreCase(SOFT.toString())) {
091: instance = SOFT;
092: } else if (link.equalsIgnoreCase(STANDARD.toString())) {
093: instance = STANDARD;
094:
095: } else {
096: // Someone has a problem.
097: throw new java.lang.IllegalArgumentException(link);
098: }
099:
100: return (instance);
101: }
102:
103: /** Returns hash code value for this object.
104: * @return hash code value
105: */
106: public int hashCode() {
107: return mLink.hashCode();
108: }
109: }
|