sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1500784 - /sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundle.java
Date Mon, 08 Jul 2013 15:03:26 GMT
Author: cziegeler
Date: Mon Jul  8 15:03:26 2013
New Revision: 1500784

URL: http://svn.apache.org/r1500784
Log:
SLING-2940 : JCR queries for jcr:language: avoid using fn:lower-case. Apply patch from Thomas
Müller

Modified:
    sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundle.java

Modified: sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundle.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundle.java?rev=1500784&r1=1500783&r2=1500784&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundle.java
(original)
+++ sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundle.java
Mon Jul  8 15:03:26 2013
@@ -86,6 +86,7 @@ public class JcrResourceBundle extends R
      *
      * @return The keys of the resources provided by this resource bundle
      */
+    @Override
     protected Set<String> handleKeySet() {
         return resources.keySet();
     }
@@ -155,24 +156,31 @@ public class JcrResourceBundle extends R
 
     private static String getFullLoadQuery(final Locale locale,
             final String baseName) {
-        StringBuilder buf = new StringBuilder(64);
+        final StringBuilder buf = new StringBuilder(64);
 
         buf.append("//element(*,mix:language)[");
 
-        String localeString = locale.toString().toLowerCase();
-        String localeRFC4646String = toRFC4646String(locale).toLowerCase();
-
-        if (localeString.equals(localeRFC4646String)) {
-            buf.append("fn:lower-case(@jcr:language)='");
-            buf.append(localeString);
-            buf.append('\'');
-        } else {
-            buf.append("(fn:lower-case(@jcr:language)='");
-            buf.append(localeString);
-            buf.append('\'');
-            buf.append(" or fn:lower-case(@jcr:language)='");
-            buf.append(localeRFC4646String);
-            buf.append("\')");
+        final String localeString = locale.toString();
+        buf.append("@jcr:language='").
+            append(localeString).
+            append('\'');
+        final String localeStringLower = localeString.toLowerCase();
+        if (!localeStringLower.equals(localeString)) {
+            buf.append(" or @jcr:language='").
+                append(localeStringLower).
+                append('\'');
+        }
+        final String localeRFC4646String = toRFC4646String(locale);
+        if (!localeRFC4646String.equals(localeString)) {
+            buf.append(" or @jcr:language='").
+                append(localeRFC4646String).
+                append('\'');
+            final String localeRFC4646StringLower = localeRFC4646String.toLowerCase();
+            if (!localeRFC4646StringLower.equals(localeRFC4646String)) {
+                buf.append(" or @jcr:language='").
+                    append(localeRFC4646StringLower).
+                    append('\'');
+            }
         }
 
         if (baseName != null) {



Mime
View raw message