You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by ra...@apache.org on 2010/09/23 08:04:34 UTC
svn commit: r1000332 [2/27] - in
/synapse/branches/commons-vfs-2-synapse-2.0: ./ core/ core/src/
core/src/main/ core/src/main/java/ core/src/main/java/org/
core/src/main/java/org/apache/ core/src/main/java/org/apache/commons/
core/src/main/java/org/apa...
Added: synapse/branches/commons-vfs-2-synapse-2.0/core/pom.xml
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/pom.xml?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/pom.xml (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/pom.xml Thu Sep 23 06:04:21 2010
@@ -0,0 +1,331 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <name>Commons VFS Core</name>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-vfs</artifactId>
+ <version>2.0-21092010</version>
+ <description>VFS is a Virtual File System library.</description>
+
+ <parent>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-vfs-project</artifactId>
+ <version>2.0-21092010</version>
+ <relativePath>../</relativePath>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>commons-net</groupId>
+ <artifactId>commons-net</artifactId>
+ <version>2.0</version>
+ <optional>true</optional>
+ </dependency>
+ <!--TODO:Revert to [compress] if/when released
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-compress</artifactId>
+ <optional>true</optional>
+ </dependency-->
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>jackrabbit-webdav</artifactId>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>com.jcraft</groupId>
+ <artifactId>jsch</artifactId>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <properties>
+ <vfs.parent.dir>${basedir}/..</vfs.parent.dir>
+ </properties>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/java</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </resource>
+ <resource>
+ <directory>..</directory>
+ <targetPath>META-INF</targetPath>
+ <includes>
+ <include>NOTICE.txt</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>..</directory>
+ <targetPath>META-INF</targetPath>
+ <includes>
+ <include>LICENSE.txt</include>
+ </includes>
+ </resource>
+ </resources>
+
+ <!-- include NOTICE/LICENSE in generated test jar -->
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ </testResource>
+ <testResource>
+ <directory>..</directory>
+ <targetPath>META-INF</targetPath>
+ <includes>
+ <include>NOTICE.txt</include>
+ </includes>
+ </testResource>
+ <testResource>
+ <directory>..</directory>
+ <targetPath>META-INF</targetPath>
+ <includes>
+ <include>LICENSE.txt</include>
+ </includes>
+ </testResource>
+ </testResources>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>process-test-classes</phase>
+ <configuration>
+ <tasks>
+ <move todir="${project.build.testOutputDirectory}/test-data/code"
+ failonerror="false">
+ <fileset dir="${project.build.testOutputDirectory}/code"/>
+ </move>
+
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <!-- surfire do not honor suite(), see MSUREFIRE-131 why our tests wont work with maven 2 -->
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemProperties>
+ <property>
+ <name>test.basedir</name>
+ <value>target/test-classes/test-data</value>
+ </property>
+ <property>
+ <name>test.basedir.res</name>
+ <value>test-data</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+ <profiles>
+ <profile>
+ <id>webdav</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.5.6</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.5.6</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemProperties>
+ <property>
+ <name>test.basedir</name>
+ <value>target/test-classes/test-data</value>
+ </property>
+ <property>
+ <name>test.basedir.res</name>
+ <value>test-data</value>
+ </property>
+ <property>
+ <name>test.webdav.uri</name>
+ <value>${test.webdav.uri}</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>ftp</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemProperties>
+ <property>
+ <name>test.basedir</name>
+ <value>target/test-classes/test-data</value>
+ </property>
+ <property>
+ <name>test.basedir.res</name>
+ <value>test-data</value>
+ </property>
+ <property>
+ <name>test.ftp.uri</name>
+ <value>${test.ftp.uri}</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>sftp</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemProperties>
+ <property>
+ <name>test.basedir</name>
+ <value>target/test-classes/test-data</value>
+ </property>
+ <property>
+ <name>test.basedir.res</name>
+ <value>test-data</value>
+ </property>
+ <property>
+ <name>test.sftp.uri</name>
+ <value>${test.sftp.uri}</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>http</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemProperties>
+ <property>
+ <name>test.basedir</name>
+ <value>target/test-classes/test-data</value>
+ </property>
+ <property>
+ <name>test.basedir.res</name>
+ <value>test-data</value>
+ </property>
+ <property>
+ <name>test.http.uri</name>
+ <value>${test.http.uri}</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/AllFileSelector.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/AllFileSelector.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/AllFileSelector.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/AllFileSelector.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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;
+
+/**
+ * A {@link FileSelector} that selects everything.
+ *
+ * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
+ * @version $Revision: 763740 $ $Date: 2009-04-09 22:52:31 +0530 (Thu, 09 Apr 2009) $
+ */
+public class AllFileSelector
+ implements FileSelector
+{
+ /**
+ * Determines if a file or folder should be selected.
+ * @param fileInfo The file selection information.
+ * @return true if the file should be selected, false otherwise.
+ */
+ public boolean includeFile(final FileSelectInfo fileInfo)
+ {
+ return true;
+ }
+
+ /**
+ * Determines whether a folder should be traversed.
+ * @param fileInfo The file selection information.
+ * @return true if descendents should be traversed, fase otherwise.
+ */
+ public boolean traverseDescendents(final FileSelectInfo fileInfo)
+ {
+ return true;
+ }
+}
Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/CacheStrategy.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/CacheStrategy.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/CacheStrategy.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/CacheStrategy.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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;
+
+/**
+ * An enumerated type to deal with the various cache strategies.
+ *
+ * @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
+ * @version $Revision: 804548 $ $Date: 2009-08-16 07:42:32 +0530 (Sun, 16 Aug 2009) $
+ */
+public final class CacheStrategy
+{
+ /**
+ * Deal with cached data manually. Call {@link FileObject#refresh()} to refresh the object data.
+ */
+ public static final CacheStrategy MANUAL = new CacheStrategy("manual");
+
+ /**
+ * Refresh the data every time you request a file from {@link FileSystemManager#resolveFile}.
+ */
+ public static final CacheStrategy ON_RESOLVE = new CacheStrategy("onresolve");
+
+ /**
+ * Refresh the data every time you call a method on the fileObject.
+ * You'll use this only if you really need the latest info as this setting is a major performance
+ * loss.
+ */
+ public static final CacheStrategy ON_CALL = new CacheStrategy("oncall");
+
+ /**
+ * Cache strategy name
+ */
+ private final String name;
+
+ private CacheStrategy(final String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * Returns the name of the scope.
+ * @return the name of the scope.
+ */
+ public String toString()
+ {
+ return name;
+ }
+
+ /**
+ * Returns the name of the scope.
+ * @return the name of the scope.
+ */
+ public String getName()
+ {
+ return name;
+ }
+}
Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/Capability.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/Capability.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/Capability.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/Capability.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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;
+
+/**
+ * An enumerated type representing the capabilities of files and file systems.
+ *
+ * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
+ * @version $Revision: 804548 $ $Date: 2009-08-16 07:42:32 +0530 (Sun, 16 Aug 2009) $
+ */
+public final class Capability
+{
+ /**
+ * File content can be read.
+ */
+ public static final Capability READ_CONTENT = new Capability("READ_CONTENT");
+
+ /**
+ * File content can be written.
+ */
+ public static final Capability WRITE_CONTENT = new Capability("WRITE_CONTENT");
+
+ /**
+ * File content can be read in random mode.<br>
+ */
+ public static final Capability RANDOM_ACCESS_READ = new Capability("RANDOM_ACCESS_READ");
+
+ /**
+ * File content can be written in random mode.<br>
+ */
+ public static final Capability RANDOM_ACCESS_WRITE = new Capability("RANDOM_ACCESS_WRITE");
+
+ /**
+ * File content can be appended.
+ */
+ public static final Capability APPEND_CONTENT = new Capability("APPEND_CONTENT");
+
+ /**
+ * File attributes are supported.
+ */
+ public static final Capability ATTRIBUTES = new Capability("ATTRIBUTES");
+
+ /**
+ * File last-modified time is supported.
+ */
+ public static final Capability LAST_MODIFIED = new Capability("LAST_MODIFIED");
+
+ /**
+ * File get last-modified time is supported.
+ */
+ public static final Capability GET_LAST_MODIFIED = new Capability("GET_LAST_MODIFIED");
+
+ /**
+ * File set last-modified time is supported.
+ */
+ public static final Capability SET_LAST_MODIFIED_FILE = new Capability("SET_LAST_MODIFIED_FILE");
+
+ /**
+ * folder set last-modified time is supported.
+ */
+ public static final Capability SET_LAST_MODIFIED_FOLDER = new Capability("SET_LAST_MODIFIED_FOLDER");
+
+ /**
+ * File content signing is supported.
+ */
+ public static final Capability SIGNING = new Capability("SIGNING");
+
+ /**
+ * Files can be created.
+ */
+ public static final Capability CREATE = new Capability("CREATE");
+
+ /**
+ * Files can be deleted.
+ */
+ public static final Capability DELETE = new Capability("DELETE");
+
+ /**
+ * Files can be renamed.
+ */
+ public static final Capability RENAME = new Capability("RENAME");
+
+ /**
+ * The file type can be determined.
+ */
+ public static final Capability GET_TYPE = new Capability("GET_TYPE");
+
+ /**
+ * Children of files can be listed.
+ */
+ public static final Capability LIST_CHILDREN = new Capability("LIST_CHILDREN");
+
+ /**
+ * URI are supported. Files without this capability use URI that do not
+ * globally and uniquely identify the file.
+ */
+ public static final Capability URI = new Capability("URI");
+
+ /**
+ * File system attributes are supported.
+ */
+ public static final Capability FS_ATTRIBUTES = new Capability("FS_ATTRIBUTE");
+
+ /**
+ * Junctions are supported.
+ */
+ public static final Capability JUNCTIONS = new Capability("JUNCTIONS");
+
+ /**
+ * The set of attributes defined by the Jar manifest specification are
+ * supported. The attributes aren't necessarily stored in a manifest file.
+ */
+ public static final Capability MANIFEST_ATTRIBUTES = new Capability("MANIFEST_ATTRIBUTES");
+
+ /**
+ * The provider itself do not provide a filesystem. It simply resolves a full name
+ * and dispatches the request back to the filesystemmanager.<br>
+ * A provider with this capability cant tell much about the capabilities about the
+ * finally used filesystem in advance.
+ */
+ public static final Capability DISPATCHER = new Capability("DISPATCHER");
+
+ /**
+ * A compressed filesystem is a filesystem which use compression.
+ */
+ public static final Capability COMPRESS = new Capability("COMPRESS");
+
+ /**
+ * A virtual filesystem can be an archive like tar or zip.
+ */
+ public static final Capability VIRTUAL = new Capability("VIRTUAL");
+
+ /**
+ * Provides directories which allows you to read its content through
+ * {@link org.apache.commons.vfs.FileContent#getInputStream()}.
+ */
+ public static final Capability DIRECTORY_READ_CONTENT = new Capability("DIRECTORY_READ_CONTENT");
+
+ /**
+ * The Capability name
+ */
+ private final String name;
+
+ private Capability(final String name)
+ {
+ this.name = name;
+ }
+
+ public String toString()
+ {
+ return name;
+ }
+}
Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileChangeEvent.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileChangeEvent.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileChangeEvent.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileChangeEvent.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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;
+
+/**
+ * An event fired when a file is changed.
+ *
+ * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
+ * @version $Revision: 763740 $ $Date: 2009-04-09 22:52:31 +0530 (Thu, 09 Apr 2009) $
+ */
+public class FileChangeEvent
+{
+ /**
+ * The file object
+ */
+ private final FileObject file;
+
+ public FileChangeEvent(final FileObject file)
+ {
+ this.file = file;
+ }
+
+ /**
+ * Returns the file that changed.
+ * @return The FileObject that was changed.
+ */
+ public FileObject getFile()
+ {
+ return file;
+ }
+}
Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileContent.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileContent.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileContent.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileContent.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,238 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.RandomAccessMode;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.security.cert.Certificate;
+import java.util.Map;
+
+/**
+ * Represents the data content of a file.
+ * <p/>
+ * <p>To read from a file, use the <code>InputStream</code> returned by
+ * {@link #getInputStream}.
+ * <p/>
+ * <p>To write to a file, use the <code>OutputStream</code> returned by
+ * {@link #getOutputStream} method. This will create the file, and the parent
+ * folder, if necessary.
+ * <p/>
+ * <p>A file may have multiple InputStreams open at the sametime.
+ * <p/>
+ *
+ * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
+ * @version $Revision: 804548 $ $Date: 2009-08-16 07:42:32 +0530 (Sun, 16 Aug 2009) $
+ * @see FileObject#getContent
+ */
+public interface FileContent
+{
+ /**
+ * Returns the file which this is the content of.
+ * @return The FileObject this is the content of.
+ */
+ FileObject getFile();
+
+ /**
+ * Determines the size of the file, in bytes.
+ *
+ * @return The size of the file, in bytes.
+ * @throws FileSystemException If the file does not exist, or is being written to, or on error
+ * determining the size.
+ */
+ long getSize() throws FileSystemException;
+
+ /**
+ * Determines the last-modified timestamp of the file.
+ *
+ * @return The last-modified timestamp.
+ * @throws FileSystemException If the file does not exist, or is being written to, or on error
+ * determining the last-modified timestamp.
+ */
+ long getLastModifiedTime() throws FileSystemException;
+
+ /**
+ * Sets the last-modified timestamp of the file. Creates the file if
+ * it does not exist.
+ *
+ * @param modTime The time to set the last-modified timestamp to.
+ * @throws FileSystemException If the file is read-only, or is being written to, or on error
+ * setting the last-modified timestamp.
+ */
+ void setLastModifiedTime(long modTime) throws FileSystemException;
+
+ /**
+ * Checks if an attribute of the file's content exists.
+ *
+ * @param attrName The name of the attribute.
+ * @return true if the attribute exists, false otherwise.
+ * @throws FileSystemException If the file does not exist, or does not support
+ * attributes.
+ */
+ boolean hasAttribute(String attrName)
+ throws FileSystemException;
+
+ /**
+ * Returns a read-only map of this file's attributes.
+ * @return The attribute Map.
+ * @throws FileSystemException If the file does not exist, or does not support attributes.
+ */
+ Map getAttributes() throws FileSystemException;
+
+ /**
+ * Lists the attributes of the file's content.
+ *
+ * @return The names of the attributes. Never returns null;
+ * @throws FileSystemException If the file does not exist, or does not support attributes.
+ */
+ String[] getAttributeNames() throws FileSystemException;
+
+ /**
+ * Gets the value of an attribute of the file's content.
+ *
+ * @param attrName The name of the attribute. Attribute names are case insensitive.
+ * @return The value of the attribute, or null if the attribute value is
+ * unknown.
+ * @throws FileSystemException If the file does not exist, or does not support attributes.
+ */
+ Object getAttribute(String attrName) throws FileSystemException;
+
+ /**
+ * Sets the value of an attribute of the file's content. Creates the
+ * file if it does not exist.
+ *
+ * @param attrName The name of the attribute.
+ * @param value The value of the attribute.
+ * @throws FileSystemException If the file does not exist, or is read-only, or does not support
+ * attributes, or on error setting the attribute.
+ */
+ void setAttribute(String attrName, Object value)
+ throws FileSystemException;
+
+ /**
+ * Removes the value of an attribute of the file's content.
+ *
+ * @param attrName The name of the attribute.
+ * @throws FileSystemException If the file does not exist, or is read-only, or does not support
+ * attributes, or on error removing the attribute.
+ */
+ void removeAttribute(String attrName)
+ throws FileSystemException;
+
+ /**
+ * Retrieves the certificates if any used to sign this file or folder.
+ *
+ * @return The certificates, or an empty array if there are no certificates or
+ * the file does not support signing.
+ * @throws FileSystemException If the file does not exist, or is being written.
+ */
+ Certificate[] getCertificates() throws FileSystemException;
+
+ /**
+ * Returns an input stream for reading the file's content.
+ * <p/>
+ * <p>There may only be a single input or output stream open for the
+ * file at any time.
+ *
+ * @return An input stream to read the file's content from. The input
+ * stream is buffered, so there is no need to wrap it in a
+ * <code>BufferedInputStream</code>.
+ * @throws FileSystemException If the file does not exist, or is being read, or is being written,
+ * or on error opening the stream.
+ */
+ InputStream getInputStream() throws FileSystemException;
+
+ /**
+ * Returns an output stream for writing the file's content.
+ * <p/>
+ * If the file does not exist, this method creates it, and the parent
+ * folder, if necessary. If the file does exist, it is replaced with
+ * whatever is written to the output stream.
+ * <p/>
+ * <p>There may only be a single input or output stream open for the
+ * file at any time.
+ *
+ * @return An output stream to write the file's content to. The stream is
+ * buffered, so there is no need to wrap it in a
+ * <code>BufferedOutputStream</code>.
+ * @throws FileSystemException If the file is read-only, or is being read, or is being written,
+ * or on error opening the stream.
+ */
+ OutputStream getOutputStream() throws FileSystemException;
+
+ /**
+ * Returns an stream for reading/writing the file's content.
+ * <p/>
+ * If the file does not exist, and you use one of the write* methods,
+ * this method creates it, and the parent folder, if necessary.
+ * If the file does exist, parts of the file are replaced with whatever is written
+ * at a given position.
+ * <p/>
+ * <p>There may only be a single input or output stream open for the
+ * file at any time.
+ *
+ * @param mode The mode to use to access the file.
+ * @return the stream for reading and writing the file's content.
+ * @throws FileSystemException If the file is read-only, or is being read, or is being written,
+ * or on error opening the stream.
+ */
+ RandomAccessContent getRandomAccessContent(final RandomAccessMode mode) throws FileSystemException;
+
+ /**
+ * Returns an output stream for writing the file's content.
+ * <p/>
+ * If the file does not exist, this method creates it, and the parent
+ * folder, if necessary. If the file does exist, it is replaced with
+ * whatever is written to the output stream.
+ * <p/>
+ * <p>There may only be a single input or output stream open for the
+ * file at any time.
+ *
+ * @param bAppend true if you would like to append to the file
+ * @return An output stream to write the file's content to. The stream is
+ * buffered, so there is no need to wrap it in a
+ * <code>BufferedOutputStream</code>.
+ * @throws FileSystemException If the file is read-only, or is being read, or is being written,
+ * or on error opening the stream.
+ */
+ OutputStream getOutputStream(boolean bAppend) throws FileSystemException;
+
+ /**
+ * Closes all resources used by the content, including any open stream.
+ * Commits pending changes to the file.
+ * <p/>
+ * <p>This method is a hint to the implementation that it can release
+ * resources. This object can continue to be used after calling this
+ * method.
+ * @throws FileSystemException if an error occurs closing the file.
+ */
+ void close() throws FileSystemException;
+
+ /**
+ * get the content info. e.g. type, encoding, ...
+ * @return the FileContentInfo
+ * @throws FileSystemException if an error occurs.
+ */
+ FileContentInfo getContentInfo() throws FileSystemException;
+
+ /**
+ * check if this file has open streams.
+ * @return true if the file is open, false otherwise.
+ */
+ boolean isOpen();
+}
Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileContentInfo.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileContentInfo.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileContentInfo.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileContentInfo.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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;
+
+/**
+ * Interface to the content info.
+ *
+ * @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
+ * @version $Revision: 804548 $ $Date: 2009-08-16 07:42:32 +0530 (Sun, 16 Aug 2009) $
+ */
+public interface FileContentInfo
+{
+ /**
+ * the content type.
+ * @return The file content type.
+ */
+ String getContentType();
+
+ /**
+ * the content encoding.
+ * @return The file content encoding.
+ */
+ String getContentEncoding();
+}
Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileContentInfoFactory.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileContentInfoFactory.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileContentInfoFactory.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileContentInfoFactory.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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;
+
+/**
+ * Create a class which is able to determine the content-info for the given content.
+ *
+ * @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
+ * @version $Revision: 804548 $ $Date: 2009-08-16 07:42:32 +0530 (Sun, 16 Aug 2009) $
+ */
+public interface FileContentInfoFactory
+{
+ FileContentInfo create(FileContent fileContent) throws FileSystemException;
+}
Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileDepthSelector.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileDepthSelector.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileDepthSelector.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileDepthSelector.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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;
+
+/**
+ * A {@link FileSelector} that selects all files in a particular depth range.
+ *
+ * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
+ * @version $Revision: 763740 $ $Date: 2009-04-09 22:52:31 +0530 (Thu, 09 Apr 2009) $
+ */
+public class FileDepthSelector
+ implements FileSelector
+{
+ /**
+ * The minimum depth
+ */
+ private final int minDepth;
+
+ /**
+ * The maximum depth
+ */
+ private final int maxDepth;
+
+ public FileDepthSelector(int minDepth, int maxDepth)
+ {
+ this.minDepth = minDepth;
+ this.maxDepth = maxDepth;
+ }
+
+ /**
+ * Determines if a file or folder should be selected.
+ * @param fileInfo The file selection information
+ * @return true if the file or folder should be included, false otherwise.
+ */
+ public boolean includeFile(final FileSelectInfo fileInfo)
+ {
+ final int depth = fileInfo.getDepth();
+ return minDepth <= depth && depth <= maxDepth;
+ }
+
+ /**
+ * Determines whether a folder should be traversed.
+ * @param fileInfo The file selection information
+ * @return true if the file or folder should be traversed, false otherwise.
+ */
+ public boolean traverseDescendents(final FileSelectInfo fileInfo)
+ {
+ return fileInfo.getDepth() < maxDepth;
+ }
+}
Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileFilter.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileFilter.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileFilter.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileFilter.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+ boolean accept(final FileSelectInfo fileInfo);
+}
Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileFilterSelector.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileFilterSelector.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileFilterSelector.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileFilterSelector.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+{
+ /**
+ * The FileFilter.
+ */
+ 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.
+ * @param fileInfo The file selection information.
+ * @return true if the file or folder should be included, false otherwise.
+ */
+ public boolean includeFile(final FileSelectInfo fileInfo)
+ {
+ if (!super.includeFile(fileInfo))
+ {
+ return false;
+ }
+
+ return accept(fileInfo);
+ }
+
+ /**
+ * Determines whether the file should be selected.
+ * @param fileInfo The file selection information.
+ * @return true if the file should be selected, false otherwise.
+ */
+ public boolean accept(final FileSelectInfo fileInfo)
+ {
+ if (fileFilter != null)
+ {
+ return fileFilter.accept(fileInfo);
+ }
+
+ throw new IllegalArgumentException(Messages.getString("vfs.selectors/filefilter.missing.error"));
+ }
+}
Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileListener.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileListener.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileListener.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileListener.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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;
+
+/**
+ * Listens for changes to a file.
+ *
+ * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
+ * @version $Revision: 763740 $ $Date: 2009-04-09 22:52:31 +0530 (Thu, 09 Apr 2009) $
+ */
+public interface FileListener
+{
+ /**
+ * Called when a file is created.
+ * @param event The FileChangeEvent.
+ * @throws Exception if an error occurs.
+ */
+ void fileCreated(FileChangeEvent event) throws Exception;
+
+ /**
+ * Called when a file is deleted.
+ * @param event The FileChangeEvent.
+ * @throws Exception if an error occurs.
+ */
+ void fileDeleted(FileChangeEvent event) throws Exception;
+
+ /**
+ * Called when a file is changed.<br />
+ * This will only happen if you monitor the file using {@link FileMonitor}.
+ * @param event The FileChangeEvent.
+ * @throws Exception if an error occurs.
+ */
+ void fileChanged(FileChangeEvent event) throws Exception;
+}
Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileMonitor.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileMonitor.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileMonitor.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileMonitor.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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;
+
+/**
+ * FileMonitor interface.
+ *
+ * @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
+ * @version $Revision: 804548 $ $Date: 2009-08-16 07:42:32 +0530 (Sun, 16 Aug 2009) $
+ */
+public interface FileMonitor
+{
+ /**
+ * Adds a file to be monitored.
+ * @param file The FileObject to monitor.
+ */
+ void addFile(final FileObject file);
+
+ /**
+ * Removes a file from being monitored.
+ * @param file The FileObject to stop monitoring.
+ */
+ void removeFile(final FileObject file);
+}
Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileName.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileName.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileName.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileName.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,206 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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;
+
+/**
+ * Represents a file name. File names are immutable, and work correctly as
+ * keys in hash tables.
+ *
+ * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
+ * @version $Revision: 804548 $ $Date: 2009-08-16 07:42:32 +0530 (Sun, 16 Aug 2009) $
+ * @see FileObject
+ */
+public interface FileName extends Comparable
+{
+ /**
+ * The separator character used in file paths.
+ */
+ char SEPARATOR_CHAR = '/';
+
+ /**
+ * The separator used in file paths.
+ */
+ String SEPARATOR = "/";
+
+ /**
+ * The absolute path of the root of a file system.
+ */
+ String ROOT_PATH = "/";
+
+ /**
+ * Returns the base name of this file. The base name is the last element
+ * of the file name. For example the base name of
+ * <code>/somefolder/somefile</code> is <code>somefile</code>.
+ * <p/>
+ * <p>The root file of a file system has an empty base name.
+ *
+ * @return The base name. Never returns null.
+ */
+ String getBaseName();
+
+ /**
+ * Returns the absolute path of this file, within its file system. This
+ * path is normalised, so that <code>.</code> and <code>..</code> elements
+ * have been removed. Also, the path only contains <code>/</code> as its
+ * separator character. The path always starts with <code>/</code>
+ * <p/>
+ * <p>The root of a file system has <code>/</code> as its absolute path.
+ *
+ * @return The path. Never returns null.
+ */
+ String getPath();
+
+ /**
+ * Returns the absolute path of this file, within its file system. This
+ * path is normalised, so that <code>.</code> and <code>..</code> elements
+ * have been removed. Also, the path only contains <code>/</code> as its
+ * separator character. The path always starts with <code>/</code>
+ * <p/>
+ * <p>The root of a file system has <code>/</code> as its absolute path.
+ * <p/>
+ * In contrast to {@link #getPath()} the path is decoded i.e. all %nn stuff
+ * replaced by its character.
+ *
+ * @return The path. Never returns null.
+ * @throws FileSystemException if the path is not correctly encoded
+ */
+ String getPathDecoded() throws FileSystemException;
+
+ /**
+ * Returns the extension of this file name.
+ *
+ * @return The extension. Returns an empty string if the name has no
+ * extension.
+ */
+ String getExtension();
+
+ /**
+ * Returns the depth of this file name, within its file system. The depth
+ * of the root of a file system is 0. The depth of any other file is
+ * 1 + the depth of its parent.
+ * @return The depth of this file name.
+ */
+ int getDepth();
+
+ /**
+ * Returns the URI scheme of this file.
+ * @return The URI scheme of this file.
+ */
+ String getScheme();
+
+ /**
+ * Returns the absolute URI of this file.
+ * @return the absolute URI of this file.
+ */
+ String getURI();
+
+ /**
+ * Returns the root URI of the file system this file belongs to.
+ * @return the root URI.
+ */
+ String getRootURI();
+
+ /**
+ * find the root of the filesystem.
+ * @return the file system root.
+ */
+ FileName getRoot();
+
+ /**
+ * Returns the file name of the parent of this file. The root of a
+ * file system has no parent.
+ *
+ * @return A {@link FileName} object representing the parent name. Returns
+ * null for the root of a file system.
+ */
+ FileName getParent();
+
+ /**
+ * Resolves a name, relative to this file name. Equivalent to calling
+ * <code>resolveName( path, NameScope.FILE_SYSTEM )</code>.
+ *
+ * @param name The name to resolve.
+ * @return A {@link FileName} object representing the resolved file name.
+ * @throws FileSystemException If the name is invalid.
+ */
+ // FileName resolveName(String name) throws FileSystemException;
+
+ /**
+ * Resolves a name, relative to this file name. Refer to {@link NameScope}
+ * for a description of how names are resolved.
+ *
+ * @param name The name to resolve.
+ * @param scope The scope to use when resolving the name.
+ * @return A {@link FileName} object representing the resolved file name.
+ * @throws FileSystemException If the name is invalid.
+ */
+ // FileName resolveName(String name, NameScope scope)
+ // throws FileSystemException;
+
+ /**
+ * Converts a file name to a relative name, relative to this file name.
+ *
+ * @param name The name to convert to a relative path.
+ * @return The relative name.
+ * @throws FileSystemException On error.
+ */
+ String getRelativeName(FileName name) throws FileSystemException;
+
+ /**
+ * Determines if another file name is an ancestor of this file name.
+ * @param ancestor The FileName to check.
+ * @return true if another file name is an ancestor of this file name.
+ */
+ boolean isAncestor(FileName ancestor);
+
+ /**
+ * Determines if another file name is a descendent of this file name.
+ * @param descendent the FileName to check.
+ * @return true if the other FileName is a descendent of this file name.
+ */
+ boolean isDescendent(FileName descendent);
+
+ /**
+ * Determines if another file name is a descendent of this file name.
+ * @param descendent the FileName to check.
+ * @param nameScope the NameScope of the FileName.
+ * @return true if the other FileName is a descendent of this file name.
+ */
+ boolean isDescendent(FileName descendent, NameScope nameScope);
+
+ /**
+ * Returns the requested or current type of this name. <br />
+ * <p>
+ * The "requested" type is the one determined during resolving the name. <br/>
+ * In this case the name is a {@link FileType#FOLDER} if it ends with an "/" else
+ * it will be a {@link FileType#FILE}<br/>
+ * </p>
+ * <p>
+ * Once attached it will be changed to reflect the real type of this resource.
+ * </p>
+ *
+ * @return {@link FileType#FOLDER} or {@link FileType#FILE}
+ */
+ FileType getType();
+
+ /**
+ * returns a "friendly path", this is a path without a password.<br />
+ * This path can not be used to resolve the path again
+ * @return the friendly URI as a String.
+ */
+ String getFriendlyURI();
+}
Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileNotFolderException.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileNotFolderException.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileNotFolderException.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileNotFolderException.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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;
+
+/**
+ * delivers a file-not-folder exception which happens when trying to issue {@link FileObject#getChildren()} on a file.
+ * @author <a href="http://commons.apache.org/vfs/team-list.html">Commons VFS team</a>
+ */
+public class FileNotFolderException extends FileSystemException
+{
+ public FileNotFolderException(final Object info0)
+ {
+ super("vfs.provider/list-children-not-folder.error", info0);
+ }
+
+ public FileNotFolderException(Object info0, Throwable throwable)
+ {
+ super("vfs.provider/list-children-not-folder.error", info0, throwable);
+ }
+}
Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileNotFoundException.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileNotFoundException.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileNotFoundException.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileNotFoundException.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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;
+
+/**
+ * delivers a file-not-found exception.
+ * @author <a href="http://commons.apache.org/vfs/team-list.html">Commons VFS team</a>
+ */
+public class FileNotFoundException extends FileSystemException
+{
+ public FileNotFoundException(final Object info0)
+ {
+ super("vfs.provider/read-not-file.error", info0);
+ }
+
+ public FileNotFoundException(Object info0, Throwable throwable)
+ {
+ super("vfs.provider/read-not-file.error", info0, throwable);
+ }
+}
Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileObject.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileObject.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileObject.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileObject.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,343 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 java.net.URL;
+import java.util.List;
+
+import org.apache.commons.vfs.operations.FileOperations;
+
+/**
+ * Represents a file, and is used to access the content and
+ * structure of the file.
+ * <p/>
+ * <p>Files are arranged in a hierarchy. Each hierachy forms a
+ * <i>file system</i>. A file system represents things like a local OS
+ * file system, a windows share, an HTTP server, or the contents of a Zip file.
+ * <p/>
+ * <p>There are two types of files: <i>Folders</i>, which contain other files,
+ * and <i>normal files</i>, which contain data, or <i>content</i>. A folder may
+ * not have any content, and a normal file cannot contain other files.
+ * <p/>
+ * <h4>File Naming</h4>
+ * <p/>
+ * <p>TODO - write this.
+ * <p/>
+ * <h4>Reading and Writing a File</h4>
+ * <p/>
+ * <p>Reading and writing a file, and all other operations on the file's
+ * <i>content</i>, is done using the {@link FileContent} object returned
+ * by {@link #getContent}.
+ * <p/>
+ * <h4>Creating and Deleting a File</h4>
+ * <p/>
+ * <p>A file is created using either {@link #createFolder}, {@link #createFile},
+ * or by writing to the file using one of the {@link FileContent} methods.
+ * <p/>
+ * <p>A file is deleted using {@link #delete}. Recursive deletion can be
+ * done using {@link #delete(FileSelector)}.
+ * <p/>
+ * <h4>Finding Files</h4>
+ * <p/>
+ * <p>Other files in the <i>same</i> file system as this file can be found
+ * using:
+ * <ul>
+ * <li>{@link #resolveFile} to find another file relative to this file.
+ * <li>{@link #getChildren} and {@link #getChild} to find the children of this file.
+ * <li>{@link #getParent} to find the folder containing this file.
+ * <li>{@link #getFileSystem} to find another file in the same file system.
+ * </ul>
+ * <p/>
+ * <p>To find files in another file system, use a {@link FileSystemManager}.
+ *
+ * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
+ * @version $Revision: 804548 $ $Date: 2009-08-16 07:42:32 +0530 (Sun, 16 Aug 2009) $
+ * @see FileSystemManager
+ * @see FileContent
+ * @see FileName
+ */
+public interface FileObject
+{
+ /**
+ * Returns the name of this file.
+ * @return the FileName.
+ */
+ FileName getName();
+
+ /**
+ * Returns a URL representing this file.
+ * @return the URL for the file.
+ * @throws FileSystemException if an error occurs.
+ */
+ URL getURL() throws FileSystemException;
+
+ /**
+ * Determines if this file exists.
+ *
+ * @return <code>true</code> if this file exists, <code>false</code> if not.
+ * @throws FileSystemException On error determining if this file exists.
+ */
+ boolean exists() throws FileSystemException;
+
+ /**
+ * Determines if this file is hidden.
+ *
+ * @return <code>true</code> if this file is hidden, <code>false</code> if not.
+ * @throws FileSystemException On error determining if this file exists.
+ */
+ boolean isHidden() throws FileSystemException;
+
+ /**
+ * Determines if this file can be read.
+ *
+ * @return <code>true</code> if this file is readable, <code>false</code> if not.
+ * @throws FileSystemException On error determining if this file exists.
+ */
+ boolean isReadable() throws FileSystemException;
+
+ /**
+ * Determines if this file can be written to.
+ *
+ * @return <code>true</code> if this file is writeable, <code>false</code> if not.
+ * @throws FileSystemException On error determining if this file exists.
+ */
+ boolean isWriteable() throws FileSystemException;
+
+ /**
+ * Returns this file's type.
+ *
+ * @return One of the {@link FileType} constants. Never returns null.
+ * @throws FileSystemException On error determining the file's type.
+ */
+ FileType getType() throws FileSystemException;
+
+ /**
+ * Returns the folder that contains this file.
+ *
+ * @return The folder that contains this file. Returns null if this file is
+ * the root of a file system.
+ * @throws FileSystemException On error finding the file's parent.
+ */
+ FileObject getParent() throws FileSystemException;
+
+ /**
+ * Returns the file system that contains this file.
+ *
+ * @return The file system.
+ */
+ FileSystem getFileSystem();
+
+ /**
+ * Lists the children of this file.
+ *
+ * @return An array containing the children of this file. The array is
+ * unordered. If the file does not have any children, a zero-length
+ * array is returned. This method never returns null.
+ * @throws FileSystemException If this file does not exist, or is not a folder, or on error
+ * listing this file's children.
+ */
+ FileObject[] getChildren() throws FileSystemException;
+
+ /**
+ * Returns a child of this file. Note that this method returns <code>null</code>
+ * when the child does not exist. This differs from
+ * {@link #resolveFile( String, NameScope)} which never returns null.
+ *
+ * @param name The name of the child.
+ * @return The child, or null if there is no such child.
+ * @throws FileSystemException If this file does not exist, or is not a folder, or on error
+ * determining this file's children.
+ */
+ FileObject getChild(String name) throws FileSystemException;
+
+ /**
+ * Finds a file, relative to this file. Refer to {@link NameScope}
+ * for a description of how names are resolved in the different scopes.
+ *
+ * @param name The name to resolve.
+ * @param scope the NameScope for the file.
+ * @return The file.
+ * @throws FileSystemException On error parsing the path, or on error finding the file.
+ */
+ FileObject resolveFile(String name, NameScope scope)
+ throws FileSystemException;
+
+ /**
+ * Finds a file, relative to this file. Equivalent to calling
+ * <code>resolveFile( path, NameScope.FILE_SYSTEM )</code>.
+ *
+ * @param path The path of the file to locate. Can either be a relative
+ * path or an absolute path.
+ * @return The file.
+ * @throws FileSystemException On error parsing the path, or on error finding the file.
+ */
+ FileObject resolveFile(String path) throws FileSystemException;
+
+ /**
+ * Finds the set of matching descendents of this file, in depthwise order.
+ *
+ * @param selector The selector to use to select matching files.
+ * @return The matching files. The files are returned in depthwise order
+ * (that is, a child appears in the list before its parent).
+ * @throws FileSystemException if an error occurs.
+ */
+ FileObject[] findFiles(FileSelector selector) throws FileSystemException;
+
+ /**
+ * Finds the set of matching descendents of this file.
+ *
+ * @param selector the selector used to determine if the file should be selected
+ * @param depthwise controls the ordering in the list. e.g. deepest first
+ * @param selected container for selected files. list needs not to be empty.
+ * @throws FileSystemException if an error occurs.
+ */
+ void findFiles(FileSelector selector, boolean depthwise, List selected) throws FileSystemException;
+
+ /**
+ * Deletes this file. Does nothing if this file does not exist of if it is a
+ * folder that has children. Does not delete any descendents of this file,
+ * use {@link #delete(FileSelector)} for that.
+ *
+ * @return true if this object has been deleted
+ * @throws FileSystemException If this file is a non-empty folder, or if this file is read-only,
+ * or on error deleteing this file.
+ */
+ boolean delete() throws FileSystemException;
+
+ /**
+ * Deletes all descendents of this file that match a selector. Does
+ * nothing if this file does not exist.
+ * <p/>
+ * <p>This method is not transactional. If it fails and throws an
+ * exception, this file will potentially only be partially deleted.
+ *
+ * @param selector The selector to use to select which files to delete.
+ * @return the number of deleted objects
+ * @throws FileSystemException If this file or one of its descendents is read-only, or on error
+ * deleting this file or one of its descendents.
+ */
+ int delete(FileSelector selector) throws FileSystemException;
+
+ /**
+ * Creates this folder, if it does not exist. Also creates any ancestor
+ * folders which do not exist. This method does nothing if the folder
+ * already exists.
+ *
+ * @throws FileSystemException If the folder already exists with the wrong type, or the parent
+ * folder is read-only, or on error creating this folder or one of
+ * its ancestors.
+ */
+ void createFolder() throws FileSystemException;
+
+ /**
+ * Creates this file, if it does not exist. Also creates any ancestor
+ * folders which do not exist. This method does nothing if the file
+ * already exists and is a file.
+ *
+ * @throws FileSystemException If the file already exists with the wrong type, or the parent
+ * folder is read-only, or on error creating this file or one of
+ * its ancestors.
+ */
+ void createFile() throws FileSystemException;
+
+ /**
+ * Copies another file, and all its descendents, to this file.
+ * <p/>
+ * If this file does not exist, it is created. Its parent folder is also
+ * created, if necessary. If this file does exist, it is deleted first.
+ * <p/>
+ * <p>This method is not transactional. If it fails and throws an
+ * exception, this file will potentially only be partially copied.
+ *
+ * @param srcFile The source file to copy.
+ * @param selector The selector to use to select which files to copy.
+ * @throws FileSystemException If this file is read-only, or if the source file does not exist,
+ * or on error copying the file.
+ */
+ void copyFrom(FileObject srcFile, FileSelector selector)
+ throws FileSystemException;
+
+ /**
+ * Move this file.
+ * <p>If the destFile exists, it is deleted first</p>
+ *
+ * @param destFile the New filename.
+ * @throws FileSystemException If this file is read-only, or if the source file does not exist,
+ * or on error copying the file.
+ */
+ void moveTo(FileObject destFile)
+ throws FileSystemException;
+
+ /**
+ * Queries the file if it is possible to rename it to newfile.
+ *
+ * @param newfile the new file(-name)
+ * @return true it this is the case
+ */
+ boolean canRenameTo(FileObject newfile);
+
+ /**
+ * Returns this file's content. The {@link FileContent} returned by this
+ * method can be used to read and write the content of the file.
+ * <p/>
+ * <p>This method can be called if the file does not exist, and
+ * the returned {@link FileContent} can be used to create the file
+ * by writing its content.
+ *
+ * @return This file's content.
+ * @throws FileSystemException On error getting this file's content.
+ */
+ FileContent getContent() throws FileSystemException;
+
+ /**
+ * Closes this file, and its content. This method is a hint to the
+ * implementation that it can release any resources associated with
+ * the file.
+ * <p/>
+ * <p>The file object can continue to be used after this method is called.
+ *
+ * @throws FileSystemException On error closing the file.
+ * @see FileContent#close
+ */
+ void close() throws FileSystemException;
+
+ /**
+ * This will prepare the fileObject to get resynchronized with the underlaying filesystem if required.
+ * @throws FileSystemException if an error occurs.
+ */
+ void refresh() throws FileSystemException;
+
+ /**
+ * check if the fileObject is attaced.
+ * @return true if the FileObject is attached.
+ */
+ boolean isAttached();
+
+ /**
+ * check if someone reads/write to this file.
+ * @return true if the file content is open.
+ */
+ boolean isContentOpen();
+
+
+ // --- OPERATIONS --
+ /**
+ * @return FileOperations interface that provides access to the operations API.
+ * @throws FileSystemException if an error occurs.
+ */
+ FileOperations getFileOperations() throws FileSystemException;
+}
Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileSelectInfo.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileSelectInfo.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileSelectInfo.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileSelectInfo.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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;
+
+/**
+ * Information about a file, that is used to select files during the
+ * traversal of a hierarchy.
+ *
+ * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
+ * @version $Revision: 764356 $ $Date: 2009-04-13 09:36:01 +0530 (Mon, 13 Apr 2009) $
+ * @todo Rename this interface, as it is used by both FileSelector and FileVisitor.
+ */
+public interface FileSelectInfo
+{
+ /**
+ * Returns the base folder of the traversal.
+ * @return FileObject representing the base folder.
+ */
+ FileObject getBaseFolder();
+
+ /**
+ * Returns the file (or folder) to be considered.
+ * @return The FileObject.
+ */
+ FileObject getFile();
+
+ /**
+ * Returns the depth of the file relative to the base folder.
+ * @return The depth of the file relative to the base folder.
+ */
+ int getDepth();
+}
Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileSelector.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileSelector.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileSelector.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/FileSelector.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 a file hierarchy.
+ *
+ * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
+ * @version $Revision: 764356 $ $Date: 2009-04-13 09:36:01 +0530 (Mon, 13 Apr 2009) $
+ * @see Selectors
+ */
+public interface FileSelector
+{
+ /**
+ * Determines if a file or folder should be selected. This method is
+ * called in depthwise order (that is, it is called for the children
+ * of a folder before it is called for the folder itself).
+ *
+ * @param fileInfo the file or folder to select.
+ * @return true if the file should be selected.
+ * @throws Exception if an error occurs.
+ */
+ boolean includeFile(FileSelectInfo fileInfo)
+ throws Exception;
+
+ /**
+ * Determines whether a folder should be traversed. If this method returns
+ * true, {@link #includeFile} is called for each of the children of
+ * the folder, and each of the child folders is recursively traversed.
+ * <p/>
+ * <p>This method is called on a folder before {@link #includeFile}
+ * is called.
+ *
+ * @param fileInfo the file or folder to select.
+ * @return true if the folder should be traversed.
+ * @throws Exception if an error occurs.
+ */
+ boolean traverseDescendents(FileSelectInfo fileInfo)
+ throws Exception;
+}