View Javadoc

1   /*
2    * Copyright 2003,2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  /*
17   * This source code implements specifications defined by the Java
18   * Community Process. In order to remain compliant with the specification
19   * DO NOT add / change / or delete method signatures!
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