You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2011/11/10 00:40:13 UTC

svn commit: r1200042 [3/3] - in /myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared: component/ config/ renderkit/html/ renderkit/html/util/ resource/ taglib/ util/ util/el/

Modified: myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/util/StringUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/util/StringUtils.java?rev=1200042&r1=1200041&r2=1200042&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/util/StringUtils.java (original)
+++ myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/util/StringUtils.java Wed Nov  9 23:40:12 2011
@@ -18,8 +18,6 @@
  */
 package org.apache.myfaces.shared.util;
 
-import org.apache.myfaces.shared.util.ArrayUtils;
-
 import java.util.ArrayList;
 
 
@@ -267,31 +265,33 @@ public final class StringUtils
             return "";
         }
 
-        int end_ = str.indexOf(quote, begin);
+        int endInt = str.indexOf(quote, begin);
 
         // If no quotes, return the original string
         // and save StringBuffer allocation/char copying
-        if (end_ < 0)
+        if (endInt < 0)
         {
             return str.substring(begin, end);
         }
 
         StringBuffer sb     = new StringBuffer(end - begin);
-        int          begin_ = begin; // need begin later
-        for (; (end_ >= 0) && (end_ < end);
-            end_ = str.indexOf(quote, begin_ = end_ + 2))
+        int          beginInt = begin; // need begin later
+        do
         {
-            if (((end_ + 1) >= end) || (str.charAt(end_ + 1) != quote))
+            if (((endInt + 1) >= end) || (str.charAt(endInt + 1) != quote))
             {
                 throw new IllegalArgumentException(
                     "Internal quote not doubled in string '"
                     + str.substring(begin, end) + "'");
             }
 
-            sb.append(substring(str, begin_, end_)).append(quote);
+            sb.append(substring(str, beginInt, endInt)).append(quote);
+            beginInt = endInt + 2;
+            endInt = str.indexOf(quote, beginInt);
         }
+        while ((endInt >= 0) && (endInt < end));
 
-        return sb.append(substring(str, begin_, end)).toString();
+        return sb.append(substring(str, beginInt, end)).toString();
     }
 
     /**
@@ -330,15 +330,15 @@ public final class StringUtils
             return str.substring(begin, end);
         }
 
-        int _end = end - 1;
-        if ((str.length() < 2) || (str.charAt(_end) != quote))
+        int endInt = end - 1;
+        if ((str.length() < 2) || (str.charAt(endInt) != quote))
         {
             throw new IllegalArgumentException(
                 "Closing quote missing in string '"
                 + substring(str, begin, end) + "'");
         }
 
-        return dequote(str, begin + 1, _end, quote);
+        return dequote(str, begin + 1, endInt, quote);
     }
 
     public static String replace(String str, String repl, String with)
@@ -358,9 +358,11 @@ public final class StringUtils
         StringBuffer out     =
             new StringBuffer((lendiff <= 0) ? str.length()
                 : (str.length() + (10 * lendiff)));
-        for (; pos >= 0; pos = str.indexOf(repl, lastindex = pos + len))
+        while(pos >= 0)
         {
             out.append(substring(str, lastindex, pos)).append(with);
+            lastindex = pos + len;
+            pos = str.indexOf(repl, lastindex);
         }
 
         return out.append(substring(str, lastindex, str.length())).toString();
@@ -383,9 +385,11 @@ public final class StringUtils
             new StringBuffer((lendiff <= 0) ? str.length()
                 : (str.length() + (10 * lendiff)));
         int          lastindex = 0;
-        for (; pos >= 0; pos = str.indexOf(repl, lastindex = pos + 1))
+        while( pos >= 0)
         {
             out.append(substring(str, lastindex, pos)).append(with);
+            lastindex = pos + 1;
+            pos = str.indexOf(repl, lastindex);
         }
 
         return out.append(substring(str, lastindex, len)).toString();
@@ -396,11 +400,13 @@ public final class StringUtils
     {
         int lastindex = 0;
         int len = repl.length();
-        for (int index = s.indexOf(repl); index >= 0;
-                    index = s.indexOf(repl, lastindex = index + len))
+        int index = s.indexOf(repl);
+        while (index >= 0)
         {
             // we have search string at position index
             out.append(substring(s, lastindex, index)).append(with);
+            lastindex = index + len;
+            index = s.indexOf(repl, lastindex);
         }
 
         return out.append(substring(s, lastindex, len));
@@ -417,21 +423,23 @@ public final class StringUtils
      */
     public static String[] splitLongString(String str, char separator)
     {
-        int len;
-        if (str == null || (len = str.length()) == 0)
+        int len = (str == null) ? 0 : str.length();
+        if (str == null || len == 0)
         {
             return ArrayUtils.EMPTY_STRING_ARRAY;
         }
 
         int       oldPos = 0;
         ArrayList list = new ArrayList();
-        for (
-            int pos = str.indexOf(separator); pos >= 0;
-                    pos = str.indexOf(separator, (oldPos = (pos + 1))))
+        int pos = str.indexOf(separator);
+        while(pos >= 0)
         {
             list.add(substring(str, oldPos, pos));
+            oldPos = (pos + 1);
+            pos = str.indexOf(separator, oldPos);
         }
 
+
         list.add(substring(str, oldPos, len));
 
         return (String[]) list.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
@@ -453,8 +461,8 @@ public final class StringUtils
     public static String[] splitLongString(
         String str, char separator, char quote)
     {
-        int len;
-        if (str == null || (len = str.length()) == 0)
+        int len = (str == null) ? 0 : str.length();
+        if (str == null || len == 0)
         {
             return ArrayUtils.EMPTY_STRING_ARRAY;
         }
@@ -518,8 +526,8 @@ public final class StringUtils
      */
     public static String[] splitShortString(String str, char separator)
     {
-        int len;
-        if (str == null || (len = str.length()) == 0)
+        int len = (str == null) ? 0 : str.length();
+        if (str == null || len == 0)
         {
             return org.apache.myfaces.shared.util.ArrayUtils.EMPTY_STRING_ARRAY;
         }
@@ -540,11 +548,14 @@ public final class StringUtils
         int      oldPos = 0;
 
         // Step 3: retrieve substrings
-        for (
-            int pos = str.indexOf(separator), i = 0; pos >= 0;
-                    pos = str.indexOf(separator, (oldPos = (pos + 1))))
+        int pos = str.indexOf(separator);
+        int i = 0;
+        
+        while (pos >= 0)
         {
             list[i++] = substring(str, oldPos, pos);
+            oldPos = (pos + 1);
+            pos = str.indexOf(separator, oldPos);
         }
 
         list[lastTokenIndex] = substring(str, oldPos, len);
@@ -569,8 +580,8 @@ public final class StringUtils
     public static String[] splitShortString(
         String str, char separator, char quote)
     {
-        int len;
-        if (str == null || (len = str.length()) == 0)
+        int len = (str == null) ? 0 : str.length();
+        if (str == null || len == 0)
         {
             return ArrayUtils.EMPTY_STRING_ARRAY;
         }

Modified: myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/util/el/GenericMap.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/util/el/GenericMap.java?rev=1200042&r1=1200041&r2=1200042&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/util/el/GenericMap.java (original)
+++ myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/util/el/GenericMap.java Wed Nov  9 23:40:12 2011
@@ -18,67 +18,80 @@
  */
 package org.apache.myfaces.shared.util.el;
 
+import java.util.Collection;
 import java.util.Map;
 import java.util.Set;
-import java.util.Collection;
 
 /**
  * @author Sylvain Vieujot (latest modification by $Author$)
  * @version $Revision$ $Date$
  *
  */
-public abstract class GenericMap implements Map {
+public abstract class GenericMap implements Map
+{
 
     /**
      * This method should return the result of the test.
      */
     protected abstract Object getValue(Object key);
 
-    public int size() {
+    public int size()
+    {
         return 1;
     }
 
-    public boolean isEmpty() {
+    public boolean isEmpty()
+    {
         return false;
     }
 
-    public boolean containsKey(Object key) {
+    public boolean containsKey(Object key)
+    {
         return true;
     }
 
-    public boolean containsValue(Object value) {
+    public boolean containsValue(Object value)
+    {
         return value instanceof Boolean;
     }
 
-    public Object get(Object key) {
+    public Object get(Object key)
+    {
         return getValue(key);
     }
 
-    public Object put(Object key, Object value) {
+    public Object put(Object key, Object value)
+    {
         return null;
     }
 
-    public Object remove(Object key) {
+    public Object remove(Object key)
+    {
         return null;
     }
 
-    public void putAll(Map m) {
+    public void putAll(Map m)
+    {
         // NoOp
     }
 
-    public void clear() {
+    public void clear()
+    {
         // NoOp
     }
 
-    public Set keySet() {
+    public Set keySet()
+    {
         return null;
     }
 
-    public Collection values() {
+    public Collection values()
+    {
         return null;
     }
 
-    public Set entrySet() {
+    public Set entrySet()
+    {
         return null;
     }
 }