Author: rfelden
Date: Thu Jan 17 11:52:36 2008
New Revision: 20

URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D20&repname=3D=
fix_apply
Log:
-> java 5

Modified:
    branches/jahia/utils/src/main/java/org/jahia/utils/StringUtils.java
    branches/jahia/utils/src/main/java/org/jahia/utils/merge/XMLMerger.java

Modified: branches/jahia/utils/src/main/java/org/jahia/utils/StringUtils.ja=
va
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/jahia/utils/=
src/main/java/org/jahia/utils/StringUtils.java&rev=3D20&repname=3Dfix_apply
=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=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/jahia/utils/src/main/java/org/jahia/utils/StringUtils.java (or=
iginal)
+++ branches/jahia/utils/src/main/java/org/jahia/utils/StringUtils.java Thu=
 Jan 17 11:52:36 2008
@@ -129,7 +129,7 @@
         int start =3D 0 ;
         int tempInd =3D string.indexOf(token, start);
         if (tempInd=3D=3D-1) return result;
-        ArrayList positions =3D new ArrayList() ;
+        ArrayList<Integer> positions =3D new ArrayList<Integer>() ;
         while(tempInd !=3D -1) {
             positions.add(new Integer(tempInd));
             start =3D tempInd+token.length();
@@ -138,7 +138,7 @@
         int size =3D positions.size();
         result =3D new int[size];
         for(int i=3D0 ; i<size ; i++)
-            result[i]=3D((Integer)positions.get(i)).intValue();
+            result[i]=3Dpositions.get(i).intValue();
         return result;
     }
 =

@@ -156,7 +156,7 @@
         int[] positions =3D getTokenPositions(string, splitToken);
         if (positions.length =3D=3D 0) return init ;
 =

-        ArrayList splitted =3D new ArrayList() ;
+        ArrayList<String> splitted =3D new ArrayList<String>() ;
         if (0<positions[0])
             splitted.add(string.substring(0, positions[0]));
         for (int i=3D0 ; i<positions.length-1 ; i++) {
@@ -165,11 +165,7 @@
         }
         if (positions[positions.length-1]< string.length())
             splitted.add(string.substring(positions[positions.length-1]+sp=
litToken.length(), string.length()));
-        String[] result =3D new String[splitted.size()] ;
-        for (int i =3D 0; i < splitted.size() ; i++) {
-            result[i] =3D (String)splitted.get(i) ;
-        }
-        return result ;
+        return splitted.toArray(new String[0]) ;
     }
 =

     /**
@@ -179,7 +175,7 @@
      * @return the processed array
      */
     public static String[] removeDuplicatesFromSortedStringArray(String[] =
sortedArray) {
-        ArrayList unique =3D new ArrayList() ;
+        ArrayList<String> unique =3D new ArrayList<String>() ;
         String temp =3D "" ;
         for (int i =3D 0; i < sortedArray.length; i++) {
             String aSortedArray =3D sortedArray[i];
@@ -188,11 +184,7 @@
                 unique.add(temp);
             }
         }
-        String[] result =3D new String[unique.size()];
-        for (int i =3D 0; i < unique.size() ; i++) {
-            result[i] =3D (String)unique.get(i) ;
-        }
-        return result ;
+        return unique.toArray(new String[0]) ;
     }
 =

     public static String[] sortStringArrayAndRemoveDuplicates(String[] arr=
ay) {
@@ -221,18 +213,14 @@
      * @return the cleaned list
      */
     public static String[] removeStringsContainingToken(String[] stringLis=
t, String token) {
-        ArrayList cleared =3D new ArrayList() ;
+        ArrayList<String> cleared =3D new ArrayList<String>() ;
         for (int i =3D 0; i < stringList.length; i++) {
             String path =3D stringList[i];
             if (path.indexOf(File.separator + token + File.separator) =3D=
=3D -1) {
                 cleared.add(path);
             }
         }
-        String[] result =3D new String[cleared.size()];
-        for (int i =3D 0; i < cleared.size() ; i++) {
-            result[i] =3D (String)cleared.get(i) ;
-        }
-        return result ;
+        return cleared.toArray(new String[0]) ;
     }
     =

 }

Modified: branches/jahia/utils/src/main/java/org/jahia/utils/merge/XMLMerge=
r.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/jahia/utils/=
src/main/java/org/jahia/utils/merge/XMLMerger.java&rev=3D20&repname=3Dfix_a=
pply
=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=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/jahia/utils/src/main/java/org/jahia/utils/merge/XMLMerger.java=
 (original)
+++ branches/jahia/utils/src/main/java/org/jahia/utils/merge/XMLMerger.java=
 Thu Jan 17 11:52:36 2008
@@ -8,7 +8,6 @@
 =

 import java.io.*;
 import java.util.List;
-import java.util.Iterator;
 =

 /**
  * This is the merger for the .xml files.
@@ -91,24 +90,22 @@
                 // retrieve the old child corresponding
                 List oldChildList =3D old.getChildren(childName) ;
                 Element oldChild =3D null ;
-                Iterator it =3D oldChildList.iterator() ;
-                while (it.hasNext()) {
-                    Element temp =3D (Element) it.next() ;
+                for (Object anOldChildList : oldChildList) {
+                    Element temp =3D (Element) anOldChildList;
                     if (areSameNodes(temp, updateChild)) {
-                        oldChild =3D temp ;
-                        break ;
+                        oldChild =3D temp;
+                        break;
                     }
                 }
 =

                 // retrieve the old child corresponding
                 List existingChildList =3D existing.getChildren(childName)=
 ;
                 Element existingChild =3D null ;
-                Iterator it2 =3D existingChildList.iterator() ;
-                while (it2.hasNext()) {
-                    Element temp =3D (Element) it2.next() ;
+                for (Object anExistingChildList : existingChildList) {
+                    Element temp =3D (Element) anExistingChildList;
                     if (areSameNodes(temp, updateChild)) {
-                        existingChild =3D temp ;
-                        break ;
+                        existingChild =3D temp;
+                        break;
                     }
                 }
 =

@@ -129,23 +126,23 @@
 =

             // if there are attributes, compare values and set if needed
             if (updateAttList.size() !=3D 0) {
-                for (int i =3D 0; i < updateAttList.size(); i++) {
-                    Attribute updateAtt =3D (Attribute) updateAttList.get(=
i) ;
-                    String attName =3D updateAtt.getName() ;
-                    Attribute oldAtt =3D old.getAttribute(attName) ;
-                    Attribute existingAtt =3D existing.getAttribute(attNam=
e) ;
+                for (Object anUpdateAttList : updateAttList) {
+                    Attribute updateAtt =3D (Attribute) anUpdateAttList;
+                    String attName =3D updateAtt.getName();
+                    Attribute oldAtt =3D old.getAttribute(attName);
+                    Attribute existingAtt =3D existing.getAttribute(attNam=
e);
 =

                     // if the comparison has to be done
                     if (oldAtt !=3D null && existingAtt !=3D null) {
                         // get the att values
-                        String updateValue =3D updateAtt.getValue() ;
-                        String oldValue =3D oldAtt.getValue() ;
-                        String existingValue =3D existingAtt.getValue() ;
+                        String updateValue =3D updateAtt.getValue();
+                        String oldValue =3D oldAtt.getValue();
+                        String existingValue =3D existingAtt.getValue();
 =

                         // compare the att values
                         if (oldValue.equals(updateValue) && !existingValue=
.equals(updateValue) && !existingValue.trim().equals("")) {
                             if (controller.requestForItem(fileName, update=
.getName() + ": " + attName, existingValue, updateValue)) {
-                                updateAtt.setValue(existingValue) ;
+                                updateAtt.setValue(existingValue);
                             }
                         }
                     }
@@ -194,14 +191,14 @@
 =

         // check att names
         boolean result =3D true ;
-        for (int i =3D 0; i < oneAttList.size(); i++) {
-            Attribute oneAtt =3D (Attribute)oneAttList.get(i) ;
+        for (Object anOneAttList : oneAttList) {
+            Attribute oneAtt =3D (Attribute) anOneAttList;
             result &=3D two.getAttribute(oneAtt.getName()) !=3D null;
         }
 =

         // check att values
-        for (int i =3D 0; i < oneAttList.size(); i++) {
-            Attribute oneAtt =3D (Attribute)oneAttList.get(i) ;
+        for (Object anOneAttList : oneAttList) {
+            Attribute oneAtt =3D (Attribute) anOneAttList;
             result &=3D two.getAttributeValue(oneAtt.getName()).equals(one=
Att.getValue());
         }
 =


_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list

Reply via email to