1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package javax.portlet;
22
23
24 /***
25 * The <CODE>WindowState</CODE> class represents
26 * the possible window states that a portlet window can assume.
27 * <P>
28 * This class defines a standard set of the most basic portlet window states.
29 * Additional window states may be defined by calling the constructor of
30 * this class. If a portal/portlet-container does not support a
31 * custom window state defined in the portlet application deployment descriptor,
32 * the custom window state will be ignored by the portal/portlet container.
33 */
34
35 public class WindowState
36 {
37
38
39 /***
40 * The <code>NORMAL</code> window state indicates that a portlet
41 * may be sharing the page with other portlets. It may also
42 * indicate that the target device has limited display capabilities.
43 * Therefore, a portlet should restrict the size of its rendered
44 * output in this window state.
45 * <p>
46 * The string value for this state is <code>"normal"</code>.
47 */
48 public final static WindowState NORMAL = new WindowState ("normal");
49
50 /***
51 * The <code>MAXIMIZED</code> window state is an indication
52 * that a portlet may be the only portlet being rendered in the
53 * portal page, or that the portlet has more space compared to other portlets
54 * in the portal page. A portlet may generate richer content
55 * when its window state is <code>MAXIMIZED</code>.
56 * <p>
57 * The string value for this state is <code>"maximized"</code>.
58 */
59 public final static WindowState MAXIMIZED = new WindowState ("maximized");
60
61 /***
62 * When a portlet is in <code>MINIMIZED</code> window state,
63 * the portlet should only render minimal output or no output at all.
64 * <p>
65 * The string value for this state is <code>"minimized"</code>.
66 */
67 public final static WindowState MINIMIZED = new WindowState ("minimized");
68
69
70
71 private String _name;
72
73
74 /***
75 * Creates a new window state with the given name.
76 * <p>
77 * Upper case letters in the name are converted to
78 * lower case letters.
79 *
80 * @param name The name of the portlet mode
81 */
82 public WindowState(String name) {
83 if (name==null) {
84 throw new IllegalArgumentException("WindowState name can not be NULL");
85 }
86 _name = name.toLowerCase();
87 }
88
89 /***
90 * Returns a String representation of this window state.
91 * Window state names are always lower case names.
92 *
93 * @return String representation of this window state.
94 */
95
96 public String toString() {
97 return _name;
98 }
99
100
101 /***
102 * Returns the hash code value for this window state.
103 * The hash code is constructed by producing the
104 * hash value of the String value of this window state.
105 *
106 * @return hash code value for this window state
107 */
108
109 public int hashCode() {
110 return _name.hashCode();
111 }
112
113
114 /***
115 * Compares the specified object with this window state
116 * for equality. Returns <code>true</code> if the
117 * Strings <code>equals</code> method for the String
118 * representing the two window states returns <code>true</code>.
119 *
120 * @param the window state to compare this window state with.
121 *
122 * @return true, if the specified object is equal with this window state.
123 */
124
125 public boolean equals(Object object) {
126 if ( object instanceof WindowState )
127 return _name.equals(((WindowState) object)._name);
128 else
129 return false;
130 }
131 }
132