001: /******************************************************************************
002: * JBoss, a division of Red Hat *
003: * Copyright 2006, Red Hat Middleware, LLC, and individual *
004: * contributors as indicated by the @authors tag. See the *
005: * copyright.txt in the distribution for a full listing of *
006: * individual contributors. *
007: * *
008: * This is free software; you can redistribute it and/or modify it *
009: * under the terms of the GNU Lesser General Public License as *
010: * published by the Free Software Foundation; either version 2.1 of *
011: * the License, or (at your option) any later version. *
012: * *
013: * This software is distributed in the hope that it will be useful, *
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
016: * Lesser General Public License for more details. *
017: * *
018: * You should have received a copy of the GNU Lesser General Public *
019: * License along with this software; if not, write to the Free *
020: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
021: * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
022: ******************************************************************************/package org.jboss.portal.wsrp.core;
023:
024: import java.io.Serializable;
025: import java.util.HashMap;
026:
027: public class StateChange implements Serializable {
028: private java.lang.String value;
029: private static java.util.Map valueMap = new HashMap();
030: public static final java.lang.String _readWriteString = "readWrite";
031: public static final java.lang.String _cloneBeforeWriteString = "cloneBeforeWrite";
032: public static final java.lang.String _readOnlyString = "readOnly";
033:
034: public static final java.lang.String _readWrite = new java.lang.String(
035: _readWriteString);
036: public static final java.lang.String _cloneBeforeWrite = new java.lang.String(
037: _cloneBeforeWriteString);
038: public static final java.lang.String _readOnly = new java.lang.String(
039: _readOnlyString);
040:
041: public static final StateChange readWrite = new StateChange(
042: _readWrite);
043: public static final StateChange cloneBeforeWrite = new StateChange(
044: _cloneBeforeWrite);
045: public static final StateChange readOnly = new StateChange(
046: _readOnly);
047:
048: protected StateChange(java.lang.String value) {
049: this .value = value;
050: valueMap.put(this .toString(), this );
051: }
052:
053: public java.lang.String getValue() {
054: return value;
055: }
056:
057: public static StateChange fromValue(java.lang.String value)
058: throws java.lang.IllegalStateException {
059: if (readWrite.value.equals(value)) {
060: return readWrite;
061: } else if (cloneBeforeWrite.value.equals(value)) {
062: return cloneBeforeWrite;
063: } else if (readOnly.value.equals(value)) {
064: return readOnly;
065: }
066: throw new java.lang.IllegalArgumentException();
067: }
068:
069: public static StateChange fromString(java.lang.String value)
070: throws java.lang.IllegalStateException {
071: StateChange ret = (StateChange) valueMap.get(value);
072: if (ret != null) {
073: return ret;
074: }
075: if (value.equals(_readWriteString)) {
076: return readWrite;
077: } else if (value.equals(_cloneBeforeWriteString)) {
078: return cloneBeforeWrite;
079: } else if (value.equals(_readOnlyString)) {
080: return readOnly;
081: }
082: throw new IllegalArgumentException();
083: }
084:
085: public java.lang.String toString() {
086: return value.toString();
087: }
088:
089: private java.lang.Object readResolve()
090: throws java.io.ObjectStreamException {
091: return fromValue(getValue());
092: }
093:
094: public boolean equals(java.lang.Object obj) {
095: if (!(obj instanceof StateChange)) {
096: return false;
097: }
098: return ((StateChange) obj).value.equals(value);
099: }
100:
101: public int hashCode() {
102: return value.hashCode();
103: }
104: }
|