commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1032388 - in /commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs: FileName.java cache/DefaultFilesCache.java cache/FileSystemAndNameKey.java cache/LRUFilesCache.java provider/AbstractFileName.java
Date Sun, 07 Nov 2010 20:54:29 GMT
Author: sebb
Date: Sun Nov  7 20:54:29 2010
New Revision: 1032388

URL: http://svn.apache.org/viewvc?rev=1032388&view=rev
Log:
Fix up generics

Modified:
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/FileName.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/cache/DefaultFilesCache.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/cache/FileSystemAndNameKey.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/cache/LRUFilesCache.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileName.java

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/FileName.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/FileName.java?rev=1032388&r1=1032387&r2=1032388&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/FileName.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/FileName.java Sun Nov
 7 20:54:29 2010
@@ -24,7 +24,7 @@ package org.apache.commons.vfs;
  * @version $Revision$ $Date$
  * @see FileObject
  */
-public interface FileName extends Comparable
+public interface FileName extends Comparable<FileName>
 {
     /**
      * The separator character used in file paths.

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/cache/DefaultFilesCache.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/cache/DefaultFilesCache.java?rev=1032388&r1=1032387&r2=1032388&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/cache/DefaultFilesCache.java
(original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/cache/DefaultFilesCache.java
Sun Nov  7 20:54:29 2010
@@ -35,32 +35,33 @@ public class DefaultFilesCache extends A
 {
 
     /** The FileSystem cache */
-    private final Map filesystemCache = new HashMap(10);
+    private final Map<FileSystem, Map<FileName, FileObject>> filesystemCache
=
+          new HashMap<FileSystem, Map<FileName, FileObject>>(10);
 
     public void putFile(final FileObject file)
     {
-        Map files = getOrCreateFilesystemCache(file.getFileSystem());
+        Map<FileName, FileObject> files = getOrCreateFilesystemCache(file.getFileSystem());
         files.put(file.getName(), file);
     }
 
     public FileObject getFile(final FileSystem filesystem, final FileName name)
     {
-        Map files = getOrCreateFilesystemCache(filesystem);
-        return (FileObject) files.get(name);
+        Map<FileName, FileObject> files = getOrCreateFilesystemCache(filesystem);
+        return files.get(name);
     }
 
     public void clear(FileSystem filesystem)
     {
-        Map files = getOrCreateFilesystemCache(filesystem);
+        Map<FileName, FileObject> files = getOrCreateFilesystemCache(filesystem);
         files.clear();
     }
 
-    protected Map getOrCreateFilesystemCache(FileSystem filesystem)
+    protected Map<FileName, FileObject> getOrCreateFilesystemCache(FileSystem filesystem)
     {
-        Map files = (Map) filesystemCache.get(filesystem);
+        Map<FileName, FileObject> files = filesystemCache.get(filesystem);
         if (files == null)
         {
-            files = new HashMap();
+            files = new HashMap<FileName, FileObject>();
             filesystemCache.put(filesystem, files);
         }
 
@@ -77,7 +78,7 @@ public class DefaultFilesCache extends A
 
     public void removeFile(FileSystem filesystem, FileName name)
     {
-        Map files = getOrCreateFilesystemCache(filesystem);
+        Map<?, ?> files = getOrCreateFilesystemCache(filesystem);
         files.remove(name);
     }
 

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/cache/FileSystemAndNameKey.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/cache/FileSystemAndNameKey.java?rev=1032388&r1=1032387&r2=1032388&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/cache/FileSystemAndNameKey.java
(original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/cache/FileSystemAndNameKey.java
Sun Nov  7 20:54:29 2010
@@ -26,7 +26,7 @@ import org.apache.commons.vfs.FileSystem
  * @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
  * @version $Revision$ $Date$
  */
-class FileSystemAndNameKey implements Comparable
+class FileSystemAndNameKey implements Comparable<FileSystemAndNameKey>
 {
     /** The FileSystem */
     private final FileSystem fileSystem;
@@ -45,10 +45,8 @@ class FileSystemAndNameKey implements Co
         this.fileName = fileName;
     }
 
-    public int compareTo(Object o)
+    public int compareTo(FileSystemAndNameKey other)
     {
-        FileSystemAndNameKey other = (FileSystemAndNameKey) o;
-
         if (fileSystemId < other.fileSystemId)
         {
             return -1;

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/cache/LRUFilesCache.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/cache/LRUFilesCache.java?rev=1032388&r1=1032387&r2=1032388&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/cache/LRUFilesCache.java
(original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/cache/LRUFilesCache.java
Sun Nov  7 20:54:29 2010
@@ -47,7 +47,8 @@ public class LRUFilesCache extends Abstr
     private final Log log = LogFactory.getLog(LRUFilesCache.class);
 
     /** The FileSystem cache */
-    private final Map filesystemCache = new HashMap(10);
+    private final Map<FileSystem, Map<FileName, FileObject>> filesystemCache
= 
+          new HashMap<FileSystem, Map<FileName, FileObject>>(10);
 
     /** The size of the cache */
     private final int lruSize;
@@ -97,7 +98,7 @@ public class LRUFilesCache extends Abstr
                         VfsLog.warn(getLogger(), log, Messages.getString("vfs.impl/LRUFilesCache-remove-ex.warn"),
e);
                     }
 
-                    Map files = (Map) filesystemCache.get(filesystem);
+                    Map<?, ?> files = filesystemCache.get(filesystem);
                     if (files.size() < 1)
                     {
                         filesystemCache.remove(filesystem);
@@ -133,7 +134,7 @@ public class LRUFilesCache extends Abstr
     {
         synchronized (this)
         {
-            Map files = getOrCreateFilesystemCache(file.getFileSystem());
+            Map<FileName, FileObject> files = getOrCreateFilesystemCache(file.getFileSystem());
 
             // System.err.println(">>> " + files.size() + " put:" + file.toString());
 
@@ -145,12 +146,12 @@ public class LRUFilesCache extends Abstr
     {
         synchronized (this)
         {
-            Map files = getOrCreateFilesystemCache(filesystem);
+            Map<FileName, FileObject> files = getOrCreateFilesystemCache(filesystem);
 
             // FileObject fo = (FileObject) files.get(name);
             // System.err.println(">>> " + files.size() + " get:" + name.toString()
+ " " + fo);
 
-            return (FileObject) files.get(name);
+            return files.get(name);
         }
     }
 
@@ -160,16 +161,16 @@ public class LRUFilesCache extends Abstr
         {
             // System.err.println(">>> clear fs " + filesystem);
 
-            Map files = getOrCreateFilesystemCache(filesystem);
+            Map<FileName, FileObject> files = getOrCreateFilesystemCache(filesystem);
             files.clear();
 
             filesystemCache.remove(filesystem);
         }
     }
 
-    protected Map getOrCreateFilesystemCache(final FileSystem filesystem)
+    protected Map<FileName, FileObject> getOrCreateFilesystemCache(final FileSystem
filesystem)
     {
-        Map files = (Map) filesystemCache.get(filesystem);
+        Map<FileName, FileObject> files = filesystemCache.get(filesystem);
         if (files == null)
         {
             // System.err.println(">>> create fs " + filesystem);
@@ -198,7 +199,7 @@ public class LRUFilesCache extends Abstr
     {
         synchronized (this)
         {
-            Map files = getOrCreateFilesystemCache(filesystem);
+            Map<?, ?> files = getOrCreateFilesystemCache(filesystem);
 
             // System.err.println(">>> " + files.size() + " remove:" + name.toString());
 

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileName.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileName.java?rev=1032388&r1=1032387&r2=1032388&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileName.java
(original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileName.java
Sun Nov  7 20:54:29 2010
@@ -106,7 +106,7 @@ public abstract class AbstractFileName
      * @param obj another abstractfilename
      * @return negative number if less than, 0 if equal, postive if greater than.
      */
-    public int compareTo(Object obj)
+    public int compareTo(FileName obj)
     {
         final AbstractFileName name = (AbstractFileName) obj;
         int ret = getRootURI().compareTo(name.getRootURI());



Mime
View raw message