Author: julien(a)jboss.com
Date: 2007-01-19 10:26:43 -0500 (Fri, 19 Jan 2007)
New Revision: 6047
Modified:
trunk/api/src/main/javax/portlet/PortletMode.java
trunk/api/src/main/javax/portlet/WindowState.java
trunk/api/src/main/org/jboss/portal/Mode.java
trunk/api/src/main/org/jboss/portal/WindowState.java
Log:
JBPORTAL-1209 : PortletMode and WindowState should use the correct to lower case
conversion
Modified: trunk/api/src/main/javax/portlet/PortletMode.java
===================================================================
--- trunk/api/src/main/javax/portlet/PortletMode.java 2007-01-19 06:34:20 UTC (rev 6046)
+++ trunk/api/src/main/javax/portlet/PortletMode.java 2007-01-19 15:26:43 UTC (rev 6047)
@@ -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.
* <p/>
@@ -93,7 +95,7 @@
{
throw new NullPointerException();
}
- this.name = name.toLowerCase();
+ this.name = name.toLowerCase(Locale.ENGLISH);
}
/**
@@ -105,9 +107,14 @@
*/
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;
}
@@ -132,5 +139,4 @@
{
return name;
}
-
}
Modified: trunk/api/src/main/javax/portlet/WindowState.java
===================================================================
--- trunk/api/src/main/javax/portlet/WindowState.java 2007-01-19 06:34:20 UTC (rev 6046)
+++ trunk/api/src/main/javax/portlet/WindowState.java 2007-01-19 15:26:43 UTC (rev 6047)
@@ -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.
* <p/>
@@ -77,21 +79,26 @@
{
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>.
*
- * @param the window state to compare this window state with.
+ * @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;
}
@@ -116,5 +123,4 @@
{
return name;
}
-
}
Modified: trunk/api/src/main/org/jboss/portal/Mode.java
===================================================================
--- trunk/api/src/main/org/jboss/portal/Mode.java 2007-01-19 06:34:20 UTC (rev 6046)
+++ trunk/api/src/main/org/jboss/portal/Mode.java 2007-01-19 15:26:43 UTC (rev 6047)
@@ -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>
@@ -53,16 +54,21 @@
{
if (name == null)
{
- throw new NullPointerException();
+ throw new IllegalArgumentException("Mode cannot be null");
}
- this.name = name;
+ this.name = name.toLowerCase(Locale.ENGLISH);
}
public boolean equals(Object o)
{
+ if (o == this)
+ {
+ return true;
+ }
if (o instanceof Mode)
{
- return o == this || name.equalsIgnoreCase(((Mode)o).name);
+ Mode that = (Mode)o;
+ return name.equals(that.name);
}
return false;
}
@@ -79,19 +85,19 @@
private Object readResolve()
{
- if (VIEW.name.equalsIgnoreCase(name))
+ if (VIEW.name.equals(name))
{
return VIEW;
}
- else if (EDIT.name.equalsIgnoreCase(name))
+ else if (EDIT.name.equals(name))
{
return EDIT;
}
- else if (HELP.name.equalsIgnoreCase(name))
+ else if (HELP.name.equals(name))
{
return HELP;
}
- else if (EDIT_DEFAULTS.name.equalsIgnoreCase(name))
+ else if (EDIT_DEFAULTS.name.equals(name))
{
return EDIT_DEFAULTS;
}
@@ -103,19 +109,19 @@
public static Mode create(String s)
{
- if (Mode.VIEW.name.equalsIgnoreCase(s))
+ if (Mode.VIEW.name.equals(s))
{
return Mode.VIEW;
}
- else if (Mode.EDIT.name.equalsIgnoreCase(s))
+ else if (Mode.EDIT.name.equals(s))
{
return Mode.EDIT;
}
- else if (Mode.HELP.name.equalsIgnoreCase(s))
+ else if (Mode.HELP.name.equals(s))
{
return Mode.HELP;
}
- else if (Mode.EDIT_DEFAULTS.name.equalsIgnoreCase(s))
+ else if (Mode.EDIT_DEFAULTS.name.equals(s))
{
return Mode.VIEW;
}
Modified: trunk/api/src/main/org/jboss/portal/WindowState.java
===================================================================
--- trunk/api/src/main/org/jboss/portal/WindowState.java 2007-01-19 06:34:20 UTC (rev
6046)
+++ trunk/api/src/main/org/jboss/portal/WindowState.java 2007-01-19 15:26:43 UTC (rev
6047)
@@ -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>
@@ -33,26 +34,38 @@
/** 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 IllegalArgumentException("Window state name cannot be
null.");
+ throw new IllegalArgumentException("Window state name cannot be
null");
}
- this.name = name;
+ this.name = name.toLowerCase(Locale.ENGLISH);
}
public boolean equals(Object o)
{
+ if (o == this)
+ {
+ return true;
+ }
if (o instanceof WindowState)
{
- return o == this || name.equalsIgnoreCase(((WindowState)o).name);
+ WindowState that = (WindowState)o;
+ return name.equals(that.name);
}
return false;
}
@@ -69,15 +82,15 @@
private Object readResolve()
{
- if (NORMAL.name.equalsIgnoreCase(name))
+ if (NORMAL.name.equals(name))
{
return NORMAL;
}
- else if (MAXIMIZED.name.equalsIgnoreCase(name))
+ else if (MAXIMIZED.name.equals(name))
{
return MAXIMIZED;
}
- else if (MINIMIZED.name.equalsIgnoreCase(name))
+ else if (MINIMIZED.name.equals(name))
{
return MINIMIZED;
}
@@ -89,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;
}