You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/11/03 16:30:42 UTC
(commons-vfs) 02/03: Sort main members
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-vfs.git
commit a47cb20129f973f684ee58ef62062a3fec700280
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Nov 3 11:58:19 2023 -0400
Sort main members
---
.../vfs2/example/ChangeLastModificationTime.java | 8 +-
.../org/apache/commons/vfs2/example/Shell.java | 308 ++++++++++-----------
.../commons/vfs2/example/ShowProperties.java | 8 +-
.../vfs2/example/filter/AgeFileFilterExample.java | 8 +-
.../example/filter/CanReadFileFilterExample.java | 8 +-
.../example/filter/CanWriteFileFilterExample.java | 8 +-
.../example/filter/DirectoryFileFilterExample.java | 8 +-
.../example/filter/EmptyFileFilterExample.java | 8 +-
.../vfs2/example/filter/FileFileFilterExample.java | 8 +-
.../example/filter/HiddenFileFilterExample.java | 8 +-
.../vfs2/example/filter/NameFileFilterExample.java | 8 +-
.../example/filter/PrefixFileFilterExample.java | 8 +-
.../example/filter/RegexFileFilterExample.java | 8 +-
.../vfs2/example/filter/SizeFileFilterExample.java | 8 +-
.../example/filter/SuffixFileFilterExample.java | 8 +-
.../example/filter/WildcardFileFilterExample.java | 8 +-
.../org/apache/commons/vfs2/libcheck/FtpCheck.java | 8 +-
.../apache/commons/vfs2/libcheck/SftpCheck.java | 12 +-
.../provider/hdfs/HdfsFileSystemConfigBuilder.java | 8 +-
.../vfs2/provider/webdav/ExceptionConverter.java | 8 +-
.../vfs2/provider/webdav/WebdavFileNameParser.java | 12 +-
.../webdav/WebdavFileSystemConfigBuilder.java | 8 +-
.../provider/webdav/WebdavMethodRetryHandler.java | 12 +-
.../vfs2/provider/webdav4/ExceptionConverter.java | 8 +-
.../provider/webdav4/Webdav4FileNameParser.java | 12 +-
.../webdav4/Webdav4FileSystemConfigBuilder.java | 20 +-
.../provider/webdav4s/Webdav4sFileNameParser.java | 12 +-
.../vfs2/provider/mime/MimeAttributesMap.java | 58 ++--
.../commons/vfs2/provider/mime/MimeFileObject.java | 188 ++++++-------
.../commons/vfs2/provider/mime/MimeFileSystem.java | 44 +--
.../commons/vfs2/provider/smb/SmbFileName.java | 56 ++--
.../vfs2/provider/smb/SmbFileNameParser.java | 42 +--
.../commons/vfs2/provider/smb/SmbFileObject.java | 128 ++++-----
.../commons/vfs2/provider/smb/SmbFileSystem.java | 12 +-
.../commons/vfs2/util/FileObjectDataSource.java | 20 +-
.../commons/vfs2/util/RACRandomAccessFile.java | 72 ++---
.../vfs2/util/SharedRandomContentInputStream.java | 144 +++++-----
.../apache/commons/vfs2/FileSystemException.java | 92 +++---
.../java/org/apache/commons/vfs2/FileUtil.java | 14 +-
.../src/main/java/org/apache/commons/vfs2/VFS.java | 8 +-
.../main/java/org/apache/commons/vfs2/VfsLog.java | 8 +-
.../apache/commons/vfs2/filter/AgeFileFilter.java | 46 +--
.../org/apache/commons/vfs2/filter/IOCase.java | 32 +--
.../commons/vfs2/filter/WildcardFileFilter.java | 118 ++++----
.../commons/vfs2/provider/AbstractFileName.java | 66 ++---
.../commons/vfs2/provider/AbstractFileObject.java | 66 ++---
.../commons/vfs2/provider/HostFileNameParser.java | 34 +--
.../apache/commons/vfs2/provider/UriParser.java | 6 +-
.../vfs2/provider/bzip2/Bzip2FileObject.java | 38 +--
.../vfs2/provider/ftp/FtpClientFactory.java | 6 +-
.../vfs2/provider/ftp/FtpFileNameParser.java | 14 +-
.../provider/ftp/FtpFileSystemConfigBuilder.java | 72 ++---
.../vfs2/provider/ftps/FtpsClientFactory.java | 8 +-
.../provider/ftps/FtpsFileSystemConfigBuilder.java | 8 +-
.../commons/vfs2/provider/gzip/GzipFileObject.java | 14 +-
.../vfs2/provider/http/HttpClientFactory.java | 6 +-
.../vfs2/provider/http/HttpFileNameParser.java | 14 +-
.../provider/http/HttpFileSystemConfigBuilder.java | 18 +-
.../vfs2/provider/http4/Http4FileNameParser.java | 14 +-
.../http4/Http4FileSystemConfigBuilder.java | 18 +-
.../vfs2/provider/http4s/Http4sFileNameParser.java | 14 +-
.../vfs2/provider/http5/Http5FileNameParser.java | 14 +-
.../http5/Http5FileSystemConfigBuilder.java | 18 +-
.../vfs2/provider/http5s/Http5sFileNameParser.java | 14 +-
.../vfs2/provider/https/HttpsFileNameParser.java | 14 +-
.../provider/ram/RamFileRandomAccessContent.java | 116 ++++----
.../provider/ram/RamFileSystemConfigBuilder.java | 14 +-
.../res/ResourceFileSystemConfigBuilder.java | 8 +-
.../vfs2/provider/sftp/SftpClientFactory.java | 16 +-
.../vfs2/provider/sftp/SftpFileNameParser.java | 14 +-
.../vfs2/provider/sftp/SftpFileProvider.java | 14 +-
.../provider/sftp/SftpFileSystemConfigBuilder.java | 8 +-
.../apache/commons/vfs2/provider/sftp/Utils.java | 8 +-
.../provider/zip/ZipFileSystemConfigBuilder.java | 14 +-
.../apache/commons/vfs2/util/CryptorFactory.java | 14 +-
.../org/apache/commons/vfs2/util/EncryptUtil.java | 12 +-
.../apache/commons/vfs2/util/FileObjectUtils.java | 8 +-
.../org/apache/commons/vfs2/util/Messages.java | 8 +-
.../main/java/org/apache/commons/vfs2/util/Os.java | 12 +-
.../apache/commons/vfs2/util/RandomAccessMode.java | 16 +-
.../org/apache/commons/vfs2/util/URIBitSets.java | 6 +-
.../org/apache/commons/vfs2/util/URIUtils.java | 18 +-
.../commons/vfs2/util/UserAuthenticatorUtils.java | 6 +-
.../commons/vfs2/util/WeakRefFileListener.java | 20 +-
84 files changed, 1219 insertions(+), 1219 deletions(-)
diff --git a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/ChangeLastModificationTime.java b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/ChangeLastModificationTime.java
index 999c6900..c9987524 100644
--- a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/ChangeLastModificationTime.java
+++ b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/ChangeLastModificationTime.java
@@ -24,10 +24,6 @@ import org.apache.commons.vfs2.VFS;
*/
public final class ChangeLastModificationTime {
- private ChangeLastModificationTime() {
- /* main class not instantiated. */
- }
-
/**
* Invokes this example from the command line.
*
@@ -47,4 +43,8 @@ public final class ChangeLastModificationTime {
System.err.println("after set: " + fo.getContent().getLastModifiedTime());
}
+ private ChangeLastModificationTime() {
+ /* main class not instantiated. */
+ }
+
}
diff --git a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/Shell.java b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/Shell.java
index 302424cd..de32da4e 100644
--- a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/Shell.java
+++ b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/Shell.java
@@ -50,8 +50,31 @@ import org.apache.commons.vfs2.util.FileObjectUtils;
*/
public final class Shell {
+ private static String getVersion(final Class<?> cls) {
+ try {
+ return cls.getPackage().getImplementationVersion();
+ } catch (final Exception ignored) {
+ return "N/A";
+ }
+ }
+ /**
+ * Invokes this example from the command line.
+ *
+ * @param args Arguments TODO
+ */
+ public static void main(final String[] args) {
+ try {
+ new Shell().go();
+ } catch (final Exception e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ System.exit(0);
+ }
private final FileSystemManager mgr;
+
private FileObject cwd;
+
private final BufferedReader reader;
private Shell() throws IOException {
@@ -72,18 +95,57 @@ public final class Shell {
}
/**
- * Invokes this example from the command line.
- *
- * @param args Arguments TODO
+ * Does a 'cat' command.
*/
- public static void main(final String[] args) {
- try {
- new Shell().go();
- } catch (final Exception e) {
- e.printStackTrace();
- System.exit(1);
+ private void cat(final String[] cmd) throws Exception {
+ if (cmd.length < 2) {
+ throw new Exception("USAGE: cat <path>");
}
- System.exit(0);
+
+ // Locate the file
+ final FileObject file = mgr.resolveFile(cwd, cmd[1]);
+
+ // Dump the contents to System.out
+ FileObjectUtils.writeContent(file, System.out);
+ System.out.println();
+ }
+
+ /**
+ * Does a 'cd' command. If the taget directory does not exist, a message is printed to {@code System.err}.
+ */
+ private void cd(final String[] cmd) throws Exception {
+ final String path;
+ if (cmd.length > 1) {
+ path = cmd[1];
+ } else {
+ path = System.getProperty("user.home");
+ }
+
+ // Locate and validate the folder
+ final FileObject tmp = mgr.resolveFile(cwd, path);
+ if (tmp.exists()) {
+ cwd = tmp;
+ } else {
+ System.out.println("Folder does not exist: " + tmp.getName());
+ }
+ System.out.println("Current folder is " + cwd.getName());
+ }
+
+ /**
+ * Does a 'cp' command.
+ */
+ private void cp(final String[] cmd) throws Exception {
+ if (cmd.length < 3) {
+ throw new Exception("USAGE: cp <src> <dest>");
+ }
+
+ final FileObject src = mgr.resolveFile(cwd, cmd[1]);
+ FileObject dest = mgr.resolveFile(cwd, cmd[2]);
+ if (dest.exists() && dest.getType() == FileType.FOLDER) {
+ dest = dest.resolveFile(src.getName().getBaseName());
+ }
+
+ dest.copyFrom(src, Selectors.SELECT_ALL);
}
private void go() throws Exception {
@@ -139,6 +201,37 @@ public final class Shell {
}
}
+ /**
+ * Does a 'help' command.
+ */
+ private void help() {
+ System.out.println("Commands:");
+ System.out.println("cat <file> Displays the contents of a file.");
+ System.out.println("cd [folder] Changes current folder.");
+ System.out.println("cp <src> <dest> Copies a file or folder.");
+ System.out.println("help Shows this message.");
+ System.out.println("info [scheme] Displays information about providers.");
+ System.out.println("ls [-R] [path] Lists contents of a file or folder.");
+ System.out.println("pwd Displays current folder.");
+ System.out.println("pwfs Displays current file system.");
+ System.out.println("rm <path> Deletes a file or folder.");
+ System.out.println("touch <path> Sets the last-modified time of a file.");
+ System.out.println("exit, quit Exits this program.");
+ }
+
+ private void info(final String scheme) throws Exception {
+ System.out.println("Provider Info for scheme \"" + scheme + "\":");
+ final Collection<Capability> caps;
+ caps = mgr.getProviderCapabilities(scheme);
+ if (caps != null && !caps.isEmpty()) {
+ System.out.println(" capabilities: " + caps);
+ }
+ final FileOperationProvider[] ops = mgr.getOperationProviders(scheme);
+ if (ops != null && ops.length > 0) {
+ System.out.println(" operations: " + Arrays.toString(ops));
+ }
+ }
+
private void info(final String[] cmd) throws Exception {
if (cmd.length > 1) {
info(cmd[1]);
@@ -166,115 +259,23 @@ public final class Shell {
}
}
- private void info(final String scheme) throws Exception {
- System.out.println("Provider Info for scheme \"" + scheme + "\":");
- final Collection<Capability> caps;
- caps = mgr.getProviderCapabilities(scheme);
- if (caps != null && !caps.isEmpty()) {
- System.out.println(" capabilities: " + caps);
- }
- final FileOperationProvider[] ops = mgr.getOperationProviders(scheme);
- if (ops != null && ops.length > 0) {
- System.out.println(" operations: " + Arrays.toString(ops));
- }
- }
-
- /**
- * Does a 'help' command.
- */
- private void help() {
- System.out.println("Commands:");
- System.out.println("cat <file> Displays the contents of a file.");
- System.out.println("cd [folder] Changes current folder.");
- System.out.println("cp <src> <dest> Copies a file or folder.");
- System.out.println("help Shows this message.");
- System.out.println("info [scheme] Displays information about providers.");
- System.out.println("ls [-R] [path] Lists contents of a file or folder.");
- System.out.println("pwd Displays current folder.");
- System.out.println("pwfs Displays current file system.");
- System.out.println("rm <path> Deletes a file or folder.");
- System.out.println("touch <path> Sets the last-modified time of a file.");
- System.out.println("exit, quit Exits this program.");
- }
-
- /**
- * Does an 'rm' command.
- */
- private void rm(final String[] cmd) throws Exception {
- if (cmd.length < 2) {
- throw new Exception("USAGE: rm <path>");
- }
-
- final FileObject file = mgr.resolveFile(cwd, cmd[1]);
- file.delete(Selectors.SELECT_SELF);
- }
-
- /**
- * Does a 'cp' command.
- */
- private void cp(final String[] cmd) throws Exception {
- if (cmd.length < 3) {
- throw new Exception("USAGE: cp <src> <dest>");
- }
-
- final FileObject src = mgr.resolveFile(cwd, cmd[1]);
- FileObject dest = mgr.resolveFile(cwd, cmd[2]);
- if (dest.exists() && dest.getType() == FileType.FOLDER) {
- dest = dest.resolveFile(src.getName().getBaseName());
- }
-
- dest.copyFrom(src, Selectors.SELECT_ALL);
- }
-
/**
- * Does a 'cat' command.
- */
- private void cat(final String[] cmd) throws Exception {
- if (cmd.length < 2) {
- throw new Exception("USAGE: cat <path>");
- }
-
- // Locate the file
- final FileObject file = mgr.resolveFile(cwd, cmd[1]);
-
- // Dump the contents to System.out
- FileObjectUtils.writeContent(file, System.out);
- System.out.println();
- }
-
- /**
- * Does a 'pwd' command.
- */
- private void pwd() {
- System.out.println("Current folder is " + cwd.getName());
- }
-
- /**
- * Does a 'pwfs' command.
- */
- private void pwfs() {
- System.out.println("FileSystem of current folder is " + cwd.getFileSystem() + " (root: " + cwd.getFileSystem().getRootURI() + ")");
- }
-
- /**
- * Does a 'cd' command. If the taget directory does not exist, a message is printed to {@code System.err}.
+ * Lists the children of a folder.
*/
- private void cd(final String[] cmd) throws Exception {
- final String path;
- if (cmd.length > 1) {
- path = cmd[1];
- } else {
- path = System.getProperty("user.home");
- }
-
- // Locate and validate the folder
- final FileObject tmp = mgr.resolveFile(cwd, path);
- if (tmp.exists()) {
- cwd = tmp;
- } else {
- System.out.println("Folder does not exist: " + tmp.getName());
+ private void listChildren(final FileObject dir, final boolean recursive, final String prefix) throws FileSystemException {
+ final FileObject[] children = dir.getChildren();
+ for (final FileObject child : children) {
+ System.out.print(prefix);
+ System.out.print(child.getName().getBaseName());
+ if (child.getType() == FileType.FOLDER) {
+ System.out.println("/");
+ if (recursive) {
+ listChildren(child, true, prefix + " ");
+ }
+ } else {
+ System.out.println();
+ }
}
- System.out.println("Current folder is " + cwd.getName());
}
/**
@@ -312,39 +313,6 @@ public final class Shell {
}
}
- /**
- * Does a 'touch' command.
- */
- private void touch(final String[] cmd) throws Exception {
- if (cmd.length < 2) {
- throw new Exception("USAGE: touch <path>");
- }
- final FileObject file = mgr.resolveFile(cwd, cmd[1]);
- if (!file.exists()) {
- file.createFile();
- }
- file.getContent().setLastModifiedTime(System.currentTimeMillis());
- }
-
- /**
- * Lists the children of a folder.
- */
- private void listChildren(final FileObject dir, final boolean recursive, final String prefix) throws FileSystemException {
- final FileObject[] children = dir.getChildren();
- for (final FileObject child : children) {
- System.out.print(prefix);
- System.out.print(child.getName().getBaseName());
- if (child.getType() == FileType.FOLDER) {
- System.out.println("/");
- if (recursive) {
- listChildren(child, true, prefix + " ");
- }
- } else {
- System.out.println();
- }
- }
- }
-
/**
* Returns the next command, split into tokens.
*/
@@ -362,11 +330,43 @@ public final class Shell {
return cmd.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
}
- private static String getVersion(final Class<?> cls) {
- try {
- return cls.getPackage().getImplementationVersion();
- } catch (final Exception ignored) {
- return "N/A";
+ /**
+ * Does a 'pwd' command.
+ */
+ private void pwd() {
+ System.out.println("Current folder is " + cwd.getName());
+ }
+
+ /**
+ * Does a 'pwfs' command.
+ */
+ private void pwfs() {
+ System.out.println("FileSystem of current folder is " + cwd.getFileSystem() + " (root: " + cwd.getFileSystem().getRootURI() + ")");
+ }
+
+ /**
+ * Does an 'rm' command.
+ */
+ private void rm(final String[] cmd) throws Exception {
+ if (cmd.length < 2) {
+ throw new Exception("USAGE: rm <path>");
}
+
+ final FileObject file = mgr.resolveFile(cwd, cmd[1]);
+ file.delete(Selectors.SELECT_SELF);
+ }
+
+ /**
+ * Does a 'touch' command.
+ */
+ private void touch(final String[] cmd) throws Exception {
+ if (cmd.length < 2) {
+ throw new Exception("USAGE: touch <path>");
+ }
+ final FileObject file = mgr.resolveFile(cwd, cmd[1]);
+ if (!file.exists()) {
+ file.createFile();
+ }
+ file.getContent().setLastModifiedTime(System.currentTimeMillis());
}
}
diff --git a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/ShowProperties.java b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/ShowProperties.java
index 68fa8399..cc160a4e 100644
--- a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/ShowProperties.java
+++ b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/ShowProperties.java
@@ -32,10 +32,6 @@ public final class ShowProperties {
/** Maximum number of children to show. */
private static final int SHOW_MAX = 5;
- private ShowProperties() {
- /* main class not instantiated. */
- }
-
/**
* Invokes this example from the command line.
*
@@ -91,4 +87,8 @@ public final class ShowProperties {
}
}
+ private ShowProperties() {
+ /* main class not instantiated. */
+ }
+
}
diff --git a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/AgeFileFilterExample.java b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/AgeFileFilterExample.java
index 36b0c4aa..b0d15593 100644
--- a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/AgeFileFilterExample.java
+++ b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/AgeFileFilterExample.java
@@ -29,10 +29,6 @@ import org.apache.commons.vfs2.filter.AgeFileFilter;
*/
// CHECKSTYLE:OFF Example code
public final class AgeFileFilterExample {
- private AgeFileFilterExample() {
- /* main class not instantiated. */
- }
-
/**
* Invokes this example from the command line.
*
@@ -55,5 +51,9 @@ public final class AgeFileFilterExample {
}
+ private AgeFileFilterExample() {
+ /* main class not instantiated. */
+ }
+
}
// CHECKSTYLE:ON
diff --git a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/CanReadFileFilterExample.java b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/CanReadFileFilterExample.java
index 725ed023..f87eb5ee 100644
--- a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/CanReadFileFilterExample.java
+++ b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/CanReadFileFilterExample.java
@@ -29,10 +29,6 @@ import org.apache.commons.vfs2.filter.CanReadFileFilter;
*/
// CHECKSTYLE:OFF Example code
public final class CanReadFileFilterExample {
- private CanReadFileFilterExample() {
- /* main class not instantiated. */
- }
-
/**
* Invokes this example from the command line.
*
@@ -66,5 +62,9 @@ public final class CanReadFileFilterExample {
}
+ private CanReadFileFilterExample() {
+ /* main class not instantiated. */
+ }
+
}
// CHECKSTYLE:ON
diff --git a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/CanWriteFileFilterExample.java b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/CanWriteFileFilterExample.java
index 9b2fba68..d636b177 100644
--- a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/CanWriteFileFilterExample.java
+++ b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/CanWriteFileFilterExample.java
@@ -29,10 +29,6 @@ import org.apache.commons.vfs2.filter.CanWriteFileFilter;
*/
// CHECKSTYLE:OFF Example code
public final class CanWriteFileFilterExample {
- private CanWriteFileFilterExample() {
- /* main class not instantiated. */
- }
-
/**
* Invokes this example from the command line.
*
@@ -59,5 +55,9 @@ public final class CanWriteFileFilterExample {
}
+ private CanWriteFileFilterExample() {
+ /* main class not instantiated. */
+ }
+
}
// CHECKSTYLE:ON
diff --git a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/DirectoryFileFilterExample.java b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/DirectoryFileFilterExample.java
index a2bf1ab9..e37d7fc1 100644
--- a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/DirectoryFileFilterExample.java
+++ b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/DirectoryFileFilterExample.java
@@ -29,10 +29,6 @@ import org.apache.commons.vfs2.filter.DirectoryFileFilter;
*/
// CHECKSTYLE:OFF Example code
public final class DirectoryFileFilterExample {
- private DirectoryFileFilterExample() {
- /* main class not instantiated. */
- }
-
/**
* Invokes this example from the command line.
*
@@ -51,5 +47,9 @@ public final class DirectoryFileFilterExample {
}
}
+ private DirectoryFileFilterExample() {
+ /* main class not instantiated. */
+ }
+
}
// CHECKSTYLE:ON
diff --git a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/EmptyFileFilterExample.java b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/EmptyFileFilterExample.java
index 145b1024..ff82bc15 100644
--- a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/EmptyFileFilterExample.java
+++ b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/EmptyFileFilterExample.java
@@ -29,10 +29,6 @@ import org.apache.commons.vfs2.filter.EmptyFileFilter;
*/
// CHECKSTYLE:OFF Example code
public final class EmptyFileFilterExample {
- private EmptyFileFilterExample() {
- /* main class not instantiated. */
- }
-
/**
* Invokes this example from the command line.
*
@@ -60,5 +56,9 @@ public final class EmptyFileFilterExample {
}
+ private EmptyFileFilterExample() {
+ /* main class not instantiated. */
+ }
+
}
// CHECKSTYLE:ON
diff --git a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/FileFileFilterExample.java b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/FileFileFilterExample.java
index ff53b04a..9331876f 100644
--- a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/FileFileFilterExample.java
+++ b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/FileFileFilterExample.java
@@ -29,10 +29,6 @@ import org.apache.commons.vfs2.filter.FileFileFilter;
*/
// CHECKSTYLE:OFF Example code
public final class FileFileFilterExample {
- private FileFileFilterExample() {
- /* main class not instantiated. */
- }
-
/**
* Invokes this example from the command line.
*
@@ -51,5 +47,9 @@ public final class FileFileFilterExample {
}
}
+ private FileFileFilterExample() {
+ /* main class not instantiated. */
+ }
+
}
// CHECKSTYLE:ON
diff --git a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/HiddenFileFilterExample.java b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/HiddenFileFilterExample.java
index 5db6e712..f9a99f6f 100644
--- a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/HiddenFileFilterExample.java
+++ b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/HiddenFileFilterExample.java
@@ -29,10 +29,6 @@ import org.apache.commons.vfs2.filter.HiddenFileFilter;
*/
// CHECKSTYLE:OFF Example code
public final class HiddenFileFilterExample {
- private HiddenFileFilterExample() {
- /* main class not instantiated. */
- }
-
/**
* Invokes this example from the command line.
*
@@ -60,5 +56,9 @@ public final class HiddenFileFilterExample {
}
+ private HiddenFileFilterExample() {
+ /* main class not instantiated. */
+ }
+
}
// CHECKSTYLE:ON
diff --git a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/NameFileFilterExample.java b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/NameFileFilterExample.java
index b6d05439..9c36928a 100644
--- a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/NameFileFilterExample.java
+++ b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/NameFileFilterExample.java
@@ -29,10 +29,6 @@ import org.apache.commons.vfs2.filter.NameFileFilter;
*/
// CHECKSTYLE:OFF Example code
public final class NameFileFilterExample {
- private NameFileFilterExample() {
- /* main class not instantiated. */
- }
-
/**
* Invokes this example from the command line.
*
@@ -52,5 +48,9 @@ public final class NameFileFilterExample {
}
+ private NameFileFilterExample() {
+ /* main class not instantiated. */
+ }
+
}
// CHECKSTYLE:ON
diff --git a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/PrefixFileFilterExample.java b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/PrefixFileFilterExample.java
index 55ef520b..b7187777 100644
--- a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/PrefixFileFilterExample.java
+++ b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/PrefixFileFilterExample.java
@@ -29,10 +29,6 @@ import org.apache.commons.vfs2.filter.PrefixFileFilter;
*/
// CHECKSTYLE:OFF Example code
public final class PrefixFileFilterExample {
- private PrefixFileFilterExample() {
- /* main class not instantiated. */
- }
-
/**
* Invokes this example from the command line.
*
@@ -52,5 +48,9 @@ public final class PrefixFileFilterExample {
}
+ private PrefixFileFilterExample() {
+ /* main class not instantiated. */
+ }
+
}
// CHECKSTYLE:ON
diff --git a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/RegexFileFilterExample.java b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/RegexFileFilterExample.java
index 268d5002..915b3060 100644
--- a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/RegexFileFilterExample.java
+++ b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/RegexFileFilterExample.java
@@ -29,10 +29,6 @@ import org.apache.commons.vfs2.filter.RegexFileFilter;
*/
// CHECKSTYLE:OFF Example code
public final class RegexFileFilterExample {
- private RegexFileFilterExample() {
- /* main class not instantiated. */
- }
-
/**
* Invokes this example from the command line.
*
@@ -52,5 +48,9 @@ public final class RegexFileFilterExample {
}
+ private RegexFileFilterExample() {
+ /* main class not instantiated. */
+ }
+
}
// CHECKSTYLE:ON
diff --git a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/SizeFileFilterExample.java b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/SizeFileFilterExample.java
index 08e04de0..f4f22c17 100644
--- a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/SizeFileFilterExample.java
+++ b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/SizeFileFilterExample.java
@@ -29,10 +29,6 @@ import org.apache.commons.vfs2.filter.SizeFileFilter;
*/
// CHECKSTYLE:OFF Example code
public final class SizeFileFilterExample {
- private SizeFileFilterExample() {
- /* main class not instantiated. */
- }
-
/**
* Invokes this example from the command line.
*
@@ -53,5 +49,9 @@ public final class SizeFileFilterExample {
}
+ private SizeFileFilterExample() {
+ /* main class not instantiated. */
+ }
+
}
// CHECKSTYLE:ON
diff --git a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/SuffixFileFilterExample.java b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/SuffixFileFilterExample.java
index 263d15d5..37b1cc42 100644
--- a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/SuffixFileFilterExample.java
+++ b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/SuffixFileFilterExample.java
@@ -29,10 +29,6 @@ import org.apache.commons.vfs2.filter.SuffixFileFilter;
*/
// CHECKSTYLE:OFF Example code
public final class SuffixFileFilterExample {
- private SuffixFileFilterExample() {
- /* main class not instantiated. */
- }
-
/**
* Invokes this example from the command line.
*
@@ -52,5 +48,9 @@ public final class SuffixFileFilterExample {
}
+ private SuffixFileFilterExample() {
+ /* main class not instantiated. */
+ }
+
}
// CHECKSTYLE:ON
diff --git a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/WildcardFileFilterExample.java b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/WildcardFileFilterExample.java
index ea668026..35727613 100644
--- a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/WildcardFileFilterExample.java
+++ b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/example/filter/WildcardFileFilterExample.java
@@ -29,10 +29,6 @@ import org.apache.commons.vfs2.filter.WildcardFileFilter;
*/
// CHECKSTYLE:OFF Example code
public final class WildcardFileFilterExample {
- private WildcardFileFilterExample() {
- /* main class not instantiated. */
- }
-
/**
* Invokes this example from the command line.
*
@@ -52,5 +48,9 @@ public final class WildcardFileFilterExample {
}
+ private WildcardFileFilterExample() {
+ /* main class not instantiated. */
+ }
+
}
// CHECKSTYLE:ON
diff --git a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/libcheck/FtpCheck.java b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/libcheck/FtpCheck.java
index 3ca57509..b4126715 100644
--- a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/libcheck/FtpCheck.java
+++ b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/libcheck/FtpCheck.java
@@ -27,10 +27,6 @@ import org.apache.commons.net.ftp.FTPReply;
* Basic check for FTP.
*/
public final class FtpCheck {
- private FtpCheck() {
- /* main class not instantiated. */
- }
-
/**
* Invokes this example from the command line.
*
@@ -87,4 +83,8 @@ public final class FtpCheck {
}
client.disconnect();
}
+
+ private FtpCheck() {
+ /* main class not instantiated. */
+ }
}
diff --git a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/libcheck/SftpCheck.java b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/libcheck/SftpCheck.java
index fa807928..46ae9dfc 100644
--- a/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/libcheck/SftpCheck.java
+++ b/commons-vfs2-examples/src/main/java/org/apache/commons/vfs2/libcheck/SftpCheck.java
@@ -28,10 +28,6 @@ import com.jcraft.jsch.UserInfo;
* Basic check for SFTP.
*/
public final class SftpCheck {
- private SftpCheck() {
- /* main class not instantiated. */
- }
-
/**
* Invokes this example from the command line.
*
@@ -63,12 +59,12 @@ public final class SftpCheck {
}
@Override
- public boolean promptPassword(final String string) {
+ public boolean promptPassphrase(final String string) {
return false;
}
@Override
- public boolean promptPassphrase(final String string) {
+ public boolean promptPassword(final String string) {
return false;
}
@@ -91,4 +87,8 @@ public final class SftpCheck {
chan.disconnect();
session.disconnect();
}
+
+ private SftpCheck() {
+ /* main class not instantiated. */
+ }
}
diff --git a/commons-vfs2-hdfs/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileSystemConfigBuilder.java b/commons-vfs2-hdfs/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileSystemConfigBuilder.java
index b83362cc..0857126c 100644
--- a/commons-vfs2-hdfs/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileSystemConfigBuilder.java
+++ b/commons-vfs2-hdfs/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileSystemConfigBuilder.java
@@ -43,10 +43,6 @@ public final class HdfsFileSystemConfigBuilder extends FileSystemConfigBuilder {
private static final String KEY_CONFIG_STREAM = "configStream";
private static final String KEY_CONFIG_CONF = "configConf";
- private HdfsFileSystemConfigBuilder() {
- super("hdfs.");
- }
-
/**
* @return HdfsFileSystemConfigBuilder instance
*/
@@ -54,6 +50,10 @@ public final class HdfsFileSystemConfigBuilder extends FileSystemConfigBuilder {
return BUILDER;
}
+ private HdfsFileSystemConfigBuilder() {
+ super("hdfs.");
+ }
+
/**
* @return HDFSFileSystem
*/
diff --git a/commons-vfs2-jackrabbit1/src/main/java/org/apache/commons/vfs2/provider/webdav/ExceptionConverter.java b/commons-vfs2-jackrabbit1/src/main/java/org/apache/commons/vfs2/provider/webdav/ExceptionConverter.java
index b0d9eb84..1810688b 100644
--- a/commons-vfs2-jackrabbit1/src/main/java/org/apache/commons/vfs2/provider/webdav/ExceptionConverter.java
+++ b/commons-vfs2-jackrabbit1/src/main/java/org/apache/commons/vfs2/provider/webdav/ExceptionConverter.java
@@ -32,10 +32,6 @@ import org.w3c.dom.Element;
*/
public final class ExceptionConverter {
- // avoid instantiation.
- private ExceptionConverter() {
- }
-
/**
* Generates a new instance of FileSystemException.
*
@@ -84,4 +80,8 @@ public final class ExceptionConverter {
return new FileSystemException(msg);
}
+
+ // avoid instantiation.
+ private ExceptionConverter() {
+ }
}
diff --git a/commons-vfs2-jackrabbit1/src/main/java/org/apache/commons/vfs2/provider/webdav/WebdavFileNameParser.java b/commons-vfs2-jackrabbit1/src/main/java/org/apache/commons/vfs2/provider/webdav/WebdavFileNameParser.java
index 6b875524..031aafc3 100644
--- a/commons-vfs2-jackrabbit1/src/main/java/org/apache/commons/vfs2/provider/webdav/WebdavFileNameParser.java
+++ b/commons-vfs2-jackrabbit1/src/main/java/org/apache/commons/vfs2/provider/webdav/WebdavFileNameParser.java
@@ -28,12 +28,6 @@ public class WebdavFileNameParser extends HttpFileNameParser {
private static final WebdavFileNameParser INSTANCE = new WebdavFileNameParser();
- /**
- * Constructs a new instance.
- */
- public WebdavFileNameParser() {
- }
-
/**
* Gets the singleton instance.
*
@@ -42,4 +36,10 @@ public class WebdavFileNameParser extends HttpFileNameParser {
public static FileNameParser getInstance() {
return INSTANCE;
}
+
+ /**
+ * Constructs a new instance.
+ */
+ public WebdavFileNameParser() {
+ }
}
diff --git a/commons-vfs2-jackrabbit1/src/main/java/org/apache/commons/vfs2/provider/webdav/WebdavFileSystemConfigBuilder.java b/commons-vfs2-jackrabbit1/src/main/java/org/apache/commons/vfs2/provider/webdav/WebdavFileSystemConfigBuilder.java
index 4c33a2be..8b1a8095 100644
--- a/commons-vfs2-jackrabbit1/src/main/java/org/apache/commons/vfs2/provider/webdav/WebdavFileSystemConfigBuilder.java
+++ b/commons-vfs2-jackrabbit1/src/main/java/org/apache/commons/vfs2/provider/webdav/WebdavFileSystemConfigBuilder.java
@@ -31,10 +31,6 @@ public final class WebdavFileSystemConfigBuilder extends HttpFileSystemConfigBui
private static final boolean DEFAULT_FOLLOW_REDIRECT = false;
- private WebdavFileSystemConfigBuilder() {
- super("webdav.");
- }
-
/**
* Gets the singleton builder.
*
@@ -44,6 +40,10 @@ public final class WebdavFileSystemConfigBuilder extends HttpFileSystemConfigBui
return BUILDER;
}
+ private WebdavFileSystemConfigBuilder() {
+ super("webdav.");
+ }
+
/**
* @return The Webdav FileSystem Class object.
*/
diff --git a/commons-vfs2-jackrabbit1/src/main/java/org/apache/commons/vfs2/provider/webdav/WebdavMethodRetryHandler.java b/commons-vfs2-jackrabbit1/src/main/java/org/apache/commons/vfs2/provider/webdav/WebdavMethodRetryHandler.java
index bd9edc83..2cac9c1f 100644
--- a/commons-vfs2-jackrabbit1/src/main/java/org/apache/commons/vfs2/provider/webdav/WebdavMethodRetryHandler.java
+++ b/commons-vfs2-jackrabbit1/src/main/java/org/apache/commons/vfs2/provider/webdav/WebdavMethodRetryHandler.java
@@ -33,12 +33,6 @@ public final class WebdavMethodRetryHandler implements HttpMethodRetryHandler {
private static final WebdavMethodRetryHandler INSTANCE = new WebdavMethodRetryHandler();
- /**
- * Constructs a new instance.
- */
- private WebdavMethodRetryHandler() {
- }
-
/**
* Gets the singleton instance.
*
@@ -48,6 +42,12 @@ public final class WebdavMethodRetryHandler implements HttpMethodRetryHandler {
return INSTANCE;
}
+ /**
+ * Constructs a new instance.
+ */
+ private WebdavMethodRetryHandler() {
+ }
+
@Override
public boolean retryMethod(final HttpMethod method, final IOException exception, final int executionCount) {
return executionCount < 2;
diff --git a/commons-vfs2-jackrabbit2/src/main/java/org/apache/commons/vfs2/provider/webdav4/ExceptionConverter.java b/commons-vfs2-jackrabbit2/src/main/java/org/apache/commons/vfs2/provider/webdav4/ExceptionConverter.java
index 1347644b..d34a0edd 100644
--- a/commons-vfs2-jackrabbit2/src/main/java/org/apache/commons/vfs2/provider/webdav4/ExceptionConverter.java
+++ b/commons-vfs2-jackrabbit2/src/main/java/org/apache/commons/vfs2/provider/webdav4/ExceptionConverter.java
@@ -31,10 +31,6 @@ import org.w3c.dom.Element;
*/
public final class ExceptionConverter {
- /** Disallow instantiation. */
- private ExceptionConverter() {
- }
-
/**
* Generates a new instance of FileSystemException.
*
@@ -71,4 +67,8 @@ public final class ExceptionConverter {
return new FileSystemException(msg);
}
+
+ /** Disallow instantiation. */
+ private ExceptionConverter() {
+ }
}
diff --git a/commons-vfs2-jackrabbit2/src/main/java/org/apache/commons/vfs2/provider/webdav4/Webdav4FileNameParser.java b/commons-vfs2-jackrabbit2/src/main/java/org/apache/commons/vfs2/provider/webdav4/Webdav4FileNameParser.java
index 01dc17f1..a2e017fe 100644
--- a/commons-vfs2-jackrabbit2/src/main/java/org/apache/commons/vfs2/provider/webdav4/Webdav4FileNameParser.java
+++ b/commons-vfs2-jackrabbit2/src/main/java/org/apache/commons/vfs2/provider/webdav4/Webdav4FileNameParser.java
@@ -27,12 +27,6 @@ import org.apache.commons.vfs2.provider.http4.Http4FileNameParser;
public class Webdav4FileNameParser extends Http4FileNameParser {
private static final Webdav4FileNameParser INSTANCE = new Webdav4FileNameParser();
- /**
- * Constructs a new instance.
- */
- public Webdav4FileNameParser() {
- }
-
/**
* Gets the singleton instance.
*
@@ -41,4 +35,10 @@ public class Webdav4FileNameParser extends Http4FileNameParser {
public static FileNameParser getInstance() {
return INSTANCE;
}
+
+ /**
+ * Constructs a new instance.
+ */
+ public Webdav4FileNameParser() {
+ }
}
diff --git a/commons-vfs2-jackrabbit2/src/main/java/org/apache/commons/vfs2/provider/webdav4/Webdav4FileSystemConfigBuilder.java b/commons-vfs2-jackrabbit2/src/main/java/org/apache/commons/vfs2/provider/webdav4/Webdav4FileSystemConfigBuilder.java
index 5fc5bc7d..f037ebb5 100644
--- a/commons-vfs2-jackrabbit2/src/main/java/org/apache/commons/vfs2/provider/webdav4/Webdav4FileSystemConfigBuilder.java
+++ b/commons-vfs2-jackrabbit2/src/main/java/org/apache/commons/vfs2/provider/webdav4/Webdav4FileSystemConfigBuilder.java
@@ -43,10 +43,6 @@ public final class Webdav4FileSystemConfigBuilder extends Http4FileSystemConfigB
private static final boolean DEFAULT_FOLLOW_REDIRECT = false;
- private Webdav4FileSystemConfigBuilder() {
- super("webdav4.");
- }
-
/**
* Gets the singleton builder.
*
@@ -56,12 +52,8 @@ public final class Webdav4FileSystemConfigBuilder extends Http4FileSystemConfigB
return BUILDER;
}
- /**
- * @return The Webdav FileSystem Class object.
- */
- @Override
- protected Class<? extends FileSystem> getConfigClass() {
- return Webdav4FileSystem.class;
+ private Webdav4FileSystemConfigBuilder() {
+ super("webdav4.");
}
/**
@@ -77,6 +69,14 @@ public final class Webdav4FileSystemConfigBuilder extends Http4FileSystemConfigB
return getBoolean(opts, KEY_APPEND_TRAILING_SLASH, DEFAULT_APPEND_TRAILING_SLASH);
}
+ /**
+ * @return The Webdav FileSystem Class object.
+ */
+ @Override
+ protected Class<? extends FileSystem> getConfigClass() {
+ return Webdav4FileSystem.class;
+ }
+
/**
* Return the user name to be associated with changes to the file.
*
diff --git a/commons-vfs2-jackrabbit2/src/main/java/org/apache/commons/vfs2/provider/webdav4s/Webdav4sFileNameParser.java b/commons-vfs2-jackrabbit2/src/main/java/org/apache/commons/vfs2/provider/webdav4s/Webdav4sFileNameParser.java
index de764f16..4b3dd1a6 100644
--- a/commons-vfs2-jackrabbit2/src/main/java/org/apache/commons/vfs2/provider/webdav4s/Webdav4sFileNameParser.java
+++ b/commons-vfs2-jackrabbit2/src/main/java/org/apache/commons/vfs2/provider/webdav4s/Webdav4sFileNameParser.java
@@ -28,12 +28,6 @@ public class Webdav4sFileNameParser extends Http4sFileNameParser {
private static final Webdav4sFileNameParser INSTANCE = new Webdav4sFileNameParser();
- /**
- * Constructs a new instance.
- */
- public Webdav4sFileNameParser() {
- }
-
/**
* Gets the singleton instance.
*
@@ -42,4 +36,10 @@ public class Webdav4sFileNameParser extends Http4sFileNameParser {
public static FileNameParser getInstance() {
return INSTANCE;
}
+
+ /**
+ * Constructs a new instance.
+ */
+ public Webdav4sFileNameParser() {
+ }
}
diff --git a/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/mime/MimeAttributesMap.java b/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/mime/MimeAttributesMap.java
index 8c62b26a..33ca961f 100644
--- a/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/mime/MimeAttributesMap.java
+++ b/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/mime/MimeAttributesMap.java
@@ -71,12 +71,19 @@ public class MimeAttributesMap implements Map<String, Object> {
}
}
- private Map<String, Object> getMap() {
- if (backingMap == null) {
- backingMap = createMap();
- }
+ @Override
+ public void clear() {
+ throw new UnsupportedOperationException();
+ }
- return backingMap;
+ @Override
+ public boolean containsKey(final Object key) {
+ return getMap().containsKey(key);
+ }
+
+ @Override
+ public boolean containsValue(final Object value) {
+ return getMap().containsValue(value);
}
private Map<String, Object> createMap() {
@@ -161,37 +168,35 @@ public class MimeAttributesMap implements Map<String, Object> {
}
@Override
- public int size() {
- return getMap().size();
+ public Set<Entry<String, Object>> entrySet() {
+ return Collections.unmodifiableSet(getMap().entrySet());
}
@Override
- public boolean isEmpty() {
- return getMap().size() < 1;
+ public Object get(final Object key) {
+ return getMap().get(key);
}
- @Override
- public boolean containsKey(final Object key) {
- return getMap().containsKey(key);
- }
+ private Map<String, Object> getMap() {
+ if (backingMap == null) {
+ backingMap = createMap();
+ }
- @Override
- public boolean containsValue(final Object value) {
- return getMap().containsValue(value);
+ return backingMap;
}
@Override
- public Object get(final Object key) {
- return getMap().get(key);
+ public boolean isEmpty() {
+ return getMap().size() < 1;
}
@Override
- public Object put(final String key, final Object value) {
- throw new UnsupportedOperationException();
+ public Set<String> keySet() {
+ return Collections.unmodifiableSet(getMap().keySet());
}
@Override
- public Object remove(final Object key) {
+ public Object put(final String key, final Object value) {
throw new UnsupportedOperationException();
}
@@ -201,22 +206,17 @@ public class MimeAttributesMap implements Map<String, Object> {
}
@Override
- public void clear() {
+ public Object remove(final Object key) {
throw new UnsupportedOperationException();
}
@Override
- public Set<String> keySet() {
- return Collections.unmodifiableSet(getMap().keySet());
+ public int size() {
+ return getMap().size();
}
@Override
public Collection<Object> values() {
return Collections.unmodifiableCollection(getMap().values());
}
-
- @Override
- public Set<Entry<String, Object>> entrySet() {
- return Collections.unmodifiableSet(getMap().entrySet());
- }
}
diff --git a/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/mime/MimeFileObject.java b/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/mime/MimeFileObject.java
index d221099f..b7734fa0 100644
--- a/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/mime/MimeFileObject.java
+++ b/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/mime/MimeFileObject.java
@@ -68,37 +68,74 @@ public class MimeFileObject extends AbstractFileObject<MimeFileSystem> implement
}
}
- private Part findPart(final String partName) throws Exception {
- if (getType() == FileType.IMAGINARY) {
- // not existent
- return null;
+ @Override
+ protected void doDetach() throws Exception {
+ }
+
+ /**
+ * Returns all headers of this part.
+ * <p>
+ * The map key is a java.lang.String and the value is a:
+ * <ul>
+ * <li>{@code java.lang.Strings} for single entries or a</li>
+ * <li>{@code java.utils.List<java.lang.Strings>} for entries with multiple values</li>
+ * </ul>
+ */
+ @Override
+ protected Map<String, Object> doGetAttributes() throws Exception {
+ if (attributeMap == null) {
+ if (part != null) {
+ attributeMap = new MimeAttributesMap(part);
+ } else {
+ attributeMap = Collections.emptyMap();
+ }
}
- if (isMultipart()) {
- final Multipart multipart = (Multipart) part.getContent();
- if (partName.startsWith(MimeFileSystem.NULL_BP_NAME)) {
- final int partNumber = Integer.parseInt(partName.substring(MimeFileSystem.NULL_BP_NAME.length()), 10);
- if (partNumber < 0 || partNumber + 1 > multipart.getCount()) {
- // non existent
- return null;
- }
+ return attributeMap;
+ }
- return multipart.getBodyPart(partNumber);
- }
+ /**
+ * Returns the size of the file content (in bytes).
+ */
+ @Override
+ protected long doGetContentSize() throws Exception {
+ return part.getSize();
+ }
- for (int i = 0; i < multipart.getCount(); i++) {
- final Part childPart = multipart.getBodyPart(i);
- if (partName.equals(childPart.getFileName())) {
- return childPart;
- }
+ /**
+ * Creates an input stream to read the file content from.
+ */
+ @Override
+ protected InputStream doGetInputStream(final int bufferSize) throws Exception {
+ if (isMultipart()) {
+ // deliver the preamble as the only content
+
+ final String preamble = ((MimeMultipart) part.getContent()).getPreamble();
+ if (preamble == null) {
+ return new ByteArrayInputStream(new byte[] {});
}
+ return new ByteArrayInputStream(preamble.getBytes(MimeFileSystem.PREAMBLE_CHARSET));
}
- return null;
+ return part.getInputStream();
}
+ /**
+ * Returns the last modified time of this file.
+ */
@Override
- protected void doDetach() throws Exception {
+ protected long doGetLastModifiedTime() throws Exception {
+ final Message mm = getMessage();
+ if (mm == null) {
+ return -1;
+ }
+ if (mm.getSentDate() != null) {
+ return mm.getSentDate().getTime();
+ }
+ if (mm.getReceivedDate() != null) {
+ mm.getReceivedDate();
+ }
+ return 0;
}
/**
@@ -159,65 +196,38 @@ public class MimeFileObject extends AbstractFileObject<MimeFileSystem> implement
return vfs.toArray(new MimeFileObject[0]);
}
- private void setPart(final Part part) {
- this.part = part;
- this.attributeMap = null;
- }
-
- /**
- * Returns the size of the file content (in bytes).
- */
- @Override
- protected long doGetContentSize() throws Exception {
- return part.getSize();
- }
-
- /**
- * Returns the last modified time of this file.
- */
- @Override
- protected long doGetLastModifiedTime() throws Exception {
- final Message mm = getMessage();
- if (mm == null) {
- return -1;
- }
- if (mm.getSentDate() != null) {
- return mm.getSentDate().getTime();
- }
- if (mm.getReceivedDate() != null) {
- mm.getReceivedDate();
- }
- return 0;
- }
-
- private Message getMessage() throws FileSystemException {
- if (part instanceof Message) {
- return (Message) part;
+ private Part findPart(final String partName) throws Exception {
+ if (getType() == FileType.IMAGINARY) {
+ // not existent
+ return null;
}
- return ((MimeFileObject) FileObjectUtils.getAbstractFileObject(getParent())).getMessage();
- }
-
- /**
- * Creates an input stream to read the file content from.
- */
- @Override
- protected InputStream doGetInputStream(final int bufferSize) throws Exception {
if (isMultipart()) {
- // deliver the preamble as the only content
+ final Multipart multipart = (Multipart) part.getContent();
+ if (partName.startsWith(MimeFileSystem.NULL_BP_NAME)) {
+ final int partNumber = Integer.parseInt(partName.substring(MimeFileSystem.NULL_BP_NAME.length()), 10);
+ if (partNumber < 0 || partNumber + 1 > multipart.getCount()) {
+ // non existent
+ return null;
+ }
- final String preamble = ((MimeMultipart) part.getContent()).getPreamble();
- if (preamble == null) {
- return new ByteArrayInputStream(new byte[] {});
+ return multipart.getBodyPart(partNumber);
+ }
+
+ for (int i = 0; i < multipart.getCount(); i++) {
+ final Part childPart = multipart.getBodyPart(i);
+ if (partName.equals(childPart.getFileName())) {
+ return childPart;
+ }
}
- return new ByteArrayInputStream(preamble.getBytes(MimeFileSystem.PREAMBLE_CHARSET));
}
- return part.getInputStream();
+ return null;
}
- boolean isMultipart() throws MessagingException {
- return part.getContentType() != null && part.getContentType().startsWith("multipart/");
+ @SuppressWarnings("unchecked") // Javadoc says Part returns Header
+ protected Enumeration<Header> getAllHeaders() throws MessagingException {
+ return part.getAllHeaders();
}
@Override
@@ -225,34 +235,24 @@ public class MimeFileObject extends AbstractFileObject<MimeFileSystem> implement
return new MimeFileContentInfoFactory();
}
+ private Message getMessage() throws FileSystemException {
+ if (part instanceof Message) {
+ return (Message) part;
+ }
+
+ return ((MimeFileObject) FileObjectUtils.getAbstractFileObject(getParent())).getMessage();
+ }
+
protected Part getPart() {
return part;
}
- /**
- * Returns all headers of this part.
- * <p>
- * The map key is a java.lang.String and the value is a:
- * <ul>
- * <li>{@code java.lang.Strings} for single entries or a</li>
- * <li>{@code java.utils.List<java.lang.Strings>} for entries with multiple values</li>
- * </ul>
- */
- @Override
- protected Map<String, Object> doGetAttributes() throws Exception {
- if (attributeMap == null) {
- if (part != null) {
- attributeMap = new MimeAttributesMap(part);
- } else {
- attributeMap = Collections.emptyMap();
- }
- }
-
- return attributeMap;
+ boolean isMultipart() throws MessagingException {
+ return part.getContentType() != null && part.getContentType().startsWith("multipart/");
}
- @SuppressWarnings("unchecked") // Javadoc says Part returns Header
- protected Enumeration<Header> getAllHeaders() throws MessagingException {
- return part.getAllHeaders();
+ private void setPart(final Part part) {
+ this.part = part;
+ this.attributeMap = null;
}
}
diff --git a/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/mime/MimeFileSystem.java b/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/mime/MimeFileSystem.java
index 1019d646..b0459df0 100644
--- a/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/mime/MimeFileSystem.java
+++ b/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/mime/MimeFileSystem.java
@@ -51,14 +51,6 @@ public class MimeFileSystem extends AbstractFileSystem {
super(rootName, parentLayer, fileSystemOptions);
}
- /**
- * Creates a file object.
- */
- @Override
- protected FileObject createFile(final AbstractFileName name) throws FileSystemException {
- return new MimeFileObject(name, null, this);
- }
-
/**
* Returns the capabilities of this file system.
*/
@@ -67,20 +59,6 @@ public class MimeFileSystem extends AbstractFileSystem {
caps.addAll(MimeFileProvider.capabilities);
}
- @Override
- protected void doCloseCommunicationLink() {
- try {
- if (mimeStream == null) {
- return;
- }
-
- closeMimeStream();
- mimeStream = null;
- } catch (final IOException e) {
- log.warn(e.getLocalizedMessage(), e);
- }
- }
-
private void closeMimeStream() throws IOException {
if (mimeStream instanceof SharedRandomContentInputStream) {
((SharedRandomContentInputStream) mimeStream).closeAll();
@@ -106,4 +84,26 @@ public class MimeFileSystem extends AbstractFileSystem {
}
return new MimeMessage(null, mimeStream);
}
+
+ /**
+ * Creates a file object.
+ */
+ @Override
+ protected FileObject createFile(final AbstractFileName name) throws FileSystemException {
+ return new MimeFileObject(name, null, this);
+ }
+
+ @Override
+ protected void doCloseCommunicationLink() {
+ try {
+ if (mimeStream == null) {
+ return;
+ }
+
+ closeMimeStream();
+ mimeStream = null;
+ } catch (final IOException e) {
+ log.warn(e.getLocalizedMessage(), e);
+ }
+ }
}
diff --git a/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/smb/SmbFileName.java b/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/smb/SmbFileName.java
index d20630f8..3a109bcf 100644
--- a/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/smb/SmbFileName.java
+++ b/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/smb/SmbFileName.java
@@ -38,25 +38,6 @@ public class SmbFileName extends GenericFileName {
this.domain = domain;
}
- /**
- * Returns the share name.
- *
- * @return share name
- */
- public String getShare() {
- return share;
- }
-
- /**
- * Builds the root URI for this file name.
- */
- @Override
- protected void appendRootUri(final StringBuilder buffer, final boolean addPassword) {
- super.appendRootUri(buffer, addPassword);
- buffer.append('/');
- buffer.append(share);
- }
-
/**
* Put {@code domain} before @{code username} if both are set.
* <p>
@@ -71,6 +52,16 @@ public class SmbFileName extends GenericFileName {
super.appendCredentials(buffer, addPassword);
}
+ /**
+ * Builds the root URI for this file name.
+ */
+ @Override
+ protected void appendRootUri(final StringBuilder buffer, final boolean addPassword) {
+ super.appendRootUri(buffer, addPassword);
+ buffer.append('/');
+ buffer.append(share);
+ }
+
/**
* Factory method for creating name instances.
*
@@ -84,6 +75,24 @@ public class SmbFileName extends GenericFileName {
type);
}
+ /**
+ * Returns the domain name.
+ *
+ * @return domain name
+ */
+ public String getDomain() {
+ return domain;
+ }
+
+ /**
+ * Returns the share name.
+ *
+ * @return share name
+ */
+ public String getShare() {
+ return share;
+ }
+
/**
* Construct the path suitable for SmbFile when used with NtlmPasswordAuthentication.
*
@@ -109,13 +118,4 @@ public class SmbFileName extends GenericFileName {
uriWithoutAuth = sb.toString();
return uriWithoutAuth;
}
-
- /**
- * Returns the domain name.
- *
- * @return domain name
- */
- public String getDomain() {
- return domain;
- }
}
diff --git a/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/smb/SmbFileNameParser.java b/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/smb/SmbFileNameParser.java
index 278ca3cf..ba06d668 100644
--- a/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/smb/SmbFileNameParser.java
+++ b/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/smb/SmbFileNameParser.java
@@ -32,13 +32,6 @@ public class SmbFileNameParser extends URLFileNameParser {
private static final SmbFileNameParser INSTANCE = new SmbFileNameParser();
private static final int SMB_PORT = 139;
- /**
- * Creates a new instance with the default port 139.
- */
- public SmbFileNameParser() {
- super(SMB_PORT);
- }
-
/**
* Gets the singleton instance.
*
@@ -48,6 +41,27 @@ public class SmbFileNameParser extends URLFileNameParser {
return INSTANCE;
}
+ /**
+ * Creates a new instance with the default port 139.
+ */
+ public SmbFileNameParser() {
+ super(SMB_PORT);
+ }
+
+ private String extractDomain(final String username) {
+ if (username == null) {
+ return null;
+ }
+
+ for (int i = 0; i < username.length(); i++) {
+ if (username.charAt(i) == '\\') {
+ return username.substring(0, i);
+ }
+ }
+
+ return null;
+ }
+
@Override
public FileName parseUri(final VfsComponentContext context, final FileName base, final String fileName)
throws FileSystemException {
@@ -81,18 +95,4 @@ public class SmbFileNameParser extends URLFileNameParser {
return new SmbFileName(auth.getScheme(), auth.getHostName(), auth.getPort(), username, auth.getPassword(),
domain, share, path, fileType);
}
-
- private String extractDomain(final String username) {
- if (username == null) {
- return null;
- }
-
- for (int i = 0; i < username.length(); i++) {
- if (username.charAt(i) == '\\') {
- return username.substring(0, i);
- }
- }
-
- return null;
- }
}
diff --git a/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/smb/SmbFileObject.java b/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/smb/SmbFileObject.java
index d28fe288..af23aa44 100644
--- a/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/smb/SmbFileObject.java
+++ b/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/smb/SmbFileObject.java
@@ -52,23 +52,6 @@ public class SmbFileObject extends AbstractFileObject<SmbFileSystem> {
// this.fileName = UriParser.decode(name.getURI());
}
- /**
- * Attaches this file object to its file resource.
- */
- @Override
- protected void doAttach() throws Exception {
- // Defer creation of the SmbFile to here
- if (file == null) {
- file = createSmbFile(getName());
- }
- }
-
- @Override
- protected void doDetach() throws Exception {
- // file closed through content-streams
- file = null;
- }
-
private SmbFile createSmbFile(final FileName fileName)
throws MalformedURLException, SmbException, FileSystemException {
final SmbFileName smbFileName = (SmbFileName) fileName;
@@ -110,42 +93,23 @@ public class SmbFileObject extends AbstractFileObject<SmbFileSystem> {
}
/**
- * Determines the type of the file, returns null if the file does not exist.
- */
- @Override
- protected FileType doGetType() throws Exception {
- if (!file.exists()) {
- return FileType.IMAGINARY;
- }
- if (file.isDirectory()) {
- return FileType.FOLDER;
- }
- if (file.isFile()) {
- return FileType.FILE;
- }
-
- throw new FileSystemException("vfs.provider.smb/get-type.error", getName());
- }
-
- /**
- * Lists the children of the file. Is only called if {@link #doGetType} returns {@link FileType#FOLDER}.
+ * Attaches this file object to its file resource.
*/
@Override
- protected String[] doListChildren() throws Exception {
- // VFS-210: do not try to get listing for anything else than directories
- if (!file.isDirectory()) {
- return null;
+ protected void doAttach() throws Exception {
+ // Defer creation of the SmbFile to here
+ if (file == null) {
+ file = createSmbFile(getName());
}
-
- return UriParser.encode(file.list());
}
/**
- * Determines if this file is hidden.
+ * Creates this file as a folder.
*/
@Override
- protected boolean doIsHidden() throws Exception {
- return file.isHidden();
+ protected void doCreateFolder() throws Exception {
+ file.mkdir();
+ file = createSmbFile(getName());
}
/**
@@ -157,17 +121,9 @@ public class SmbFileObject extends AbstractFileObject<SmbFileSystem> {
}
@Override
- protected void doRename(final FileObject newfile) throws Exception {
- file.renameTo(createSmbFile(newfile.getName()));
- }
-
- /**
- * Creates this file as a folder.
- */
- @Override
- protected void doCreateFolder() throws Exception {
- file.mkdir();
- file = createSmbFile(getName());
+ protected void doDetach() throws Exception {
+ // file closed through content-streams
+ file = null;
}
/**
@@ -178,14 +134,6 @@ public class SmbFileObject extends AbstractFileObject<SmbFileSystem> {
return file.length();
}
- /**
- * Returns the last modified time of this file.
- */
- @Override
- protected long doGetLastModifiedTime() throws Exception {
- return file.getLastModified();
- }
-
/**
* Creates an input stream to read the file content from.
*/
@@ -205,6 +153,14 @@ public class SmbFileObject extends AbstractFileObject<SmbFileSystem> {
}
}
+ /**
+ * Returns the last modified time of this file.
+ */
+ @Override
+ protected long doGetLastModifiedTime() throws Exception {
+ return file.getLastModified();
+ }
+
/**
* Creates an output stream to write the file content to.
*/
@@ -221,6 +177,50 @@ public class SmbFileObject extends AbstractFileObject<SmbFileSystem> {
return new SmbFileRandomAccessContent(file, mode);
}
+ /**
+ * Determines the type of the file, returns null if the file does not exist.
+ */
+ @Override
+ protected FileType doGetType() throws Exception {
+ if (!file.exists()) {
+ return FileType.IMAGINARY;
+ }
+ if (file.isDirectory()) {
+ return FileType.FOLDER;
+ }
+ if (file.isFile()) {
+ return FileType.FILE;
+ }
+
+ throw new FileSystemException("vfs.provider.smb/get-type.error", getName());
+ }
+
+ /**
+ * Determines if this file is hidden.
+ */
+ @Override
+ protected boolean doIsHidden() throws Exception {
+ return file.isHidden();
+ }
+
+ /**
+ * Lists the children of the file. Is only called if {@link #doGetType} returns {@link FileType#FOLDER}.
+ */
+ @Override
+ protected String[] doListChildren() throws Exception {
+ // VFS-210: do not try to get listing for anything else than directories
+ if (!file.isDirectory()) {
+ return null;
+ }
+
+ return UriParser.encode(file.list());
+ }
+
+ @Override
+ protected void doRename(final FileObject newfile) throws Exception {
+ file.renameTo(createSmbFile(newfile.getName()));
+ }
+
@Override
protected boolean doSetLastModifiedTime(final long modtime) throws Exception {
file.setLastModified(modtime);
diff --git a/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/smb/SmbFileSystem.java b/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/smb/SmbFileSystem.java
index bae807d4..a300b71a 100644
--- a/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/smb/SmbFileSystem.java
+++ b/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/smb/SmbFileSystem.java
@@ -35,18 +35,18 @@ public class SmbFileSystem extends AbstractFileSystem {
}
/**
- * Creates a file object.
+ * Returns the capabilities of this file system.
*/
@Override
- protected FileObject createFile(final AbstractFileName name) throws FileSystemException {
- return new SmbFileObject(name, this);
+ protected void addCapabilities(final Collection<Capability> caps) {
+ caps.addAll(SmbFileProvider.capabilities);
}
/**
- * Returns the capabilities of this file system.
+ * Creates a file object.
*/
@Override
- protected void addCapabilities(final Collection<Capability> caps) {
- caps.addAll(SmbFileProvider.capabilities);
+ protected FileObject createFile(final AbstractFileName name) throws FileSystemException {
+ return new SmbFileObject(name, this);
}
}
diff --git a/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/util/FileObjectDataSource.java b/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/util/FileObjectDataSource.java
index 6d155c58..f8b90fa4 100644
--- a/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/util/FileObjectDataSource.java
+++ b/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/util/FileObjectDataSource.java
@@ -35,16 +35,6 @@ public class FileObjectDataSource implements DataSource {
this.fo = fo;
}
- @Override
- public InputStream getInputStream() throws IOException {
- return fo.getContent().getInputStream();
- }
-
- @Override
- public OutputStream getOutputStream() throws IOException {
- return fo.getContent().getOutputStream();
- }
-
@Override
public String getContentType() {
try {
@@ -54,8 +44,18 @@ public class FileObjectDataSource implements DataSource {
}
}
+ @Override
+ public InputStream getInputStream() throws IOException {
+ return fo.getContent().getInputStream();
+ }
+
@Override
public String getName() {
return fo.getName().getBaseName();
}
+
+ @Override
+ public OutputStream getOutputStream() throws IOException {
+ return fo.getContent().getOutputStream();
+ }
}
diff --git a/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/util/RACRandomAccessFile.java b/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/util/RACRandomAccessFile.java
index 125e22e8..1c507cbf 100644
--- a/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/util/RACRandomAccessFile.java
+++ b/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/util/RACRandomAccessFile.java
@@ -27,22 +27,27 @@ import org.apache.commons.vfs2.RandomAccessContent;
* instance.
*/
public class RACRandomAccessFile extends RandomAccessFile implements RandomAccessContent {
+ private static File createTempFile() throws IOException {
+ return File.createTempFile("fraf", "");
+ }
+
private final byte[] singleByteBuf = new byte[1];
private RandomAccessContent rac;
- public RACRandomAccessFile(final RandomAccessContent rac) throws IOException {
- this(createTempFile());
- this.rac = rac;
- }
-
private RACRandomAccessFile(final File tempFile) throws IOException {
super(tempFile, "r");
deleteTempFile(tempFile);
}
- private static File createTempFile() throws IOException {
- return File.createTempFile("fraf", "");
+ public RACRandomAccessFile(final RandomAccessContent rac) throws IOException {
+ this(createTempFile());
+ this.rac = rac;
+ }
+
+ @Override
+ public void close() throws IOException {
+ this.rac.close();
}
private void deleteTempFile(final File tempFile) {
@@ -61,13 +66,8 @@ public class RACRandomAccessFile extends RandomAccessFile implements RandomAcces
}
@Override
- public void seek(final long pos) throws IOException {
- this.rac.seek(pos);
- }
-
- @Override
- public int skipBytes(final int n) throws IOException {
- return this.rac.skipBytes(n);
+ public InputStream getInputStream() throws IOException {
+ return this.rac.getInputStream();
}
@Override
@@ -76,43 +76,36 @@ public class RACRandomAccessFile extends RandomAccessFile implements RandomAcces
}
@Override
- public void setLength(final long newLength) throws IOException {
- throw new IOException("Underlying RandomAccessContent instance length cannot be modified.");
- }
-
- @Override
- public InputStream getInputStream() throws IOException {
- return this.rac.getInputStream();
+ public final int read() throws IOException {
+ final byte[] buf = this.singleByteBuf;
+ final int count = read(buf, 0, 1);
+ return count < 0 ? -1 : buf[0] & 0xFF;
}
@Override
- public void close() throws IOException {
- this.rac.close();
+ public final int read(final byte[] b) throws IOException {
+ return read(b, 0, b.length);
}
@Override
- public final int read(final byte[] b) throws IOException {
- return read(b, 0, b.length);
+ public int read(final byte[] b, final int off, final int len) throws IOException {
+ this.rac.readFully(b, off, len);
+ return len;
}
@Override
- public final int read() throws IOException {
- final byte[] buf = this.singleByteBuf;
- final int count = read(buf, 0, 1);
- return count < 0 ? -1 : buf[0] & 0xFF;
+ public void seek(final long pos) throws IOException {
+ this.rac.seek(pos);
}
@Override
- public int read(final byte[] b, final int off, final int len) throws IOException {
- this.rac.readFully(b, off, len);
- return len;
+ public void setLength(final long newLength) throws IOException {
+ throw new IOException("Underlying RandomAccessContent instance length cannot be modified.");
}
@Override
- public final void write(final int b) throws IOException {
- final byte[] buf = this.singleByteBuf;
- buf[0] = (byte) b;
- write(buf, 0, 1);
+ public int skipBytes(final int n) throws IOException {
+ return this.rac.skipBytes(n);
}
@Override
@@ -125,4 +118,11 @@ public class RACRandomAccessFile extends RandomAccessFile implements RandomAcces
this.rac.write(b, off, len);
}
+ @Override
+ public final void write(final int b) throws IOException {
+ final byte[] buf = this.singleByteBuf;
+ buf[0] = (byte) b;
+ write(buf, 0, 1);
+ }
+
}
diff --git a/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/util/SharedRandomContentInputStream.java b/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/util/SharedRandomContentInputStream.java
index d7f559e6..910b8290 100644
--- a/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/util/SharedRandomContentInputStream.java
+++ b/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/util/SharedRandomContentInputStream.java
@@ -41,6 +41,10 @@ public class SharedRandomContentInputStream extends BufferedInputStream implemen
private long pos;
private long resetCount;
+ public SharedRandomContentInputStream(final FileObject fo) throws FileSystemException {
+ this(new HashSet<SharedRandomContentInputStream>(), fo, 0, -1, fo.getContent().getInputStream());
+ }
+
private SharedRandomContentInputStream(final Set<SharedRandomContentInputStream> createdStreams,
final FileObject fo, final long fileStart, final long fileEnd, final InputStream is)
throws FileSystemException {
@@ -60,53 +64,21 @@ public class SharedRandomContentInputStream extends BufferedInputStream implemen
}
}
- public SharedRandomContentInputStream(final FileObject fo) throws FileSystemException {
- this(new HashSet<SharedRandomContentInputStream>(), fo, 0, -1, fo.getContent().getInputStream());
- }
-
- @Override
- public synchronized int read() throws IOException {
- if (checkEnd()) {
- return -1;
- }
- final int r = super.read();
- pos++;
- resetCount++;
- return r;
+ protected long calcFilePosition(final long nadd) {
+ return getFilePosition() + nadd;
}
- @Override
- public synchronized int read(final byte[] b, final int off, int len) throws IOException {
- if (checkEnd()) {
- return -1;
- }
-
- if (fileEnd > -1 && calcFilePosition(len) > fileEnd) {
- // we can not read past our end
- len = (int) (fileEnd - getFilePosition());
- }
-
- final int nread = super.read(b, off, len);
- pos += nread;
- resetCount += nread;
- return nread;
+ private boolean checkEnd() {
+ return fileEnd > -1 && (getFilePosition() >= fileEnd);
}
@Override
- public synchronized long skip(long n) throws IOException {
- if (checkEnd()) {
- return -1;
- }
+ public void close() throws IOException {
+ super.close();
- if (fileEnd > -1 && calcFilePosition(n) > fileEnd) {
- // we can not skip past our end
- n = fileEnd - getFilePosition();
+ synchronized (createdStreams) {
+ createdStreams.remove(this);
}
-
- final long nskip = super.skip(n);
- pos += nskip;
- resetCount += nskip;
- return nskip;
}
/*
@@ -120,43 +92,29 @@ public class SharedRandomContentInputStream extends BufferedInputStream implemen
* return (int) available; }
*/
- private boolean checkEnd() {
- return fileEnd > -1 && (getFilePosition() >= fileEnd);
+ public void closeAll() throws IOException {
+ synchronized (createdStreams) {
+ final SharedRandomContentInputStream[] streams = new SharedRandomContentInputStream[createdStreams.size()];
+ createdStreams.toArray(streams);
+ for (final SharedRandomContentInputStream stream : streams) {
+ stream.close();
+ }
+ }
}
protected long getFilePosition() {
return fileStart + pos;
}
- protected long calcFilePosition(final long nadd) {
- return getFilePosition() + nadd;
- }
-
- @Override
- public synchronized void mark(final int readLimit) {
- super.mark(readLimit);
- resetCount = 0;
- }
-
- @Override
- public synchronized void reset() throws IOException {
- super.reset();
- pos -= resetCount;
- resetCount = 0;
- }
-
@Override
public long getPosition() {
return pos;
}
@Override
- public void close() throws IOException {
- super.close();
-
- synchronized (createdStreams) {
- createdStreams.remove(this);
- }
+ public synchronized void mark(final int readLimit) {
+ super.mark(readLimit);
+ resetCount = 0;
}
@Override
@@ -174,13 +132,55 @@ public class SharedRandomContentInputStream extends BufferedInputStream implemen
}
}
- public void closeAll() throws IOException {
- synchronized (createdStreams) {
- final SharedRandomContentInputStream[] streams = new SharedRandomContentInputStream[createdStreams.size()];
- createdStreams.toArray(streams);
- for (final SharedRandomContentInputStream stream : streams) {
- stream.close();
- }
+ @Override
+ public synchronized int read() throws IOException {
+ if (checkEnd()) {
+ return -1;
+ }
+ final int r = super.read();
+ pos++;
+ resetCount++;
+ return r;
+ }
+
+ @Override
+ public synchronized int read(final byte[] b, final int off, int len) throws IOException {
+ if (checkEnd()) {
+ return -1;
+ }
+
+ if (fileEnd > -1 && calcFilePosition(len) > fileEnd) {
+ // we can not read past our end
+ len = (int) (fileEnd - getFilePosition());
+ }
+
+ final int nread = super.read(b, off, len);
+ pos += nread;
+ resetCount += nread;
+ return nread;
+ }
+
+ @Override
+ public synchronized void reset() throws IOException {
+ super.reset();
+ pos -= resetCount;
+ resetCount = 0;
+ }
+
+ @Override
+ public synchronized long skip(long n) throws IOException {
+ if (checkEnd()) {
+ return -1;
+ }
+
+ if (fileEnd > -1 && calcFilePosition(n) > fileEnd) {
+ // we can not skip past our end
+ n = fileEnd - getFilePosition();
}
+
+ final long nskip = super.skip(n);
+ pos += nskip;
+ resetCount += nskip;
+ return nskip;
}
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/FileSystemException.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/FileSystemException.java
index 6a734595..41e6e93c 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/FileSystemException.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/FileSystemException.java
@@ -39,6 +39,52 @@ public class FileSystemException extends IOException {
/** Password pattern */
private static final Pattern PASSWORD_PATTERN = Pattern.compile(":(?:[^/]+)@");
+ /**
+ * Throws a FileSystemException when the given object is null.
+ *
+ * @param obj
+ * the object reference to check for null.
+ * @param code
+ * message used when {@code
+ * FileSystemException} is thrown
+ * @param <T>
+ * the type of the reference
+ * @return {@code obj} if not {@code null}
+ * @throws FileSystemException
+ * if {@code obj} is {@code null}
+ * @since 2.3
+ */
+ public static <T> T requireNonNull(final T obj, final String code) throws FileSystemException {
+ if (obj == null) {
+ throw new FileSystemException(code);
+ }
+ return obj;
+ }
+
+ /**
+ * Throws a FileSystemException when the given object is null.
+ *
+ * @param obj
+ * the object reference to check for null.
+ * @param code
+ * message used when {@code
+ * FileSystemException} is thrown
+ * @param info
+ * one context information.
+ * @param <T>
+ * the type of the reference
+ * @return {@code obj} if not {@code null}
+ * @throws FileSystemException
+ * if {@code obj} is {@code null}
+ * @since 2.3
+ */
+ public static <T> T requireNonNull(final T obj, final String code, final Object... info) throws FileSystemException {
+ if (obj == null) {
+ throw new FileSystemException(code, info);
+ }
+ return obj;
+ }
+
/**
* Array of complementary info (context).
*/
@@ -142,52 +188,6 @@ public class FileSystemException extends IOException {
this(cause.getMessage(), cause, (Object[]) null);
}
- /**
- * Throws a FileSystemException when the given object is null.
- *
- * @param obj
- * the object reference to check for null.
- * @param code
- * message used when {@code
- * FileSystemException} is thrown
- * @param <T>
- * the type of the reference
- * @return {@code obj} if not {@code null}
- * @throws FileSystemException
- * if {@code obj} is {@code null}
- * @since 2.3
- */
- public static <T> T requireNonNull(final T obj, final String code) throws FileSystemException {
- if (obj == null) {
- throw new FileSystemException(code);
- }
- return obj;
- }
-
- /**
- * Throws a FileSystemException when the given object is null.
- *
- * @param obj
- * the object reference to check for null.
- * @param code
- * message used when {@code
- * FileSystemException} is thrown
- * @param info
- * one context information.
- * @param <T>
- * the type of the reference
- * @return {@code obj} if not {@code null}
- * @throws FileSystemException
- * if {@code obj} is {@code null}
- * @since 2.3
- */
- public static <T> T requireNonNull(final T obj, final String code, final Object... info) throws FileSystemException {
- if (obj == null) {
- throw new FileSystemException(code, info);
- }
- return obj;
- }
-
/**
* Retrieves error code of the exception. Could be used as key for internationalization.
*
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/FileUtil.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/FileUtil.java
index 7157a331..2e616c4f 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/FileUtil.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/FileUtil.java
@@ -29,13 +29,6 @@ import org.apache.commons.vfs2.util.FileObjectUtils;
@Deprecated
public final class FileUtil {
- /**
- * No instances.
- */
- private FileUtil() {
- // empty
- }
-
/**
* Copies the content from a source file to a destination file.
*
@@ -78,4 +71,11 @@ public final class FileUtil {
FileObjectUtils.writeContent(file, output);
}
+ /**
+ * No instances.
+ */
+ private FileUtil() {
+ // empty
+ }
+
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/VFS.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/VFS.java
index 36e4e044..8fb4497b 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/VFS.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/VFS.java
@@ -33,10 +33,6 @@ public final class VFS {
/** The URI style */
private static Boolean uriStyle;
- private VFS() {
- // no public instantiation.
- }
-
/**
* Closes the default {@link FileSystemManager} instance.
* <p>
@@ -142,4 +138,8 @@ public final class VFS {
}
VFS.uriStyle = Boolean.valueOf(uriStyle);
}
+
+ private VFS() {
+ // no public instantiation.
+ }
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/VfsLog.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/VfsLog.java
index 7a11a5c3..ce224fe1 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/VfsLog.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/VfsLog.java
@@ -24,10 +24,6 @@ import org.apache.commons.logging.Log;
*/
public final class VfsLog {
- // static utility class
- private VfsLog() {
- }
-
/**
* debug.
*
@@ -182,4 +178,8 @@ public final class VfsLog {
commonslog.warn(message, t);
}
}
+
+ // static utility class
+ private VfsLog() {
+ }
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/AgeFileFilter.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/AgeFileFilter.java
index a469a7b4..c8799954 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/AgeFileFilter.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/AgeFileFilter.java
@@ -54,6 +54,29 @@ public class AgeFileFilter implements FileFilter, Serializable {
private static final long serialVersionUID = 1L;
+ /**
+ * Tests if the specified {@code File} is newer than the specified time
+ * reference.
+ *
+ * @param fileObject the {@code File} of which the modification date must
+ * be compared, must not be {@code null}
+ * @param timeMillis the time reference measured in milliseconds since the epoch
+ * (00:00:00 GMT, January 1, 1970)
+ * @return true if the {@code File} exists and has been modified after the
+ * given time reference.
+ * @throws FileSystemException Thrown for file system errors.
+ * @throws IllegalArgumentException if the file is {@code null}
+ */
+ private static boolean isFileNewer(final FileObject fileObject, final long timeMillis) throws FileSystemException {
+ Objects.requireNonNull(fileObject, "fileObject");
+ if (!fileObject.exists()) {
+ return false;
+ }
+ try (FileContent content = fileObject.getContent()) {
+ return content.getLastModifiedTime() > timeMillis;
+ }
+ }
+
/** Whether the files accepted will be older or newer. */
private final boolean acceptOlder;
@@ -135,29 +158,6 @@ public class AgeFileFilter implements FileFilter, Serializable {
this.cutoff = cutoff;
}
- /**
- * Tests if the specified {@code File} is newer than the specified time
- * reference.
- *
- * @param fileObject the {@code File} of which the modification date must
- * be compared, must not be {@code null}
- * @param timeMillis the time reference measured in milliseconds since the epoch
- * (00:00:00 GMT, January 1, 1970)
- * @return true if the {@code File} exists and has been modified after the
- * given time reference.
- * @throws FileSystemException Thrown for file system errors.
- * @throws IllegalArgumentException if the file is {@code null}
- */
- private static boolean isFileNewer(final FileObject fileObject, final long timeMillis) throws FileSystemException {
- Objects.requireNonNull(fileObject, "fileObject");
- if (!fileObject.exists()) {
- return false;
- }
- try (FileContent content = fileObject.getContent()) {
- return content.getLastModifiedTime() > timeMillis;
- }
- }
-
/**
* Checks to see if the last modification of the file matches cutoff favorably.
* <p>
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/IOCase.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/IOCase.java
index af6df87c..41aea63d 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/IOCase.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/IOCase.java
@@ -67,6 +67,22 @@ public enum IOCase {
/** Serialization version. */
private static final long serialVersionUID = -6343169151696340687L;
+ /**
+ * Factory method to create an IOCase from a name.
+ *
+ * @param name the name to find
+ * @return the IOCase object
+ * @throws IllegalArgumentException if the name is invalid
+ */
+ public static IOCase forName(final String name) {
+ for (final IOCase ioCase : IOCase.values()) {
+ if (ioCase.getName().equals(name)) {
+ return ioCase;
+ }
+ }
+ throw new IllegalArgumentException("Invalid IOCase name: " + name);
+ }
+
/** The enumeration name. */
private final String name;
@@ -84,22 +100,6 @@ public enum IOCase {
this.sensitive = sensitive;
}
- /**
- * Factory method to create an IOCase from a name.
- *
- * @param name the name to find
- * @return the IOCase object
- * @throws IllegalArgumentException if the name is invalid
- */
- public static IOCase forName(final String name) {
- for (final IOCase ioCase : IOCase.values()) {
- if (ioCase.getName().equals(name)) {
- return ioCase;
- }
- }
- throw new IllegalArgumentException("Invalid IOCase name: " + name);
- }
-
/**
* Compares two strings using the case-sensitivity rule.
* <p>
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/WildcardFileFilter.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/WildcardFileFilter.java
index 97c135e0..60033b2a 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/WildcardFileFilter.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/WildcardFileFilter.java
@@ -61,65 +61,6 @@ public class WildcardFileFilter implements FileFilter, Serializable {
private static final long serialVersionUID = 1L;
- /** Whether the comparison is case-sensitive. */
- private final IOCase caseSensitivity;
-
- /** The wildcards that will be used to match file names. */
- private final List<String> wildcards;
-
- /**
- * Construct a new wildcard filter for a list of wildcards specifying
- * case-sensitivity.
- *
- * @param caseSensitivity how to handle case sensitivity, null means
- * case-sensitive
- * @param wildcards the list of wildcards to match, not null
- */
- public WildcardFileFilter(final IOCase caseSensitivity, final List<String> wildcards) {
- if (wildcards == null) {
- throw new IllegalArgumentException("The wildcard list must not be null");
- }
- this.wildcards = new ArrayList<>(wildcards);
- this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity;
- }
-
- /**
- * Construct a new wildcard filter for an array of wildcards specifying
- * case-sensitivity.
- *
- * @param caseSensitivity how to handle case sensitivity, null means
- * case-sensitive
- * @param wildcards the array of wildcards to match, not null
- */
- public WildcardFileFilter(final IOCase caseSensitivity, final String... wildcards) {
- if (wildcards == null) {
- throw new IllegalArgumentException("The wildcard array must not be null");
- }
- this.wildcards = new ArrayList<>(Arrays.asList(wildcards));
- this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity;
- }
-
- /**
- * Construct a new case-sensitive wildcard filter for a list of wildcards.
- *
- * @param wildcards the list of wildcards to match, not null
- */
- public WildcardFileFilter(final List<String> wildcards) {
- this(null, wildcards);
- }
-
- /**
- * Construct a new case-sensitive wildcard filter for an array of wildcards.
- * <p>
- * The array is not cloned, so could be changed after constructing the instance.
- * This would be inadvisable however.
- *
- * @param wildcards the array of wildcards to match
- */
- public WildcardFileFilter(final String... wildcards) {
- this(null, wildcards);
- }
-
/**
* Splits a string into a number of tokens. The text is split by '?' and '*'.
* Where multiple '*' occur consecutively they are collapsed into a single '*'.
@@ -260,6 +201,65 @@ public class WildcardFileFilter implements FileFilter, Serializable {
}
// CHECKSTYLE:ON
+ /** Whether the comparison is case-sensitive. */
+ private final IOCase caseSensitivity;
+
+ /** The wildcards that will be used to match file names. */
+ private final List<String> wildcards;
+
+ /**
+ * Construct a new wildcard filter for a list of wildcards specifying
+ * case-sensitivity.
+ *
+ * @param caseSensitivity how to handle case sensitivity, null means
+ * case-sensitive
+ * @param wildcards the list of wildcards to match, not null
+ */
+ public WildcardFileFilter(final IOCase caseSensitivity, final List<String> wildcards) {
+ if (wildcards == null) {
+ throw new IllegalArgumentException("The wildcard list must not be null");
+ }
+ this.wildcards = new ArrayList<>(wildcards);
+ this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity;
+ }
+
+ /**
+ * Construct a new wildcard filter for an array of wildcards specifying
+ * case-sensitivity.
+ *
+ * @param caseSensitivity how to handle case sensitivity, null means
+ * case-sensitive
+ * @param wildcards the array of wildcards to match, not null
+ */
+ public WildcardFileFilter(final IOCase caseSensitivity, final String... wildcards) {
+ if (wildcards == null) {
+ throw new IllegalArgumentException("The wildcard array must not be null");
+ }
+ this.wildcards = new ArrayList<>(Arrays.asList(wildcards));
+ this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity;
+ }
+
+ /**
+ * Construct a new case-sensitive wildcard filter for a list of wildcards.
+ *
+ * @param wildcards the list of wildcards to match, not null
+ */
+ public WildcardFileFilter(final List<String> wildcards) {
+ this(null, wildcards);
+ }
+
+ /**
+ * Construct a new case-sensitive wildcard filter for an array of wildcards.
+ * <p>
+ * The array is not cloned, so could be changed after constructing the instance.
+ * This would be inadvisable however.
+ *
+ * @param wildcards the array of wildcards to match
+ */
+ public WildcardFileFilter(final String... wildcards) {
+ this(null, wildcards);
+ }
+
/**
* Checks to see if the file name matches one of the wildcards.
*
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractFileName.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractFileName.java
index a7ab0a56..7356b319 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractFileName.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractFileName.java
@@ -42,39 +42,6 @@ public abstract class AbstractFileName implements FileName {
// Therefore only # is a reserved char in a URI as part of the path that can be in the file name.
private static final char[] RESERVED_URI_CHARS = {'#', ' '};
- private final String scheme;
- private final String absPath;
- private FileType type;
-
- // Cached attributes
- private String uriString;
- private String baseName;
- private String rootUri;
- private String extension;
- private String decodedAbsPath;
-
- private String key;
-
- /**
- * Constructs a new instance.
- *
- * @param scheme The scheme.
- * @param absolutePath the absolute path, maybe empty or null.
- * @param type the file type.
- */
- public AbstractFileName(final String scheme, final String absolutePath, final FileType type) {
- this.rootUri = null;
- this.scheme = scheme;
- this.type = type;
- if (StringUtils.isEmpty(absolutePath)) {
- this.absPath = ROOT_PATH;
- } else if (absolutePath.length() > 1 && absolutePath.endsWith("/")) {
- this.absPath = absolutePath.substring(0, absolutePath.length() - 1);
- } else {
- this.absPath = absolutePath;
- }
- }
-
/**
* Checks whether a path fits in a particular scope of another path.
*
@@ -111,6 +78,39 @@ public abstract class AbstractFileName implements FileName {
}
throw new IllegalArgumentException();
}
+ private final String scheme;
+ private final String absPath;
+
+ private FileType type;
+ // Cached attributes
+ private String uriString;
+ private String baseName;
+ private String rootUri;
+ private String extension;
+
+ private String decodedAbsPath;
+
+ private String key;
+
+ /**
+ * Constructs a new instance.
+ *
+ * @param scheme The scheme.
+ * @param absolutePath the absolute path, maybe empty or null.
+ * @param type the file type.
+ */
+ public AbstractFileName(final String scheme, final String absolutePath, final FileType type) {
+ this.rootUri = null;
+ this.scheme = scheme;
+ this.type = type;
+ if (StringUtils.isEmpty(absolutePath)) {
+ this.absPath = ROOT_PATH;
+ } else if (absolutePath.length() > 1 && absolutePath.endsWith("/")) {
+ this.absPath = absolutePath.substring(0, absolutePath.length() - 1);
+ } else {
+ this.absPath = absolutePath;
+ }
+ }
/**
* Builds the root URI for this file name. Note that the root URI must not end with a separator character.
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractFileObject.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractFileObject.java
index 06ad528e..b68c7113 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractFileObject.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractFileObject.java
@@ -78,39 +78,6 @@ public abstract class AbstractFileObject<AFS extends AbstractFileSystem> impleme
private static final String DO_GET_INPUT_STREAM_INT = "doGetInputStream(int)";
- private final AbstractFileName fileName;
- private final AFS fileSystem;
-
- private FileContent content;
- // Cached info
- private boolean attached;
- private FileType type;
-
- private FileObject parent;
- // Changed to hold only the name of the children and let the object
- // go into the global files cache
- // private FileObject[] children;
- private FileName[] children;
-
- private List<Object> objects;
-
- /**
- * FileServices instance.
- */
- private FileOperations operations;
-
- /**
- * Constructs a new instance.
- *
- * @param fileName the file name.
- * @param fileSystem the file system.
- */
- protected AbstractFileObject(final AbstractFileName fileName, final AFS fileSystem) {
- this.fileName = fileName;
- this.fileSystem = fileSystem;
- fileSystem.fileObjectHanded(this);
- }
-
/**
* Traverses a file.
*/
@@ -147,6 +114,39 @@ public abstract class AbstractFileObject<AFS extends AbstractFileSystem> impleme
}
}
}
+ private final AbstractFileName fileName;
+
+ private final AFS fileSystem;
+ private FileContent content;
+ // Cached info
+ private boolean attached;
+
+ private FileType type;
+ private FileObject parent;
+
+ // Changed to hold only the name of the children and let the object
+ // go into the global files cache
+ // private FileObject[] children;
+ private FileName[] children;
+
+ private List<Object> objects;
+
+ /**
+ * FileServices instance.
+ */
+ private FileOperations operations;
+
+ /**
+ * Constructs a new instance.
+ *
+ * @param fileName the file name.
+ * @param fileSystem the file system.
+ */
+ protected AbstractFileObject(final AbstractFileName fileName, final AFS fileSystem) {
+ this.fileName = fileName;
+ this.fileSystem = fileSystem;
+ fileSystem.fileObjectHanded(this);
+ }
/**
* Attaches to the file.
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/HostFileNameParser.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/HostFileNameParser.java
index 18aaeb3f..760bb9c9 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/HostFileNameParser.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/HostFileNameParser.java
@@ -146,6 +146,23 @@ public class HostFileNameParser extends AbstractFileNameParser {
}
}
+ private static boolean isHostNameTerminatingChar(final char ch, final boolean isIPv6Host) {
+ if (isIPv6Host) {
+ return ch == ']';
+ }
+
+ return ch == '/' || ch == ';' || ch == '?' || ch == ':' || ch == '@' || ch == '&' || ch == '=' || ch == '+'
+ || ch == '$' || ch == ',';
+ }
+
+ private static boolean isIPv6Host(String name) {
+ return name.length() > 0 && isIPv6HostHeadingChar(name.charAt(0));
+ }
+
+ private static boolean isIPv6HostHeadingChar(final char ch) {
+ return ch == '[';
+ }
+
private final int defaultPort;
/**
@@ -369,21 +386,4 @@ public class HostFileNameParser extends AbstractFileNameParser {
return new GenericFileName(auth.scheme, auth.hostName, auth.port, defaultPort, auth.userName, auth.password,
path, fileType);
}
-
- private static boolean isIPv6HostHeadingChar(final char ch) {
- return ch == '[';
- }
-
- private static boolean isHostNameTerminatingChar(final char ch, final boolean isIPv6Host) {
- if (isIPv6Host) {
- return ch == ']';
- }
-
- return ch == '/' || ch == ';' || ch == '?' || ch == ':' || ch == '@' || ch == '&' || ch == '=' || ch == '+'
- || ch == '$' || ch == ',';
- }
-
- private static boolean isIPv6Host(String name) {
- return name.length() > 0 && isIPv6HostHeadingChar(name.charAt(0));
- }
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/UriParser.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/UriParser.java
index 07411de5..327f6049 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/UriParser.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/UriParser.java
@@ -47,9 +47,6 @@ public final class UriParser {
private static final char LOW_MASK = 0x0F;
- private UriParser() {
- }
-
/**
* Encodes and appends a string to a StringBuilder.
*
@@ -560,4 +557,7 @@ public final class UriParser {
return fileType;
}
+
+ private UriParser() {
+ }
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/bzip2/Bzip2FileObject.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/bzip2/Bzip2FileObject.java
index 0d41ec3c..5510634b 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/bzip2/Bzip2FileObject.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/bzip2/Bzip2FileObject.java
@@ -32,25 +32,6 @@ import org.apache.commons.vfs2.provider.compressed.CompressedFileFileSystem;
*/
public class Bzip2FileObject extends CompressedFileFileObject<Bzip2FileSystem> {
- protected Bzip2FileObject(final AbstractFileName name, final FileObject container, final Bzip2FileSystem fs) {
- super(name, container, fs);
- }
-
- /**
- * Deprecated since 2.1.
- *
- * @param name Abstract file name.
- * @param container My container.
- * @param fs My file system.
- *
- * @deprecated Use {@link #Bzip2FileObject(AbstractFileName, FileObject, Bzip2FileSystem)} instead.
- */
- @Deprecated
- protected Bzip2FileObject(final AbstractFileName name, final FileObject container,
- final CompressedFileFileSystem fs) {
- super(name, container, cast(fs));
- }
-
private static Bzip2FileSystem cast(final CompressedFileFileSystem fs) {
if (fs instanceof Bzip2FileSystem) {
return (Bzip2FileSystem) fs;
@@ -70,6 +51,25 @@ public class Bzip2FileObject extends CompressedFileFileObject<Bzip2FileSystem> {
return new BZip2CompressorInputStream(inputStream);
}
+ protected Bzip2FileObject(final AbstractFileName name, final FileObject container, final Bzip2FileSystem fs) {
+ super(name, container, fs);
+ }
+
+ /**
+ * Deprecated since 2.1.
+ *
+ * @param name Abstract file name.
+ * @param container My container.
+ * @param fs My file system.
+ *
+ * @deprecated Use {@link #Bzip2FileObject(AbstractFileName, FileObject, Bzip2FileSystem)} instead.
+ */
+ @Deprecated
+ protected Bzip2FileObject(final AbstractFileName name, final FileObject container,
+ final CompressedFileFileSystem fs) {
+ super(name, container, cast(fs));
+ }
+
@Override
protected InputStream doGetInputStream(final int bufferSize) throws Exception {
// check file
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpClientFactory.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpClientFactory.java
index eb8b8750..ffd6d458 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpClientFactory.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpClientFactory.java
@@ -281,9 +281,6 @@ public final class FtpClientFactory {
}
}
- private FtpClientFactory() {
- }
-
/**
* Creates a new connection to the server.
*
@@ -302,4 +299,7 @@ public final class FtpClientFactory {
final FtpConnectionFactory factory = new FtpConnectionFactory(FtpFileSystemConfigBuilder.getInstance());
return factory.createConnection(hostname, port, username, password, workingDirectory, fileSystemOptions);
}
+
+ private FtpClientFactory() {
+ }
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpFileNameParser.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpFileNameParser.java
index 8798226d..8f7e17e3 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpFileNameParser.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpFileNameParser.java
@@ -28,13 +28,6 @@ public class FtpFileNameParser extends HostFileNameParser {
private static final int PORT = 21;
- /**
- * Constructs a new instance with the default port.
- */
- public FtpFileNameParser() {
- super(PORT);
- }
-
/**
* Gets the singleton instance.
*
@@ -43,4 +36,11 @@ public class FtpFileNameParser extends HostFileNameParser {
public static FileNameParser getInstance() {
return INSTANCE;
}
+
+ /**
+ * Constructs a new instance with the default port.
+ */
+ public FtpFileNameParser() {
+ super(PORT);
+ }
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpFileSystemConfigBuilder.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpFileSystemConfigBuilder.java
index 6aa81bea..9dd85b59 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpFileSystemConfigBuilder.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpFileSystemConfigBuilder.java
@@ -61,20 +61,6 @@ public class FtpFileSystemConfigBuilder extends FileSystemConfigBuilder {
private static final String TRANSFER_ABORTED_OK_REPLY_CODES = PREFIX + ".TRANSFER_ABORTED_OK_REPLY_CODES";
private static final String MDTM_LAST_MODIFED_TIME = PREFIX + ".MDTM_LAST_MODIFED_TIME";
- private FtpFileSystemConfigBuilder() {
- super("ftp.");
- }
-
- /**
- * Create new config builder with specified prefix string.
- *
- * @param prefix prefix string to use for parameters of this config builder.
- * @since 2.1
- */
- protected FtpFileSystemConfigBuilder(final String prefix) {
- super(prefix);
- }
-
/**
* Gets the singleton instance.
*
@@ -96,6 +82,31 @@ public class FtpFileSystemConfigBuilder extends FileSystemConfigBuilder {
return new ArrayList<>(Arrays.asList(FTPReply.TRANSFER_ABORTED, FTPReply.FILE_UNAVAILABLE));
}
+ private FtpFileSystemConfigBuilder() {
+ super("ftp.");
+ }
+
+ /**
+ * Create new config builder with specified prefix string.
+ *
+ * @param prefix prefix string to use for parameters of this config builder.
+ * @since 2.1
+ */
+ protected FtpFileSystemConfigBuilder(final String prefix) {
+ super(prefix);
+ }
+
+ /**
+ * Gets the active port range.
+ *
+ * @param options The FileSystemOptions.
+ * @return the Range of active ports
+ * @since 2.10.0
+ */
+ public Range<Integer> getActivePortRange(final FileSystemOptions options) {
+ return getParam(options, ACTIVE_PORT_RANGE);
+ }
+
/**
* Gets whether to try to autodetect the server encoding (only UTF8 is supported).
*
@@ -246,17 +257,6 @@ public class FtpFileSystemConfigBuilder extends FileSystemConfigBuilder {
return getBoolean(options, PASSIVE_MODE);
}
- /**
- * Gets the active port range.
- *
- * @param options The FileSystemOptions.
- * @return the Range of active ports
- * @since 2.10.0
- */
- public Range<Integer> getActivePortRange(final FileSystemOptions options) {
- return getParam(options, ACTIVE_PORT_RANGE);
- }
-
/**
* Gets the Proxy.
*
@@ -368,6 +368,17 @@ public class FtpFileSystemConfigBuilder extends FileSystemConfigBuilder {
return getBoolean(options, USER_DIR_IS_ROOT, Boolean.TRUE);
}
+ /**
+ * Sets the active port range.
+ *
+ * @param options The FileSystemOptions.
+ * @param portRange the Range of active ports
+ * @since 2.10.0
+ */
+ public void setActivePortRange(final FileSystemOptions options, final Range<Integer> portRange) {
+ setParam(options, ACTIVE_PORT_RANGE, portRange);
+ }
+
/**
* Sets whether to try to autodetect the server encoding (only UTF8 is supported).
*
@@ -541,17 +552,6 @@ public class FtpFileSystemConfigBuilder extends FileSystemConfigBuilder {
setParam(options, PASSIVE_MODE, toBooleanObject(passiveMode));
}
- /**
- * Sets the active port range.
- *
- * @param options The FileSystemOptions.
- * @param portRange the Range of active ports
- * @since 2.10.0
- */
- public void setActivePortRange(final FileSystemOptions options, final Range<Integer> portRange) {
- setParam(options, ACTIVE_PORT_RANGE, portRange);
- }
-
/**
* Sets the Proxy.
* <p>
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsClientFactory.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsClientFactory.java
index ee43f42d..df178fb4 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsClientFactory.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsClientFactory.java
@@ -74,10 +74,6 @@ public final class FtpsClientFactory {
}
}
- private FtpsClientFactory() {
- // empty
- }
-
/**
* Creates a new connection to the server.
*
@@ -96,4 +92,8 @@ public final class FtpsClientFactory {
final FtpsConnectionFactory factory = new FtpsConnectionFactory(FtpsFileSystemConfigBuilder.getInstance());
return factory.createConnection(hostname, port, username, password, workingDirectory, fileSystemOptions);
}
+
+ private FtpsClientFactory() {
+ // empty
+ }
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsFileSystemConfigBuilder.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsFileSystemConfigBuilder.java
index 190e67ab..10eace79 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsFileSystemConfigBuilder.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsFileSystemConfigBuilder.java
@@ -39,10 +39,6 @@ public final class FtpsFileSystemConfigBuilder extends FtpFileSystemConfigBuilde
private static final String KEY_MANAGER = PREFIX + ".KEY_MANAGER";
private static final String TRUST_MANAGER = PREFIX + ".TRUST_MANAGER";
- private FtpsFileSystemConfigBuilder() {
- super("ftps.");
- }
-
/**
* Gets the singleton builder.
*
@@ -52,6 +48,10 @@ public final class FtpsFileSystemConfigBuilder extends FtpFileSystemConfigBuilde
return BUILDER;
}
+ private FtpsFileSystemConfigBuilder() {
+ super("ftps.");
+ }
+
/**
* Gets the data channel protection level (PROT).
*
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/gzip/GzipFileObject.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/gzip/GzipFileObject.java
index f087a2ce..6d184e68 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/gzip/GzipFileObject.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/gzip/GzipFileObject.java
@@ -31,6 +31,13 @@ import org.apache.commons.vfs2.provider.compressed.CompressedFileFileSystem;
*/
public class GzipFileObject extends CompressedFileFileObject<GzipFileSystem> {
+ private static GzipFileSystem cast(final CompressedFileFileSystem fs) {
+ if (fs instanceof GzipFileSystem) {
+ return (GzipFileSystem) fs;
+ }
+ throw new IllegalArgumentException("GzipFileObject expects an instance of GzipFileSystem");
+ }
+
/**
* Deprecated since 2.1.
*
@@ -50,13 +57,6 @@ public class GzipFileObject extends CompressedFileFileObject<GzipFileSystem> {
super(name, container, fs);
}
- private static GzipFileSystem cast(final CompressedFileFileSystem fs) {
- if (fs instanceof GzipFileSystem) {
- return (GzipFileSystem) fs;
- }
- throw new IllegalArgumentException("GzipFileObject expects an instance of GzipFileSystem");
- }
-
@Override
protected InputStream doGetInputStream(final int bufferSize) throws Exception {
return new GZIPInputStream(getContainer().getContent().getInputStream(), bufferSize);
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpClientFactory.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpClientFactory.java
index 022bda79..baa9db30 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpClientFactory.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpClientFactory.java
@@ -38,9 +38,6 @@ import org.apache.commons.vfs2.util.UserAuthenticatorUtils;
*/
public final class HttpClientFactory {
- private HttpClientFactory() {
- }
-
/**
* Creates a new connection to the server.
*
@@ -149,4 +146,7 @@ public final class HttpClientFactory {
return createConnection(HttpFileSystemConfigBuilder.getInstance(), scheme, hostname, port, username, password, fileSystemOptions);
}
+ private HttpClientFactory() {
+ }
+
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpFileNameParser.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpFileNameParser.java
index 40cde246..31b1e1e3 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpFileNameParser.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpFileNameParser.java
@@ -28,13 +28,6 @@ public class HttpFileNameParser extends URLFileNameParser {
private static final HttpFileNameParser INSTANCE = new HttpFileNameParser();
- /**
- * Creates a new instance with the default port 80.
- */
- public HttpFileNameParser() {
- super(DEFAULT_PORT);
- }
-
/**
* Gets the singleton instance.
*
@@ -43,4 +36,11 @@ public class HttpFileNameParser extends URLFileNameParser {
public static FileNameParser getInstance() {
return INSTANCE;
}
+
+ /**
+ * Creates a new instance with the default port 80.
+ */
+ public HttpFileNameParser() {
+ super(DEFAULT_PORT);
+ }
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpFileSystemConfigBuilder.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpFileSystemConfigBuilder.java
index b1d67c8a..30c52af8 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpFileSystemConfigBuilder.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpFileSystemConfigBuilder.java
@@ -57,6 +57,15 @@ public class HttpFileSystemConfigBuilder extends FileSystemConfigBuilder {
private static final String KEY_PREEMPTIVE_AUTHENTICATION = "preemptiveAuth";
+ /**
+ * Gets the singleton builder.
+ *
+ * @return the singleton builder.
+ */
+ public static HttpFileSystemConfigBuilder getInstance() {
+ return BUILDER;
+ }
+
private HttpFileSystemConfigBuilder() {
super("http.");
}
@@ -71,15 +80,6 @@ public class HttpFileSystemConfigBuilder extends FileSystemConfigBuilder {
super(prefix);
}
- /**
- * Gets the singleton builder.
- *
- * @return the singleton builder.
- */
- public static HttpFileSystemConfigBuilder getInstance() {
- return BUILDER;
- }
-
@Override
protected Class<? extends FileSystem> getConfigClass() {
return HttpFileSystem.class;
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http4/Http4FileNameParser.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http4/Http4FileNameParser.java
index 9c658ac1..0c0b39dc 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http4/Http4FileNameParser.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http4/Http4FileNameParser.java
@@ -30,13 +30,6 @@ public class Http4FileNameParser extends GenericURLFileNameParser {
private static final Http4FileNameParser INSTANCE = new Http4FileNameParser();
- /**
- * Creates a new instance with the default port 80.
- */
- public Http4FileNameParser() {
- super(DEFAULT_PORT);
- }
-
/**
* Gets the singleton instance.
*
@@ -45,4 +38,11 @@ public class Http4FileNameParser extends GenericURLFileNameParser {
public static FileNameParser getInstance() {
return INSTANCE;
}
+
+ /**
+ * Creates a new instance with the default port 80.
+ */
+ public Http4FileNameParser() {
+ super(DEFAULT_PORT);
+ }
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http4/Http4FileSystemConfigBuilder.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http4/Http4FileSystemConfigBuilder.java
index a9b64ce6..125b33f5 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http4/Http4FileSystemConfigBuilder.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http4/Http4FileSystemConfigBuilder.java
@@ -176,6 +176,15 @@ public class Http4FileSystemConfigBuilder extends FileSystemConfigBuilder {
*/
private static final String PROXY_SCHEME = "proxyScheme";
+ /**
+ * Gets the singleton builder.
+ *
+ * @return the singleton builder.
+ */
+ public static Http4FileSystemConfigBuilder getInstance() {
+ return BUILDER;
+ }
+
private Http4FileSystemConfigBuilder() {
super("http.");
}
@@ -189,15 +198,6 @@ public class Http4FileSystemConfigBuilder extends FileSystemConfigBuilder {
super(prefix);
}
- /**
- * Gets the singleton builder.
- *
- * @return the singleton builder.
- */
- public static Http4FileSystemConfigBuilder getInstance() {
- return BUILDER;
- }
-
@Override
protected Class<? extends FileSystem> getConfigClass() {
return Http4FileSystem.class;
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http4s/Http4sFileNameParser.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http4s/Http4sFileNameParser.java
index 669ca941..38bb2eba 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http4s/Http4sFileNameParser.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http4s/Http4sFileNameParser.java
@@ -30,13 +30,6 @@ public class Http4sFileNameParser extends GenericURLFileNameParser {
private static final Http4sFileNameParser INSTANCE = new Http4sFileNameParser();
- /**
- * Creates a new instance with the default port 443.
- */
- public Http4sFileNameParser() {
- super(DEFAULT_PORT);
- }
-
/**
* Gets the singleton instance.
*
@@ -45,4 +38,11 @@ public class Http4sFileNameParser extends GenericURLFileNameParser {
public static FileNameParser getInstance() {
return INSTANCE;
}
+
+ /**
+ * Creates a new instance with the default port 443.
+ */
+ public Http4sFileNameParser() {
+ super(DEFAULT_PORT);
+ }
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/Http5FileNameParser.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/Http5FileNameParser.java
index 5adfcf4f..a6e31f5e 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/Http5FileNameParser.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/Http5FileNameParser.java
@@ -30,13 +30,6 @@ public class Http5FileNameParser extends GenericURLFileNameParser {
private static final Http5FileNameParser INSTANCE = new Http5FileNameParser();
- /**
- * Creates a new instance with the default port 80.
- */
- public Http5FileNameParser() {
- super(DEFAULT_PORT);
- }
-
/**
* Gets the singleton instance.
*
@@ -45,4 +38,11 @@ public class Http5FileNameParser extends GenericURLFileNameParser {
public static FileNameParser getInstance() {
return INSTANCE;
}
+
+ /**
+ * Creates a new instance with the default port 80.
+ */
+ public Http5FileNameParser() {
+ super(DEFAULT_PORT);
+ }
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/Http5FileSystemConfigBuilder.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/Http5FileSystemConfigBuilder.java
index 0d0c0934..7f81840b 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/Http5FileSystemConfigBuilder.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/Http5FileSystemConfigBuilder.java
@@ -196,6 +196,15 @@ public class Http5FileSystemConfigBuilder extends FileSystemConfigBuilder {
*/
private static final String DEFAULT_TLS_VERSIONS = "V_1_2";
+ /**
+ * Gets the singleton builder.
+ *
+ * @return the singleton builder.
+ */
+ public static Http5FileSystemConfigBuilder getInstance() {
+ return BUILDER;
+ }
+
private Http5FileSystemConfigBuilder() {
super("http.");
}
@@ -209,15 +218,6 @@ public class Http5FileSystemConfigBuilder extends FileSystemConfigBuilder {
super(prefix);
}
- /**
- * Gets the singleton builder.
- *
- * @return the singleton builder.
- */
- public static Http5FileSystemConfigBuilder getInstance() {
- return BUILDER;
- }
-
@Override
protected Class<? extends FileSystem> getConfigClass() {
return Http5FileSystem.class;
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5s/Http5sFileNameParser.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5s/Http5sFileNameParser.java
index 7eb1bbe7..8fdec7c4 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5s/Http5sFileNameParser.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5s/Http5sFileNameParser.java
@@ -30,13 +30,6 @@ public class Http5sFileNameParser extends GenericURLFileNameParser {
private static final Http5sFileNameParser INSTANCE = new Http5sFileNameParser();
- /**
- * Creates a new instance with the default port 443.
- */
- public Http5sFileNameParser() {
- super(DEFAULT_PORT);
- }
-
/**
* Gets the singleton instance.
*
@@ -45,4 +38,11 @@ public class Http5sFileNameParser extends GenericURLFileNameParser {
public static FileNameParser getInstance() {
return INSTANCE;
}
+
+ /**
+ * Creates a new instance with the default port 443.
+ */
+ public Http5sFileNameParser() {
+ super(DEFAULT_PORT);
+ }
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/https/HttpsFileNameParser.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/https/HttpsFileNameParser.java
index c0df4a19..a1579232 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/https/HttpsFileNameParser.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/https/HttpsFileNameParser.java
@@ -28,13 +28,6 @@ public class HttpsFileNameParser extends URLFileNameParser {
private static final HttpsFileNameParser INSTANCE = new HttpsFileNameParser();
- /**
- * Creates a new instance with the default port 443.
- */
- public HttpsFileNameParser() {
- super(DEFAULT_PORT);
- }
-
/**
* Gets the singleton instance.
*
@@ -43,4 +36,11 @@ public class HttpsFileNameParser extends URLFileNameParser {
public static FileNameParser getInstance() {
return INSTANCE;
}
+
+ /**
+ * Creates a new instance with the default port 443.
+ */
+ public HttpsFileNameParser() {
+ super(DEFAULT_PORT);
+ }
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ram/RamFileRandomAccessContent.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ram/RamFileRandomAccessContent.java
index 04ef5652..df21237b 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ram/RamFileRandomAccessContent.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ram/RamFileRandomAccessContent.java
@@ -35,6 +35,64 @@ public class RamFileRandomAccessContent implements RandomAccessContent {
private static final int BYTE_VALUE_MASK = 0xFF;
+ /**
+ * Build an 8-byte array from a long. No check is performed on the array length.
+ *
+ * @param n The number to convert.
+ * @param b The array to fill.
+ * @return A byte[].
+ */
+ public static byte[] toBytes(long n, final byte[] b) {
+ b[7] = (byte) n;
+ n >>>= 8;
+ b[6] = (byte) n;
+ n >>>= 8;
+ b[5] = (byte) n;
+ n >>>= 8;
+ b[4] = (byte) n;
+ n >>>= 8;
+ b[3] = (byte) n;
+ n >>>= 8;
+ b[2] = (byte) n;
+ n >>>= 8;
+ b[1] = (byte) n;
+ n >>>= 8;
+ b[0] = (byte) n;
+ return b;
+ }
+
+ /**
+ * Build a long from first 8 bytes of the array.
+ *
+ * @param b The byte[] to convert.
+ * @return A long.
+ */
+ public static long toLong(final byte[] b) {
+ return ((long) b[7] & BYTE_VALUE_MASK) + (((long) b[6] & BYTE_VALUE_MASK) << 8) + (((long) b[5] & BYTE_VALUE_MASK) << 16)
+ + (((long) b[4] & BYTE_VALUE_MASK) << 24) + (((long) b[3] & BYTE_VALUE_MASK) << 32) + (((long) b[2] & BYTE_VALUE_MASK) << 40)
+ + (((long) b[1] & BYTE_VALUE_MASK) << 48) + (((long) b[0] & BYTE_VALUE_MASK) << 56);
+ }
+
+ /**
+ * Build a short from first 2 bytes of the array.
+ *
+ * @param b The byte[] to convert.
+ * @return A short.
+ */
+ public static short toShort(final byte[] b) {
+ return (short) toUnsignedShort(b);
+ }
+
+ /**
+ * Build a short from first 2 bytes of the array.
+ *
+ * @param b The byte[] to convert.
+ * @return A short.
+ */
+ public static int toUnsignedShort(final byte[] b) {
+ return (b[1] & BYTE_VALUE_MASK) + ((b[0] & BYTE_VALUE_MASK) << 8);
+ }
+
/**
* File Pointer
*/
@@ -125,64 +183,6 @@ public class RamFileRandomAccessContent implements RandomAccessContent {
};
}
- /**
- * Build an 8-byte array from a long. No check is performed on the array length.
- *
- * @param n The number to convert.
- * @param b The array to fill.
- * @return A byte[].
- */
- public static byte[] toBytes(long n, final byte[] b) {
- b[7] = (byte) n;
- n >>>= 8;
- b[6] = (byte) n;
- n >>>= 8;
- b[5] = (byte) n;
- n >>>= 8;
- b[4] = (byte) n;
- n >>>= 8;
- b[3] = (byte) n;
- n >>>= 8;
- b[2] = (byte) n;
- n >>>= 8;
- b[1] = (byte) n;
- n >>>= 8;
- b[0] = (byte) n;
- return b;
- }
-
- /**
- * Build a long from first 8 bytes of the array.
- *
- * @param b The byte[] to convert.
- * @return A long.
- */
- public static long toLong(final byte[] b) {
- return ((long) b[7] & BYTE_VALUE_MASK) + (((long) b[6] & BYTE_VALUE_MASK) << 8) + (((long) b[5] & BYTE_VALUE_MASK) << 16)
- + (((long) b[4] & BYTE_VALUE_MASK) << 24) + (((long) b[3] & BYTE_VALUE_MASK) << 32) + (((long) b[2] & BYTE_VALUE_MASK) << 40)
- + (((long) b[1] & BYTE_VALUE_MASK) << 48) + (((long) b[0] & BYTE_VALUE_MASK) << 56);
- }
-
- /**
- * Build a short from first 2 bytes of the array.
- *
- * @param b The byte[] to convert.
- * @return A short.
- */
- public static short toShort(final byte[] b) {
- return (short) toUnsignedShort(b);
- }
-
- /**
- * Build a short from first 2 bytes of the array.
- *
- * @param b The byte[] to convert.
- * @return A short.
- */
- public static int toUnsignedShort(final byte[] b) {
- return (b[1] & BYTE_VALUE_MASK) + ((b[0] & BYTE_VALUE_MASK) << 8);
- }
-
/*
* (non-Javadoc)
*
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ram/RamFileSystemConfigBuilder.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ram/RamFileSystemConfigBuilder.java
index ba958a02..d117ad89 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ram/RamFileSystemConfigBuilder.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ram/RamFileSystemConfigBuilder.java
@@ -31,13 +31,6 @@ public final class RamFileSystemConfigBuilder extends FileSystemConfigBuilder {
/** config builder SINGLETON. */
private static final RamFileSystemConfigBuilder SINGLETON = new RamFileSystemConfigBuilder();
- /**
- * Constructor
- */
- private RamFileSystemConfigBuilder() {
- super("ram.");
- }
-
/**
* Gets the singleton builder.
*
@@ -47,6 +40,13 @@ public final class RamFileSystemConfigBuilder extends FileSystemConfigBuilder {
return SINGLETON;
}
+ /**
+ * Constructor
+ */
+ private RamFileSystemConfigBuilder() {
+ super("ram.");
+ }
+
/**
* {@inheritDoc}
*/
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/res/ResourceFileSystemConfigBuilder.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/res/ResourceFileSystemConfigBuilder.java
index 0b1ca9dd..8d2f7e97 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/res/ResourceFileSystemConfigBuilder.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/res/ResourceFileSystemConfigBuilder.java
@@ -28,10 +28,6 @@ public final class ResourceFileSystemConfigBuilder extends FileSystemConfigBuild
private static final ResourceFileSystemConfigBuilder BUILDER = new ResourceFileSystemConfigBuilder();
- private ResourceFileSystemConfigBuilder() {
- super("resource.");
- }
-
/**
* Gets the singleton builder.
*
@@ -41,6 +37,10 @@ public final class ResourceFileSystemConfigBuilder extends FileSystemConfigBuild
return BUILDER;
}
+ private ResourceFileSystemConfigBuilder() {
+ super("resource.");
+ }
+
/**
* Gets the class loader from the FileSystemOptions.
*
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpClientFactory.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpClientFactory.java
index 8ffa8f91..98e87729 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpClientFactory.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpClientFactory.java
@@ -45,11 +45,6 @@ import com.jcraft.jsch.UserInfo;
*/
public final class SftpClientFactory {
- private static final String KEY_COMPRESSION_C2S = "compression.c2s";
- private static final String KEY_COMPRESSION_S2C = "compression.s2c";
- private static final String KEY_PREFERRED_AUTHENTICATIONS = "PreferredAuthentications";
- private static final String KEY_STRICT_HOST_KEY_CHECKING = "StrictHostKeyChecking";
-
/** Interface JSchLogger with JCL. */
private static final class JSchLogger implements Logger {
@Override
@@ -93,6 +88,11 @@ public final class SftpClientFactory {
}
}
}
+ private static final String KEY_COMPRESSION_C2S = "compression.c2s";
+ private static final String KEY_COMPRESSION_S2C = "compression.s2c";
+ private static final String KEY_PREFERRED_AUTHENTICATIONS = "PreferredAuthentications";
+
+ private static final String KEY_STRICT_HOST_KEY_CHECKING = "StrictHostKeyChecking";
private static final String SSH_DIR_NAME = ".ssh";
private static final String OPENSSH_CONFIG_NAME = "config";
@@ -102,9 +102,6 @@ public final class SftpClientFactory {
JSch.setLogger(new JSchLogger());
}
- private SftpClientFactory() {
- }
-
private static void addIdentities(final JSch jsch, final File sshDir, final IdentityProvider[] identities)
throws FileSystemException {
if (identities != null) {
@@ -344,4 +341,7 @@ public final class SftpClientFactory {
}
}
+
+ private SftpClientFactory() {
+ }
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileNameParser.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileNameParser.java
index f24a3e3f..a307b8b2 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileNameParser.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileNameParser.java
@@ -28,13 +28,6 @@ public class SftpFileNameParser extends URLFileNameParser {
private static final SftpFileNameParser INSTANCE = new SftpFileNameParser();
- /**
- * Creates a new instance with the default port 22.
- */
- public SftpFileNameParser() {
- super(DEFAULT_PORT);
- }
-
/**
* Gets the singleton instance.
*
@@ -43,4 +36,11 @@ public class SftpFileNameParser extends URLFileNameParser {
public static FileNameParser getInstance() {
return INSTANCE;
}
+
+ /**
+ * Creates a new instance with the default port 22.
+ */
+ public SftpFileNameParser() {
+ super(DEFAULT_PORT);
+ }
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileProvider.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileProvider.java
index 2be1afcd..576ee16d 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileProvider.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileProvider.java
@@ -50,13 +50,6 @@ public class SftpFileProvider extends AbstractOriginatingFileProvider {
Capability.RENAME, Capability.GET_TYPE, Capability.LIST_CHILDREN, Capability.READ_CONTENT, Capability.URI, Capability.WRITE_CONTENT,
Capability.GET_LAST_MODIFIED, Capability.SET_LAST_MODIFIED_FILE, Capability.RANDOM_ACCESS_READ, Capability.APPEND_CONTENT));
- /**
- * Constructs a new provider.
- */
- public SftpFileProvider() {
- setFileNameParser(SftpFileNameParser.getInstance());
- }
-
/**
* Creates a new Session.
*
@@ -81,6 +74,13 @@ public class SftpFileProvider extends AbstractOriginatingFileProvider {
}
}
+ /**
+ * Constructs a new provider.
+ */
+ public SftpFileProvider() {
+ setFileNameParser(SftpFileNameParser.getInstance());
+ }
+
/**
* Creates a {@link FileSystem}.
*/
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileSystemConfigBuilder.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileSystemConfigBuilder.java
index 1cbc14a8..e37a4261 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileSystemConfigBuilder.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileSystemConfigBuilder.java
@@ -129,10 +129,6 @@ public final class SftpFileSystemConfigBuilder extends FileSystemConfigBuilder {
private static final String STRICT_HOST_KEY_CHECKING = PREFIX + ".STRICT_HOST_KEY_CHECKING";
private static final String USER_DIR_IS_ROOT = PREFIX + ".USER_DIR_IS_ROOT";
- private SftpFileSystemConfigBuilder() {
- super("sftp.");
- }
-
/**
* Gets the singleton builder.
*
@@ -142,6 +138,10 @@ public final class SftpFileSystemConfigBuilder extends FileSystemConfigBuilder {
return BUILDER;
}
+ private SftpFileSystemConfigBuilder() {
+ super("sftp.");
+ }
+
/**
* @param options The FileSystem options.
* @return The names of the compression algorithms, comma-separated.
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/Utils.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/Utils.java
index d84b0ef7..42db9dfb 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/Utils.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/Utils.java
@@ -19,12 +19,12 @@ package org.apache.commons.vfs2.provider.sftp;
final class Utils {
- private Utils() {
- // never
- }
-
static byte[] clone(final byte[] array) {
return array != null ? array.clone() : null;
}
+ private Utils() {
+ // never
+ }
+
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/zip/ZipFileSystemConfigBuilder.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/zip/ZipFileSystemConfigBuilder.java
index f66f9289..f22eeae7 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/zip/ZipFileSystemConfigBuilder.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/zip/ZipFileSystemConfigBuilder.java
@@ -29,13 +29,6 @@ public class ZipFileSystemConfigBuilder extends FileSystemConfigBuilder {
private static final ZipFileSystemConfigBuilder INSTANCE = new ZipFileSystemConfigBuilder();
private static final String KEY_CHARSET = PREFIX + ".charset";
- /**
- * Constructs a new instance.
- */
- private ZipFileSystemConfigBuilder() {
- super("zip.");
- }
-
/**
* Gets the singleton instance.
*
@@ -45,6 +38,13 @@ public class ZipFileSystemConfigBuilder extends FileSystemConfigBuilder {
return INSTANCE;
}
+ /**
+ * Constructs a new instance.
+ */
+ private ZipFileSystemConfigBuilder() {
+ super("zip.");
+ }
+
/**
* Gets the Charset from the FileSystemOptions.
*
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/CryptorFactory.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/CryptorFactory.java
index 533cde0f..2c03b551 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/CryptorFactory.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/CryptorFactory.java
@@ -30,13 +30,6 @@ public final class CryptorFactory {
private static Cryptor instance;
- /**
- * Prevent instantiation of the class.
- */
- private CryptorFactory() {
-
- }
-
/**
* Return the Cryptor. If one has not been previously set, create it. The Cryptor class can be set by setting the
* "org.apache.commons.vfs2.cryptor" System property to the name of the Cryptor class.
@@ -70,4 +63,11 @@ public final class CryptorFactory {
public static synchronized void setCryptor(final Cryptor cryptor) {
instance = cryptor;
}
+
+ /**
+ * Prevent instantiation of the class.
+ */
+ private CryptorFactory() {
+
+ }
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/EncryptUtil.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/EncryptUtil.java
index b7d36076..cb8a1e39 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/EncryptUtil.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/EncryptUtil.java
@@ -23,12 +23,6 @@ package org.apache.commons.vfs2.util;
*/
public final class EncryptUtil {
- /**
- * Don't allow class instantiation.
- */
- private EncryptUtil() {
- }
-
/**
* This class can be called with "encrypt" password as the arguments where encrypt is a literal and password is
* replaced with the clear text password to be encrypted.
@@ -48,4 +42,10 @@ public final class EncryptUtil {
System.out.println(cryptor.encrypt(args[1]));
}
}
+
+ /**
+ * Don't allow class instantiation.
+ */
+ private EncryptUtil() {
+ }
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/FileObjectUtils.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/FileObjectUtils.java
index dc6e7f10..4f07211f 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/FileObjectUtils.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/FileObjectUtils.java
@@ -33,10 +33,6 @@ import org.apache.commons.vfs2.provider.AbstractFileObject;
*/
public final class FileObjectUtils {
- private FileObjectUtils() {
- // noop
- }
-
/**
* Null-safe call to {@link FileObject#exists()}.
*
@@ -209,4 +205,8 @@ public final class FileObjectUtils {
content.write(output);
}
}
+
+ private FileObjectUtils() {
+ // noop
+ }
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/Messages.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/Messages.java
index 6e2e332d..7daae587 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/Messages.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/Messages.java
@@ -35,10 +35,6 @@ public final class Messages {
private static final ConcurrentMap<String, MessageFormat> MESSAGE_MAP = new ConcurrentHashMap<>();
private static final ResourceBundle RESOURCES = new CombinedResources("org.apache.commons.vfs2.Resources");
- private Messages() {
- // no instances.
- }
-
/**
* Locates a message by its code.
*/
@@ -88,4 +84,8 @@ public final class Messages {
return "Unknown message with code \"" + code + "\".";
}
}
+
+ private Messages() {
+ // no instances.
+ }
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/Os.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/Os.java
index cccd2d4f..cb529183 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/Os.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/Os.java
@@ -94,12 +94,6 @@ public final class Os {
OS_ALL_FAMILIES = determineAllFamilies();
}
- /**
- * Private constructor to block instantiation.
- */
- private Os() {
- }
-
private static boolean archMatches(final String arch) {
boolean isArch = true;
if (arch != null) {
@@ -278,4 +272,10 @@ public final class Os {
}
return isVersion;
}
+
+ /**
+ * Private constructor to block instantiation.
+ */
+ private Os() {
+ }
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/RandomAccessMode.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/RandomAccessMode.java
index f0bde48f..426f484d 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/RandomAccessMode.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/RandomAccessMode.java
@@ -61,14 +61,6 @@ public enum RandomAccessMode {
private static final AccessMode[] ACCESS_MODE_READ = {AccessMode.READ};
private static final AccessMode[] ACCESS_MODE_READ_WRITE = {AccessMode.READ, AccessMode.WRITE};
- private final boolean read;
- private final boolean write;
-
- RandomAccessMode(final boolean read, final boolean write) {
- this.read = read;
- this.write = write;
- }
-
/**
* Converts an array of {@link AccessMode} into a RandomAccessMode.
*
@@ -90,6 +82,14 @@ public enum RandomAccessMode {
}
throw new IllegalArgumentException(Arrays.toString(accessModes));
}
+ private final boolean read;
+
+ private final boolean write;
+
+ RandomAccessMode(final boolean read, final boolean write) {
+ this.read = read;
+ this.write = write;
+ }
/**
* Gets this instance as an access mode string suitable for other APIs, like {@code "r"} for {@link #READ} and
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/URIBitSets.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/URIBitSets.java
index e10ab320..f8cb53a6 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/URIBitSets.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/URIBitSets.java
@@ -720,9 +720,6 @@ final class URIBitSets {
private static final int NBITS = 256;
- private URIBitSets() {
- }
-
static FluentBitSet bitSet() {
return new FluentBitSet(NBITS);
}
@@ -731,4 +728,7 @@ final class URIBitSets {
return bitSet().set(bitIndexArray);
}
+ private URIBitSets() {
+ }
+
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/URIUtils.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/URIUtils.java
index c9c5bf0f..628a6846 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/URIUtils.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/URIUtils.java
@@ -48,9 +48,6 @@ public class URIUtils {
*/
private static final class EncodingUtils {
- private EncodingUtils() {
- }
-
/**
* Converts the byte array of ASCII characters to a string. This method is
* to be used when decoding content of HTTP elements (such as response
@@ -93,6 +90,9 @@ public class URIUtils {
return data.getBytes(Charset.defaultCharset());
}
}
+
+ private EncodingUtils() {
+ }
}
/**
@@ -131,9 +131,6 @@ public class URIUtils {
*/
private static final int RADIX = 16;
- private URLCodecUtils() {
- }
-
static byte[] encodeUrl(FluentBitSet urlsafe, final byte[] bytes) {
if (bytes == null) {
return null;
@@ -167,6 +164,9 @@ public class URIUtils {
private static char hexDigit(final int b) {
return Character.toUpperCase(Character.forDigit(b & UNSIGNED_BYTE_MASK, RADIX));
}
+
+ private URLCodecUtils() {
+ }
}
private static final Log LOG = LogFactory.getLog(URIUtils.class);
@@ -176,9 +176,6 @@ public class URIUtils {
*/
private static final String DEFAULT_PROTOCOL_CHARSET = "UTF-8";
- private URIUtils() {
- }
-
private static String encode(final String unescaped, final FluentBitSet allowed, final String charset) {
final byte[] rawdata = URLCodecUtils.encodeUrl(allowed, EncodingUtils.getBytes(unescaped, charset));
return EncodingUtils.getAsciiString(rawdata, 0, rawdata.length);
@@ -211,4 +208,7 @@ public class URIUtils {
return encode(unescaped, URIBitSets.ALLOWED_ABS_PATH, charset);
}
+ private URIUtils() {
+ }
+
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/UserAuthenticatorUtils.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/UserAuthenticatorUtils.java
index 361ab5c1..7625cbe6 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/UserAuthenticatorUtils.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/UserAuthenticatorUtils.java
@@ -26,9 +26,6 @@ import org.apache.commons.vfs2.impl.DefaultFileSystemConfigBuilder;
*/
public final class UserAuthenticatorUtils {
- private UserAuthenticatorUtils() {
- }
-
/**
* Authenticates if there is an authenticator, else returns null.
*
@@ -118,4 +115,7 @@ public final class UserAuthenticatorUtils {
return new String(data);
}
+
+ private UserAuthenticatorUtils() {
+ }
}
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/WeakRefFileListener.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/WeakRefFileListener.java
index 2b25b35b..9c355075 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/WeakRefFileListener.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/WeakRefFileListener.java
@@ -31,16 +31,6 @@ import org.apache.commons.vfs2.FileSystem;
*/
public class WeakRefFileListener implements FileListener {
- private final FileSystem fs;
- private final FileName name;
- private final WeakReference<FileListener> listener;
-
- protected WeakRefFileListener(final FileObject file, final FileListener listener) {
- this.fs = file.getFileSystem();
- this.name = file.getName();
- this.listener = new WeakReference<>(listener);
- }
-
/**
* Installs the {@code listener} at the given {@code file}.
*
@@ -50,6 +40,16 @@ public class WeakRefFileListener implements FileListener {
public static void installListener(final FileObject file, final FileListener listener) {
file.getFileSystem().addListener(file, new WeakRefFileListener(file, new WeakRefFileListener(file, listener)));
}
+ private final FileSystem fs;
+ private final FileName name;
+
+ private final WeakReference<FileListener> listener;
+
+ protected WeakRefFileListener(final FileObject file, final FileListener listener) {
+ this.fs = file.getFileSystem();
+ this.name = file.getName();
+ this.listener = new WeakReference<>(listener);
+ }
/**
* Called when a file is changed.