Sort members.
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/DefaultLocalFileProvider.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/DefaultLocalFileProvider.java
index ac18609..5c2dbe2 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/DefaultLocalFileProvider.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/DefaultLocalFileProvider.java
@@ -57,14 +57,27 @@
}
/**
- * Determines if a name is an absolute file name.
- *
- * @param name The file name.
- * @return true if the name is absolute, false otherwise.
+ * Creates the file system.
*/
@Override
- public boolean isAbsoluteLocalName(final String name) {
- return ((LocalFileNameParser) getFileNameParser()).isAbsoluteName(name);
+ protected FileSystem doCreateFileSystem(final FileName name, final FileSystemOptions fileSystemOptions)
+ throws FileSystemException {
+ // Create the file system
+ final LocalFileName rootName = (LocalFileName) name;
+ return new LocalFileSystem(rootName, rootName.getRootFile(), fileSystemOptions);
+ }
+
+ /**
+ * Finds a local file.
+ *
+ * @param file The File to locate.
+ * @return the located FileObject.
+ * @throws FileSystemException if an error occurs.
+ */
+ @Override
+ public FileObject findLocalFile(final File file) throws FileSystemException {
+ return findLocalFile(UriParser.encode(file.getAbsolutePath()));
+ // return findLocalFile(file.getAbsolutePath());
}
/**
@@ -84,32 +97,19 @@
return findFile(fileName, null);
}
- /**
- * Finds a local file.
- *
- * @param file The File to locate.
- * @return the located FileObject.
- * @throws FileSystemException if an error occurs.
- */
- @Override
- public FileObject findLocalFile(final File file) throws FileSystemException {
- return findLocalFile(UriParser.encode(file.getAbsolutePath()));
- // return findLocalFile(file.getAbsolutePath());
- }
-
- /**
- * Creates the file system.
- */
- @Override
- protected FileSystem doCreateFileSystem(final FileName name, final FileSystemOptions fileSystemOptions)
- throws FileSystemException {
- // Create the file system
- final LocalFileName rootName = (LocalFileName) name;
- return new LocalFileSystem(rootName, rootName.getRootFile(), fileSystemOptions);
- }
-
@Override
public Collection<Capability> getCapabilities() {
return capabilities;
}
+
+ /**
+ * Determines if a name is an absolute file name.
+ *
+ * @param name The file name.
+ * @return true if the name is absolute, false otherwise.
+ */
+ @Override
+ public boolean isAbsoluteLocalName(final String name) {
+ return ((LocalFileNameParser) getFileNameParser()).isAbsoluteName(name);
+ }
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/GenericFileNameParser.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/GenericFileNameParser.java
index 2498f7f..3cdf9d9 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/GenericFileNameParser.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/GenericFileNameParser.java
@@ -37,6 +37,16 @@
return INSTANCE;
}
+ /*
+ * ... this is why whe need this: here the rootFilename can only be "/" (see above) put this "/" is also in the
+ * pathname so its of no value for the LocalFileName instance
+ */
+ @Override
+ protected FileName createFileName(final String scheme, final String rootFile, final String path,
+ final FileType type) {
+ return new LocalFileName(scheme, "", path, type);
+ }
+
/**
* Pops the root prefix off a URI, which has had the scheme removed.
*/
@@ -52,14 +62,4 @@
// do not strip the separator, BUT also return it ...
return "/";
}
-
- /*
- * ... this is why whe need this: here the rootFilename can only be "/" (see above) put this "/" is also in the
- * pathname so its of no value for the LocalFileName instance
- */
- @Override
- protected FileName createFileName(final String scheme, final String rootFile, final String path,
- final FileType type) {
- return new LocalFileName(scheme, "", path, type);
- }
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFile.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFile.java
index 94eb6c2..d9f6c1d 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFile.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFile.java
@@ -199,14 +199,6 @@
}
/**
- * Determines if this file can be written to.
- */
- @Override
- protected boolean doIsWriteable() throws FileSystemException {
- return file.canWrite();
- }
-
- /**
* Determines if this file is a symbolic link.
* @since 2.4
*/
@@ -216,6 +208,14 @@
}
/**
+ * Determines if this file can be written to.
+ */
+ @Override
+ protected boolean doIsWriteable() throws FileSystemException {
+ return file.canWrite();
+ }
+
+ /**
* Returns the children of the file.
*/
@Override
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileName.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileName.java
index fe479dd..ff86c02 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileName.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileName.java
@@ -35,12 +35,13 @@
}
/**
- * Returns the root file for this file.
- *
- * @return The root file name.
+ * Builds the root URI for this file name.
*/
- public String getRootFile() {
- return rootFile;
+ @Override
+ protected void appendRootUri(final StringBuilder buffer, final boolean addPassword) {
+ buffer.append(getScheme());
+ buffer.append("://");
+ buffer.append(rootFile);
}
/**
@@ -56,6 +57,15 @@
}
/**
+ * Returns the root file for this file.
+ *
+ * @return The root file name.
+ */
+ public String getRootFile() {
+ return rootFile;
+ }
+
+ /**
* Returns the decoded URI of the file.
*
* @return the FileName as a URI.
@@ -68,14 +78,4 @@
return super.getURI();
}
}
-
- /**
- * Builds the root URI for this file name.
- */
- @Override
- protected void appendRootUri(final StringBuilder buffer, final boolean addPassword) {
- buffer.append(getScheme());
- buffer.append("://");
- buffer.append(rootFile);
- }
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileNameParser.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileNameParser.java
index 44c609c..b012932 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileNameParser.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileNameParser.java
@@ -30,6 +30,26 @@
*/
public abstract class LocalFileNameParser extends AbstractFileNameParser {
+ protected abstract FileName createFileName(String scheme, final String rootFile, final String path,
+ final FileType type);
+
+ /**
+ * Pops the root prefix off a URI, which has had the scheme removed.
+ *
+ * @param name the URI to modify.
+ * @param uri the whole URI for error reporting.
+ * @return the root prefix extracted.
+ * @throws FileSystemException if an error occurs.
+ */
+ protected abstract String extractRootPrefix(final String uri, final StringBuilder name) throws FileSystemException;
+
+ private String[] getSchemes(final VfsComponentContext context, final FileName base, final String uri) {
+ if (context == null) {
+ return new String[] { base != null ? base.getScheme() : URI.create(uri).getScheme() };
+ }
+ return context.getFileSystemManager().getSchemes();
+ }
+
/**
* Determines if a name is an absolute file name.
*
@@ -48,16 +68,6 @@
}
}
- /**
- * Pops the root prefix off a URI, which has had the scheme removed.
- *
- * @param name the URI to modify.
- * @param uri the whole URI for error reporting.
- * @return the root prefix extracted.
- * @throws FileSystemException if an error occurs.
- */
- protected abstract String extractRootPrefix(final String uri, final StringBuilder name) throws FileSystemException;
-
@Override
public FileName parseUri(final VfsComponentContext context, final FileName base, final String uri)
throws FileSystemException {
@@ -87,14 +97,4 @@
return createFileName(scheme, rootFile, path, fileType);
}
-
- private String[] getSchemes(final VfsComponentContext context, final FileName base, final String uri) {
- if (context == null) {
- return new String[] { base != null ? base.getScheme() : URI.create(uri).getScheme() };
- }
- return context.getFileSystemManager().getSchemes();
- }
-
- protected abstract FileName createFileName(String scheme, final String rootFile, final String path,
- final FileType type);
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileRandomAccessContent.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileRandomAccessContent.java
index 3067377..edb353d 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileRandomAccessContent.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileRandomAccessContent.java
@@ -32,11 +32,11 @@
*/
final class LocalFileRandomAccessContent extends AbstractRandomAccessContent {
+ private final static int BYTE_VALUE_MASK = 0xFF;
// private final LocalFile localFile;
private final RandomAccessFile raf;
- private final InputStream rafis;
- private final static int BYTE_VALUE_MASK = 0xFF;
+ private final InputStream rafis;
LocalFileRandomAccessContent(final File localFile, final RandomAccessMode mode) throws FileSystemException {
super(mode);
@@ -45,6 +45,21 @@
raf = new RandomAccessFile(localFile, mode.getModeString());
rafis = new InputStream() {
@Override
+ public int available() throws IOException {
+ final long available = raf.length() - raf.getFilePointer();
+ if (available > Integer.MAX_VALUE) {
+ return Integer.MAX_VALUE;
+ }
+
+ return (int) available;
+ }
+
+ @Override
+ public void close() throws IOException {
+ raf.close();
+ }
+
+ @Override
public int read() throws IOException {
try {
return raf.readByte() & BYTE_VALUE_MASK;
@@ -54,17 +69,6 @@
}
@Override
- public long skip(final long n) throws IOException {
- raf.seek(raf.getFilePointer() + n);
- return n;
- }
-
- @Override
- public void close() throws IOException {
- raf.close();
- }
-
- @Override
public int read(final byte[] b) throws IOException {
return raf.read(b);
}
@@ -75,13 +79,9 @@
}
@Override
- public int available() throws IOException {
- final long available = raf.length() - raf.getFilePointer();
- if (available > Integer.MAX_VALUE) {
- return Integer.MAX_VALUE;
- }
-
- return (int) available;
+ public long skip(final long n) throws IOException {
+ raf.seek(raf.getFilePointer() + n);
+ return n;
}
};
} catch (final FileNotFoundException e) {
@@ -90,13 +90,18 @@
}
@Override
+ public void close() throws IOException {
+ raf.close();
+ }
+
+ @Override
public long getFilePointer() throws IOException {
return raf.getFilePointer();
}
@Override
- public void seek(final long pos) throws IOException {
- raf.seek(pos);
+ public InputStream getInputStream() throws IOException {
+ return rafis;
}
@Override
@@ -105,8 +110,8 @@
}
@Override
- public void close() throws IOException {
- raf.close();
+ public boolean readBoolean() throws IOException {
+ return raf.readBoolean();
}
@Override
@@ -130,21 +135,21 @@
}
@Override
+ public void readFully(final byte[] b) throws IOException {
+ raf.readFully(b);
+ }
+
+ @Override
+ public void readFully(final byte[] b, final int off, final int len) throws IOException {
+ raf.readFully(b, off, len);
+ }
+
+ @Override
public int readInt() throws IOException {
return raf.readInt();
}
@Override
- public int readUnsignedByte() throws IOException {
- return raf.readUnsignedByte();
- }
-
- @Override
- public int readUnsignedShort() throws IOException {
- return raf.readUnsignedShort();
- }
-
- @Override
public long readLong() throws IOException {
return raf.readLong();
}
@@ -155,23 +160,13 @@
}
@Override
- public boolean readBoolean() throws IOException {
- return raf.readBoolean();
+ public int readUnsignedByte() throws IOException {
+ return raf.readUnsignedByte();
}
@Override
- public int skipBytes(final int n) throws IOException {
- return raf.skipBytes(n);
- }
-
- @Override
- public void readFully(final byte[] b) throws IOException {
- raf.readFully(b);
- }
-
- @Override
- public void readFully(final byte[] b, final int off, final int len) throws IOException {
- raf.readFully(b, off, len);
+ public int readUnsignedShort() throws IOException {
+ return raf.readUnsignedShort();
}
@Override
@@ -180,48 +175,18 @@
}
@Override
- public void writeDouble(final double v) throws IOException {
- raf.writeDouble(v);
+ public void seek(final long pos) throws IOException {
+ raf.seek(pos);
}
@Override
- public void writeFloat(final float v) throws IOException {
- raf.writeFloat(v);
+ public void setLength(final long newLength) throws IOException {
+ raf.setLength(newLength);
}
@Override
- public void write(final int b) throws IOException {
- raf.write(b);
- }
-
- @Override
- public void writeByte(final int v) throws IOException {
- raf.writeByte(v);
- }
-
- @Override
- public void writeChar(final int v) throws IOException {
- raf.writeChar(v);
- }
-
- @Override
- public void writeInt(final int v) throws IOException {
- raf.writeInt(v);
- }
-
- @Override
- public void writeShort(final int v) throws IOException {
- raf.writeShort(v);
- }
-
- @Override
- public void writeLong(final long v) throws IOException {
- raf.writeLong(v);
- }
-
- @Override
- public void writeBoolean(final boolean v) throws IOException {
- raf.writeBoolean(v);
+ public int skipBytes(final int n) throws IOException {
+ return raf.skipBytes(n);
}
@Override
@@ -235,27 +200,62 @@
}
@Override
+ public void write(final int b) throws IOException {
+ raf.write(b);
+ }
+
+ @Override
+ public void writeBoolean(final boolean v) throws IOException {
+ raf.writeBoolean(v);
+ }
+
+ @Override
+ public void writeByte(final int v) throws IOException {
+ raf.writeByte(v);
+ }
+
+ @Override
public void writeBytes(final String s) throws IOException {
raf.writeBytes(s);
}
@Override
+ public void writeChar(final int v) throws IOException {
+ raf.writeChar(v);
+ }
+
+ @Override
public void writeChars(final String s) throws IOException {
raf.writeChars(s);
}
@Override
+ public void writeDouble(final double v) throws IOException {
+ raf.writeDouble(v);
+ }
+
+ @Override
+ public void writeFloat(final float v) throws IOException {
+ raf.writeFloat(v);
+ }
+
+ @Override
+ public void writeInt(final int v) throws IOException {
+ raf.writeInt(v);
+ }
+
+ @Override
+ public void writeLong(final long v) throws IOException {
+ raf.writeLong(v);
+ }
+
+ @Override
+ public void writeShort(final int v) throws IOException {
+ raf.writeShort(v);
+ }
+
+ @Override
public void writeUTF(final String str) throws IOException {
raf.writeUTF(str);
}
-
- @Override
- public InputStream getInputStream() throws IOException {
- return rafis;
- }
-
- @Override
- public void setLength(final long newLength) throws IOException {
- raf.setLength(newLength);
- }
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileSystem.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileSystem.java
index 584e47d..9d1a8f4 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileSystem.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileSystem.java
@@ -43,6 +43,14 @@
}
/**
+ * Returns the capabilities of this file system.
+ */
+ @Override
+ protected void addCapabilities(final Collection<Capability> caps) {
+ caps.addAll(DefaultLocalFileProvider.capabilities);
+ }
+
+ /**
* Creates a file object.
*/
@Override
@@ -52,14 +60,6 @@
}
/**
- * Returns the capabilities of this file system.
- */
- @Override
- protected void addCapabilities(final Collection<Capability> caps) {
- caps.addAll(DefaultLocalFileProvider.capabilities);
- }
-
- /**
* Creates a temporary local copy of a file and its descendants.
*/
@Override
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/WindowsFileName.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/WindowsFileName.java
index f35fbdb..e56f4ab 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/WindowsFileName.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/WindowsFileName.java
@@ -29,18 +29,6 @@
}
/**
- * Factory method for creating name instances.
- *
- * @param path The file path.
- * @param type The file type.
- * @return The FileName.
- */
- @Override
- public FileName createName(final String path, final FileType type) {
- return new WindowsFileName(getScheme(), getRootFile(), path, type);
- }
-
- /**
* Builds the root URI for this file name.
*/
@Override
@@ -53,4 +41,16 @@
}
buffer.append(getRootFile());
}
+
+ /**
+ * Factory method for creating name instances.
+ *
+ * @param path The file path.
+ * @param type The file type.
+ * @return The FileName.
+ */
+ @Override
+ public FileName createName(final String path, final FileType type) {
+ return new WindowsFileName(getScheme(), getRootFile(), path, type);
+ }
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/WindowsFileNameParser.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/WindowsFileNameParser.java
index 5ab3da7..68a2939 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/WindowsFileNameParser.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/WindowsFileNameParser.java
@@ -25,6 +25,41 @@
*/
public class WindowsFileNameParser extends LocalFileNameParser {
+ @Override
+ protected FileName createFileName(final String scheme, final String rootFile, final String path,
+ final FileType type) {
+ return new WindowsFileName(scheme, rootFile, path, type);
+ }
+
+ /**
+ * Extracts a drive prefix from a path. Leading '/' chars have been removed.
+ */
+ private String extractDrivePrefix(final StringBuilder name) {
+ // Looking for <letter> ':' '/'
+ if (name.length() < 3) {
+ // Too short
+ return null;
+ }
+ final char ch = name.charAt(0);
+ if (ch == '/' || ch == ':') {
+ // Missing drive letter
+ return null;
+ }
+ if (name.charAt(1) != ':') {
+ // Missing ':'
+ return null;
+ }
+ if (name.charAt(2) != '/') {
+ // Missing separator
+ return null;
+ }
+
+ final String prefix = name.substring(0, 2);
+ name.delete(0, 2);
+
+ return prefix.intern();
+ }
+
/**
* Pops the root prefix off a URI, which has had the scheme removed.
*/
@@ -33,10 +68,34 @@
return extractWindowsRootPrefix(uri, name);
}
- @Override
- protected FileName createFileName(final String scheme, final String rootFile, final String path,
- final FileType type) {
- return new WindowsFileName(scheme, rootFile, path, type);
+ /**
+ * Extracts a UNC name from a path. Leading '/' chars have been removed.
+ */
+ private String extractUNCPrefix(final String uri, final StringBuilder name) throws FileSystemException {
+ // Looking for <name> '/' <name> ( '/' | <end> )
+
+ // Look for first separator
+ final int maxpos = name.length();
+ int pos = 0;
+ for (; pos < maxpos && name.charAt(pos) != '/'; pos++) {
+ }
+ pos++;
+ if (pos >= maxpos) {
+ throw new FileSystemException("vfs.provider.local/missing-share-name.error", uri);
+ }
+
+ // Now have <name> '/'
+ final int startShareName = pos;
+ for (; pos < maxpos && name.charAt(pos) != '/'; pos++) {
+ }
+ if (pos == startShareName) {
+ throw new FileSystemException("vfs.provider.local/missing-share-name.error", uri);
+ }
+
+ // Now have <name> '/' <name> ( '/' | <end> )
+ final String prefix = name.substring(0, pos);
+ name.delete(0, pos);
+ return prefix;
}
/**
@@ -71,63 +130,4 @@
return "//" + extractUNCPrefix(uri, name);
}
-
- /**
- * Extracts a drive prefix from a path. Leading '/' chars have been removed.
- */
- private String extractDrivePrefix(final StringBuilder name) {
- // Looking for <letter> ':' '/'
- if (name.length() < 3) {
- // Too short
- return null;
- }
- final char ch = name.charAt(0);
- if (ch == '/' || ch == ':') {
- // Missing drive letter
- return null;
- }
- if (name.charAt(1) != ':') {
- // Missing ':'
- return null;
- }
- if (name.charAt(2) != '/') {
- // Missing separator
- return null;
- }
-
- final String prefix = name.substring(0, 2);
- name.delete(0, 2);
-
- return prefix.intern();
- }
-
- /**
- * Extracts a UNC name from a path. Leading '/' chars have been removed.
- */
- private String extractUNCPrefix(final String uri, final StringBuilder name) throws FileSystemException {
- // Looking for <name> '/' <name> ( '/' | <end> )
-
- // Look for first separator
- final int maxpos = name.length();
- int pos = 0;
- for (; pos < maxpos && name.charAt(pos) != '/'; pos++) {
- }
- pos++;
- if (pos >= maxpos) {
- throw new FileSystemException("vfs.provider.local/missing-share-name.error", uri);
- }
-
- // Now have <name> '/'
- final int startShareName = pos;
- for (; pos < maxpos && name.charAt(pos) != '/'; pos++) {
- }
- if (pos == startShareName) {
- throw new FileSystemException("vfs.provider.local/missing-share-name.error", uri);
- }
-
- // Now have <name> '/' <name> ( '/' | <end> )
- final String prefix = name.substring(0, pos);
- name.delete(0, pos);
- return prefix;
- }
}