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 c2845b9e4b10bc53f3b7200b497edaeeaf87c9fa Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Mon Aug 12 08:43:16 2024 -0400 Javadoc Better private instance variable names --- .../commons/vfs2/cache/DefaultFilesCache.java | 12 ++++++-- .../commons/vfs2/impl/DefaultFileReplicator.java | 29 ++++++++++++++++---- .../vfs2/impl/DefaultFileSystemManager.java | 5 ++++ .../commons/vfs2/provider/AbstractFileName.java | 10 +++++++ .../commons/vfs2/provider/AbstractFileObject.java | 8 ++++-- .../vfs2/provider/AbstractFileProvider.java | 18 +++++++++--- .../commons/vfs2/provider/AbstractFileSystem.java | 7 +++++ .../vfs2/provider/AbstractRandomAccessContent.java | 5 ++++ .../AbstractRandomAccessStreamContent.java | 11 ++++++++ .../compressed/CompressedFileFileObject.java | 5 ++++ .../compressed/CompressedFileFileProvider.java | 9 ++++++ .../vfs2/provider/ftp/FTPClientWrapper.java | 32 ++++++++++++++++------ .../vfs2/provider/ftp/FtpClientFactory.java | 14 ++++++++++ .../commons/vfs2/provider/http/HttpFileSystem.java | 5 ++++ .../vfs2/provider/local/LocalFileNameParser.java | 11 +++++++- .../commons/vfs2/provider/zip/ZipFileSystem.java | 4 +-- .../commons/vfs2/util/CombinedResources.java | 14 +++++++++- .../util/DelegatingFileSystemOptionsBuilder.java | 5 ++++ 18 files changed, 175 insertions(+), 29 deletions(-) diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/cache/DefaultFilesCache.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/cache/DefaultFilesCache.java index 19db612b..00fe303a 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/cache/DefaultFilesCache.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/cache/DefaultFilesCache.java @@ -76,11 +76,17 @@ public class DefaultFilesCache extends AbstractFilesCache { return files.get(name); // or null } - protected ConcurrentMap<FileName, FileObject> getOrCreateFilesystemCache(final FileSystem filesystem) { - ConcurrentMap<FileName, FileObject> files = fileSystemCache.get(filesystem); + /** + * Gets or creates a Map. + * + * @param fileSystem the key + * @return an existing or new Map. + */ + protected ConcurrentMap<FileName, FileObject> getOrCreateFilesystemCache(final FileSystem fileSystem) { + ConcurrentMap<FileName, FileObject> files = fileSystemCache.get(fileSystem); // we loop to make sure we never return null even when concurrent clean is called while (files == null) { - files = fileSystemCache.computeIfAbsent(filesystem, + files = fileSystemCache.computeIfAbsent(fileSystem, k -> new ConcurrentHashMap<>(INITIAL_CAPACITY, LOAD_FACTOR, Math.max(2, Runtime.getRuntime().availableProcessors()) / 2)); } return files; diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileReplicator.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileReplicator.java index 1dc2e942..ac25cf4d 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileReplicator.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileReplicator.java @@ -37,6 +37,7 @@ import org.apache.commons.vfs2.util.Messages; * A simple file replicator and temporary file store. */ public class DefaultFileReplicator extends AbstractVfsComponent implements FileReplicator, TemporaryFileStore { + private static final Log log = LogFactory.getLog(DefaultFileReplicator.class); private static final int MASK = 0xffff; @@ -45,7 +46,7 @@ public class DefaultFileReplicator extends AbstractVfsComponent implements FileR private static final char[] TMP_RESERVED_CHARS = {'?', '/', '\\', ' ', '&', '"', '\'', '*', '#', ';', ':', '<', '>', '|'}; private final ArrayList<Object> copies = new ArrayList<>(); - private long filecount; + private long fileCount; private File tempDir; private boolean tempDirMessageLogged; @@ -64,6 +65,11 @@ public class DefaultFileReplicator extends AbstractVfsComponent implements FileR this.tempDir = tempDir; } + /** + * Adds a file. + * + * @param file the file to add. + */ protected void addFile(final Object file) { synchronized (copies) { copies.add(file); @@ -82,7 +88,7 @@ public class DefaultFileReplicator extends AbstractVfsComponent implements FileR // Create a unique-ish file name final String actualBaseName = createFilename(baseName); synchronized (this) { - filecount++; + fileCount++; } return createAndAddFile(tempDir, actualBaseName); @@ -110,12 +116,18 @@ public class DefaultFileReplicator extends AbstractVfsComponent implements FileR } } + /** + * Adds a file. + * + * @param parent ignored. + * @param baseName the base file name. + * @return a File. + * @throws FileSystemException if a file system error occurs. + */ protected File createAndAddFile(final File parent, final String baseName) throws FileSystemException { final File file = createFile(tempDir, baseName); - // Keep track to delete later addFile(file); - return file; } @@ -162,8 +174,13 @@ public class DefaultFileReplicator extends AbstractVfsComponent implements FileR } } + /** + * Gets the file count. + * + * @return the file count. + */ protected long getFilecount() { - return filecount; + return fileCount; } /** @@ -177,7 +194,7 @@ public class DefaultFileReplicator extends AbstractVfsComponent implements FileR tempDir = new File(FileUtils.getTempDirectoryPath(), "vfs_cache").getAbsoluteFile(); } - filecount = RANDOM.nextInt() & MASK; + fileCount = RANDOM.nextInt() & MASK; if (!tempDirMessageLogged) { final String message = Messages.getString("vfs.impl/temp-dir.debug", tempDir); diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileSystemManager.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileSystemManager.java index dd6e5e0a..ae3b92db 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileSystemManager.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileSystemManager.java @@ -295,6 +295,11 @@ public class DefaultFileSystemManager implements FileSystemManager { } } + /** + * Adds a scheme. + * + * @param rootUri the URI containing the scheme to add. + */ protected void addVirtualFileSystemScheme(String rootUri) { if (rootUri.indexOf(':') != -1) { rootUri = rootUri.substring(0, rootUri.indexOf(':')); 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 ccef4ac8..45e1b9cf 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 @@ -141,6 +141,11 @@ public abstract class AbstractFileName implements FileName { */ public abstract FileName createName(String absolutePath, FileType fileType); + /** + * Creates a URI. + * + * @return a URI. + */ protected String createURI() { return createURI(false, true); } @@ -429,6 +434,11 @@ public abstract class AbstractFileName implements FileName { return uriString; } + /** + * Gets the string to end a URI. + * + * @return the string to end a URI + */ protected String getUriTrailer() { return getType().hasChildren() ? "/" : ""; } 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 6a65d460..a8da6c04 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 @@ -416,7 +416,6 @@ public abstract class AbstractFileObject<AFS extends AbstractFileSystem> impleme for (final FileObject fileObject : files) { final AbstractFileObject file = FileObjectUtils.getAbstractFileObject(fileObject); // file.attach(); - // VFS-210: It seems impossible to me that findFiles will return a list with hidden files/directories // in it, else it would not be hidden. Checking for the file-type seems ok in this case // If the file is a folder, make sure all its children have been deleted @@ -424,13 +423,11 @@ public abstract class AbstractFileObject<AFS extends AbstractFileSystem> impleme // Skip - as the selector forced us not to delete all files continue; } - // Delete the file if (file.deleteSelf()) { nuofDeleted++; } } - return nuofDeleted; } @@ -1491,6 +1488,11 @@ public abstract class AbstractFileObject<AFS extends AbstractFileSystem> impleme objects.add(strongRef); } + /** + * Sets the file type. + * + * @param fileType the file type. + */ protected void injectType(final FileType fileType) { setFileType(fileType); } diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractFileProvider.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractFileProvider.java index c7996d2a..b1e1553b 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractFileProvider.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractFileProvider.java @@ -43,13 +43,13 @@ public abstract class AbstractFileProvider extends AbstractVfsContainer implemen */ private final Map<FileSystemKey, FileSystem> fileSystemMap = new TreeMap<>(); // @GuardedBy("self") - private FileNameParser parser; + private FileNameParser fileNameParser; /** * Constructs a new instance. */ public AbstractFileProvider() { - parser = GenericFileNameParser.getInstance(); + fileNameParser = GenericFileNameParser.getInstance(); } /** @@ -158,8 +158,13 @@ public abstract class AbstractFileProvider extends AbstractVfsContainer implemen return null; } + /** + * Gets the file name parser. + * + * @return the file name parser. + */ protected FileNameParser getFileNameParser() { - return parser; + return fileNameParser; } /** @@ -179,7 +184,12 @@ public abstract class AbstractFileProvider extends AbstractVfsContainer implemen throw new FileSystemException("vfs.provider/filename-parser-missing.error"); } + /** + * Sets the file name parser. + * + * @param parser a file name parser. + */ protected void setFileNameParser(final FileNameParser parser) { - this.parser = parser; + this.fileNameParser = parser; } } diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractFileSystem.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractFileSystem.java index e988a4cb..bd9ba7e4 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractFileSystem.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractFileSystem.java @@ -183,6 +183,13 @@ public abstract class AbstractFileSystem extends AbstractVfsComponent implements */ protected abstract FileObject createFile(AbstractFileName name) throws Exception; + /** + * Decorates the given file object. + * + * @param file the file object. + * @return the decorated file object. + * @throws FileSystemException if a file system error occurs. + */ protected FileObject decorateFileObject(FileObject file) throws FileSystemException { if (getFileSystemManager().getCacheStrategy().equals(CacheStrategy.ON_CALL)) { file = new OnCallRefreshFileObject(file); diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractRandomAccessContent.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractRandomAccessContent.java index 84536016..645fe9a8 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractRandomAccessContent.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractRandomAccessContent.java @@ -31,6 +31,11 @@ import org.apache.commons.vfs2.util.RandomAccessMode; */ public abstract class AbstractRandomAccessContent implements RandomAccessContent { + /** + * Constructs a new instance. + * + * @param mode the RandomAccessMode. + */ protected AbstractRandomAccessContent(final RandomAccessMode mode) { Objects.requireNonNull(mode, "mode"); } diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractRandomAccessStreamContent.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractRandomAccessStreamContent.java index 0928fc4a..b32621b6 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractRandomAccessStreamContent.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractRandomAccessStreamContent.java @@ -27,10 +27,21 @@ import org.apache.commons.vfs2.util.RandomAccessMode; */ public abstract class AbstractRandomAccessStreamContent extends AbstractRandomAccessContent { + /** + * Constructs a new instance. + * + * @param mode the RandomAccessMode. + */ protected AbstractRandomAccessStreamContent(final RandomAccessMode mode) { super(mode); } + /** + * Gets a DataInputStream. + * + * @return a DataInputStream. + * @throws IOException if an IO error occurs. + */ protected abstract DataInputStream getDataInputStream() throws IOException; @Override diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/compressed/CompressedFileFileObject.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/compressed/CompressedFileFileObject.java index a5665de6..6b349389 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/compressed/CompressedFileFileObject.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/compressed/CompressedFileFileObject.java @@ -105,6 +105,11 @@ public abstract class CompressedFileFileObject<FS extends CompressedFileFileSyst return children; } + /** + * Gets the container. + * + * @return the container. + */ protected FileObject getContainer() { return container; } diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/compressed/CompressedFileFileProvider.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/compressed/CompressedFileFileProvider.java index dd770368..5a14a2cc 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/compressed/CompressedFileFileProvider.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/compressed/CompressedFileFileProvider.java @@ -39,6 +39,15 @@ public abstract class CompressedFileFileProvider extends AbstractLayeredFileProv public CompressedFileFileProvider() { } + /** + * Create a FileSystem. + * + * @param name a file name. + * @param file a file object. + * @param fileSystemOptions the file system options. + * @return a FileSystem. + * @throws FileSystemException if a file system error occurs. + */ protected abstract FileSystem createFileSystem(FileName name, FileObject file, FileSystemOptions fileSystemOptions) throws FileSystemException; /** diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FTPClientWrapper.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FTPClientWrapper.java index 2d232461..62d9f6ff 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FTPClientWrapper.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/ftp/FTPClientWrapper.java @@ -47,11 +47,18 @@ public class FTPClientWrapper implements FtpClient { */ protected final FileSystemOptions fileSystemOptions; private FTPClient ftpClient; - private final GenericFileName root; + private final GenericFileName rootFileName; - protected FTPClientWrapper(final GenericFileName root, final FileSystemOptions fileSystemOptions) + /** + * Constructs a new instance. + * + * @param rootFileName the root file name. + * @param fileSystemOptions the file system options. + * @throws FileSystemException if a file system error occurs. + */ + protected FTPClientWrapper(final GenericFileName rootFileName, final FileSystemOptions fileSystemOptions) throws FileSystemException { - this.root = root; + this.rootFileName = rootFileName; this.fileSystemOptions = fileSystemOptions; getFtpClient(); // fail-fast } @@ -104,14 +111,21 @@ public class FTPClientWrapper implements FtpClient { } } - protected FTPClient createClient(final GenericFileName rootName, final UserAuthenticationData authData) + /** + * Creates an FTPClient. + * @param rootFileName the root file name. + * @param authData authentication data. + * @return an FTPClient. + * @throws FileSystemException if a file system error occurs. + */ + protected FTPClient createClient(final GenericFileName rootFileName, final UserAuthenticationData authData) throws FileSystemException { - return FtpClientFactory.createConnection(rootName.getHostName(), rootName.getPort(), + return FtpClientFactory.createConnection(rootFileName.getHostName(), rootFileName.getPort(), UserAuthenticatorUtils.getData(authData, UserAuthenticationData.USERNAME, - UserAuthenticatorUtils.toChar(rootName.getUserName())), + UserAuthenticatorUtils.toChar(rootFileName.getUserName())), UserAuthenticatorUtils.getData(authData, UserAuthenticationData.PASSWORD, - UserAuthenticatorUtils.toChar(rootName.getPassword())), - rootName.getPath(), getFileSystemOptions()); + UserAuthenticatorUtils.toChar(rootFileName.getPassword())), + rootFileName.getPath(), getFileSystemOptions()); } @Override @@ -174,7 +188,7 @@ public class FTPClientWrapper implements FtpClient { * @return the root file name. */ public GenericFileName getRoot() { - return root; + return rootFileName; } /** 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 ffd6d458..dcc5f214 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 @@ -106,6 +106,13 @@ public final class FtpClientFactory { } } + /** + * Creates a new client. + * + * @param fileSystemOptions the file system options. + * @return a new client. + * @throws FileSystemException if a file system error occurs. + */ protected abstract C createClient(FileSystemOptions fileSystemOptions) throws FileSystemException; /** @@ -259,6 +266,13 @@ public final class FtpClientFactory { } } + /** + * Sets up a new client. + * + * @param client the client. + * @param fileSystemOptions the file system options. + * @throws IOException if an IO error occurs. + */ protected abstract void setupOpenConnection(C client, FileSystemOptions fileSystemOptions) throws IOException; } diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpFileSystem.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpFileSystem.java index c59a5876..d497ede9 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpFileSystem.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpFileSystem.java @@ -78,6 +78,11 @@ public class HttpFileSystem extends AbstractFileSystem { return new HttpFileObject<>(name, this); } + /** + * Gets the HTTP client. + * + * @return the HttpClient. + */ protected HttpClient getClient() { return httpClient; } diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileNameParser.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileNameParser.java index bdb67dcd..40fa9ff3 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileNameParser.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileNameParser.java @@ -30,7 +30,16 @@ import org.apache.commons.vfs2.provider.VfsComponentContext; */ public abstract class LocalFileNameParser extends AbstractFileNameParser { - protected abstract FileName createFileName(String scheme, String rootFile, String path, FileType type); + /** + * Creates a FileName. + * + * @param scheme The scheme. + * @param rootFile the root file. + * @param path the path. + * @param fileType the file type. + * @return a FileName. + */ + protected abstract FileName createFileName(String scheme, String rootFile, String path, FileType fileType); /** * Pops the root prefix off a URI, which has had the scheme removed. diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/zip/ZipFileSystem.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/zip/ZipFileSystem.java index 73fe4cda..1b5489d2 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/zip/ZipFileSystem.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/zip/ZipFileSystem.java @@ -101,7 +101,7 @@ public class ZipFileSystem extends AbstractFileSystem { /** * Creates a Zip file. * - * @param file the underlying file. + * @param file the underlying file. * @return a Zip file. * @throws FileSystemException if a file system error occurs. */ @@ -116,7 +116,7 @@ public class ZipFileSystem extends AbstractFileSystem { /** * Creates a new Zip file object. * - * @param fileName the underlying file. + * @param fileName the underlying file. * @param entry the Zip entry. * @return a new ZipFileObject. * @throws FileSystemException if a file system error occurs. diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/CombinedResources.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/CombinedResources.java index d3e2d66d..47d47759 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/CombinedResources.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/CombinedResources.java @@ -78,17 +78,24 @@ public class CombinedResources extends ResourceBundle { return properties.get(key); } + /** + * Initializes this instance. + */ protected void init() { if (inited) { return; } - loadResources(getResourceName()); loadResources(Locale.getDefault()); loadResources(getLocale()); inited = true; } + /** + * Loads resources. + * + * @param locale a Locale. + */ protected void loadResources(final Locale locale) { if (locale == null) { return; @@ -108,6 +115,11 @@ public class CombinedResources extends ResourceBundle { } } + /** + * Loads a resource. + * + * @param resourceName the resource to load. + */ protected void loadResources(String resourceName) { ClassLoader loader = getClass().getClassLoader(); if (loader == null) { diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/DelegatingFileSystemOptionsBuilder.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/DelegatingFileSystemOptionsBuilder.java index b73393e1..4f6ab3e3 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/DelegatingFileSystemOptionsBuilder.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/DelegatingFileSystemOptionsBuilder.java @@ -238,6 +238,11 @@ public class DelegatingFileSystemOptionsBuilder { return true; } + /** + * Gets the FileSystemManager. + * + * @return the FileSystemManager. + */ protected FileSystemManager getManager() { return manager; }