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 2017/09/14 19:26:44 UTC
svn commit: r1808381 [9/25] - in /commons/proper/vfs/trunk/commons-vfs2/src:
main/java/org/apache/commons/vfs2/ main/java/org/apache/commons/vfs2/auth/
main/java/org/apache/commons/vfs2/cache/
main/java/org/apache/commons/vfs2/events/ main/java/org/apa...
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractFileProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractFileProvider.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractFileProvider.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractFileProvider.java Thu Sep 14 19:26:39 2017
@@ -28,38 +28,29 @@ import org.apache.commons.vfs2.FileSyste
import org.apache.commons.vfs2.provider.local.GenericFileNameParser;
/**
- * A partial {@link FileProvider} implementation. Takes care of managing the
- * file systems created by the provider.
+ * A partial {@link FileProvider} implementation. Takes care of managing the file systems created by the provider.
*/
-public abstract class AbstractFileProvider
- extends AbstractVfsContainer
- implements FileProvider
-{
+public abstract class AbstractFileProvider extends AbstractVfsContainer implements FileProvider {
private static final AbstractFileSystem[] EMPTY_ABSTRACTFILESYSTEMS = new AbstractFileSystem[0];
/**
* The cached file systems.
* <p>
- * This is a mapping from {@link FileSystemKey} (root URI and options)
- * to {@link FileSystem}.
+ * This is a mapping from {@link FileSystemKey} (root URI and options) to {@link FileSystem}.
*/
- private final Map<FileSystemKey, FileSystem> fileSystems
- = new TreeMap<>(); // @GuardedBy("self")
+ private final Map<FileSystemKey, FileSystem> fileSystems = new TreeMap<>(); // @GuardedBy("self")
private FileNameParser parser;
- public AbstractFileProvider()
- {
+ public AbstractFileProvider() {
parser = GenericFileNameParser.getInstance();
}
- protected FileNameParser getFileNameParser()
- {
+ protected FileNameParser getFileNameParser() {
return parser;
}
- protected void setFileNameParser(final FileNameParser parser)
- {
+ protected void setFileNameParser(final FileNameParser parser) {
this.parser = parser;
}
@@ -67,10 +58,8 @@ public abstract class AbstractFileProvid
* Closes the file systems created by this provider.
*/
@Override
- public void close()
- {
- synchronized (fileSystems)
- {
+ public void close() {
+ synchronized (fileSystems) {
fileSystems.clear();
}
@@ -78,7 +67,8 @@ public abstract class AbstractFileProvid
}
/**
- * Creates a layered file system. This method throws a 'not supported' exception.
+ * Creates a layered file system. This method throws a 'not supported' exception.
+ *
* @param scheme The protocol to use to access the file.
* @param file a FileObject.
* @param properties Options to the file system.
@@ -87,8 +77,7 @@ public abstract class AbstractFileProvid
*/
@Override
public FileObject createFileSystem(final String scheme, final FileObject file, final FileSystemOptions properties)
- throws FileSystemException
- {
+ throws FileSystemException {
// Can't create a layered file system
throw new FileSystemException("vfs.provider/not-layered-fs.error", scheme);
}
@@ -97,21 +86,19 @@ public abstract class AbstractFileProvid
* Adds a file system to those cached by this provider.
* <p>
* The file system may implement {@link VfsComponent}, in which case it is initialised.
+ *
* @param key The root file of the file system, part of the cache key.
* @param fs the file system to add.
* @throws FileSystemException if any error occurs.
*/
- protected void addFileSystem(final Comparable<?> key, final FileSystem fs)
- throws FileSystemException
- {
+ protected void addFileSystem(final Comparable<?> key, final FileSystem fs) throws FileSystemException {
// Add to the container and initialize
addComponent(fs);
final FileSystemKey treeKey = new FileSystemKey(key, fs.getFileSystemOptions());
((AbstractFileSystem) fs).setCacheKey(treeKey);
- synchronized (fileSystems)
- {
+ synchronized (fileSystems) {
fileSystems.put(treeKey, fs);
}
}
@@ -123,43 +110,37 @@ public abstract class AbstractFileProvid
* @param fileSystemProps file system options the file system instance must have.
* @return The file system instance, or null if it is not cached.
*/
- protected FileSystem findFileSystem(final Comparable<?> key, final FileSystemOptions fileSystemProps)
- {
+ protected FileSystem findFileSystem(final Comparable<?> key, final FileSystemOptions fileSystemProps) {
final FileSystemKey treeKey = new FileSystemKey(key, fileSystemProps);
- synchronized (fileSystems)
- {
+ synchronized (fileSystems) {
return fileSystems.get(treeKey);
}
}
/**
* Returns the FileSystemConfigBuidler.
+ *
* @return the FileSystemConfigBuilder.
*/
@Override
- public FileSystemConfigBuilder getConfigBuilder()
- {
+ public FileSystemConfigBuilder getConfigBuilder() {
return null;
}
/**
* Free unused resources.
*/
- public void freeUnusedResources()
- {
+ public void freeUnusedResources() {
AbstractFileSystem[] abstractFileSystems;
- synchronized (fileSystems)
- {
+ synchronized (fileSystems) {
// create snapshot under lock
abstractFileSystems = fileSystems.values().toArray(EMPTY_ABSTRACTFILESYSTEMS);
}
// process snapshot outside lock
- for (final AbstractFileSystem fs : abstractFileSystems)
- {
- if (fs.isReleaseable())
- {
+ for (final AbstractFileSystem fs : abstractFileSystems) {
+ if (fs.isReleaseable()) {
fs.closeCommunicationLink();
}
}
@@ -167,17 +148,15 @@ public abstract class AbstractFileProvid
/**
* Close the FileSystem.
+ *
* @param filesystem The FileSystem to close.
*/
- public void closeFileSystem(final FileSystem filesystem)
- {
+ public void closeFileSystem(final FileSystem filesystem) {
final AbstractFileSystem fs = (AbstractFileSystem) filesystem;
final FileSystemKey key = fs.getCacheKey();
- if (key != null)
- {
- synchronized (fileSystems)
- {
+ if (key != null) {
+ synchronized (fileSystems) {
fileSystems.remove(key);
}
}
@@ -195,10 +174,8 @@ public abstract class AbstractFileProvid
* @throws FileSystemException if an error occurs.
*/
@Override
- public FileName parseUri(final FileName base, final String uri) throws FileSystemException
- {
- if (getFileNameParser() != null)
- {
+ public FileName parseUri(final FileName base, final String uri) throws FileSystemException {
+ if (getFileNameParser() != null) {
return getFileNameParser().parseUri(getContext(), base, uri);
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractFileSystem.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractFileSystem.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractFileSystem.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractFileSystem.java Thu Sep 14 19:26:39 2017
@@ -52,21 +52,17 @@ import org.apache.commons.vfs2.util.Mess
/**
* A partial {@link org.apache.commons.vfs2.FileSystem} implementation.
*/
-public abstract class AbstractFileSystem
- extends AbstractVfsComponent
- implements FileSystem
-{
+public abstract class AbstractFileSystem extends AbstractVfsComponent implements FileSystem {
private static final Log LOG = LogFactory.getLog(AbstractFileSystem.class);
/**
- * The "root" of the file system. This is always "/" so it isn't always the "real"
- * root.
+ * The "root" of the file system. This is always "/" so it isn't always the "real" root.
*/
private final FileName rootName;
/**
- * The root URI of the file system. The base path specified as a file system option
- * when the file system was created.
+ * The root URI of the file system. The base path specified as a file system option when the file system was
+ * created.
*/
private final String rootURI;
@@ -89,7 +85,6 @@ public abstract class AbstractFileSystem
*/
private final AtomicLong useCount = new AtomicLong(0);
-
private FileSystemKey cacheKey;
/**
@@ -97,17 +92,14 @@ public abstract class AbstractFileSystem
*/
private final AtomicInteger openStreams = new AtomicInteger(0);
- protected AbstractFileSystem(final FileName rootName,
- final FileObject parentLayer,
- final FileSystemOptions fileSystemOptions)
- {
+ protected AbstractFileSystem(final FileName rootName, final FileObject parentLayer,
+ final FileSystemOptions fileSystemOptions) {
this.parentLayer = parentLayer;
this.rootName = rootName;
this.fileSystemOptions = fileSystemOptions;
final FileSystemConfigBuilder builder = DefaultFileSystemConfigBuilder.getInstance();
String uri = builder.getRootURI(fileSystemOptions);
- if (uri == null)
- {
+ if (uri == null) {
uri = rootName.getURI();
}
this.rootURI = uri;
@@ -115,11 +107,11 @@ public abstract class AbstractFileSystem
/**
* Initializes this component.
+ *
* @throws FileSystemException if an error occurs.
*/
@Override
- public void init() throws FileSystemException
- {
+ public void init() throws FileSystemException {
addCapabilities(caps);
}
@@ -127,8 +119,7 @@ public abstract class AbstractFileSystem
* Closes this component.
*/
@Override
- public void close()
- {
+ public void close() {
closeCommunicationLink();
parentLayer = null;
@@ -137,10 +128,8 @@ public abstract class AbstractFileSystem
/**
* Close the underlying link used to access the files.
*/
- public void closeCommunicationLink()
- {
- synchronized (this)
- {
+ public void closeCommunicationLink() {
+ synchronized (this) {
doCloseCommunicationLink();
}
}
@@ -148,8 +137,7 @@ public abstract class AbstractFileSystem
/**
* Close the underlying link used to access the files
*/
- protected void doCloseCommunicationLink()
- {
+ protected void doCloseCommunicationLink() {
}
/**
@@ -172,40 +160,38 @@ public abstract class AbstractFileSystem
/**
* Returns the name of the root of this file system.
+ *
* @return the root FileName.
*/
@Override
- public FileName getRootName()
- {
+ public FileName getRootName() {
return rootName;
}
/**
* Returns the root URI specified for this file System.
+ *
* @return The root URI used in this file system.
* @since 2.0
*/
@Override
- public String getRootURI()
- {
+ public String getRootURI() {
return rootURI;
}
/**
* Adds a file object to the cache.
+ *
* @param file the file to add.
*/
- protected void putFileToCache(final FileObject file)
- {
+ protected void putFileToCache(final FileObject file) {
getCache().putFile(file);
}
- private FilesCache getCache()
- {
+ private FilesCache getCache() {
FilesCache files;
files = getContext().getFileSystemManager().getFilesCache();
- if (files == null)
- {
+ if (files == null) {
throw new RuntimeException(Messages.getString("vfs.provider/files-cache-missing.error"));
}
@@ -214,92 +200,89 @@ public abstract class AbstractFileSystem
/**
* Returns a cached file.
+ *
* @param name name to search for.
* @return file object or null if not found.
*/
- protected FileObject getFileFromCache(final FileName name)
- {
+ protected FileObject getFileFromCache(final FileName name) {
return getCache().getFile(this, name);
}
/**
* Remove a cached file.
+ *
* @param name The file name to remove.
*/
- protected void removeFileFromCache(final FileName name)
- {
+ protected void removeFileFromCache(final FileName name) {
getCache().removeFile(this, name);
}
/**
* Determines if this file system has a particular capability.
+ *
* @param capability the Capability to check for.
* @return true if the FileSystem has the Capability, false otherwise.
*/
@Override
- public boolean hasCapability(final Capability capability)
- {
+ public boolean hasCapability(final Capability capability) {
return caps.contains(capability);
}
/**
- * Retrieves the attribute with the specified name. The default
- * implementation simply throws an exception.
+ * Retrieves the attribute with the specified name. The default implementation simply throws an exception.
+ *
* @param attrName The name of the attribute.
* @return the Object associated with the attribute or null if no object is.
* @throws FileSystemException if an error occurs.
*/
@Override
- public Object getAttribute(final String attrName) throws FileSystemException
- {
+ public Object getAttribute(final String attrName) throws FileSystemException {
throw new FileSystemException("vfs.provider/get-attribute-not-supported.error");
}
/**
- * Sets the attribute with the specified name. The default
- * implementation simply throws an exception.
+ * Sets the attribute with the specified name. The default implementation simply throws an exception.
+ *
* @param attrName the attribute name.
* @param value The object to associate with the attribute.
* @throws FileSystemException if an error occurs.
*/
@Override
- public void setAttribute(final String attrName, final Object value)
- throws FileSystemException
- {
+ public void setAttribute(final String attrName, final Object value) throws FileSystemException {
throw new FileSystemException("vfs.provider/set-attribute-not-supported.error");
}
/**
* Returns the parent layer if this is a layered file system.
+ *
* @return The FileObject for the parent layer.
* @throws FileSystemException if an error occurs.
*/
@Override
- public FileObject getParentLayer() throws FileSystemException
- {
+ public FileObject getParentLayer() throws FileSystemException {
return parentLayer;
}
/**
* Returns the root file of this file system.
+ *
* @return The root FileObject of the FileSystem
* @throws FileSystemException if an error occurs.
*/
@Override
- public FileObject getRoot() throws FileSystemException
- {
+ public FileObject getRoot() throws FileSystemException {
return resolveFile(rootName);
}
/**
* Finds a file in this file system.
+ *
* @param nameStr The name of the file to resolve.
* @return The located FileObject or null if none could be located.
* @throws FileSystemException if an error occurs.
*/
@Override
- public FileObject resolveFile(final String nameStr) throws FileSystemException
- {
+ public FileObject resolveFile(final String nameStr) throws FileSystemException {
// Resolve the name, and create the file
final FileName name = getFileSystemManager().resolveName(rootName, nameStr);
return resolveFile(name);
@@ -307,51 +290,42 @@ public abstract class AbstractFileSystem
/**
* Finds a file in this file system.
+ *
* @param name The name of the file to locate.
* @return The located FileObject or null if none could be located.
* @throws FileSystemException if an error occurs.
*/
@Override
- public FileObject resolveFile(final FileName name) throws FileSystemException
- {
+ public FileObject resolveFile(final FileName name) throws FileSystemException {
return resolveFile(name, true);
}
- private synchronized FileObject resolveFile(final FileName name, final boolean useCache) throws FileSystemException
- {
- if (!rootName.getRootURI().equals(name.getRootURI()))
- {
- throw new FileSystemException("vfs.provider/mismatched-fs-for-name.error",
- name, rootName, name.getRootURI());
+ private synchronized FileObject resolveFile(final FileName name, final boolean useCache)
+ throws FileSystemException {
+ if (!rootName.getRootURI().equals(name.getRootURI())) {
+ throw new FileSystemException("vfs.provider/mismatched-fs-for-name.error", name, rootName,
+ name.getRootURI());
}
// imario@apache.org ==> use getFileFromCache
FileObject file;
- if (useCache)
- {
+ if (useCache) {
file = getFileFromCache(name);
- }
- else
- {
+ } else {
file = null;
}
- if (file == null)
- {
- try
- {
+ if (file == null) {
+ try {
file = createFile((AbstractFileName) name);
- }
- catch (final Exception e)
- {
+ } catch (final Exception e) {
throw new FileSystemException("vfs.provider/resolve-file.error", name, e);
}
file = decorateFileObject(file);
// imario@apache.org ==> use putFileToCache
- if (useCache)
- {
+ if (useCache) {
putFileToCache(file);
}
}
@@ -359,39 +333,28 @@ public abstract class AbstractFileSystem
/**
* resync the file information if requested
*/
- if (getFileSystemManager().getCacheStrategy().equals(CacheStrategy.ON_RESOLVE))
- {
+ if (getFileSystemManager().getCacheStrategy().equals(CacheStrategy.ON_RESOLVE)) {
file.refresh();
}
return file;
}
- protected FileObject decorateFileObject(FileObject file) throws FileSystemException
- {
- if (getFileSystemManager().getCacheStrategy().equals(CacheStrategy.ON_CALL))
- {
+ protected FileObject decorateFileObject(FileObject file) throws FileSystemException {
+ if (getFileSystemManager().getCacheStrategy().equals(CacheStrategy.ON_CALL)) {
file = new OnCallRefreshFileObject(file);
}
- if (getFileSystemManager().getFileObjectDecoratorConst() != null)
- {
- try
- {
- file = (FileObject) getFileSystemManager().getFileObjectDecoratorConst().
- newInstance(new Object[]{file});
- }
- catch (final InstantiationException e)
- {
+ if (getFileSystemManager().getFileObjectDecoratorConst() != null) {
+ try {
+ file = (FileObject) getFileSystemManager().getFileObjectDecoratorConst()
+ .newInstance(new Object[] { file });
+ } catch (final InstantiationException e) {
throw new FileSystemException("vfs.impl/invalid-decorator.error",
getFileSystemManager().getFileObjectDecorator().getName(), e);
- }
- catch (final IllegalAccessException e)
- {
+ } catch (final IllegalAccessException e) {
throw new FileSystemException("vfs.impl/invalid-decorator.error",
getFileSystemManager().getFileObjectDecorator().getName(), e);
- }
- catch (final InvocationTargetException e)
- {
+ } catch (final InvocationTargetException e) {
throw new FileSystemException("vfs.impl/invalid-decorator.error",
getFileSystemManager().getFileObjectDecorator().getName(), e);
}
@@ -402,48 +365,42 @@ public abstract class AbstractFileSystem
/**
* Creates a temporary local copy of a file and its descendants.
+ *
* @param file The FileObject to replicate.
* @param selector The FileSelector.
* @return The replicated File.
* @throws FileSystemException if an error occurs.
*/
@Override
- public File replicateFile(final FileObject file,
- final FileSelector selector)
- throws FileSystemException
- {
- if (!file.exists())
- {
+ public File replicateFile(final FileObject file, final FileSelector selector) throws FileSystemException {
+ if (!file.exists()) {
throw new FileSystemException("vfs.provider/replicate-missing-file.error", file.getName());
}
- try
- {
+ try {
return doReplicateFile(file, selector);
- }
- catch (final Exception e)
- {
+ } catch (final Exception e) {
throw new FileSystemException("vfs.provider/replicate-file.error", file.getName(), e);
}
}
/**
* Return the FileSystemOptions used to instantiate this filesystem.
+ *
* @return the FileSystemOptions.
*/
@Override
- public FileSystemOptions getFileSystemOptions()
- {
+ public FileSystemOptions getFileSystemOptions() {
return fileSystemOptions;
}
/**
* Return the FileSystemManager used to instantiate this filesystem.
+ *
* @return the FileSystemManager.
*/
@Override
- public FileSystemManager getFileSystemManager()
- {
+ public FileSystemManager getFileSystemManager() {
return getContext().getFileSystemManager();
}
@@ -453,8 +410,7 @@ public abstract class AbstractFileSystem
* @return ms 0 perfectly accurate, {@literal >0} might be off by this value e.g. sftp 1000ms
*/
@Override
- public double getLastModTimeAccuracy()
- {
+ public double getLastModTimeAccuracy() {
return 0;
}
@@ -466,52 +422,44 @@ public abstract class AbstractFileSystem
* @return replicated root file.
* @throws Exception any Exception is wrapped as FileSystemException.
*/
- protected File doReplicateFile(final FileObject file,
- final FileSelector selector)
- throws Exception
- {
+ protected File doReplicateFile(final FileObject file, final FileSelector selector) throws Exception {
return getContext().getReplicator().replicateFile(file, selector);
}
/**
* Adds a junction to this file system.
+ *
* @param junctionPoint The junction point.
* @param targetFile The target to add.
* @throws FileSystemException if an error occurs.
*/
@Override
- public void addJunction(final String junctionPoint,
- final FileObject targetFile)
- throws FileSystemException
- {
+ public void addJunction(final String junctionPoint, final FileObject targetFile) throws FileSystemException {
throw new FileSystemException("vfs.provider/junctions-not-supported.error", rootName);
}
/**
* Removes a junction from this file system.
+ *
* @param junctionPoint The junction point.
* @throws FileSystemException if an error occurs
*/
@Override
- public void removeJunction(final String junctionPoint) throws FileSystemException
- {
+ public void removeJunction(final String junctionPoint) throws FileSystemException {
throw new FileSystemException("vfs.provider/junctions-not-supported.error", rootName);
}
/**
* Adds a listener on a file in this file system.
+ *
* @param file The FileObject to be monitored.
* @param listener The FileListener
*/
@Override
- public void addListener(final FileObject file,
- final FileListener listener)
- {
- synchronized (listenerMap)
- {
+ public void addListener(final FileObject file, final FileListener listener) {
+ synchronized (listenerMap) {
ArrayList<FileListener> listeners = listenerMap.get(file.getName());
- if (listeners == null)
- {
+ if (listeners == null) {
listeners = new ArrayList<>();
listenerMap.put(file.getName(), listeners);
}
@@ -521,21 +469,17 @@ public abstract class AbstractFileSystem
/**
* Removes a listener from a file in this file system.
+ *
* @param file The FileObject to be monitored.
* @param listener The FileListener
*/
@Override
- public void removeListener(final FileObject file,
- final FileListener listener)
- {
- synchronized (listenerMap)
- {
+ public void removeListener(final FileObject file, final FileListener listener) {
+ synchronized (listenerMap) {
final ArrayList<?> listeners = listenerMap.get(file.getName());
- if (listeners != null)
- {
+ if (listeners != null) {
listeners.remove(listener);
- if (listeners.isEmpty())
- {
+ if (listeners.isEmpty()) {
listenerMap.remove(file.getName());
}
}
@@ -544,19 +488,19 @@ public abstract class AbstractFileSystem
/**
* Fires a file create event.
+ *
* @param file The FileObject that was created.
*/
- public void fireFileCreated(final FileObject file)
- {
+ public void fireFileCreated(final FileObject file) {
fireEvent(new CreateEvent(file));
}
/**
* Fires a file delete event.
+ *
* @param file The FileObject that was deleted.
*/
- public void fireFileDeleted(final FileObject file)
- {
+ public void fireFileDeleted(final FileObject file) {
fireEvent(new DeleteEvent(file));
}
@@ -567,8 +511,7 @@ public abstract class AbstractFileSystem
*
* @param file The FileObject that changed.
*/
- public void fireFileChanged(final FileObject file)
- {
+ public void fireFileChanged(final FileObject file) {
fireEvent(new ChangedEvent(file));
}
@@ -577,42 +520,32 @@ public abstract class AbstractFileSystem
*
* @return true if no file is using this FileSystem.
*/
- public boolean isReleaseable()
- {
+ public boolean isReleaseable() {
return useCount.get() < 1;
}
- void freeResources()
- {
+ void freeResources() {
}
/**
* Fires an event.
*/
- private void fireEvent(final AbstractFileChangeEvent event)
- {
+ private void fireEvent(final AbstractFileChangeEvent event) {
FileListener[] fileListeners = null;
final FileObject file = event.getFile();
- synchronized (listenerMap)
- {
+ synchronized (listenerMap) {
final ArrayList<?> listeners = listenerMap.get(file.getName());
- if (listeners != null)
- {
+ if (listeners != null) {
fileListeners = listeners.toArray(new FileListener[listeners.size()]);
}
}
- if (fileListeners != null)
- {
- for (final FileListener fileListener : fileListeners)
- {
- try
- {
+ if (fileListeners != null) {
+ for (final FileListener fileListener : fileListeners) {
+ try {
event.notify(fileListener);
- }
- catch (final Exception e)
- {
+ } catch (final Exception e) {
final String message = Messages.getString("vfs.provider/notify-listener.warn", file);
// getLogger().warn(message, e);
VfsLog.warn(getLogger(), LOG, message, e);
@@ -621,46 +554,37 @@ public abstract class AbstractFileSystem
}
}
- void fileObjectHanded(final FileObject fileObject)
- {
+ void fileObjectHanded(final FileObject fileObject) {
useCount.incrementAndGet();
}
- void fileObjectDestroyed(final FileObject fileObject)
- {
+ void fileObjectDestroyed(final FileObject fileObject) {
useCount.decrementAndGet();
}
- void setCacheKey(final FileSystemKey cacheKey)
- {
+ void setCacheKey(final FileSystemKey cacheKey) {
this.cacheKey = cacheKey;
}
- FileSystemKey getCacheKey()
- {
+ FileSystemKey getCacheKey() {
return this.cacheKey;
}
- void streamOpened()
- {
+ void streamOpened() {
openStreams.incrementAndGet();
}
- void streamClosed()
- {
+ void streamClosed() {
int count;
- do
- {
+ do {
count = openStreams.get();
- if (count < 1)
- {
+ if (count < 1) {
return;
}
- } while(openStreams.compareAndSet(count, count - 1));
+ } while (openStreams.compareAndSet(count, count - 1));
- if (count == 1)
- {
+ if (count == 1) {
notifyAllStreamsClosed();
}
}
@@ -668,16 +592,15 @@ public abstract class AbstractFileSystem
/**
* will be called after all file-objects closed their streams.
*/
- protected void notifyAllStreamsClosed()
- {
+ protected void notifyAllStreamsClosed() {
}
/**
* check if this filesystem has open streams.
+ *
* @return true if the FileSystem has open streams.
*/
- public boolean isOpen()
- {
+ public boolean isOpen() {
return openStreams.get() > 0;
}
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractLayeredFileProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractLayeredFileProvider.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractLayeredFileProvider.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractLayeredFileProvider.java Thu Sep 14 19:26:39 2017
@@ -23,20 +23,17 @@ import org.apache.commons.vfs2.FileSyste
import org.apache.commons.vfs2.FileSystemOptions;
/**
- * A {@link FileProvider} that is layered on top of another, such as the
- * contents of a zip or tar file.
+ * A {@link FileProvider} that is layered on top of another, such as the contents of a zip or tar file.
*/
-public abstract class AbstractLayeredFileProvider
- extends AbstractFileProvider
-{
- public AbstractLayeredFileProvider()
- {
+public abstract class AbstractLayeredFileProvider extends AbstractFileProvider {
+ public AbstractLayeredFileProvider() {
super();
setFileNameParser(LayeredFileNameParser.getInstance());
}
/**
* Locates a file object, by absolute URI.
+ *
* @param baseFile The base FileObject.
* @param uri The name of the file to locate.
* @param fileSystemOptions The FileSystemOptions.
@@ -44,10 +41,8 @@ public abstract class AbstractLayeredFil
* @throws FileSystemException if an error occurs.
*/
@Override
- public FileObject findFile(final FileObject baseFile,
- final String uri,
- final FileSystemOptions fileSystemOptions) throws FileSystemException
- {
+ public FileObject findFile(final FileObject baseFile, final String uri, final FileSystemOptions fileSystemOptions)
+ throws FileSystemException {
// Split the URI up into its parts
final LayeredFileName name = (LayeredFileName) parseUri(baseFile != null ? baseFile.getName() : null, uri);
@@ -66,6 +61,7 @@ public abstract class AbstractLayeredFil
/**
* Creates a layered file system.
+ *
* @param scheme The protocol to use.
* @param file a FileObject.
* @param fileSystemOptions Options to access the FileSystem.
@@ -73,16 +69,12 @@ public abstract class AbstractLayeredFil
* @throws FileSystemException if an error occurs.
*/
@Override
- public synchronized FileObject createFileSystem(final String scheme,
- final FileObject file,
- final FileSystemOptions fileSystemOptions)
- throws FileSystemException
- {
+ public synchronized FileObject createFileSystem(final String scheme, final FileObject file,
+ final FileSystemOptions fileSystemOptions) throws FileSystemException {
// Check if cached
final FileName rootName = file.getName();
FileSystem fs = findFileSystem(rootName, fileSystemOptions);
- if (fs == null)
- {
+ if (fs == null) {
// Create the file system
fs = doCreateFileSystem(scheme, file, fileSystemOptions);
addFileSystem(rootName, fs);
@@ -96,14 +88,12 @@ public abstract class AbstractLayeredFil
* This method is called if the file system is not cached.
*
* @param scheme The URI scheme.
- * @param file The file to create the file system on top of.
+ * @param file The file to create the file system on top of.
* @param fileSystemOptions options for new and underlying file systems.
* @return The file system, never null. Might implement {@link VfsComponent}.
* @throws FileSystemException if the file system cannot be created.
*/
- protected abstract FileSystem doCreateFileSystem(final String scheme,
- final FileObject file,
- final FileSystemOptions fileSystemOptions)
- throws FileSystemException;
+ protected abstract FileSystem doCreateFileSystem(final String scheme, final FileObject file,
+ final FileSystemOptions fileSystemOptions) throws FileSystemException;
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractOriginatingFileProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractOriginatingFileProvider.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractOriginatingFileProvider.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractOriginatingFileProvider.java Thu Sep 14 19:26:39 2017
@@ -23,15 +23,11 @@ import org.apache.commons.vfs2.FileSyste
import org.apache.commons.vfs2.FileSystemOptions;
/**
- * A {@link FileProvider} that handles physical files, such as the files in a
- * local fs, or on an FTP server. An originating file system cannot be
- * layered on top of another file system.
+ * A {@link FileProvider} that handles physical files, such as the files in a local fs, or on an FTP server. An
+ * originating file system cannot be layered on top of another file system.
*/
-public abstract class AbstractOriginatingFileProvider
- extends AbstractFileProvider
-{
- public AbstractOriginatingFileProvider()
- {
+public abstract class AbstractOriginatingFileProvider extends AbstractFileProvider {
+ public AbstractOriginatingFileProvider() {
super();
}
@@ -45,18 +41,13 @@ public abstract class AbstractOriginatin
* @throws FileSystemException if an error occurs.
*/
@Override
- public FileObject findFile(final FileObject baseFile,
- final String uri,
- final FileSystemOptions fileSystemOptions) throws FileSystemException
- {
+ public FileObject findFile(final FileObject baseFile, final String uri, final FileSystemOptions fileSystemOptions)
+ throws FileSystemException {
// Parse the URI
final FileName name;
- try
- {
+ try {
name = parseUri(baseFile != null ? baseFile.getName() : null, uri);
- }
- catch (final FileSystemException exc)
- {
+ } catch (final FileSystemException exc) {
throw new FileSystemException("vfs.provider/invalid-absolute-uri.error", uri, exc);
}
@@ -66,14 +57,14 @@ public abstract class AbstractOriginatin
/**
* Locates a file from its parsed URI.
+ *
* @param name The file name.
* @param fileSystemOptions FileSystem options.
* @return A FileObject associated with the file.
* @throws FileSystemException if an error occurs.
*/
protected FileObject findFile(final FileName name, final FileSystemOptions fileSystemOptions)
- throws FileSystemException
- {
+ throws FileSystemException {
// Check in the cache for the file system
final FileName rootName = getContext().getFileSystemManager().resolveName(name, FileName.ROOT_PATH);
@@ -86,6 +77,7 @@ public abstract class AbstractOriginatin
/**
* Returns the FileSystem associated with the specified root.
+ *
* @param rootName The root path.
* @param fileSystemOptions The FileSystem options.
* @return The FileSystem.
@@ -93,11 +85,9 @@ public abstract class AbstractOriginatin
* @since 2.0
*/
protected synchronized FileSystem getFileSystem(final FileName rootName, final FileSystemOptions fileSystemOptions)
- throws FileSystemException
- {
+ throws FileSystemException {
FileSystem fs = findFileSystem(rootName, fileSystemOptions);
- if (fs == null)
- {
+ if (fs == null) {
// Need to create the file system, and cache it
fs = doCreateFileSystem(rootName, fileSystemOptions);
addFileSystem(rootName, fs);
@@ -105,11 +95,8 @@ public abstract class AbstractOriginatin
return fs;
}
-
-
/**
- * Creates a {@link FileSystem}. If the returned FileSystem implements
- * {@link VfsComponent}, it will be initialised.
+ * Creates a {@link FileSystem}. If the returned FileSystem implements {@link VfsComponent}, it will be initialised.
*
* @param rootName The name of the root file of the file system to create.
* @param fileSystemOptions The FileSystem options.
@@ -117,5 +104,5 @@ public abstract class AbstractOriginatin
* @throws FileSystemException if an error occurs.
*/
protected abstract FileSystem doCreateFileSystem(final FileName rootName, final FileSystemOptions fileSystemOptions)
- throws FileSystemException;
+ throws FileSystemException;
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractRandomAccessContent.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractRandomAccessContent.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractRandomAccessContent.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractRandomAccessContent.java Thu Sep 14 19:26:39 2017
@@ -26,107 +26,89 @@ import org.apache.commons.vfs2.util.Rand
* {@link UnsupportedOperationException} when one of these methods are called. For read-only random access
* implementations.
*/
-public abstract class AbstractRandomAccessContent implements RandomAccessContent
-{
- protected AbstractRandomAccessContent(final RandomAccessMode mode)
- {
+public abstract class AbstractRandomAccessContent implements RandomAccessContent {
+ protected AbstractRandomAccessContent(final RandomAccessMode mode) {
}
/**
* @deprecated see {@link java.io.DataInputStream#readLine()} This method will be removed when it is removed from
* the DataInput interface this class implements (which will probably never happen).
* @return The line as a String.
- * @throws IOException
- * if an error occurs.
+ * @throws IOException if an error occurs.
*/
@Override
@Deprecated
- public String readLine() throws IOException
- {
+ public String readLine() throws IOException {
throw new UnsupportedOperationException("deprecated");
}
@Override
- public void write(final byte[] b) throws IOException
- {
+ public void write(final byte[] b) throws IOException {
throw new UnsupportedOperationException();
}
@Override
- public void write(final byte[] b, final int off, final int len) throws IOException
- {
+ public void write(final byte[] b, final int off, final int len) throws IOException {
throw new UnsupportedOperationException();
}
@Override
- public void write(final int b) throws IOException
- {
+ public void write(final int b) throws IOException {
throw new UnsupportedOperationException();
}
@Override
- public void writeBoolean(final boolean v) throws IOException
- {
+ public void writeBoolean(final boolean v) throws IOException {
throw new UnsupportedOperationException();
}
@Override
- public void writeByte(final int v) throws IOException
- {
+ public void writeByte(final int v) throws IOException {
throw new UnsupportedOperationException();
}
@Override
- public void writeBytes(final String s) throws IOException
- {
+ public void writeBytes(final String s) throws IOException {
throw new UnsupportedOperationException();
}
@Override
- public void writeChar(final int v) throws IOException
- {
+ public void writeChar(final int v) throws IOException {
throw new UnsupportedOperationException();
}
@Override
- public void writeChars(final String s) throws IOException
- {
+ public void writeChars(final String s) throws IOException {
throw new UnsupportedOperationException();
}
@Override
- public void writeDouble(final double v) throws IOException
- {
+ public void writeDouble(final double v) throws IOException {
throw new UnsupportedOperationException();
}
@Override
- public void writeFloat(final float v) throws IOException
- {
+ public void writeFloat(final float v) throws IOException {
throw new UnsupportedOperationException();
}
@Override
- public void writeInt(final int v) throws IOException
- {
+ public void writeInt(final int v) throws IOException {
throw new UnsupportedOperationException();
}
@Override
- public void writeLong(final long v) throws IOException
- {
+ public void writeLong(final long v) throws IOException {
throw new UnsupportedOperationException();
}
@Override
- public void writeShort(final int v) throws IOException
- {
+ public void writeShort(final int v) throws IOException {
throw new UnsupportedOperationException();
}
@Override
- public void writeUTF(final String str) throws IOException
- {
+ public void writeUTF(final String str) throws IOException {
throw new UnsupportedOperationException();
}
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractRandomAccessStreamContent.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractRandomAccessStreamContent.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractRandomAccessStreamContent.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractRandomAccessStreamContent.java Thu Sep 14 19:26:39 2017
@@ -25,108 +25,90 @@ import org.apache.commons.vfs2.util.Rand
/**
* Implements the part usable for all stream-based random access.
*/
-public abstract class AbstractRandomAccessStreamContent extends AbstractRandomAccessContent
-{
- protected AbstractRandomAccessStreamContent(final RandomAccessMode mode)
- {
+public abstract class AbstractRandomAccessStreamContent extends AbstractRandomAccessContent {
+ protected AbstractRandomAccessStreamContent(final RandomAccessMode mode) {
super(mode);
}
protected abstract DataInputStream getDataInputStream() throws IOException;
@Override
- public byte readByte() throws IOException
- {
+ public byte readByte() throws IOException {
return getDataInputStream().readByte();
}
@Override
- public char readChar() throws IOException
- {
+ public char readChar() throws IOException {
return getDataInputStream().readChar();
}
@Override
- public double readDouble() throws IOException
- {
+ public double readDouble() throws IOException {
return getDataInputStream().readDouble();
}
@Override
- public float readFloat() throws IOException
- {
+ public float readFloat() throws IOException {
return getDataInputStream().readFloat();
}
@Override
- public int readInt() throws IOException
- {
+ public int readInt() throws IOException {
return getDataInputStream().readInt();
}
@Override
- public int readUnsignedByte() throws IOException
- {
+ public int readUnsignedByte() throws IOException {
return getDataInputStream().readUnsignedByte();
}
@Override
- public int readUnsignedShort() throws IOException
- {
+ public int readUnsignedShort() throws IOException {
return getDataInputStream().readUnsignedShort();
}
@Override
- public long readLong() throws IOException
- {
+ public long readLong() throws IOException {
return getDataInputStream().readLong();
}
@Override
- public short readShort() throws IOException
- {
+ public short readShort() throws IOException {
return getDataInputStream().readShort();
}
@Override
- public boolean readBoolean() throws IOException
- {
+ public boolean readBoolean() throws IOException {
return getDataInputStream().readBoolean();
}
@Override
- public int skipBytes(final int n) throws IOException
- {
+ public int skipBytes(final int n) throws IOException {
return getDataInputStream().skipBytes(n);
}
@Override
- public void readFully(final byte[] b) throws IOException
- {
+ public void readFully(final byte[] b) throws IOException {
getDataInputStream().readFully(b);
}
@Override
- public void readFully(final byte[] b, final int off, final int len) throws IOException
- {
+ public void readFully(final byte[] b, final int off, final int len) throws IOException {
getDataInputStream().readFully(b, off, len);
}
@Override
- public String readUTF() throws IOException
- {
+ public String readUTF() throws IOException {
return getDataInputStream().readUTF();
}
@Override
- public InputStream getInputStream() throws IOException
- {
+ public InputStream getInputStream() throws IOException {
return getDataInputStream();
}
@Override
- public void setLength(final long newLength) throws IOException
- {
+ public void setLength(final long newLength) throws IOException {
throw new UnsupportedOperationException();
}
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractVfsComponent.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractVfsComponent.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractVfsComponent.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractVfsComponent.java Thu Sep 14 19:26:39 2017
@@ -22,64 +22,61 @@ import org.apache.commons.vfs2.FileSyste
/**
* A partial {@link VfsComponent} implementation.
*/
-public abstract class AbstractVfsComponent
- implements VfsComponent
-{
+public abstract class AbstractVfsComponent implements VfsComponent {
private VfsComponentContext context;
private Log log;
/**
* Sets the Logger to use for the component.
+ *
* @param log The Log to use.
*/
@Override
- public final void setLogger(final Log log)
- {
+ public final void setLogger(final Log log) {
this.log = log;
}
/**
* Sets the context for this file system provider.
+ *
* @param context The VfsComponentContext.
*/
@Override
- public final void setContext(final VfsComponentContext context)
- {
+ public final void setContext(final VfsComponentContext context) {
this.context = context;
}
/**
- * Initializes the component. This implementation does nothing.
+ * Initializes the component. This implementation does nothing.
+ *
* @throws FileSystemException if an error occurs.
*/
@Override
- public void init() throws FileSystemException
- {
+ public void init() throws FileSystemException {
}
/**
- * Closes the provider. This implementation does nothing.
+ * Closes the provider. This implementation does nothing.
*/
@Override
- public void close()
- {
+ public void close() {
}
/**
* Returns the logger for this file system to use.
+ *
* @return logger for this file system
*/
- protected final Log getLogger()
- {
+ protected final Log getLogger() {
return log;
}
/**
* Returns the context for this provider.
+ *
* @return provider context
*/
- protected final VfsComponentContext getContext()
- {
+ protected final VfsComponentContext getContext() {
return context;
}
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractVfsContainer.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractVfsContainer.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractVfsContainer.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractVfsContainer.java Thu Sep 14 19:26:39 2017
@@ -23,33 +23,26 @@ import org.apache.commons.vfs2.FileSyste
/**
* A {@link VfsComponent} that contains a set of sub-components.
*/
-public abstract class AbstractVfsContainer
- extends AbstractVfsComponent
-{
+public abstract class AbstractVfsContainer extends AbstractVfsComponent {
/**
* The components contained by this component.
*/
- private final ArrayList<Object> components
- = new ArrayList<>(); // @GuardedBy("self")
+ private final ArrayList<Object> components = new ArrayList<>(); // @GuardedBy("self")
/**
* Adds a sub-component to this component.
* <p>
- * If the sub-component implements {@link VfsComponent}, it is initialised.
- * All sub-components are closed when this component is closed.
+ * If the sub-component implements {@link VfsComponent}, it is initialised. All sub-components are closed when this
+ * component is closed.
+ *
* @param component the component to add.
* @throws FileSystemException if any error occurs.
*/
- protected void addComponent(final Object component)
- throws FileSystemException
- {
- synchronized (components)
- {
- if (!components.contains(component))
- {
+ protected void addComponent(final Object component) throws FileSystemException {
+ synchronized (components) {
+ if (!components.contains(component)) {
// Initialise
- if (component instanceof VfsComponent)
- {
+ if (component instanceof VfsComponent) {
final VfsComponent vfsComponent = (VfsComponent) component;
vfsComponent.setLogger(getLogger());
vfsComponent.setContext(getContext());
@@ -67,10 +60,8 @@ public abstract class AbstractVfsContain
*
* @param component the component to remove.
*/
- protected void removeComponent(final Object component)
- {
- synchronized (components)
- {
+ protected void removeComponent(final Object component) {
+ synchronized (components) {
// multiple instances should not happen
components.remove(component);
}
@@ -80,20 +71,16 @@ public abstract class AbstractVfsContain
* Closes the sub-components of this component.
*/
@Override
- public void close()
- {
+ public void close() {
final Object[] toclose;
- synchronized (components)
- {
+ synchronized (components) {
toclose = components.toArray();
components.clear();
}
-
+
// Close all components
- for (final Object component : toclose)
- {
- if (component instanceof VfsComponent)
- {
+ for (final Object component : toclose) {
+ if (component instanceof VfsComponent) {
final VfsComponent vfsComponent = (VfsComponent) component;
vfsComponent.close();
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/CompositeFileProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/CompositeFileProvider.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/CompositeFileProvider.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/CompositeFileProvider.java Thu Sep 14 19:26:39 2017
@@ -23,23 +23,23 @@ import org.apache.commons.vfs2.FileSyste
/**
* Description.
*/
-public abstract class CompositeFileProvider extends AbstractFileProvider
-{
+public abstract class CompositeFileProvider extends AbstractFileProvider {
private static final int INITIAL_BUFSZ = 80;
- public CompositeFileProvider()
- {
+ public CompositeFileProvider() {
super();
}
/**
* The schemes known.
+ *
* @return Array of supported schemes.
*/
protected abstract String[] getSchemes();
/**
* Locates a file object, by absolute URI.
+ *
* @param baseFile The base FileObject.
* @param uri The file to find.
* @param fileSystemOptions The options for the FileSystem.
@@ -47,18 +47,14 @@ public abstract class CompositeFileProvi
* @throws FileSystemException if an error occurs.
*/
@Override
- public FileObject findFile(final FileObject baseFile,
- final String uri,
- final FileSystemOptions fileSystemOptions)
- throws FileSystemException
- {
+ public FileObject findFile(final FileObject baseFile, final String uri, final FileSystemOptions fileSystemOptions)
+ throws FileSystemException {
final StringBuilder buf = new StringBuilder(INITIAL_BUFSZ);
UriParser.extractScheme(uri, buf);
final String[] schemes = getSchemes();
- for (final String scheme : schemes)
- {
+ for (final String scheme : schemes) {
buf.insert(0, ":");
buf.insert(0, scheme);
}