Author: ivaynberg
Date: Mon Oct 13 12:59:25 2008
New Revision: 704221

URL: http://svn.apache.org/viewvc?rev=704221&view=rev
Log:
rolling back WICKET-1868 because it broke the world

Removed:
    
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/packaged1_en.txt
    
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/packaged1_foo_bar.txt
Modified:
    
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/resource/locator/ResourceNameIterator.java
    
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/PackageResourceTest.java

Modified: 
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/resource/locator/ResourceNameIterator.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/resource/locator/ResourceNameIterator.java?rev=704221&r1=704220&r2=704221&view=diff
==============================================================================
--- 
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/resource/locator/ResourceNameIterator.java
 (original)
+++ 
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/resource/locator/ResourceNameIterator.java
 Mon Oct 13 12:59:25 2008
@@ -16,12 +16,8 @@
  */
 package org.apache.wicket.util.resource.locator;
 
-import java.util.Arrays;
-import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Locale;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 import org.apache.wicket.WicketRuntimeException;
 import org.apache.wicket.util.string.Strings;
@@ -54,8 +50,6 @@
  */
 public class ResourceNameIterator implements Iterator
 {
-       private static final Pattern LOCALE_PATTERN = 
Pattern.compile("_[a-zA-Z]{2}($|(?=_))");
-
        // The locale to search for the resource file
        private final Locale locale;
 
@@ -70,10 +64,6 @@
        // The latest exact Locale used
        private Locale currentLocale;
 
-       private final HashSet isoCountries = new 
HashSet(Arrays.asList(Locale.getISOCountries()));
-
-       private final HashSet isoLanguages = new 
HashSet(Arrays.asList(Locale.getISOLanguages()));
-
        /**
         * Construct.
         * 
@@ -87,7 +77,7 @@
         *            the filname's extensions (comma separated)
         */
        public ResourceNameIterator(String path, final String style, final 
Locale locale,
-               final String extensions)
+                       final String extensions)
        {
                this.locale = locale;
                if (extensions == null)
@@ -100,63 +90,7 @@
                        this.extensions = extensions;
                }
 
-               Matcher matcher = LOCALE_PATTERN.matcher(path);
-               if (matcher.find())
-               {
-                       String language = null;
-                       String country = null;
-                       String variant = null;
-                       int firstValidLocalePatternFragment = -1;
-                       do
-                       {
-                               String s = matcher.group().substring(1, 3);
-                               if (Character.isLowerCase(s.charAt(0)))
-                               {
-                                       if (isoLanguages.contains(s))
-                                       {
-                                               language = s;
-                                               firstValidLocalePatternFragment 
= matcher.start();
-                                               break;
-                                       }
-                               }
-                       }
-                       while (matcher.find());
-
-                       // did we find a language?
-                       if (language != null)
-                       {
-                               // check for country
-                               if (matcher.find())
-                               {
-                                       do
-                                       {
-                                               String s = 
matcher.group().substring(1, 3);
-                                               if 
(Character.isUpperCase(s.charAt(0)))
-                                               {
-                                                       if 
(isoCountries.contains(s))
-                                                       {
-                                                               country = s;
-                                                               break;
-                                                       }
-                                               }
-                                       }
-                                       while (matcher.find());
-                               }
-                               if (country != null)
-                               {
-                                       // country found... just get the rest 
of the string for any variant
-                                       if (matcher.find())
-                                       {
-                                               variant = 
path.substring(matcher.start());
-                                       }
-                               }
-                               path = path.substring(0, 
firstValidLocalePatternFragment);
-                               localeIterator = new 
LocaleResourceNameIterator(path, new Locale(language,
-                                       country != null ? country : "", variant 
!= null ? variant : ""));
-                       } // else skip the whole thing... probably user 
specific underscores used
-               }
-
-               styleIterator = new StyleAndVariationResourceNameIterator(path, 
style, null);
+               this.styleIterator = new 
StyleAndVariationResourceNameIterator(path, style, null);
        }
 
        /**
@@ -166,7 +100,7 @@
         */
        public final Locale getLocale()
        {
-               return currentLocale;
+               return this.currentLocale;
        }
 
        /**
@@ -175,9 +109,9 @@
        public boolean hasNext()
        {
                // Most inner loop. Loop through all extensions provided
-               if (extenstionsIterator != null)
+               if (this.extenstionsIterator != null)
                {
-                       if (extenstionsIterator.hasNext() == true)
+                       if (this.extenstionsIterator.hasNext() == true)
                        {
                                return true;
                        }
@@ -189,36 +123,38 @@
                }
 
                // 2nd inner loop: Loop through all Locale combinations
-               if (localeIterator != null)
+               if (this.localeIterator != null)
                {
-                       while (localeIterator.hasNext())
+                       while (this.localeIterator.hasNext())
                        {
                                // Get the next Locale from the iterator and 
start the next
                                // inner iterator over again.
-                               String newPath = (String)localeIterator.next();
-                               currentLocale = localeIterator.getLocale();
-                               extenstionsIterator = new 
ExtensionResourceNameIterator(newPath, extensions);
-                               if (extenstionsIterator.hasNext() == true)
+                               String newPath = 
(String)this.localeIterator.next();
+                               this.currentLocale = 
this.localeIterator.getLocale();
+                               this.extenstionsIterator = new 
ExtensionResourceNameIterator(newPath,
+                                               this.extensions);
+                               if (this.extenstionsIterator.hasNext() == true)
                                {
                                        return true;
                                }
                        }
-                       localeIterator = null;
+                       this.localeIterator = null;
                }
 
                // Most outer loop: Loop through all combinations of styles and
                // variations
-               while (styleIterator.hasNext())
+               while (this.styleIterator.hasNext())
                {
-                       String newPath = (String)styleIterator.next();
+                       String newPath = (String)this.styleIterator.next();
 
-                       localeIterator = new 
LocaleResourceNameIterator(newPath, locale);
-                       while (localeIterator.hasNext())
+                       this.localeIterator = new 
LocaleResourceNameIterator(newPath, this.locale);
+                       while (this.localeIterator.hasNext())
                        {
-                               newPath = (String)localeIterator.next();
-                               currentLocale = localeIterator.getLocale();
-                               extenstionsIterator = new 
ExtensionResourceNameIterator(newPath, extensions);
-                               if (extenstionsIterator.hasNext() == true)
+                               newPath = (String)this.localeIterator.next();
+                               this.currentLocale = 
this.localeIterator.getLocale();
+                               this.extenstionsIterator = new 
ExtensionResourceNameIterator(newPath,
+                                               this.extensions);
+                               if (this.extenstionsIterator.hasNext() == true)
                                {
                                        return true;
                                }
@@ -239,7 +175,7 @@
                        return extenstionsIterator.next();
                }
                throw new WicketRuntimeException(
-                       "Illegal call of next(). Iterator not properly 
initialized");
+                               "Illegal call of next(). Iterator not properly 
initialized");
        }
 
        /**

Modified: 
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/PackageResourceTest.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/PackageResourceTest.java?rev=704221&r1=704220&r2=704221&view=diff
==============================================================================
--- 
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/PackageResourceTest.java
 (original)
+++ 
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/PackageResourceTest.java
 Mon Oct 13 12:59:25 2008
@@ -65,9 +65,9 @@
                final SharedResources sharedResources = 
Application.get().getSharedResources();
                PackageResource.bind(application, PackageResourceTest.class, 
"packaged1.txt");
                assertNotNull("resource packaged1.txt should be available as a 
packaged resource",
-                       sharedResources.get(PackageResourceTest.class, 
"packaged1.txt", null, null, true));
+                               sharedResources.get(PackageResourceTest.class, 
"packaged1.txt", null, null, true));
                assertNull("resource packaged2.txt should NOT be available as a 
packaged resource",
-                       sharedResources.get(PackageResourceTest.class, 
"packaged2.txt", null, null, true));
+                               sharedResources.get(PackageResourceTest.class, 
"packaged2.txt", null, null, true));
        }
 
        /**
@@ -91,43 +91,14 @@
                assertFalse(guard.accept(PackageResourceTest.class, 
"Bar.java"));
        }
 
-       /**
-        * Test lenient matching
-        * 
-        * @throws Exception
-        */
-       public void testLenientPackageResourceMatching() throws Exception
+       public void testInvalidPackageResource() throws Exception
        {
                final SharedResources sharedResources = 
Application.get().getSharedResources();
                Resource invalidResource = new 
PackageResource(PackageResourceTest.class, "packaged3.txt",
-                       Locale.ENGLISH, null);
+                               Locale.ENGLISH, null);
                assertNotNull(
-                       "resource packaged3.txt SHOULD be available as a 
packaged resource even if it doesn't exist",
-                       invalidResource);
-
-               assertTrue(PackageResource.exists(PackageResourceTest.class, 
"packaged1.txt", null, null));
-               assertTrue(PackageResource.exists(PackageResourceTest.class, 
"packaged1.txt", Locale.CHINA,
-                       null));
-               assertTrue(PackageResource.exists(PackageResourceTest.class, 
"packaged1.txt", Locale.CHINA,
-                       "foo"));
-               assertTrue(PackageResource.exists(PackageResourceTest.class, 
"packaged1.txt", null, "foo"));
-               assertTrue(PackageResource.exists(PackageResourceTest.class, 
"packaged1_en.txt", null, null));
-               assertTrue(PackageResource.exists(PackageResourceTest.class, 
"packaged1_en_US.txt", null,
-                       null));
-               assertTrue(PackageResource.exists(PackageResourceTest.class, 
"packaged1_en_US.txt", null,
-                       "foo"));
-               assertTrue(PackageResource.exists(PackageResourceTest.class, 
"packaged1_en_US.txt",
-                       Locale.US, null));
-               assertTrue(PackageResource.exists(PackageResourceTest.class, 
"packaged1_en_US.txt",
-                       Locale.CANADA, null));
-               assertTrue(PackageResource.exists(PackageResourceTest.class, 
"packaged1_en_US.txt",
-                       Locale.CHINA, null));
-               assertTrue(PackageResource.exists(PackageResourceTest.class, 
"packaged1_foo_bar_en.txt",
-                       null, null));
-               assertTrue(PackageResource.exists(PackageResourceTest.class, 
"packaged1_foo_bar_en_US.txt",
-                       null, null));
-               assertTrue(PackageResource.exists(PackageResourceTest.class,
-                       "packaged1_foo_bar_en_US_MAC.txt", null, null));
+                               "resource packaged3.txt SHOULD be available as 
a packaged resource even if it doesn't exist",
+                               invalidResource);
 
                try
                {


Reply via email to