Author: ggregory
Date: Tue Oct 11 19:40:24 2011
New Revision: 1182050
URL: http://svn.apache.org/viewvc?rev=1182050&view=rev
Log:
[VFS-367] Add API FileObject isFile().
Modified:
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/FileName.java
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/impl/DefaultFileSystemManager.java
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/AbstractFileName.java
Modified:
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/FileName.java
URL:
http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/FileName.java?rev=1182050&r1=1182049&r2=1182050&view=diff
==============================================================================
---
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/FileName.java
(original)
+++
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/FileName.java
Tue Oct 11 19:40:24 2011
@@ -182,6 +182,16 @@ public interface FileName extends Compar
boolean isDescendent(FileName descendent, NameScope nameScope);
/**
+ * Checks if this file name is a name for a regular file.
+ *
+ * @return true if this file name is a name for a regular file.
+ * @throws FileSystemException if an error occurs.
+ * @see #getType()
+ * @see FileType#FILE
+ */
+ public boolean isFile() throws FileSystemException;
+
+ /**
* Returns the requested or current type of this name. <br />
* <p>
* The "requested" type is the one determined during resolving the name.
<br/>
Modified:
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/impl/DefaultFileSystemManager.java
URL:
http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/impl/DefaultFileSystemManager.java?rev=1182050&r1=1182049&r2=1182050&view=diff
==============================================================================
---
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/impl/DefaultFileSystemManager.java
(original)
+++
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/impl/DefaultFileSystemManager.java
Tue Oct 11 19:40:24 2011
@@ -665,7 +665,7 @@ public class DefaultFileSystemManager im
{
final FileObject realBaseFile;
if (baseFile != null && VFS.isUriStyle()
- && baseFile.getName().getType() == FileType.FILE)
+ && baseFile.getName().isFile())
{
realBaseFile = baseFile.getParent();
}
@@ -751,7 +751,7 @@ public class DefaultFileSystemManager im
final NameScope scope) throws FileSystemException
{
final FileName realBase;
- if (base != null && VFS.isUriStyle() && base.getType() ==
FileType.FILE)
+ if (base != null && VFS.isUriStyle() && base.isFile())
{
realBase = base.getParent();
}
Modified:
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/AbstractFileName.java
URL:
http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/AbstractFileName.java?rev=1182050&r1=1182049&r2=1182050&view=diff
==============================================================================
---
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/AbstractFileName.java
(original)
+++
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/AbstractFileName.java
Tue Oct 11 19:40:24 2011
@@ -447,6 +447,19 @@ public abstract class AbstractFileName i
}
/**
+ * Checks if this file name is a name for a regular file by using its type.
+ *
+ * @return true if this file is a regular file.
+ * @throws FileSystemException
+ * @see #getType()
+ * @see FileType#FILE
+ */
+ public boolean isFile() throws FileSystemException {
+ // Use equals instead of == to avoid any class loader worries.
+ return FileType.FILE.equals(this.getType());
+ }
+
+ /**
* Returns the requested or current type of this name. <br />
* <p>
* The "requested" type is the one determined during resolving the name.
<br/>