|
From: <die...@us...> - 2014-03-04 09:55:38
|
Revision: 4566
http://openutils.svn.sourceforge.net/openutils/?rev=4566&view=rev
Author: diego_schivo
Date: 2014-03-04 09:55:34 +0000 (Tue, 04 Mar 2014)
Log Message:
-----------
XPathTextUtils SPECIAL_CHARS
Modified Paths:
--------------
magnoliamodules/branches/magnolia44/openutils-mgnlcriteria/src/main/java/net/sourceforge/openutils/mgnlcriteria/jcr/query/xpath/utils/XPathTextUtils.java
magnoliamodules/branches/magnolia44/openutils-mgnlcriteria/src/test/java/net/sourceforge/openutils/mgnlcriteria/jcr/query/EscapeSignTest.java
Modified: magnoliamodules/branches/magnolia44/openutils-mgnlcriteria/src/main/java/net/sourceforge/openutils/mgnlcriteria/jcr/query/xpath/utils/XPathTextUtils.java
===================================================================
--- magnoliamodules/branches/magnolia44/openutils-mgnlcriteria/src/main/java/net/sourceforge/openutils/mgnlcriteria/jcr/query/xpath/utils/XPathTextUtils.java 2014-03-04 09:18:57 UTC (rev 4565)
+++ magnoliamodules/branches/magnolia44/openutils-mgnlcriteria/src/main/java/net/sourceforge/openutils/mgnlcriteria/jcr/query/xpath/utils/XPathTextUtils.java 2014-03-04 09:55:34 UTC (rev 4566)
@@ -19,10 +19,14 @@
package net.sourceforge.openutils.mgnlcriteria.jcr.query.xpath.utils;
+import java.util.Arrays;
import java.util.Calendar;
+import java.util.HashSet;
import java.util.Locale;
+import java.util.Set;
import java.util.TimeZone;
+import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.FastDateFormat;
import org.slf4j.Logger;
@@ -48,6 +52,64 @@
TimeZone.getDefault(),
Locale.ENGLISH);
+ public static final Set<Character> SPECIAL_CHARS = new HashSet<Character>(Arrays.asList(ArrayUtils
+ .toObject(new char[]{'\u0020', //
+ '\u0021', // !
+ '\u0022', // "
+ '\u0023', // #
+ '\u0024', // $
+ '\u0025', // %
+ '\u0026', // &
+ '\u002c', // ,
+ '\u003a', // :
+ '\u003b', // ;
+ '\u003c', // <
+ '\u003d', // =
+ '\u003e', // >
+ '\u003f', // ?
+ '\u0040', // @
+ '\u005c\', // \
+ '\u005e', // ^
+ '\u0060', // `
+ '\u007b', // {
+ '\u007d', // }
+ '\u007e', // ~
+ '\u00a0', //
+ '\u00a1', // ¡
+ '\u00a2', // ¢
+ '\u00a3', // £
+ '\u00a4', // ¤
+ '\u00a5', // ¥
+ '\u00a6', // ¦
+ '\u00a7', // §
+ '\u00a8', // ¨
+ '\u00a9', // ©
+ '\u00aa', // ª
+ '\u00ab', // «
+ '\u00ac', // ¬
+ '\u00ad', //
+ '\u00ae', // ®
+ '\u00af', // ¯
+ '\u00b0', // °
+ '\u00b1', // ±
+ '\u00b2', // ²
+ '\u00b3', // ³
+ '\u00b4', // ´
+ '\u00b5', // µ
+ '\u00b6', // ¶
+ '\u00b7', // ·
+ '\u00b8', // ¸
+ '\u00b9', // ¹
+ '\u00ba', // º
+ '\u00bb', // »
+ '\u00bc', // ¼
+ '\u00bd', // ½
+ '\u00be', // ¾
+ '\u00bf', // ¿
+ '\u00d7', // ×
+ '\u00f7' // ÷
+ })));
+
private XPathTextUtils()
{
}
@@ -137,28 +199,10 @@
{
encodedPath.append("_x002d_");
}
- else if (inXpathCondition <= 0 && ch == ' ')
+ else if (inXpathCondition <= 0 && SPECIAL_CHARS.contains(ch))
{
- encodedPath.append("_x0020_");
+ encodedPath.append("_x").append(String.format("%04x", (int) ch)).append("_");
}
- else if (inXpathCondition <= 0 && ch == ',')
- {
- encodedPath.append("_x002c_");
- }
- // CRIT-53
- else if (inXpathCondition <= 0 && ch == '\u00b0')
- {
- encodedPath.append("_x00b0_");
- }
- // CRIT-54
- else if (inXpathCondition <= 0 && ch == '$')
- {
- encodedPath.append("_x0024_");
- }
- else if (inXpathCondition <= 0 && ch == '©')
- {
- encodedPath.append("_x00a9_");
- }
else
{
Modified: magnoliamodules/branches/magnolia44/openutils-mgnlcriteria/src/test/java/net/sourceforge/openutils/mgnlcriteria/jcr/query/EscapeSignTest.java
===================================================================
--- magnoliamodules/branches/magnolia44/openutils-mgnlcriteria/src/test/java/net/sourceforge/openutils/mgnlcriteria/jcr/query/EscapeSignTest.java 2014-03-04 09:18:57 UTC (rev 4565)
+++ magnoliamodules/branches/magnolia44/openutils-mgnlcriteria/src/test/java/net/sourceforge/openutils/mgnlcriteria/jcr/query/EscapeSignTest.java 2014-03-04 09:55:34 UTC (rev 4566)
@@ -138,12 +138,14 @@
{
for (int i = 0; i < 0x100; i++)
{
- char c = (char) i;
- if (!isPrintableChar(c))
+ if (i == 0x27 || i == 0x5b || i == 0x5d)
{
- log.warn("Skipping \\u{}", String.format("%04x", i));
+ continue;
}
- else
+ char c = (char) i;
+ boolean printable = isPrintableChar(c);
+ log.debug("\\u{} (printable={})", String.format("%04x", i), printable);
+ if (printable)
{
Criteria criteria = JCRCriteriaFactory
.createCriteria()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|