KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > db > CmsProjectResourcesDisplayMode


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/db/CmsProjectResourcesDisplayMode.java,v $
3  * Date : $Date: 2006/03/27 14:52:27 $
4  * Version: $Revision: 1.10 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.db;
33
34 import org.opencms.main.CmsIllegalArgumentException;
35
36 import java.io.Serializable JavaDoc;
37 import java.util.Arrays JavaDoc;
38 import java.util.Collections JavaDoc;
39 import java.util.Iterator JavaDoc;
40 import java.util.List JavaDoc;
41
42 /**
43  * Wrapper class for
44  * the different types of project files view.<p>
45  *
46  * The possibles values are:<br>
47  * <ul>
48  * <li>{@link #ALL_CHANGES}</li>
49  * <li>{@link #NEW_FILES}</li>
50  * <li>{@link #DELETED_FILES}</li>
51  * <li>{@link #MODIFIED_FILES}</li>
52  * </ul>
53  * <p>
54  *
55  * @author Michael Moossen
56  *
57  * @version $Revision: 1.10 $
58  *
59  * @since 6.0.0
60  */

61 public final class CmsProjectResourcesDisplayMode implements Serializable JavaDoc {
62
63     /** Serial version UID required for safe serialization. */
64     private static final long serialVersionUID = 923124162399716633L;
65
66     /** Constant for the all changes view. */
67     public static final CmsProjectResourcesDisplayMode ALL_CHANGES = new CmsProjectResourcesDisplayMode("all");
68
69     /** Constant for the deleted files only view. */
70     public static final CmsProjectResourcesDisplayMode DELETED_FILES = new CmsProjectResourcesDisplayMode("deleted");
71
72     /** Constant for the modified files only view. */
73     public static final CmsProjectResourcesDisplayMode MODIFIED_FILES = new CmsProjectResourcesDisplayMode("changed");
74
75     /** Constant for the new files only view. */
76     public static final CmsProjectResourcesDisplayMode NEW_FILES = new CmsProjectResourcesDisplayMode("new");
77
78     /** Array constant for all available align types. */
79     private static final CmsProjectResourcesDisplayMode[] VALUE_ARRAY = {
80         ALL_CHANGES,
81         NEW_FILES,
82         DELETED_FILES,
83         MODIFIED_FILES};
84
85     /** List of mode constants. */
86     public static final List JavaDoc VALUES = Collections.unmodifiableList(Arrays.asList(VALUE_ARRAY));
87
88     /** Internal representation. */
89     private final String JavaDoc m_mode;
90
91     /**
92      * Private constructor.<p>
93      *
94      * @param mode the view mode
95      */

96     private CmsProjectResourcesDisplayMode(String JavaDoc mode) {
97
98         m_mode = mode;
99     }
100
101     /**
102      * Parses an string into an element of this enumeration.<p>
103      *
104      * @param value the mode to parse
105      *
106      * @return the enumeration element
107      *
108      * @throws CmsIllegalArgumentException if the given value could not be matched against a
109      * <code>CmsListColumnAlignEnum</code> type.
110      */

111     public static CmsProjectResourcesDisplayMode valueOf(String JavaDoc value) throws CmsIllegalArgumentException {
112
113         Iterator JavaDoc iter = VALUES.iterator();
114         while (iter.hasNext()) {
115             CmsProjectResourcesDisplayMode target = (CmsProjectResourcesDisplayMode)iter.next();
116             if (value.equals(target.getMode())) {
117                 return target;
118             }
119         }
120         throw new CmsIllegalArgumentException(Messages.get().container(
121             Messages.ERR_MODE_ENUM_PARSE_2,
122             value,
123             CmsProjectResourcesDisplayMode.class.getName()));
124     }
125
126     /**
127      * Returns the mode string.<p>
128      *
129      * @return the mode string
130      */

131     public String JavaDoc getMode() {
132
133         return m_mode;
134     }
135
136     /**
137      * @see java.lang.Object#toString()
138      */

139     public String JavaDoc toString() {
140
141         return m_mode;
142     }
143 }
Popular Tags