commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1032379 - /commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/
Date Sun, 07 Nov 2010 20:18:14 GMT
Author: sebb
Date: Sun Nov  7 20:18:14 2010
New Revision: 1032379

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

Modified:
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileObject.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileProvider.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileSystem.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractVfsContainer.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DefaultFileContent.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DelegateFileObject.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/FileContentThreadData.java

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileObject.java?rev=1032379&r1=1032378&r2=1032379&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileObject.java
(original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileObject.java
Sun Nov  7 20:18:14 2010
@@ -84,7 +84,7 @@ public abstract class AbstractFileObject
     // go into the global files cache
     // private FileObject[] children;
     private FileName[] children;
-    private List objects;
+    private List<Object> objects;
 
     /**
      * FileServices instance.
@@ -292,10 +292,10 @@ public abstract class AbstractFileObject
      * <p/>
      * This implementation always returns an empty map.
      */
-    protected Map doGetAttributes()
+    protected Map<String, Object> doGetAttributes()
         throws Exception
     {
-        return Collections.EMPTY_MAP;
+        return Collections.emptyMap();
     }
 
     /**
@@ -425,9 +425,9 @@ public abstract class AbstractFileObject
         final StringBuffer buf = new StringBuffer();
         try
         {
-            return (URL) AccessController.doPrivileged(new PrivilegedExceptionAction()
+            return AccessController.doPrivileged(new PrivilegedExceptionAction<URL>()
             {
-                public Object run() throws MalformedURLException
+                public URL run() throws MalformedURLException
                 {
                     return new URL(UriParser.extractScheme(name.getURI(), buf), "", -1,
                         buf.toString(), new DefaultURLStreamHandler(fs.getContext(), fs.getFileSystemOptions()));
@@ -856,14 +856,14 @@ public abstract class AbstractFileObject
         */
 
         // Locate all the files to delete
-        ArrayList files = new ArrayList();
+        ArrayList<FileObject> files = new ArrayList<FileObject>();
         findFiles(selector, true, files);
 
         // Delete 'em
         final int count = files.size();
         for (int i = 0; i < count; i++)
         {
-            final AbstractFileObject file = FileObjectUtils.getAbstractFileObject((FileObject)
files.get(i));
+            final AbstractFileObject file = FileObjectUtils.getAbstractFileObject(files.get(i));
             // file.attach();
 
             // VFS-210: It seems impossible to me that findFiles will return a list with
hidden files/directories
@@ -995,14 +995,14 @@ public abstract class AbstractFileObject
         */
 
         // Locate the files to copy across
-        final ArrayList files = new ArrayList();
+        final ArrayList<FileObject> files = new ArrayList<FileObject>();
         file.findFiles(selector, false, files);
 
         // Copy everything across
         final int count = files.size();
         for (int i = 0; i < count; i++)
         {
-            final FileObject srcFile = (FileObject) files.get(i);
+            final FileObject srcFile = files.get(i);
 
             // Determine the destination file
             final String relPath = file.getName().getRelativeName(srcFile.getName());
@@ -1165,9 +1165,9 @@ public abstract class AbstractFileObject
             return null;
         }
 
-        final ArrayList list = new ArrayList();
+        final ArrayList<FileObject> list = new ArrayList<FileObject>();
         findFiles(selector, true, list);
-        return (FileObject[]) list.toArray(new FileObject[list.size()]);
+        return list.toArray(new FileObject[list.size()]);
     }
 
     /**
@@ -1597,7 +1597,7 @@ public abstract class AbstractFileObject
             if (childName != null && newType != null)
             {
                 // TODO - figure out if children[] can be replaced by list
-                ArrayList list = new ArrayList(Arrays.asList(children));
+                ArrayList<FileName> list = new ArrayList<FileName>(Arrays.asList(children));
                 if (newType.equals(FileType.IMAGINARY))
                 {
                     list.remove(childName);
@@ -1647,7 +1647,7 @@ public abstract class AbstractFileObject
      */
     public void findFiles(final FileSelector selector,
                           final boolean depthwise,
-                          final List selected) throws FileSystemException
+                          final List<FileObject> selected) throws FileSystemException
     {
         try
         {
@@ -1673,7 +1673,7 @@ public abstract class AbstractFileObject
     private static void traverse(final DefaultFileSelectorInfo fileInfo,
                                  final FileSelector selector,
                                  final boolean depthwise,
-                                 final List selected)
+                                 final List<FileObject> selected)
         throws Exception
     {
         // Check the file itself
@@ -1776,11 +1776,12 @@ public abstract class AbstractFileObject
      *
      * @param strongRef The Object to add.
      */
+    // TODO should this be a FileObject?
     public void holdObject(Object strongRef)
     {
         if (objects == null)
         {
-            objects = new ArrayList(INITIAL_LISTSZ);
+            objects = new ArrayList<Object>(INITIAL_LISTSZ);
         }
         objects.add(strongRef);
     }

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileProvider.java?rev=1032379&r1=1032378&r2=1032379&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileProvider.java
(original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileProvider.java
Sun Nov  7 20:18:14 2010
@@ -43,7 +43,7 @@ public abstract class AbstractFileProvid
      * FileSystem object.
      */
     // private final Map fileSystems = new HashMap();
-    private final Map fileSystems = new TreeMap();
+    private final Map<FileSystemKey, FileSystem> fileSystems = new TreeMap<FileSystemKey,
FileSystem>();
 
     private FileNameParser parser;
 
@@ -121,7 +121,7 @@ public abstract class AbstractFileProvid
 
         synchronized (this)
         {
-            return (FileSystem) fileSystems.get(treeKey);
+            return fileSystems.get(treeKey);
         }
     }
 

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileSystem.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileSystem.java?rev=1032379&r1=1032378&r2=1032379&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileSystem.java
(original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractFileSystem.java
Sun Nov  7 20:18:14 2010
@@ -83,7 +83,7 @@ public abstract class AbstractFileSystem
     /**
      * Map from FileName to an ArrayList of listeners for that file.
      */
-    private final Map listenerMap = new HashMap();
+    private final Map<FileName, ArrayList<FileListener>> listenerMap = new HashMap<FileName,
ArrayList<FileListener>>();
 
     /**
      * FileSystemOptions used for configuration
@@ -502,10 +502,10 @@ public abstract class AbstractFileSystem
     {
         synchronized (listenerMap)
         {
-            ArrayList listeners = (ArrayList) listenerMap.get(file.getName());
+            ArrayList<FileListener> listeners = listenerMap.get(file.getName());
             if (listeners == null)
             {
-                listeners = new ArrayList();
+                listeners = new ArrayList<FileListener>();
                 listenerMap.put(file.getName(), listeners);
             }
             listeners.add(listener);
@@ -522,7 +522,7 @@ public abstract class AbstractFileSystem
     {
         synchronized (listenerMap)
         {
-            final ArrayList listeners = (ArrayList) listenerMap.get(file.getName());
+            final ArrayList<?> listeners = listenerMap.get(file.getName());
             if (listeners != null)
             {
                 listeners.remove(listener);
@@ -585,10 +585,10 @@ public abstract class AbstractFileSystem
 
         synchronized (listenerMap)
         {
-            final ArrayList listeners = (ArrayList) listenerMap.get(file.getName());
+            final ArrayList<?> listeners = listenerMap.get(file.getName());
             if (listeners != null)
             {
-                fileListeners = (FileListener[]) listeners.toArray(new FileListener[listeners.size()]);
+                fileListeners = listeners.toArray(new FileListener[listeners.size()]);
             }
         }
 

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractVfsContainer.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractVfsContainer.java?rev=1032379&r1=1032378&r2=1032379&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractVfsContainer.java
(original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/AbstractVfsContainer.java
Sun Nov  7 20:18:14 2010
@@ -32,7 +32,7 @@ public abstract class AbstractVfsContain
     /**
      * The components contained by this component.
      */
-    private final ArrayList components = new ArrayList();
+    private final ArrayList<Object> components = new ArrayList<Object>();
 
     /**
      * Adds a sub-component to this component.  If the sub-component implements

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DefaultFileContent.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DefaultFileContent.java?rev=1032379&r1=1032378&r2=1032379&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DefaultFileContent.java
(original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DefaultFileContent.java
Sun Nov  7 20:18:14 2010
@@ -54,12 +54,12 @@ public final class DefaultFileContent im
     static final int STATE_OPENED = 1;
 
     private final AbstractFileObject file;
-    private Map attrs;
-    private Map roAttrs;
+    private Map<String, Object> attrs;
+    private Map<String, Object> roAttrs;
     private FileContentInfo fileContentInfo;
     private final FileContentInfoFactory fileContentInfoFactory;
 
-    private final ThreadLocal threadData = new ThreadLocal();
+    private final ThreadLocal<FileContentThreadData> threadData = new ThreadLocal<FileContentThreadData>();
     private boolean resetAttributes;
 
     /**
@@ -75,7 +75,7 @@ public final class DefaultFileContent im
 
     private FileContentThreadData getThreadData()
     {
-        FileContentThreadData data = (FileContentThreadData) this.threadData.get();
+        FileContentThreadData data = this.threadData.get();
         if (data == null)
         {
             data = new FileContentThreadData();
@@ -226,7 +226,7 @@ public final class DefaultFileContent im
      * @return a Map of the file's attributes.
      * @throws FileSystemException if an error occurs.
      */
-    public Map getAttributes() throws FileSystemException
+    public Map<String, Object> getAttributes() throws FileSystemException
     {
         if (!file.getType().hasAttributes())
         {
@@ -268,8 +268,8 @@ public final class DefaultFileContent im
     public String[] getAttributeNames() throws FileSystemException
     {
         getAttributes();
-        final Set names = attrs.keySet();
-        return (String[]) names.toArray(new String[names.size()]);
+        final Set<String> names = attrs.keySet();
+        return names.toArray(new String[names.size()]);
     }
 
     /**
@@ -587,12 +587,12 @@ public final class DefaultFileContent im
         extends MonitorInputStream
     {
         // avoid gc
-        private final FileObject file;
+        private final FileObject _file;
 
         FileContentInputStream(final FileObject file, final InputStream instr)
         {
             super(instr);
-            this.file = file;
+            this._file = file;
         }
 
         /**
@@ -607,7 +607,7 @@ public final class DefaultFileContent im
             }
             catch (final IOException e)
             {
-                throw new FileSystemException("vfs.provider/close-instr.error", file, e);
+                throw new FileSystemException("vfs.provider/close-instr.error", _file, e);
             }
         }
 
@@ -634,13 +634,15 @@ public final class DefaultFileContent im
     private final class FileRandomAccessContent extends MonitorRandomAccessContent
     {
         // avoid gc
-        private final FileObject file;
+        @SuppressWarnings("unused")
+        private final FileObject _file;
+        @SuppressWarnings("unused")
         private final RandomAccessContent content;
 
         FileRandomAccessContent(final FileObject file, final RandomAccessContent content)
         {
             super(content);
-            this.file = file;
+            this._file = file;
             this.content = content;
         }
 
@@ -667,12 +669,12 @@ public final class DefaultFileContent im
     final class FileContentOutputStream extends MonitorOutputStream
     {
         // avoid gc
-        private final FileObject file;
+        private final FileObject _file;
 
         FileContentOutputStream(final FileObject file, final OutputStream outstr)
         {
             super(outstr);
-            this.file = file;
+            this._file = file;
         }
 
         /**
@@ -687,7 +689,7 @@ public final class DefaultFileContent im
             }
             catch (final IOException e)
             {
-                throw new FileSystemException("vfs.provider/close-outstr.error", file, e);
+                throw new FileSystemException("vfs.provider/close-outstr.error", _file, e);
             }
         }
 
@@ -709,7 +711,7 @@ public final class DefaultFileContent im
                 }
                 catch (Exception e)
                 {
-                    throw new FileSystemException("vfs.provider/close-outstr.error", file,
e);
+                    throw new FileSystemException("vfs.provider/close-outstr.error", _file,
e);
                 }
             }
         }

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DelegateFileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DelegateFileObject.java?rev=1032379&r1=1032378&r2=1032379&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DelegateFileObject.java
(original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/DelegateFileObject.java
Sun Nov  7 20:18:14 2010
@@ -48,7 +48,7 @@ public class DelegateFileObject
     implements FileListener
 {
     private FileObject file;
-    private final Set children = new HashSet();
+    private final Set<String> children = new HashSet<String>();
     private boolean ignoreEvent;
 
     public DelegateFileObject(final FileName name,
@@ -222,7 +222,7 @@ public class DelegateFileObject
         }
         else
         {
-            return (String[]) children.toArray(new String[children.size()]);
+            return children.toArray(new String[children.size()]);
         }
     }
 
@@ -274,7 +274,7 @@ public class DelegateFileObject
      * Returns the attributes of this file.
      */
     @Override
-    protected Map doGetAttributes()
+    protected Map<String, Object> doGetAttributes()
         throws Exception
     {
         return file.getContent().getAttributes();

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/FileContentThreadData.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/FileContentThreadData.java?rev=1032379&r1=1032378&r2=1032379&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/FileContentThreadData.java
(original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/FileContentThreadData.java
Sun Nov  7 20:18:14 2010
@@ -30,8 +30,8 @@ class FileContentThreadData
 {
     // private int state = DefaultFileContent.STATE_CLOSED;
 
-    private final ArrayList instrs = new ArrayList();
-    private final ArrayList rastrs = new ArrayList();
+    private final ArrayList<InputStream> instrs = new ArrayList<InputStream>();
+    private final ArrayList<RandomAccessContent> rastrs = new ArrayList<RandomAccessContent>();
     private DefaultFileContent.FileContentOutputStream outstr;
 
     FileContentThreadData()



Mime
View raw message