Author: julien(a)jboss.com
Date: 2007-01-19 10:33:39 -0500 (Fri, 19 Jan 2007)
New Revision: 6049
Modified:
branches/JBoss_Portal_Branch_2_2/api/src/main/javax/portlet/PortletMode.java
branches/JBoss_Portal_Branch_2_2/api/src/main/javax/portlet/WindowState.java
branches/JBoss_Portal_Branch_2_2/server/src/main/org/jboss/portal/Mode.java
branches/JBoss_Portal_Branch_2_2/server/src/main/org/jboss/portal/WindowState.java
Log:
JBPORTAL-1209 : PortletMode and WindowState should use the correct to lower case
conversion
Modified: branches/JBoss_Portal_Branch_2_2/api/src/main/javax/portlet/PortletMode.java
===================================================================
---
branches/JBoss_Portal_Branch_2_2/api/src/main/javax/portlet/PortletMode.java 2007-01-19
15:30:24 UTC (rev 6048)
+++
branches/JBoss_Portal_Branch_2_2/api/src/main/javax/portlet/PortletMode.java 2007-01-19
15:33:39 UTC (rev 6049)
@@ -22,6 +22,8 @@
******************************************************************************/
package javax.portlet;
+import java.util.Locale;
+
/**
* The <CODE>PortletMode</CODE> class represents
* the possible modes that a portlet can assume.
@@ -48,42 +50,37 @@
{
/**
- * Within the <code>EDIT</code> portlet mode, a portlet should provide
- * content and logic that lets a user customize the behavior of the portlet.
- * The EDIT portlet mode may include one or more screens among which
- * users can navigate to enter their customization data.
- * <p>
- * Typically, portlets in <code>EDIT</code> portlet mode will
- * set or update portlet preferences.
- * <P>
+ * Within the <code>EDIT</code> portlet mode, a portlet should provide
content and logic that lets a user customize
+ * the behavior of the portlet. The EDIT portlet mode may include one or more screens
among which users can navigate
+ * to enter their customization data.
+ * <p/>
+ * Typically, portlets in <code>EDIT</code> portlet mode will set or
update portlet preferences.
+ * <p/>
* This mode is optional.
- * <p>
+ * <p/>
* The string value for this mode is <code>"edit"</code>.
*/
public static final PortletMode EDIT = new PortletMode("edit");
/**
- * When in <code>HELP</code> portlet mode, a portlet should provide help
- * information about the portlet. This help information could be
- * a simple help screen explaining the entire portlet in
- * coherent text or it could be context-sensitive help.
- * <P>
+ * When in <code>HELP</code> portlet mode, a portlet should provide help
information about the portlet. This help
+ * information could be a simple help screen explaining the entire portlet in coherent
text or it could be
+ * context-sensitive help.
+ * <p/>
* This mode is optional.
- * <p>
+ * <p/>
* The string value for this mode is <code>"help"</code>.
*/
public static final PortletMode HELP = new PortletMode("help");
/**
- * The expected functionality for a portlet in <code>VIEW</code> portlet
mode
- * is to generate markup reflecting the current state of the portlet.
- * For example, the <code>VIEW</code> portlet mode of a portlet may
- * include one or more screens that the user can navigate and interact
- * with, or it may consist of static content that does not require any
- * user interaction.
- * <P>
+ * The expected functionality for a portlet in <code>VIEW</code> portlet
mode is to generate markup reflecting the
+ * current state of the portlet. For example, the <code>VIEW</code>
portlet mode of a portlet may include one or more
+ * screens that the user can navigate and interact with, or it may consist of static
content that does not require
+ * any user interaction.
+ * <p/>
* This mode must be supported by the portlet.
- * <p>
+ * <p/>
* The string value for this mode is <code>"view"</code>.
*/
public static final PortletMode VIEW = new PortletMode("view");
@@ -92,9 +89,8 @@
/**
* Creates a new portlet mode with the given name.
- * <p>
- * Upper case letters in the name are converted to
- * lower case letters.
+ * <p/>
+ * Upper case letters in the name are converted to lower case letters.
*
* @param name The name of the portlet mode
*/
@@ -104,34 +100,35 @@
{
throw new NullPointerException();
}
- this.name = name.toLowerCase();
+ this.name = name.toLowerCase(Locale.ENGLISH);
}
/**
- * Compares the specified object with this portlet mode
- * for equality. Returns <code>true</code> if the
- * Strings <code>equals</code> method for the String
- * representing the two portlet modes returns <code>true</code>.
+ * Compares the specified object with this portlet mode for equality. Returns
<code>true</code> if the Strings
+ * <code>equals</code> method for the String representing the two portlet
modes returns <code>true</code>.
*
- * @param o portlet mode to compare this portlet mode with
- *
- * @return true, if the specified object is equal with this portlet mode
+ * @param o portlet mode to compare this portlet mode with
+ * @return true, if the specified object is equal with this portlet mode
*/
public boolean equals(Object o)
{
+ if (o == this)
+ {
+ return true;
+ }
if (o instanceof PortletMode)
{
- return o == this || name.equals(((PortletMode)o).name);
+ PortletMode that = (PortletMode)o;
+ return name.equals(that.name);
}
return false;
}
/**
- * Returns the hash code value for this portlet mode.
- * The hash code is constructed by producing the
- * hash value of the String value of this mode.
+ * Returns the hash code value for this portlet mode. The hash code is constructed by
producing the hash value of the
+ * String value of this mode.
*
- * @return hash code value for this portlet mode
+ * @return hash code value for this portlet mode
*/
public int hashCode()
{
@@ -139,14 +136,12 @@
}
/**
- * Returns a String representation of this portlet mode.
- * Portlet mode names are always lower case names.
+ * Returns a String representation of this portlet mode. Portlet mode names are always
lower case names.
*
- * @return String representation of this portlet mode
+ * @return String representation of this portlet mode
*/
public String toString()
{
return name;
}
-
}
Modified: branches/JBoss_Portal_Branch_2_2/api/src/main/javax/portlet/WindowState.java
===================================================================
---
branches/JBoss_Portal_Branch_2_2/api/src/main/javax/portlet/WindowState.java 2007-01-19
15:30:24 UTC (rev 6048)
+++
branches/JBoss_Portal_Branch_2_2/api/src/main/javax/portlet/WindowState.java 2007-01-19
15:33:39 UTC (rev 6049)
@@ -22,6 +22,8 @@
******************************************************************************/
package javax.portlet;
+import java.util.Locale;
+
/**
* The <CODE>WindowState</CODE> class represents
* the possible window states that a portlet window can assume.
@@ -39,31 +41,27 @@
{
/**
- * The <code>NORMAL</code> window state indicates that a portlet
- * may be sharing the page with other portlets. It may also
- * indicate that the target device has limited display capabilities.
- * Therefore, a portlet should restrict the size of its rendered
- * output in this window state.
- * <p>
+ * The <code>NORMAL</code> window state indicates that a portlet may be
sharing the page with other portlets. It may
+ * also indicate that the target device has limited display capabilities. Therefore, a
portlet should restrict the
+ * size of its rendered output in this window state.
+ * <p/>
* The string value for this state is <code>"normal"</code>.
*/
public static final WindowState NORMAL = new WindowState("normal");
/**
- * When a portlet is in <code>MINIMIZED</code> window state,
- * the portlet should only render minimal output or no output at all.
- * <p>
+ * When a portlet is in <code>MINIMIZED</code> window state, the portlet
should only render minimal output or no
+ * output at all.
+ * <p/>
* The string value for this state is <code>"minimized"</code>.
*/
public static final WindowState MINIMIZED = new WindowState("minimized");
/**
- * The <code>MAXIMIZED</code> window state is an indication
- * that a portlet may be the only portlet being rendered in the
- * portal page, or that the portlet has more space compared to other portlets
- * in the portal page. A portlet may generate richer content
- * when its window state is <code>MAXIMIZED</code>.
- * <p>
+ * The <code>MAXIMIZED</code> window state is an indication that a portlet
may be the only portlet being rendered in
+ * the portal page, or that the portlet has more space compared to other portlets in
the portal page. A portlet may
+ * generate richer content when its window state is
<code>MAXIMIZED</code>.
+ * <p/>
* The string value for this state is <code>"maximized"</code>.
*/
public static final WindowState MAXIMIZED = new WindowState("maximized");
@@ -72,9 +70,8 @@
/**
* Creates a new window state with the given name.
- * <p>
- * Upper case letters in the name are converted to
- * lower case letters.
+ * <p/>
+ * Upper case letters in the name are converted to lower case letters.
*
* @param name The name of the portlet mode
*/
@@ -84,34 +81,35 @@
{
throw new NullPointerException();
}
- this.name = name.toLowerCase();
+ this.name = name.toLowerCase(Locale.ENGLISH);
}
/**
- * Compares the specified object with this window state
- * for equality. Returns <code>true</code> if the
- * Strings <code>equals</code> method for the String
- * representing the two window states returns <code>true</code>.
+ * Compares the specified object with this window state for equality. Returns
<code>true</code> if the Strings
+ * <code>equals</code> method for the String representing the two window
states returns <code>true</code>.
*
- * @param the window state to compare this window state with.
- *
- * @return true, if the specified object is equal with this window state.
+ * @param o the window state to compare this window state with.
+ * @return true, if the specified object is equal with this window state.
*/
public boolean equals(Object o)
{
+ if (o == this)
+ {
+ return true;
+ }
if (o instanceof WindowState)
{
- return o == this || name.equals(((WindowState)o).name);
+ WindowState that = (WindowState)o;
+ return name.equals(that.name);
}
return false;
}
/**
- * Returns the hash code value for this window state.
- * The hash code is constructed by producing the
- * hash value of the String value of this window state.
+ * Returns the hash code value for this window state. The hash code is constructed by
producing the hash value of the
+ * String value of this window state.
*
- * @return hash code value for this window state
+ * @return hash code value for this window state
*/
public int hashCode()
{
@@ -119,14 +117,12 @@
}
/**
- * Returns a String representation of this window state.
- * Window state names are always lower case names.
+ * Returns a String representation of this window state. Window state names are always
lower case names.
*
- * @return String representation of this window state.
+ * @return String representation of this window state.
*/
public String toString()
{
return name;
}
-
}
Modified: branches/JBoss_Portal_Branch_2_2/server/src/main/org/jboss/portal/Mode.java
===================================================================
--- branches/JBoss_Portal_Branch_2_2/server/src/main/org/jboss/portal/Mode.java 2007-01-19
15:30:24 UTC (rev 6048)
+++ branches/JBoss_Portal_Branch_2_2/server/src/main/org/jboss/portal/Mode.java 2007-01-19
15:33:39 UTC (rev 6049)
@@ -23,6 +23,7 @@
package org.jboss.portal;
import java.io.Serializable;
+import java.util.Locale;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -31,26 +32,43 @@
public class Mode implements Serializable
{
+ /** The serialVersionUID. */
+ private static final long serialVersionUID = 6033765240710422050L;
+
+ /** . */
public static final Mode EDIT = new Mode("edit");
+
+ /** . */
public static final Mode HELP = new Mode("help");
+
+ /** . */
public static final Mode VIEW = new Mode("view");
+ /** . */
+ public static final Mode EDIT_DEFAULTS = new Mode("edit_defaults");
+
+ /** . */
private String name;
public Mode(String name)
{
if (name == null)
{
- throw new NullPointerException();
+ throw new IllegalArgumentException("Mode cannot be null");
}
- this.name = name.toLowerCase();
+ this.name = name.toLowerCase(Locale.ENGLISH);
}
public boolean equals(Object o)
{
+ if (o == this)
+ {
+ return true;
+ }
if (o instanceof Mode)
{
- return o == this || name.equals(((Mode)o).name);
+ Mode that = (Mode)o;
+ return name.equals(that.name);
}
return false;
}
@@ -79,6 +97,10 @@
{
return HELP;
}
+ else if (EDIT_DEFAULTS.name.equals(name))
+ {
+ return EDIT_DEFAULTS;
+ }
else
{
return this;
@@ -87,15 +109,19 @@
public static Mode create(String s)
{
- if (Mode.EDIT.toString().equalsIgnoreCase(s))
+ if (Mode.VIEW.name.equals(s))
{
+ return Mode.VIEW;
+ }
+ else if (Mode.EDIT.name.equals(s))
+ {
return Mode.EDIT;
}
- else if (Mode.HELP.toString().equalsIgnoreCase(s))
+ else if (Mode.HELP.name.equals(s))
{
return Mode.HELP;
}
- else if (Mode.VIEW.toString().equalsIgnoreCase(s))
+ else if (Mode.EDIT_DEFAULTS.name.equals(s))
{
return Mode.VIEW;
}
Modified:
branches/JBoss_Portal_Branch_2_2/server/src/main/org/jboss/portal/WindowState.java
===================================================================
---
branches/JBoss_Portal_Branch_2_2/server/src/main/org/jboss/portal/WindowState.java 2007-01-19
15:30:24 UTC (rev 6048)
+++
branches/JBoss_Portal_Branch_2_2/server/src/main/org/jboss/portal/WindowState.java 2007-01-19
15:33:39 UTC (rev 6049)
@@ -23,6 +23,7 @@
package org.jboss.portal;
import java.io.Serializable;
+import java.util.Locale;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -31,26 +32,40 @@
public class WindowState implements Serializable
{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -6305311518934458562L;
+
+ /** . */
public static final WindowState NORMAL = new WindowState("normal");
+
+ /** . */
public static final WindowState MINIMIZED = new WindowState("minimized");
+
+ /** . */
public static final WindowState MAXIMIZED = new WindowState("maximized");
+ /** . */
private String name;
public WindowState(String name)
{
if (name == null)
{
- throw new NullPointerException();
+ throw new IllegalArgumentException("Window state name cannot be
null");
}
- this.name = name.toLowerCase();
+ this.name = name.toLowerCase(Locale.ENGLISH);
}
public boolean equals(Object o)
{
+ if (o == this)
+ {
+ return true;
+ }
if (o instanceof WindowState)
{
- return o == this || name.equals(((WindowState)o).name);
+ WindowState that = (WindowState)o;
+ return name.equals(that.name);
}
return false;
}
@@ -87,15 +102,15 @@
public static WindowState create(String s)
{
- if (WindowState.NORMAL.toString().equalsIgnoreCase(s))
+ if (WindowState.NORMAL.name.equals(s))
{
return WindowState.NORMAL;
}
- else if (WindowState.MINIMIZED.toString().equalsIgnoreCase(s))
+ else if (WindowState.MINIMIZED.name.equals(s))
{
return WindowState.MINIMIZED;
}
- else if (WindowState.MAXIMIZED.toString().equalsIgnoreCase(s))
+ else if (WindowState.MAXIMIZED.name.equals(s))
{
return WindowState.MAXIMIZED;
}