001: /*
002: * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/projects/CmsProjectResourcesDisplayMode.java,v $
003: * Date : $Date: 2008-02-27 12:05:51 $
004: * Version: $Revision: 1.4 $
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.projects;
033:
034: import org.opencms.main.CmsIllegalArgumentException;
035:
036: import java.io.Serializable;
037: import java.util.Arrays;
038: import java.util.Collections;
039: import java.util.Iterator;
040: import java.util.List;
041:
042: /**
043: * Wrapper class for
044: * the different types of project files view.<p>
045: *
046: * The possibles values are:<br>
047: * <ul>
048: * <li>{@link #ALL_CHANGES}</li>
049: * <li>{@link #NEW_FILES}</li>
050: * <li>{@link #DELETED_FILES}</li>
051: * <li>{@link #MODIFIED_FILES}</li>
052: * </ul>
053: * <p>
054: *
055: * @author Michael Moossen
056: *
057: * @version $Revision: 1.4 $
058: *
059: * @since 6.0.0
060: */
061: public final class CmsProjectResourcesDisplayMode implements
062: Serializable {
063:
064: /** Serial version UID required for safe serialization. */
065: private static final long serialVersionUID = 923124162399716633L;
066:
067: /** Constant for the all changes view. */
068: public static final CmsProjectResourcesDisplayMode ALL_CHANGES = new CmsProjectResourcesDisplayMode(
069: "all");
070:
071: /** Constant for the deleted files only view. */
072: public static final CmsProjectResourcesDisplayMode DELETED_FILES = new CmsProjectResourcesDisplayMode(
073: "deleted");
074:
075: /** Constant for the modified files only view. */
076: public static final CmsProjectResourcesDisplayMode MODIFIED_FILES = new CmsProjectResourcesDisplayMode(
077: "changed");
078:
079: /** Constant for the new files only view. */
080: public static final CmsProjectResourcesDisplayMode NEW_FILES = new CmsProjectResourcesDisplayMode(
081: "new");
082:
083: /** Array constant for all available align types. */
084: private static final CmsProjectResourcesDisplayMode[] VALUE_ARRAY = {
085: ALL_CHANGES, NEW_FILES, DELETED_FILES, MODIFIED_FILES };
086:
087: /** List of mode constants. */
088: public static final List VALUES = Collections
089: .unmodifiableList(Arrays.asList(VALUE_ARRAY));
090:
091: /** Internal representation. */
092: private final String m_mode;
093:
094: /**
095: * Private constructor.<p>
096: *
097: * @param mode the view mode
098: */
099: private CmsProjectResourcesDisplayMode(String mode) {
100:
101: m_mode = mode;
102: }
103:
104: /**
105: * Parses an string into an element of this enumeration.<p>
106: *
107: * @param value the mode to parse
108: *
109: * @return the enumeration element
110: *
111: * @throws CmsIllegalArgumentException if the given value could not be matched against a
112: * <code>CmsListColumnAlignEnum</code> type.
113: */
114: public static CmsProjectResourcesDisplayMode valueOf(String value)
115: throws CmsIllegalArgumentException {
116:
117: Iterator iter = VALUES.iterator();
118: while (iter.hasNext()) {
119: CmsProjectResourcesDisplayMode target = (CmsProjectResourcesDisplayMode) iter
120: .next();
121: if (value.equals(target.getMode())) {
122: return target;
123: }
124: }
125: throw new CmsIllegalArgumentException(org.opencms.db.Messages
126: .get().container(
127: org.opencms.db.Messages.ERR_MODE_ENUM_PARSE_2,
128: value,
129: CmsProjectResourcesDisplayMode.class.getName()));
130: }
131:
132: /**
133: * Returns the mode string.<p>
134: *
135: * @return the mode string
136: */
137: public String getMode() {
138:
139: return m_mode;
140: }
141:
142: /**
143: * @see java.lang.Object#toString()
144: */
145: public String toString() {
146:
147: return m_mode;
148: }
149: }
|