Skip to content

Commit

Permalink
Javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Aug 12, 2024
1 parent f0e0ac1 commit c2f2714
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ public FileObject getFile(final FileSystem filesystem, final FileName name) {
}
}

/**
* Gets or creates a new Map.
*
* @param fileSystem the key
* @return an existing or new Map.
*/
protected Map<FileName, FileObject> getOrCreateFilesystemCache(final FileSystem fileSystem) {
return fileSystemCache.computeIfAbsent(fileSystem, k -> new MyLRUMap(k, lruSize));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,15 @@ private synchronized void close(final FileSystem fileSystem) {
}
}

protected Reference<FileObject> createReference(final FileObject file, final ReferenceQueue<FileObject> refqueue) {
return new SoftReference<>(file, refqueue);
/**
* Creates a new Reference.
*
* @param file a file object.
* @param referenceQueue a ReferenceQueue.
* @return a new Reference on the given input.
*/
protected Reference<FileObject> createReference(final FileObject file, final ReferenceQueue<FileObject> referenceQueue) {
return new SoftReference<>(file, referenceQueue);
}

private synchronized void endThread() {
Expand All @@ -142,11 +149,16 @@ public synchronized FileObject getFile(final FileSystem fileSystem, final FileNa
return fo;
}

/**
* Gets or creates a new Map.
*
* @param fileSystem the key.
* @return an existing or new Map.
*/
protected synchronized Map<FileName, Reference<FileObject>> getOrCreateFilesystemCache(final FileSystem fileSystem) {
if (fileSystemCache.isEmpty()) {
startThread();
}

return fileSystemCache.computeIfAbsent(fileSystem, k -> new HashMap<>());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@ protected void configurePlugins() throws FileSystemException {
}
}

/**
* Gets a new DefaultFileReplicator.
*
* @return a new DefaultFileReplicator.
*/
protected DefaultFileReplicator createDefaultFileReplicator() {
return new DefaultFileReplicator();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ public class SftpFileSystem extends AbstractFileSystem {
*/
private final boolean execDisabled;

/**
* Constructs a new instance.
*
* @param rootName The root file name of this file system.
* @param session The session.
* @param fileSystemOptions Options to build this file system.
*/
protected SftpFileSystem(final GenericFileName rootName, final Session session, final FileSystemOptions fileSystemOptions) {
super(rootName, null, fileSystemOptions);
this.session = Objects.requireNonNull(session, "session");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
* A read-only file system for ZIP and JAR files.
*/
public class ZipFileSystem extends AbstractFileSystem {

private static final char[] ENC = {'!'};

private static final Log LOG = LogFactory.getLog(ZipFileSystem.class);
Expand Down Expand Up @@ -97,6 +98,13 @@ protected FileObject createFile(final AbstractFileName name) throws FileSystemEx
return new ZipFileObject(name, null, this, false);
}

/**
* Creates a Zip file.
*
* @param file the underlying file.
* @return a Zip file.
* @throws FileSystemException if a file system error occurs.
*/
protected ZipFile createZipFile(final File file) throws FileSystemException {
try {
return new ZipFile(file, charset);
Expand All @@ -105,8 +113,16 @@ protected ZipFile createZipFile(final File file) throws FileSystemException {
}
}

protected ZipFileObject createZipFileObject(final AbstractFileName name, final ZipEntry entry) throws FileSystemException {
return new ZipFileObject(name, entry, this, true);
/**
* Creates a new Zip file object.
*
* @param fileName the underlying file.
* @param entry the Zip entry.
* @return a new ZipFileObject.
* @throws FileSystemException if a file system error occurs.
*/
protected ZipFileObject createZipFileObject(final AbstractFileName fileName, final ZipEntry entry) throws FileSystemException {
return new ZipFileObject(fileName, entry, this, true);
}

@Override
Expand All @@ -133,18 +149,23 @@ protected Charset getCharset() {
}

/**
* Returns a cached file.
* Gets a cached file.
*/
@Override
protected FileObject getFileFromCache(final FileName name) {
return cache.get(name);
}

/**
* Gets the zip file.
*
* @return the zip file.
* @throws FileSystemException if a file system error occurs.
*/
protected ZipFile getZipFile() throws FileSystemException {
if (zipFile == null && file.exists()) {
zipFile = createZipFile(file);
}

return zipFile;
}

Expand Down

0 comments on commit c2f2714

Please sign in to comment.