From jbossws-commits at lists.jboss.org Thu Mar 11 12:06:10 2010
Content-Type: multipart/mixed; boundary="===============8016976326583630328=="
MIME-Version: 1.0
From: jbossws-commits at lists.jboss.org
To: jbossws-commits at lists.jboss.org
Subject: [jbossws-commits] JBossWS SVN: r11765 - in common/trunk/src:
test/java/org/jboss/test/ws/common and 1 other directory.
Date: Thu, 11 Mar 2010 12:06:10 -0500
Message-ID: <201003111706.o2BH6Asp023702@svn01.web.mwc.hst.phx2.redhat.com>
--===============8016976326583630328==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: darran.lofthouse(a)jboss.com
Date: 2010-03-11 12:06:09 -0500 (Thu, 11 Mar 2010)
New Revision: 11765
Removed:
common/trunk/src/test/java/org/jboss/test/ws/common/NormalizerTestCase.j=
ava
Modified:
common/trunk/src/main/java/org/jboss/wsf/common/Normalizer.java
Log:
[JBWS-2885] Revert changes.
Modified: common/trunk/src/main/java/org/jboss/wsf/common/Normalizer.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- common/trunk/src/main/java/org/jboss/wsf/common/Normalizer.java 2010-03=
-11 12:56:34 UTC (rev 11764)
+++ common/trunk/src/main/java/org/jboss/wsf/common/Normalizer.java 2010-03=
-11 17:06:09 UTC (rev 11765)
@@ -28,18 +28,13 @@
*
* @author Martin Vecera
* @author Alessio Soldano=
a>
-* @author Darran Lofthouse=
-* =
* @since 09-Dic-2009
+* =
*/
final public class Normalizer
{
private static final Pattern PATTERN =3D Pattern.compile("[&<>'\"\r\n]"=
);
=
- private static final String CDATA_START =3D "";
-
public static String normalize(String strValue)
{
return normalize(strValue, false);
@@ -50,57 +45,11 @@
Matcher m =3D PATTERN.matcher(strValue);
if (m.find())
{
- int len =3D strValue.length();
- StringBuilder sb =3D new StringBuilder(len * 3); // faster than S=
tringBuffer, not thread safe
- int start =3D 0;
-
- while (start < len)
- {
- int cdataStart =3D strValue.indexOf(CDATA_START, start);
- if (cdataStart > -1)
- {
- int cdataEnd =3D strValue.indexOf(CDATA_END, cdataStart);
- // If a valid start and end to a section are
- // identified exclude from normalisation. =
- if (cdataEnd > -1)
- {
- if (cdataStart > start)
- {
- normalize(strValue.substring(start, cdataStart), cano=
nical, sb);
- }
- sb.append(strValue.subSequence(cdataStart, cdataEnd + 3)=
);
- start =3D cdataEnd + 3;
- }
- else
- {
- normalize(strValue.substring(start, len), canonical, sb);
- start =3D len;
- }
- }
- else
- {
- normalize(strValue.substring(start, len), canonical, sb);
- start =3D len;
- }
- }
-
- return sb.toString();
- }
- else
- {
- return strValue;
- }
- }
-
- private static void normalize(String strValue, boolean canonical, Strin=
gBuilder sb)
- {
- Matcher m =3D PATTERN.matcher(strValue);
- if (m.find())
- {
int pos =3D m.start(); // we can use previous match to skip some =
part at the string beginning
int len =3D strValue.length(); // just a single call to length()
char[] input =3D new char[len]; // this is to ommit calls to Stri=
ng.charAt()
strValue.getChars(0, len, input, 0);
+ StringBuilder sb =3D new StringBuilder(len * 3); // faster than S=
tringBuffer, not thread safe
=
int copyStart =3D 0;
=
@@ -170,10 +119,12 @@
{
sb.append(input, copyStart, len - copyStart);
}
+
+ return sb.toString();
}
else
{
- sb.append(strValue);
+ return strValue;
}
}
}
Deleted: common/trunk/src/test/java/org/jboss/test/ws/common/NormalizerTest=
Case.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- common/trunk/src/test/java/org/jboss/test/ws/common/NormalizerTestCase.=
java 2010-03-11 12:56:34 UTC (rev 11764)
+++ common/trunk/src/test/java/org/jboss/test/ws/common/NormalizerTestCase.=
java 2010-03-11 17:06:09 UTC (rev 11765)
@@ -1,104 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.ws.common;
-
-import org.jboss.wsf.common.Normalizer;
-
-import junit.framework.TestCase;
-
-/**
- * [JBWS-2885] http://jira.jboss.com/jira/browse/JBWS-2885
- * =
- * Test case to test sections are skipped in the =
- * normalization process.
- * =
- * @author darran.lofthouse(a)jboss.com
- * @since Mar 10, 2010
- */
-public class NormalizerTestCase extends TestCase
-{
-
- private static final String CDATA_STRING =3D "";
-
- public void testCDATAOnly()
- {
- String normalized =3D Normalizer.normalize(CDATA_STRING);
-
- assertEquals("Normalized String", CDATA_STRING, normalized);
- }
-
- public void testCDATABegin()
- {
- String normalized =3D Normalizer.normalize(CDATA_STRING + "ABC");
-
- assertEquals("Normalized String", CDATA_STRING + "ABC", normalized);
- }
-
- public void testCDATAEnd()
- {
- String normalized =3D Normalizer.normalize("ABD" + CDATA_STRING);
-
- assertEquals("Normalized String", "ABD" + CDATA_STRING, normalized);
- }
-
- public void testCDATAMid()
- {
- String normalized =3D Normalizer.normalize("ABD" + CDATA_STRING + "E=
FG");
-
- assertEquals("Normalized String", "ABD" + CDATA_STRING + "EFG", norm=
alized);
- }
-
- public void testCDATADouble()
- {
- String normalized =3D Normalizer.normalize("ABD" + CDATA_STRING + "E=
FG" + CDATA_STRING + "HIJ");
-
- assertEquals("Normalized String", "ABD" + CDATA_STRING + "EFG" + CDA=
TA_STRING + "HIJ", normalized);
- }
- =
- public void testCDATABegin_Replace()
- {
- String normalized =3D Normalizer.normalize(CDATA_STRING + "<>");
-
- assertEquals("Normalized String", CDATA_STRING + "<>", normali=
zed);
- }
-
- public void testCDATAEnd_Replace()
- {
- String normalized =3D Normalizer.normalize("<>" + CDATA_STRING);
-
- assertEquals("Normalized String", "<>" + CDATA_STRING, normali=
zed);
- }
-
- public void testCDATAMid_Replace()
- {
- String normalized =3D Normalizer.normalize("<>" + CDATA_STRING + "<>=
");
-
- assertEquals("Normalized String", "<>" + CDATA_STRING + "<&=
gt;", normalized);
- }
-
- public void testCDATADouble_Replace()
- {
- String normalized =3D Normalizer.normalize("<>" + CDATA_STRING + "<>=
" + CDATA_STRING + "<>");
-
- assertEquals("Normalized String", "<>" + CDATA_STRING + "<&=
gt;" + CDATA_STRING + "<>", normalized);
- }
-}
--===============8016976326583630328==--