001: /**
002: * Copyright 2003 IBM Corporation and Sun Microsystems, Inc.
003: * All rights reserved.
004: * Use is subject to license terms.
005: */package javax.portlet;
006:
007: /**
008: * The <CODE>WindowState</CODE> class represents
009: * the possible window states that a portlet window can assume.
010: * <P>
011: * This class defines a standard set of the most basic portlet window states.
012: * Additional window states may be defined by calling the constructor of
013: * this class. If a portal/portlet-container does not support a
014: * custom window state defined in the portlet application deployment descriptor,
015: * the custom window state will be ignored by the portal/portlet container.
016: */
017:
018: public class WindowState {
019:
020: /**
021: * The <code>NORMAL</code> window state indicates that a portlet
022: * may be sharing the page with other portlets. It may also
023: * indicate that the target device has limited display capabilities.
024: * Therefore, a portlet should restrict the size of its rendered
025: * output in this window state.
026: * <p/>
027: * The string value for this state is <code>"normal"</code>.
028: */
029: public final static WindowState NORMAL = new WindowState("normal");
030:
031: /**
032: * The <code>MAXIMIZED</code> window state is an indication
033: * that a portlet may be the only portlet being rendered in the
034: * portal page, or that the portlet has more space compared to other portlets
035: * in the portal page. A portlet may generate richer content
036: * when its window state is <code>MAXIMIZED</code>.
037: * <p/>
038: * The string value for this state is <code>"maximized"</code>.
039: */
040: public final static WindowState MAXIMIZED = new WindowState(
041: "maximized");
042:
043: /**
044: * When a portlet is in <code>MINIMIZED</code> window state,
045: * the portlet should only render minimal output or no output at all.
046: * <p/>
047: * The string value for this state is <code>"minimized"</code>.
048: */
049: public final static WindowState MINIMIZED = new WindowState(
050: "minimized");
051:
052: private String _name;
053:
054: /**
055: * Creates a new window state with the given name.
056: * <p/>
057: * Upper case letters in the name are converted to
058: * lower case letters.
059: *
060: * @param name The name of the portlet mode
061: */
062: public WindowState(String name) {
063: if (name == null) {
064: throw new IllegalArgumentException(
065: "WindowState name can not be NULL");
066: }
067: _name = name.toLowerCase();
068: }
069:
070: /**
071: * Returns a String representation of this window state.
072: * Window state names are always lower case names.
073: *
074: * @return String representation of this window state.
075: */
076:
077: public String toString() {
078: return _name;
079: }
080:
081: /**
082: * Returns the hash code value for this window state.
083: * The hash code is constructed by producing the
084: * hash value of the String value of this window state.
085: *
086: * @return hash code value for this window state
087: */
088:
089: public int hashCode() {
090: return _name.hashCode();
091: }
092:
093: /**
094: * Compares the specified object with this window state
095: * for equality. Returns <code>true</code> if the
096: * Strings <code>equals</code> method for the String
097: * representing the two window states returns <code>true</code>.
098: *
099: * @param object window state to compare this window state with.
100: * @return true, if the specified object is equal with this window state.
101: */
102:
103: public boolean equals(Object object) {
104: if (object instanceof WindowState)
105: return _name.equals(((WindowState) object)._name);
106: else
107: return false;
108: }
109: }
|