jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r804224 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystem.java
Date Fri, 14 Aug 2009 13:40:08 GMT
Author: thomasm
Date: Fri Aug 14 13:40:08 2009
New Revision: 804224

URL: http://svn.apache.org/viewvc?rev=804224&view=rev
Log:
JCR-2087 Upgrade to Java 5 as the base platform - use generics

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystem.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystem.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystem.java?rev=804224&r1=804223&r2=804224&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystem.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystem.java
Fri Aug 14 13:40:08 2009
@@ -24,7 +24,6 @@
 import java.io.OutputStream;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 
@@ -36,7 +35,7 @@
  */
 public class MemoryFileSystem implements FileSystem {
 
-    private Map entries = new HashMap();
+    private Map<String, MemoryFileSystemEntry> entries = new HashMap<String, MemoryFileSystemEntry>();
 
     public void close() {
     }
@@ -77,16 +76,13 @@
 
     public void deleteFolder(String folderPath) throws FileSystemException {
         assertIsFolder(folderPath);
-        Set allNames = entries.keySet();
-        Set selectedNames = new HashSet();
-        for (Iterator iter = allNames.iterator(); iter.hasNext();) {
-            String name = (String) iter.next();
+        Set<String> selectedNames = new HashSet<String>();
+        for (String name : entries.keySet()) {
             if (name.equals(folderPath) || name.startsWith(folderPath + SEPARATOR)) {
                 selectedNames.add(name);
             }
         }
-        for (Iterator iter = selectedNames.iterator(); iter.hasNext();) {
-            String name = (String) iter.next();
+        for (String name : selectedNames) {
             entries.remove(name);
         }
     }
@@ -160,7 +156,7 @@
     }
 
     private MemoryFileSystemEntry getEntry(String path) {
-        return ((MemoryFileSystemEntry) entries.get(path));
+        return entries.get(path);
     }
 
     private void assertExistence(String path) throws FileSystemException {
@@ -191,15 +187,13 @@
         if (folderPath.equals("/")) {
             folderPath = "";
         }
-        Set allNames = entries.keySet();
-        Set selectedNames = new HashSet();
-        for (Iterator iter = allNames.iterator(); iter.hasNext();) {
-            String name = (String) iter.next();
+        Set<String> selectedNames = new HashSet<String>();
+        for (String name : entries.keySet()) {
             if (name.matches(folderPath + "/[^/]*") && !name.equals("/")) {
                 selectedNames.add(name.substring(folderPath.length() + 1));
             }
         }
-        return (String[]) selectedNames.toArray(new String[selectedNames.size()]);
+        return selectedNames.toArray(new String[selectedNames.size()]);
     }
 
     public String[] listFiles(String folderPath) {
@@ -215,13 +209,13 @@
         if (folderPath.equals("/")) {
             folderPath = "";
         }
-        Set result = new HashSet();
-        for (int i = 0; i < names.length; i++) {
-            if (getEntry(folderPath + "/" + names[i]).isFolder() == isFolder) {
-                result.add(names[i]);
+        Set<String> result = new HashSet<String>();
+        for (String n : names) {
+            if (getEntry(folderPath + "/" + n).isFolder() == isFolder) {
+                result.add(n);
             }
         }
-        return (String[]) result.toArray(new String[result.size()]);
+        return result.toArray(new String[result.size()]);
     }
 
 }



Mime
View raw message