KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > server > plugins > windowstate > WindowState


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.plugins.windowstate;
10
11 import java.io.Serializable JavaDoc;
12
13 /**
14  * The window state similar to javax.portlet.WindowState
15  *
16  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
17  * @version $Revision: 1.1.1.1 $
18  */

19 public class WindowState implements Serializable JavaDoc
20 {
21
22    public static final WindowState NORMAL = new WindowState("normal");
23    public static final WindowState MINIMIZED = new WindowState("minimized");
24    public static final WindowState MAXIMIZED = new WindowState("maximized");
25
26    private String JavaDoc name;
27
28    public WindowState(String JavaDoc name)
29    {
30       if (name == null)
31       {
32          throw new NullPointerException JavaDoc();
33       }
34       this.name = name.toLowerCase();
35    }
36
37    public boolean equals(Object JavaDoc o)
38    {
39       if (o instanceof WindowState)
40       {
41          return o == this || name.equals(((WindowState)o).name);
42       }
43       return false;
44    }
45
46    public int hashCode()
47    {
48       return name.hashCode();
49    }
50
51    public String JavaDoc toString()
52    {
53       return name;
54    }
55
56    private Object JavaDoc readResolve()
57    {
58       if (NORMAL.name.equals(name))
59       {
60          return NORMAL;
61       }
62       else if (MAXIMIZED.name.equals(name))
63       {
64          return MAXIMIZED;
65       }
66       else if (MINIMIZED.name.equals(name))
67       {
68          return MINIMIZED;
69       }
70       else
71       {
72          return this;
73       }
74    }
75
76    public static WindowState create(String JavaDoc s)
77    {
78       if (WindowState.NORMAL.toString().equals(s))
79       {
80          return WindowState.NORMAL;
81       }
82       else if (WindowState.MINIMIZED.toString().equals(s))
83       {
84          return WindowState.MINIMIZED;
85       }
86       else if (WindowState.MAXIMIZED.toString().equals(s))
87       {
88          return WindowState.MAXIMIZED;
89       }
90       else
91       {
92          return new WindowState(s);
93       }
94    }
95 }
96
Popular Tags