commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ima...@apache.org
Subject svn commit: r154336 - in jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs: AllFileSelector.java FileDepthSelector.java FileFilter.java FileFilterSelector.java Resources.properties
Date Fri, 18 Feb 2005 19:12:38 GMT
Author: imario
Date: Fri Feb 18 11:12:36 2005
New Revision: 154336

URL: http://svn.apache.org/viewcvs?view=rev&rev=154336
Log:
removed "final" from AllFileSelector and FileDepthSelector.

added FileFilterSelector to mimic the java.io.FileFilter interface. This will traverse only
the direct children of the given folder. You have to override the "accept" method.
One could override the accept() method or pass a FileFilter instance

Added:
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/FileFilter.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/FileFilterSelector.java
Modified:
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/AllFileSelector.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/FileDepthSelector.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/Resources.properties

Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/AllFileSelector.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/AllFileSelector.java?view=diff&r1=154335&r2=154336
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/AllFileSelector.java
(original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/AllFileSelector.java
Fri Feb 18 11:12:36 2005
@@ -21,7 +21,7 @@
  * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  * @version $Revision: 1.2 $ $Date: 2002/07/05 04:08:17 $
  */
-public final class AllFileSelector
+public class AllFileSelector
     implements FileSelector
 {
     /**

Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/FileDepthSelector.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/FileDepthSelector.java?view=diff&r1=154335&r2=154336
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/FileDepthSelector.java
(original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/FileDepthSelector.java
Fri Feb 18 11:12:36 2005
@@ -21,7 +21,7 @@
  * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  * @version $Revision: 1.2 $ $Date: 2002/07/05 04:08:17 $
  */
-public final class FileDepthSelector
+public class FileDepthSelector
     implements FileSelector
 {
     private final int minDepth;

Added: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/FileFilter.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/FileFilter.java?view=auto&rev=154336
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/FileFilter.java (added)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/FileFilter.java Fri
Feb 18 11:12:36 2005
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2002, 2003,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs;
+
+/**
+ * This interface is used to select files when traversing the direct children of the base.
+ *
+ * @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
+ */
+public interface FileFilter
+{
+    /**
+     * Determines if a file or folder should be selected.
+     *
+     * @param fileInfo the file or folder to select.
+     * @return true if the file should be selected.
+     */
+    public abstract boolean accept(final FileSelectInfo fileInfo);
+}

Added: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/FileFilterSelector.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/FileFilterSelector.java?view=auto&rev=154336
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/FileFilterSelector.java
(added)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/FileFilterSelector.java
Fri Feb 18 11:12:36 2005
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2002, 2003,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs;
+
+import org.apache.commons.vfs.util.Messages;
+
+/**
+ * A {@link org.apache.commons.vfs.FileSelector} that selects all children of the given fileObject.<br
/>
+ * This is to mimic the {@link java.io.FileFilter} interface
+ *
+ * @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
+ */
+public class FileFilterSelector extends FileDepthSelector
+{
+    private FileFilter fileFilter;
+
+    public FileFilterSelector()
+    {
+        super(1, 1);
+    }
+
+    public FileFilterSelector(FileFilter fileFilter)
+    {
+        this();
+        this.fileFilter = fileFilter;
+    }
+
+    /**
+     * Determines if a file or folder should be selected.
+     */
+    public boolean includeFile(final FileSelectInfo fileInfo)
+    {
+        if (!super.includeFile(fileInfo))
+        {
+            return false;
+        }
+
+        return accept(fileInfo);
+    }
+
+    public boolean accept(final FileSelectInfo fileInfo)
+    {
+        if (fileFilter != null)
+        {
+            return fileFilter.accept(fileInfo);
+        }
+
+        throw new IllegalArgumentException(Messages.getString("vfs.selectors/filefilter.missing.error"));
+    }
+}

Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/Resources.properties
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/Resources.properties?view=diff&r1=154335&r2=154336
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/Resources.properties
(original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/Resources.properties
Fri Feb 18 11:12:36 2005
@@ -229,4 +229,7 @@
 vfs.tasks/sync.src-file-no-exist.warn=Source file "{0}" does not exist.
 vfs.tasks/sync.duplicate-source-files.warn=Multiple source files for destination file "{0}".
 vfs.tasks/delete.no-source-files.error=No files to delete specified.
-vfs.tasks/mkdir.create-folder.info=Creating directory "{0}".
\ No newline at end of file
+vfs.tasks/mkdir.create-folder.info=Creating directory "{0}".
+
+# Selectors
+vfs.selectors/filefilter.missing.error=Configure a fileFilter or override accept();
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message