Author: julien(a)jboss.com
Date: 2007-01-18 15:23:54 -0500 (Thu, 18 Jan 2007)
New Revision: 6037
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletUtils.java
Log:
improved implementation of generateNamespaceFrom method
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletUtils.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletUtils.java 2007-01-18
19:31:56 UTC (rev 6036)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletUtils.java 2007-01-18
20:23:54 UTC (rev 6037)
@@ -163,11 +163,26 @@
* Generates a namespace suitable for Portlet prefixing of tokens that need to be
unique in an aggregated page.
*
* @param windowId
- * @return
* @since 2.6
*/
public static String generateNamespaceFrom(String windowId)
{
- return PREFIX + Integer.toHexString(windowId.hashCode());
+ StringBuffer tmp = new StringBuffer(PREFIX.length() + windowId.length() * 2);
+ tmp.append(PREFIX);
+ for (int i = 0;i < windowId.length();i++)
+ {
+ char c = windowId.charAt(i);
+ if (Character.isLetterOrDigit(c))
+ {
+ tmp.append(c);
+ }
+ else
+ {
+ tmp.append('_');
+ tmp.append(Character.forDigit((((int)c) & 0XF0) >> 4, 16));
+ tmp.append(Character.forDigit((((int)c) & 0X0F), 16));
+ }
+ }
+ return tmp.toString();
}
}
Show replies by date