KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > portlet > WindowState


1 /**
2   * Copyright 2003 IBM Corporation and Sun Microsystems, Inc.
3   * All rights reserved.
4   * Use is subject to license terms.
5   */

6
7 package javax.portlet;
8
9
10 /**
11  * The <CODE>WindowState</CODE> class represents
12  * the possible window states that a portlet window can assume.
13  * <P>
14  * This class defines a standard set of the most basic portlet window states.
15  * Additional window states may be defined by calling the constructor of
16  * this class. If a portal/portlet-container does not support a
17  * custom window state defined in the portlet application deployment descriptor,
18  * the custom window state will be ignored by the portal/portlet container.
19  */

20
21 public class WindowState
22 {
23
24   /**
25    * The <code>NORMAL</code> window state indicates that a portlet
26    * may be sharing the page with other portlets. It may also
27    * indicate that the target device has limited display capabilities.
28    * Therefore, a portlet should restrict the size of its rendered
29    * output in this window state.
30    * <p>
31    * The string value for this state is <code>"normal"</code>.
32    */

33   public final static WindowState NORMAL = new WindowState ("normal");
34
35   /**
36    * The <code>MAXIMIZED</code> window state is an indication
37    * that a portlet may be the only portlet being rendered in the
38    * portal page, or that the portlet has more space compared to other portlets
39    * in the portal page. A portlet may generate richer content
40    * when its window state is <code>MAXIMIZED</code>.
41    * <p>
42    * The string value for this state is <code>"maximized"</code>.
43    */

44   public final static WindowState MAXIMIZED = new WindowState ("maximized");
45   
46   /**
47    * When a portlet is in <code>MINIMIZED</code> window state,
48    * the portlet should only render minimal output or no output at all.
49    * <p>
50    * The string value for this state is <code>"minimized"</code>.
51    */

52   public final static WindowState MINIMIZED = new WindowState ("minimized");
53
54
55
56   private String JavaDoc _name;
57
58
59   /**
60    * Creates a new window state with the given name.
61    * <p>
62    * Upper case letters in the name are converted to
63    * lower case letters.
64    *
65    * @param name The name of the portlet mode
66    */

67   public WindowState(String JavaDoc name) {
68     if (name==null) {
69       throw new IllegalArgumentException JavaDoc("WindowState name can not be NULL");
70     }
71     _name = name.toLowerCase();
72   }
73
74   /**
75    * Returns a String representation of this window state.
76    * Window state names are always lower case names.
77    *
78    * @return String representation of this window state.
79    */

80
81   public String JavaDoc toString() {
82     return _name;
83   }
84
85
86   /**
87    * Returns the hash code value for this window state.
88    * The hash code is constructed by producing the
89    * hash value of the String value of this window state.
90    *
91    * @return hash code value for this window state
92    */

93
94   public int hashCode() {
95     return _name.hashCode();
96   }
97
98
99   /**
100    * Compares the specified object with this window state
101    * for equality. Returns <code>true</code> if the
102    * Strings <code>equals</code> method for the String
103    * representing the two window states returns <code>true</code>.
104    *
105    * @param the window state to compare this window state with.
106    *
107    * @return true, if the specified object is equal with this window state.
108    */

109
110   public boolean equals(Object JavaDoc object) {
111     if ( object instanceof WindowState )
112       return _name.equals(((WindowState) object)._name);
113     else
114       return false;
115   }
116 }
117
118
Popular Tags