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 CookieProtocol implements Serializable {
028: private java.lang.String value;
029: private static java.util.Map valueMap = new HashMap();
030: public static final java.lang.String _noneString = "none";
031: public static final java.lang.String _perUserString = "perUser";
032: public static final java.lang.String _perGroupString = "perGroup";
033:
034: public static final java.lang.String _none = new java.lang.String(
035: _noneString);
036: public static final java.lang.String _perUser = new java.lang.String(
037: _perUserString);
038: public static final java.lang.String _perGroup = new java.lang.String(
039: _perGroupString);
040:
041: public static final CookieProtocol none = new CookieProtocol(_none);
042: public static final CookieProtocol perUser = new CookieProtocol(
043: _perUser);
044: public static final CookieProtocol perGroup = new CookieProtocol(
045: _perGroup);
046:
047: protected CookieProtocol(java.lang.String value) {
048: this .value = value;
049: valueMap.put(this .toString(), this );
050: }
051:
052: public java.lang.String getValue() {
053: return value;
054: }
055:
056: public static CookieProtocol fromValue(java.lang.String value)
057: throws java.lang.IllegalStateException {
058: if (none.value.equals(value)) {
059: return none;
060: } else if (perUser.value.equals(value)) {
061: return perUser;
062: } else if (perGroup.value.equals(value)) {
063: return perGroup;
064: }
065: throw new java.lang.IllegalArgumentException();
066: }
067:
068: public static CookieProtocol fromString(java.lang.String value)
069: throws java.lang.IllegalStateException {
070: CookieProtocol ret = (CookieProtocol) valueMap.get(value);
071: if (ret != null) {
072: return ret;
073: }
074: if (value.equals(_noneString)) {
075: return none;
076: } else if (value.equals(_perUserString)) {
077: return perUser;
078: } else if (value.equals(_perGroupString)) {
079: return perGroup;
080: }
081: throw new IllegalArgumentException();
082: }
083:
084: public java.lang.String toString() {
085: return value.toString();
086: }
087:
088: private java.lang.Object readResolve()
089: throws java.io.ObjectStreamException {
090: return fromValue(getValue());
091: }
092:
093: public boolean equals(java.lang.Object obj) {
094: if (!(obj instanceof CookieProtocol)) {
095: return false;
096: }
097: return ((CookieProtocol) obj).value.equals(value);
098: }
099:
100: public int hashCode() {
101: return value.hashCode();
102: }
103: }
|