commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1033620 - in /commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/operations: AbstractFileOperationProvider.java DefaultFileOperations.java FileOperationProvider.java FileOperations.java
Date Wed, 10 Nov 2010 18:07:39 GMT
Author: sebb
Date: Wed Nov 10 18:07:39 2010
New Revision: 1033620

URL: http://svn.apache.org/viewvc?rev=1033620&view=rev
Log:
Hopefully better implementation of generics for FileOperation classes

Modified:
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/operations/AbstractFileOperationProvider.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/operations/DefaultFileOperations.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/operations/FileOperationProvider.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/operations/FileOperations.java

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/operations/AbstractFileOperationProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/operations/AbstractFileOperationProvider.java?rev=1033620&r1=1033619&r2=1033620&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/operations/AbstractFileOperationProvider.java
(original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/operations/AbstractFileOperationProvider.java
Wed Nov 10 18:07:39 2010
@@ -39,7 +39,7 @@ public abstract class AbstractFileOperat
      * "svn", "svnssh", but not for "file", etc. The Map has scheme as a key and
      * Colleaction of operations that are available for that scheme.
      */
-    private final Collection<Class<?>> operations = new ArrayList<Class<?>>();
+    private final Collection<Class<? extends FileOperation>> operations = new
ArrayList<Class<? extends FileOperation>>();
 
     /**
      * Gather available operations for the specified FileObject and put them into
@@ -55,7 +55,7 @@ public abstract class AbstractFileOperat
      * @throws org.apache.commons.vfs.FileSystemException
      *             if list of operations cannto be retrieved.
      */
-    public final void collectOperations(final Collection<?> operationsList,
+    public final void collectOperations(final Collection<Class<? extends FileOperation>>
operationsList,
             final FileObject file) throws FileSystemException
     {
 
@@ -67,7 +67,7 @@ public abstract class AbstractFileOperat
      * @throws FileSystemException
      */
     protected abstract void doCollectOperations(
-            final Collection<?> availableOperations, final Collection<?> resultList,
+            final Collection<Class<? extends FileOperation>> availableOperations,
final Collection<Class<? extends FileOperation>> resultList,
             final FileObject file) throws FileSystemException;
 
     /**
@@ -79,10 +79,10 @@ public abstract class AbstractFileOperat
      * @throws org.apache.commons.vfs.FileSystemException
      *             if operation cannot be retrieved.
      */
-    public final FileOperation getOperation(FileObject file, Class<?> operationClass)
+    public final FileOperation getOperation(FileObject file, Class<? extends FileOperation>
operationClass)
             throws FileSystemException
     {
-        Class<?> implementation = lookupOperation(operationClass);
+        Class<? extends FileOperation> implementation = lookupOperation(operationClass);
 
         FileOperation operationInstance = instantiateOperation(file, implementation);
 
@@ -96,14 +96,14 @@ public abstract class AbstractFileOperat
      * @throws FileSystemException
      */
     protected abstract FileOperation instantiateOperation(final FileObject file,
-            final Class<?> operationClass) throws FileSystemException;
+            final Class<? extends FileOperation> operationClass) throws FileSystemException;
 
     /**
      *
      * @param operationClass
      * @return never returns null
      */
-    protected final Class<?> lookupOperation(final Class<?> operationClass)
+    protected final Class<? extends FileOperation> lookupOperation(final Class<?
extends FileOperation> operationClass)
             throws FileSystemException
     {
         // check validity of passed class
@@ -113,11 +113,11 @@ public abstract class AbstractFileOperat
         }
 
         // find appropriate class
-        Class<?> foundClass = null;
-        Iterator<Class<?>> iterator = operations.iterator();
+        Class<? extends FileOperation> foundClass = null;
+        Iterator<Class<? extends FileOperation>> iterator = operations.iterator();
         while (iterator.hasNext())
         {
-            Class<?> operation = iterator.next();
+            Class<? extends FileOperation> operation = iterator.next();
             if (operationClass.isAssignableFrom(operation))
             {
                 foundClass = operation;
@@ -138,7 +138,7 @@ public abstract class AbstractFileOperat
      * @param operationClass
      * @throws FileSystemException
      */
-    protected final void addOperation(final Class<?> operationClass)
+    protected final void addOperation(final Class<? extends FileOperation> operationClass)
             throws FileSystemException
     {
         // check validity of passed class

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/operations/DefaultFileOperations.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/operations/DefaultFileOperations.java?rev=1033620&r1=1033619&r2=1033620&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/operations/DefaultFileOperations.java
(original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/operations/DefaultFileOperations.java
Wed Nov 10 18:07:39 2010
@@ -56,7 +56,7 @@ public class DefaultFileOperations imple
      * @throws FileSystemException If an error occurs.
      *
      */
-    public Class<?>[] getOperations() throws FileSystemException
+    public Class<? extends FileOperation>[] getOperations() throws FileSystemException
     {
 
         final String scheme = fileObject.getURL().getProtocol();
@@ -68,7 +68,7 @@ public class DefaultFileOperations imple
             return null;
         }
 
-        final List<Class<?>> operations = new ArrayList<Class<?>>();
+        final List<Class<? extends FileOperation>> operations = new ArrayList<Class<?
extends FileOperation>>();
 
         for (int i = 0; i < providers.length; i++)
         {
@@ -77,7 +77,9 @@ public class DefaultFileOperations imple
             provider.collectOperations(operations, fileObject);
         }
 
-        return operations.toArray(new Class[] {});
+        @SuppressWarnings("unchecked") 
+        Class<? extends FileOperation>[] array = (Class<? extends FileOperation>[])
operations.toArray(new Class<?>[] {});
+        return array;
     }
 
     /**
@@ -86,7 +88,7 @@ public class DefaultFileOperations imple
      * @throws FileSystemException if an error occurs.
      *
      */
-    public FileOperation getOperation(Class<?> operationClass)
+    public FileOperation getOperation(Class<? extends FileOperation> operationClass)
             throws FileSystemException
     {
 
@@ -131,9 +133,9 @@ public class DefaultFileOperations imple
      * @throws FileSystemException if an error occurs.
      *
      */
-    public boolean hasOperation(Class<?> operationClass) throws FileSystemException
+    public boolean hasOperation(Class<? extends FileOperation> operationClass) throws
FileSystemException
     {
-        Class<?>[] operations = getOperations();
+        Class<? extends FileOperation>[] operations = getOperations();
         if (operations == null)
         {
             return false;
@@ -141,7 +143,7 @@ public class DefaultFileOperations imple
 
         for (int i = 0; i < operations.length; i++)
         {
-            Class<?> operation = operations[i];
+            Class<? extends FileOperation> operation = operations[i];
             if (operationClass.isAssignableFrom(operation))
             {
                 return true;

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/operations/FileOperationProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/operations/FileOperationProvider.java?rev=1033620&r1=1033619&r2=1033620&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/operations/FileOperationProvider.java
(original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/operations/FileOperationProvider.java
Wed Nov 10 18:07:39 2010
@@ -45,7 +45,7 @@ public interface FileOperationProvider
      * @throws FileSystemException
      *             if list of operations cannto be retrieved.
      */
-    void collectOperations(final Collection<?> operationsList, final FileObject file)
+    void collectOperations(final Collection<Class<? extends FileOperation>> operationsList,
final FileObject file)
             throws FileSystemException;
 
     /**
@@ -58,6 +58,6 @@ public interface FileOperationProvider
      * @throws FileSystemException
      *             if operation cannot be retrieved.
      */
-    FileOperation getOperation(final FileObject file, final Class<?> operationClass)
+    FileOperation getOperation(final FileObject file, final Class<? extends FileOperation>
operationClass)
             throws FileSystemException;
 }

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/operations/FileOperations.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/operations/FileOperations.java?rev=1033620&r1=1033619&r2=1033620&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/operations/FileOperations.java
(original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/operations/FileOperations.java
Wed Nov 10 18:07:39 2010
@@ -32,19 +32,19 @@ public interface FileOperations
      * @return all operations associated with the fileObject
      * @throws FileSystemException if an error occurs.
      */
-    Class<?>[] getOperations() throws FileSystemException;
+    Class<? extends FileOperation>[] getOperations() throws FileSystemException;
 
     /**
      * @param operationClass the operation Class.
      * @return a operation implementing the given <code>operationClass</code>
      * @throws FileSystemException if an error occus.
      */
-    FileOperation getOperation(Class<?> operationClass) throws FileSystemException;
+    FileOperation getOperation(Class<? extends FileOperation> operationClass) throws
FileSystemException;
 
     /**
      * @param operationClass the operation Class.
      * @return if a operation <code>operationClass</code> is available
      * @throws FileSystemException if an error ocurs.
      */
-    boolean hasOperation(Class<?> operationClass) throws FileSystemException;
+    boolean hasOperation(Class<? extends FileOperation> operationClass) throws FileSystemException;
 }



Mime
View raw message