001: /*
002: * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/accounts/CmsDependencyIconActionType.java,v $
003: * Date : $Date: 2008-02-27 12:05:26 $
004: * Version: $Revision: 1.6 $
005: *
006: * This library is part of OpenCms -
007: * the Open Source Content Management System
008: *
009: * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
010: *
011: * This library is free software; you can redistribute it and/or
012: * modify it under the terms of the GNU Lesser General Public
013: * License as published by the Free Software Foundation; either
014: * version 2.1 of the License, or (at your option) any later version.
015: *
016: * This library is distributed in the hope that it will be useful,
017: * but WITHOUT ANY WARRANTY; without even the implied warranty of
018: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: * Lesser General Public License for more details.
020: *
021: * For further information about Alkacon Software GmbH, please see the
022: * company website: http://www.alkacon.com
023: *
024: * For further information about OpenCms, please see the
025: * project website: http://www.opencms.org
026: *
027: * You should have received a copy of the GNU Lesser General Public
028: * License along with this library; if not, write to the Free Software
029: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
030: */
031:
032: package org.opencms.workplace.tools.accounts;
033:
034: import org.opencms.main.CmsIllegalArgumentException;
035:
036: import java.util.Arrays;
037: import java.util.Collections;
038: import java.util.Iterator;
039: import java.util.List;
040:
041: /**
042: * Wrapper class for
043: * the different types of icon actions the dependency lists.<p>
044: *
045: * The possibles values are:<br>
046: * <ul>
047: * <li>{@link #RESOURCE}</li>
048: * <li>{@link #GROUP}</li>
049: * <li>{@link #USER}</li>
050: * </ul>
051: * <p>
052: *
053: * @author Michael Moossen
054: *
055: * @version $Revision: 1.6 $
056: *
057: * @since 6.0.0
058: */
059: public final class CmsDependencyIconActionType {
060:
061: /** Constant for the resource icon action. */
062: public static final CmsDependencyIconActionType RESOURCE = new CmsDependencyIconActionType(
063: "r");
064:
065: /** Constant for the group icon action. */
066: public static final CmsDependencyIconActionType GROUP = new CmsDependencyIconActionType(
067: "g");
068:
069: /** Constant for the user icon action. */
070: public static final CmsDependencyIconActionType USER = new CmsDependencyIconActionType(
071: "u");
072:
073: /** Array constant for all available align types. */
074: private static final CmsDependencyIconActionType[] VALUE_ARRAY = {
075: RESOURCE, GROUP, USER };
076:
077: /** List of mode constants. */
078: public static final List VALUES = Collections
079: .unmodifiableList(Arrays.asList(VALUE_ARRAY));
080:
081: /** Internal representation. */
082: private final String m_mode;
083:
084: /**
085: * Private constructor.<p>
086: *
087: * @param mode the view mode
088: */
089: private CmsDependencyIconActionType(String mode) {
090:
091: m_mode = mode;
092: }
093:
094: /**
095: * Parses an string into an element of this enumeration.<p>
096: *
097: * @param value the id to parse
098: *
099: * @return the enumeration element
100: *
101: * @throws CmsIllegalArgumentException if the given value could not be matched against a
102: * <code>{@link CmsDependencyIconActionType}</code> type.
103: */
104: public static CmsDependencyIconActionType valueOf(String value)
105: throws CmsIllegalArgumentException {
106:
107: Iterator iter = VALUES.iterator();
108: while (iter.hasNext()) {
109: CmsDependencyIconActionType target = (CmsDependencyIconActionType) iter
110: .next();
111: if (value.equals(target.getId())) {
112: return target;
113: }
114: }
115: throw new CmsIllegalArgumentException(org.opencms.db.Messages
116: .get().container(
117: org.opencms.db.Messages.ERR_MODE_ENUM_PARSE_2,
118: value,
119: CmsDependencyIconActionType.class.getName()));
120: }
121:
122: /**
123: * Returns the id string.<p>
124: *
125: * @return the id string
126: */
127: public String getId() {
128:
129: return m_mode;
130: }
131:
132: /**
133: * @see java.lang.Object#toString()
134: */
135: public String toString() {
136:
137: return m_mode;
138: }
139: }
|