KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > workplace > list > CmsListColumnAlignEnum


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/list/CmsListColumnAlignEnum.java,v $
3  * Date : $Date: 2005/06/27 23:22:25 $
4  * Version: $Revision: 1.8 $
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.workplace.list;
33
34 import org.opencms.main.CmsIllegalArgumentException;
35
36 import java.util.Arrays JavaDoc;
37 import java.util.Collections JavaDoc;
38 import java.util.Iterator JavaDoc;
39 import java.util.List JavaDoc;
40
41 /**
42  * Wrapper class for
43  * the different types of table cell horizontal alignments.<p>
44  *
45  * The possibles values are:<br>
46  * <ul>
47  * <li>LeftAlign</li>
48  * <li>CenterAlign</li>
49  * <li>RightAlign</li>
50  * </ul>
51  * <p>
52  *
53  * @author Michael Moossen
54  *
55  * @version $Revision: 1.8 $
56  *
57  * @since 6.0.0
58  */

59 public final class CmsListColumnAlignEnum {
60
61     /** Constant for center alignment . */
62     public static final CmsListColumnAlignEnum ALIGN_CENTER = new CmsListColumnAlignEnum("center");
63
64     /** Constant for left alignment. */
65     public static final CmsListColumnAlignEnum ALIGN_LEFT = new CmsListColumnAlignEnum("left");
66
67     /** Constant for right alignment. */
68     public static final CmsListColumnAlignEnum ALIGN_RIGHT = new CmsListColumnAlignEnum("right");
69
70     /** Array constant for all available align types. */
71     private static final CmsListColumnAlignEnum[] VALUE_ARRAY = {ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT};
72
73     /** List of mode constants. */
74     public static final List JavaDoc VALUES = Collections.unmodifiableList(Arrays.asList(VALUE_ARRAY));
75
76     /** Internal representation. */
77     private final String JavaDoc m_align;
78
79     /**
80      * Private constructor.<p>
81      *
82      * @param align html align value
83      */

84     private CmsListColumnAlignEnum(String JavaDoc align) {
85
86         m_align = align;
87     }
88
89     /**
90      * Parses an string into an element of this enumeration.<p>
91      *
92      * @param value the align to parse
93      *
94      * @return the enumeration element
95      *
96      * @throws CmsIllegalArgumentException if the given value could not be matched against a
97      * <code>CmsListColumnAlignEnum</code> type.
98      */

99     public static CmsListColumnAlignEnum valueOf(String JavaDoc value) throws CmsIllegalArgumentException {
100
101         Iterator JavaDoc iter = VALUES.iterator();
102         while (iter.hasNext()) {
103             CmsListColumnAlignEnum target = (CmsListColumnAlignEnum)iter.next();
104             if (value == target.getAlign()) {
105                 return target;
106             }
107         }
108         throw new CmsIllegalArgumentException(Messages.get().container(
109             Messages.ERR_LIST_ENUM_PARSE_2,
110             new Integer JavaDoc(value),
111             CmsListColumnAlignEnum.class.getName()));
112     }
113
114     /**
115      * Returns the align string.<p>
116      *
117      * @return the align string
118      */

119     public String JavaDoc getAlign() {
120
121         return m_align;
122     }
123
124     /**
125      * @see java.lang.Object#toString()
126      */

127     public String JavaDoc toString() {
128
129         return m_align;
130     }
131 }
Popular Tags