KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > server > theme > RegionOrientation


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

9 package org.jboss.portal.server.theme;
10
11 /**
12  * Type save enumeration of allowed region orientations.
13  *
14  * @author <a HREF="mailto:mholzner@novell.com>Martin Holzner</a>
15  * @version $LastChangedRevision$, $LastChangedDate$
16  * @see org.jboss.portal.server.theme.Region
17  */

18 public final class RegionOrientation
19 {
20    /**
21     * Place portlets in one region in vertical order.
22     */

23    public static final RegionOrientation VERTICAL = new RegionOrientation("vertical");
24
25    /**
26     * Place portlets in one region in horizontal order.
27     */

28    public static final RegionOrientation HORIZONTAL = new RegionOrientation("horizontal");
29
30    private final String JavaDoc m_orient;
31
32    private RegionOrientation()
33    {
34       this("vertical");
35    }
36
37    private RegionOrientation(String JavaDoc orient)
38    {
39       m_orient = orient;
40    }
41
42    public String JavaDoc toString()
43    {
44       return m_orient;
45    }
46
47    public boolean equals(Object JavaDoc o)
48    {
49       if (this == o)
50       {
51          return true;
52       }
53       if (!(o instanceof RegionOrientation))
54       {
55          return false;
56       }
57
58       final RegionOrientation orientation = (RegionOrientation)o;
59
60       if (m_orient != null ? !m_orient.equals(orientation.m_orient) : orientation.m_orient != null)
61       {
62          return false;
63       }
64
65       return true;
66    }
67
68    public int hashCode()
69    {
70       return (m_orient != null ? m_orient.hashCode() : 0);
71    }
72
73    /**
74     * parse a string representation of a region orientation into a defined type.
75     *
76     * @param orientation the string representation of the orientation
77     * @return the defined type for the string
78     * @throws IllegalArgumentException if the provided orientation String is invalid
79     */

80    public static RegionOrientation parseOrientation(String JavaDoc orientation)
81    {
82       if (orientation != null)
83       {
84          if (orientation.equalsIgnoreCase(VERTICAL.toString()))
85          {
86             return VERTICAL;
87          }
88          if (orientation.equalsIgnoreCase(HORIZONTAL.toString()))
89          {
90             return HORIZONTAL;
91          }
92       }
93
94       throw new IllegalArgumentException JavaDoc("invalid orientation: " + orientation);
95    }
96 }
97
Popular Tags