Author: thomas.heute(a)jboss.com
Date: 2007-11-01 12:01:21 -0400 (Thu, 01 Nov 2007)
New Revision: 8817
Modified:
modules/common/trunk/common/src/main/java/org/jboss/portal/common/text/FastURLDecoder.java
Log:
Fix FastURLDecoder
Modified:
modules/common/trunk/common/src/main/java/org/jboss/portal/common/text/FastURLDecoder.java
===================================================================
---
modules/common/trunk/common/src/main/java/org/jboss/portal/common/text/FastURLDecoder.java 2007-11-01
13:48:13 UTC (rev 8816)
+++
modules/common/trunk/common/src/main/java/org/jboss/portal/common/text/FastURLDecoder.java 2007-11-01
16:01:21 UTC (rev 8817)
@@ -22,6 +22,11 @@
******************************************************************************/
package org.jboss.portal.common.text;
+import java.io.StringWriter;
+import java.io.Writer;
+
+import org.jboss.portal.common.io.WriterCharWriter;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
@@ -244,39 +249,12 @@
*/
public String encode(String s) throws IllegalArgumentException
{
- StringBuilder tmp = new StringBuilder();
- encode(s, tmp);
- return tmp.toString();
+ Writer sw = new StringWriter();
+ CharWriter charWriter = new WriterCharWriter(sw);
+ encodeNoCheck(s.toCharArray(), 0, s.length(), charWriter);
+ return sw.toString();
}
-
- /**
- * @param s
- * @param out
- * @throws IllegalArgumentException
- * @since 1.1
- */
- public void encode(String s, StringBuilder out) throws IllegalArgumentException
- {
- if (s == null)
- {
- throw new IllegalArgumentException();
- }
- if (out == null)
- {
- throw new IllegalArgumentException();
- }
- for (int i = 0; i < s.length(); i++)
- {
- char c = s.charAt(i);
- int[] z = conversions[c];
- if (z == null)
- {
- throw new MalformedInputException("Cannot encode char=" + (int)c);
- }
- out.append(z);
- }
- }
-
+
private void encodeNoCheck(char[] chars, int i, int length, CharWriter tmp)
{
while (i < length)
Show replies by date