Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileSystemManager.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileSystemManager.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileSystemManager.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileSystemManager.java Thu Sep 14 19:26:39 2017 @@ -60,8 +60,7 @@ import org.apache.commons.vfs2.provider. /** * The default file system manager implementation. */ -public class DefaultFileSystemManager implements FileSystemManager -{ +public class DefaultFileSystemManager implements FileSystemManager { /** * Mapping from URI scheme to FileProvider. */ @@ -80,15 +79,13 @@ public class DefaultFileSystemManager im /** * Operations providers added to this manager. */ - private final Map<String, List<FileOperationProvider>> operationProviders = - new HashMap<>(); + private final Map<String, List<FileOperationProvider>> operationProviders = new HashMap<>(); /** * Mappings of file types. */ private final FileTypeMap typeMap = new FileTypeMap(); - /** * The provider for local files. */ @@ -153,60 +150,44 @@ public class DefaultFileSystemManager im */ private boolean init; - /** * Returns the logger used by this manager. + * * @return the Logger. */ - protected Log getLogger() - { + protected Log getLogger() { return log; } /** * Registers a file system provider. * <p> - * The manager takes care of all lifecycle management. - * A provider may be registered multiple times. - * The first {@link LocalFileProvider} added will be - * remembered for {@link #getLocalFileProvider()}. - * - * @param urlScheme - * The scheme the provider will handle. - * @param provider - * The provider. + * The manager takes care of all lifecycle management. A provider may be registered multiple times. The first + * {@link LocalFileProvider} added will be remembered for {@link #getLocalFileProvider()}. + * + * @param urlScheme The scheme the provider will handle. + * @param provider The provider. * @throws FileSystemException if an error occurs adding the provider. */ - public void addProvider(final String urlScheme, final FileProvider provider) - throws FileSystemException - { - addProvider(new String[] {urlScheme}, provider); + public void addProvider(final String urlScheme, final FileProvider provider) throws FileSystemException { + addProvider(new String[] { urlScheme }, provider); } /** * Registers a file system provider. * <p> - * The manager takes care of all lifecycle management. - * A provider may be registered multiple times. - * The first {@link LocalFileProvider} added will be - * remembered for {@link #getLocalFileProvider()}. - * - * @param urlSchemes - * The schemes the provider will handle. - * @param provider - * The provider. + * The manager takes care of all lifecycle management. A provider may be registered multiple times. The first + * {@link LocalFileProvider} added will be remembered for {@link #getLocalFileProvider()}. + * + * @param urlSchemes The schemes the provider will handle. + * @param provider The provider. * @throws FileSystemException if an error occurs adding the provider. */ - public void addProvider(final String[] urlSchemes, - final FileProvider provider) throws FileSystemException - { + public void addProvider(final String[] urlSchemes, final FileProvider provider) throws FileSystemException { // fail duplicate schemes - for (final String scheme : urlSchemes) - { - if (providers.containsKey(scheme)) - { - throw new FileSystemException( - "vfs.impl/multiple-providers-for-scheme.error", scheme); + for (final String scheme : urlSchemes) { + if (providers.containsKey(scheme)) { + throw new FileSystemException("vfs.impl/multiple-providers-for-scheme.error", scheme); } } @@ -214,13 +195,11 @@ public class DefaultFileSystemManager im setupComponent(provider); // Add to map - for (final String scheme : urlSchemes) - { + for (final String scheme : urlSchemes) { providers.put(scheme, provider); } - if (provider instanceof LocalFileProvider && localFileProvider == null) - { + if (provider instanceof LocalFileProvider && localFileProvider == null) { localFileProvider = (LocalFileProvider) provider; } } @@ -232,8 +211,7 @@ public class DefaultFileSystemManager im * @return true if a provider is configured for this scheme, false otherwise. */ @Override - public boolean hasProvider(final String scheme) - { + public boolean hasProvider(final String scheme) { return providers.containsKey(scheme); } @@ -243,8 +221,7 @@ public class DefaultFileSystemManager im * @param extension The file name extension. * @param scheme The scheme to use for files with this extension. */ - public void addExtensionMap(final String extension, final String scheme) - { + public void addExtensionMap(final String extension, final String scheme) { typeMap.addExtension(extension, scheme); } @@ -254,31 +231,29 @@ public class DefaultFileSystemManager im * @param mimeType The mime type. * @param scheme The scheme to use for files with this mime type. */ - public void addMimeTypeMap(final String mimeType, final String scheme) - { + public void addMimeTypeMap(final String mimeType, final String scheme) { typeMap.addMimeType(mimeType, scheme); } /** - * Sets the default provider. This is the provider that will handle URI with - * unknown schemes. The manager takes care of all lifecycle management. + * Sets the default provider. This is the provider that will handle URI with unknown schemes. The manager takes care + * of all lifecycle management. + * * @param provider The FileProvider. * @throws FileSystemException if an error occurs setting the provider. */ - public void setDefaultProvider(final FileProvider provider) - throws FileSystemException - { + public void setDefaultProvider(final FileProvider provider) throws FileSystemException { setupComponent(provider); defaultProvider = provider; } /** * Returns the filesCache implementation used to cache files. + * * @return The FilesCache. */ @Override - public FilesCache getFilesCache() - { + public FilesCache getFilesCache() { return filesCache; } @@ -287,17 +262,13 @@ public class DefaultFileSystemManager im * <p> * Can only be set before the FileSystemManager is initialized. * <p> - * The manager takes care of the lifecycle. If none is set, a default is picked - * in {@link #init()}. + * The manager takes care of the lifecycle. If none is set, a default is picked in {@link #init()}. * * @param filesCache The FilesCache. * @throws FileSystemException if an error occurs setting the cache.. */ - public void setFilesCache(final FilesCache filesCache) - throws FileSystemException - { - if (init) - { + public void setFilesCache(final FilesCache filesCache) throws FileSystemException { + if (init) { throw new FileSystemException("vfs.impl/already-inited.error"); } @@ -312,14 +283,10 @@ public class DefaultFileSystemManager im * The default is {@link CacheStrategy#ON_RESOLVE} * * @param fileCacheStrategy The CacheStrategy to use. - * @throws FileSystemException - * if this is not possible. e.g. it is already set. + * @throws FileSystemException if this is not possible. e.g. it is already set. */ - public void setCacheStrategy(final CacheStrategy fileCacheStrategy) - throws FileSystemException - { - if (init) - { + public void setCacheStrategy(final CacheStrategy fileCacheStrategy) throws FileSystemException { + if (init) { throw new FileSystemException("vfs.impl/already-inited.error"); } @@ -328,32 +295,31 @@ public class DefaultFileSystemManager im /** * Get the cache strategy used. + * * @return The CacheStrategy. */ @Override - public CacheStrategy getCacheStrategy() - { + public CacheStrategy getCacheStrategy() { return fileCacheStrategy; } /** * Get the file object decorator used. + * * @return The decorator. */ @Override - public Class<?> getFileObjectDecorator() - { + public Class<?> getFileObjectDecorator() { return fileObjectDecorator; } /** - * The constructor associated to the fileObjectDecorator. - * We cache it here for performance reasons. + * The constructor associated to the fileObjectDecorator. We cache it here for performance reasons. + * * @return The decorator's Constructor. */ @Override - public Constructor<?> getFileObjectDecoratorConst() - { + public Constructor<?> getFileObjectDecoratorConst() { return fileObjectDecoratorConst; } @@ -362,27 +328,21 @@ public class DefaultFileSystemManager im * <p> * Can only be set before the FileSystemManager is initialized. * - * @param fileObjectDecorator must be inherted from {@link DecoratedFileObject} a has to provide a - * constructor with a single {@link FileObject} as argument + * @param fileObjectDecorator must be inherted from {@link DecoratedFileObject} a has to provide a constructor with + * a single {@link FileObject} as argument * @throws FileSystemException if an error occurs setting the decorator. */ - public void setFileObjectDecorator(final Class<?> fileObjectDecorator) throws FileSystemException - { - if (init) - { + public void setFileObjectDecorator(final Class<?> fileObjectDecorator) throws FileSystemException { + if (init) { throw new FileSystemException("vfs.impl/already-inited.error"); } - if (!DecoratedFileObject.class.isAssignableFrom(fileObjectDecorator)) - { + if (!DecoratedFileObject.class.isAssignableFrom(fileObjectDecorator)) { throw new FileSystemException("vfs.impl/invalid-decorator.error", fileObjectDecorator.getName()); } - try - { - fileObjectDecoratorConst = fileObjectDecorator.getConstructor(new Class[]{FileObject.class}); - } - catch (final NoSuchMethodException e) - { + try { + fileObjectDecoratorConst = fileObjectDecorator.getConstructor(new Class[] { FileObject.class }); + } catch (final NoSuchMethodException e) { throw new FileSystemException("vfs.impl/invalid-decorator.error", fileObjectDecorator.getName(), e); } @@ -390,19 +350,17 @@ public class DefaultFileSystemManager im } /** - * get the fileContentInfoFactory used to determine the infos of a file - * content. + * get the fileContentInfoFactory used to determine the infos of a file content. + * * @return The FileContentInfoFactory. */ @Override - public FileContentInfoFactory getFileContentInfoFactory() - { + public FileContentInfoFactory getFileContentInfoFactory() { return fileContentInfoFactory; } /** - * set the fileContentInfoFactory used to determine the infos of a file - * content. + * set the fileContentInfoFactory used to determine the infos of a file content. * <p> * Can only be set before the FileSystemManager is initialized. * @@ -410,10 +368,8 @@ public class DefaultFileSystemManager im * @throws FileSystemException if an error occurs setting the FileContentInfoFactory. */ public void setFileContentInfoFactory(final FileContentInfoFactory fileContentInfoFactory) - throws FileSystemException - { - if (init) - { + throws FileSystemException { + if (init) { throw new FileSystemException("vfs.impl/already-inited.error"); } @@ -428,9 +384,7 @@ public class DefaultFileSystemManager im * @param replicator The FileReplicator. * @throws FileSystemException if an error occurs setting the replicator. */ - public void setReplicator(final FileReplicator replicator) - throws FileSystemException - { + public void setReplicator(final FileReplicator replicator) throws FileSystemException { setupComponent(replicator); fileReplicator = replicator; } @@ -443,9 +397,7 @@ public class DefaultFileSystemManager im * @param tempFileStore The temporary FileStore. * @throws FileSystemException if an error occurs adding the file store. */ - public void setTemporaryFileStore(final TemporaryFileStore tempFileStore) - throws FileSystemException - { + public void setTemporaryFileStore(final TemporaryFileStore tempFileStore) throws FileSystemException { setupComponent(tempFileStore); this.tempFileStore = tempFileStore; } @@ -458,8 +410,7 @@ public class DefaultFileSystemManager im * @param log The Logger to use. */ @Override - public void setLogger(final Log log) - { + public void setLogger(final Log log) { this.log = log; } @@ -469,13 +420,9 @@ public class DefaultFileSystemManager im * @param component The component to setup. * @throws FileSystemException if an error occurs. */ - private void setupComponent(final Object component) - throws FileSystemException - { - if (!components.contains(component)) - { - if (component instanceof VfsComponent) - { + private void setupComponent(final Object component) throws FileSystemException { + if (!components.contains(component)) { + if (component instanceof VfsComponent) { final VfsComponent vfsComponent = (VfsComponent) component; vfsComponent.setLogger(getLogger()); vfsComponent.setContext(context); @@ -490,12 +437,9 @@ public class DefaultFileSystemManager im * * @param component The component to close. */ - private void closeComponent(final Object component) - { - if (component != null && components.contains(component)) - { - if (component instanceof VfsComponent) - { + private void closeComponent(final Object component) { + if (component != null && components.contains(component)) { + if (component instanceof VfsComponent) { final VfsComponent vfsComponent = (VfsComponent) component; vfsComponent.close(); } @@ -509,10 +453,8 @@ public class DefaultFileSystemManager im * @return The file replicator. Never returns null. * @throws FileSystemException if there is no FileReplicator. */ - public FileReplicator getReplicator() throws FileSystemException - { - if (fileReplicator == null) - { + public FileReplicator getReplicator() throws FileSystemException { + if (fileReplicator == null) { throw new FileSystemException("vfs.impl/no-replicator.error"); } return fileReplicator; @@ -524,11 +466,8 @@ public class DefaultFileSystemManager im * @return The file store. Never returns null. * @throws FileSystemException if there is no TemporaryFileStore. */ - public TemporaryFileStore getTemporaryFileStore() - throws FileSystemException - { - if (tempFileStore == null) - { + public TemporaryFileStore getTemporaryFileStore() throws FileSystemException { + if (tempFileStore == null) { throw new FileSystemException("vfs.impl/no-temp-file-store.error"); } return tempFileStore; @@ -537,8 +476,7 @@ public class DefaultFileSystemManager im /** * Initializes this manager. * <p> - * If no value for the following properties was specified, it will - * use the following defaults: + * If no value for the following properties was specified, it will use the following defaults: * <ul> * <li>fileContentInfoFactory = new FileContentInfoFilenameFactory()</li> * <li>filesCache = new SoftRefFilesCache()</li> @@ -547,20 +485,16 @@ public class DefaultFileSystemManager im * * @throws FileSystemException if an error occurs during initialization. */ - public void init() throws FileSystemException - { - if (fileContentInfoFactory == null) - { + public void init() throws FileSystemException { + if (fileContentInfoFactory == null) { fileContentInfoFactory = new FileContentInfoFilenameFactory(); } - if (filesCache == null) - { + if (filesCache == null) { // filesCache = new DefaultFilesCache(); filesCache = new SoftRefFilesCache(); } - if (fileCacheStrategy == null) - { + if (fileCacheStrategy == null) { fileCacheStrategy = CacheStrategy.ON_RESOLVE; } setupComponent(filesCache); @@ -574,16 +508,13 @@ public class DefaultFileSystemManager im /** * Closes the manager. * <p> - * This will close all providers (all files), it will also close - * all managed components including temporary files, replicator, - * file cache and file operations. + * This will close all providers (all files), it will also close all managed components including temporary files, + * replicator, file cache and file operations. * <p> * The manager is in uninitialized state after this method. */ - public void close() - { - if (!init) - { + public void close() { + if (!init) { return; } @@ -592,8 +523,7 @@ public class DefaultFileSystemManager im // are closed here // Close the file system providers. - for (final FileProvider provider : providers.values()) - { + for (final FileProvider provider : providers.values()) { closeComponent(provider); } // unregister all @@ -607,10 +537,8 @@ public class DefaultFileSystemManager im closeComponent(defaultProvider); // FileOperations are components, too - for (final List<FileOperationProvider> opproviders : operationProviders.values()) - { - for (final FileOperationProvider p : opproviders) - { + for (final List<FileOperationProvider> opproviders : operationProviders.values()) { + for (final FileOperationProvider p : opproviders) { closeComponent(p); } } @@ -621,8 +549,7 @@ public class DefaultFileSystemManager im typeMap.clear(); // should not happen, but make debugging easier: - if (!components.isEmpty()) - { + if (!components.isEmpty()) { log.warn("DefaultFilesystemManager.close: not all components are closed: " + components.toString()); } components.clear(); @@ -649,16 +576,13 @@ public class DefaultFileSystemManager im /** * Free all resources used by unused filesystems created by this manager. */ - public void freeUnusedResources() - { - if (!init) - { + public void freeUnusedResources() { + if (!init) { return; } // Close the providers. - for (final FileProvider fileProvider : providers.values()) - { + for (final FileProvider fileProvider : providers.values()) { final AbstractFileProvider provider = (AbstractFileProvider) fileProvider; provider.freeUnusedResources(); } @@ -667,50 +591,50 @@ public class DefaultFileSystemManager im /** * Sets the base file to use when resolving relative URI. + * * @param baseFile The new base FileObject. * @throws FileSystemException if an error occurs. */ - public void setBaseFile(final FileObject baseFile) - throws FileSystemException - { + public void setBaseFile(final FileObject baseFile) throws FileSystemException { this.baseFile = baseFile; } /** * Sets the base file to use when resolving relative URI. + * * @param baseFile The new base FileObject. * @throws FileSystemException if an error occurs. */ - public void setBaseFile(final File baseFile) throws FileSystemException - { + public void setBaseFile(final File baseFile) throws FileSystemException { this.baseFile = getLocalFileProvider().findLocalFile(baseFile); } /** * Returns the base file used to resolve relative URI. + * * @return The FileObject that represents the base file. * @throws FileSystemException if an error occurs. */ @Override - public FileObject getBaseFile() throws FileSystemException - { + public FileObject getBaseFile() throws FileSystemException { return baseFile; } /** * Locates a file by URI. + * * @param uri The URI of the file to locate. * @return The FileObject for the located file. * @throws FileSystemException if the file cannot be located or an error occurs. */ @Override - public FileObject resolveFile(final String uri) throws FileSystemException - { + public FileObject resolveFile(final String uri) throws FileSystemException { return resolveFile(getBaseFile(), uri); } /** * Locate a file by URI, use the FileSystemOptions for file-system creation. + * * @param uri The URI of the file to locate. * @param fileSystemOptions The options for the FileSystem. * @return The FileObject for the located file. @@ -718,10 +642,8 @@ public class DefaultFileSystemManager im */ @Override - public FileObject resolveFile(final String uri, - final FileSystemOptions fileSystemOptions) - throws FileSystemException - { + public FileObject resolveFile(final String uri, final FileSystemOptions fileSystemOptions) + throws FileSystemException { // return resolveFile(baseFile, uri, fileSystemOptions); return resolveFile(getBaseFile(), uri, fileSystemOptions); } @@ -729,8 +651,7 @@ public class DefaultFileSystemManager im /** * Resolves a URI, relative to base file. * <p> - * Uses the {@linkplain #getLocalFileProvider() local file provider} to - * locate the system file. + * Uses the {@linkplain #getLocalFileProvider() local file provider} to locate the system file. * * @param baseFile The base File to use to locate the file. * @param uri The URI of the file to locate. @@ -738,32 +659,27 @@ public class DefaultFileSystemManager im * @throws FileSystemException if the file cannot be located or an error occurs. */ @Override - public FileObject resolveFile(final File baseFile, final String uri) - throws FileSystemException - { - final FileObject baseFileObj = getLocalFileProvider().findLocalFile( - baseFile); + public FileObject resolveFile(final File baseFile, final String uri) throws FileSystemException { + final FileObject baseFileObj = getLocalFileProvider().findLocalFile(baseFile); return resolveFile(baseFileObj, uri); } /** * Resolves a URI, relative to a base file. + * * @param baseFile The base FileOjbect to use to locate the file. * @param uri The URI of the file to locate. * @return The FileObject for the located file. * @throws FileSystemException if the file cannot be located or an error occurs. */ @Override - public FileObject resolveFile(final FileObject baseFile, final String uri) - throws FileSystemException - { - return resolveFile(baseFile, uri, baseFile == null ? null : baseFile - .getFileSystem().getFileSystemOptions()); + public FileObject resolveFile(final FileObject baseFile, final String uri) throws FileSystemException { + return resolveFile(baseFile, uri, baseFile == null ? null : baseFile.getFileSystem().getFileSystemOptions()); } /** - * Resolves a URI, relative to a base file with specified FileSystem - * configuration. + * Resolves a URI, relative to a base file with specified FileSystem configuration. + * * @param baseFile The base file. * @param uri The file name. May be a fully qualified or relative path or a url. * @param fileSystemOptions Options to pass to the file system. @@ -771,61 +687,47 @@ public class DefaultFileSystemManager im * @throws FileSystemException if an error occurs accessing the file. */ public FileObject resolveFile(final FileObject baseFile, final String uri, - final FileSystemOptions fileSystemOptions) - throws FileSystemException - { + final FileSystemOptions fileSystemOptions) throws FileSystemException { final FileObject realBaseFile; - if (baseFile != null && VFS.isUriStyle() - && baseFile.getName().isFile()) - { + if (baseFile != null && VFS.isUriStyle() && baseFile.getName().isFile()) { realBaseFile = baseFile.getParent(); - } - else - { + } else { realBaseFile = baseFile; } // TODO: use resolveName and use this name to resolve the fileObject UriParser.checkUriEncoding(uri); - if (uri == null) - { + if (uri == null) { throw new IllegalArgumentException(); } // Extract the scheme final String scheme = UriParser.extractScheme(uri); - if (scheme != null) - { + if (scheme != null) { // An absolute URI - locate the provider final FileProvider provider = providers.get(scheme); - if (provider != null) - { + if (provider != null) { return provider.findFile(realBaseFile, uri, fileSystemOptions); } // Otherwise, assume a local file } // Handle absolute file names - if (localFileProvider != null - && localFileProvider.isAbsoluteLocalName(uri)) - { + if (localFileProvider != null && localFileProvider.isAbsoluteLocalName(uri)) { return localFileProvider.findLocalFile(uri); } - if (scheme != null) - { + if (scheme != null) { // An unknown scheme - hand it to the default provider - if (defaultProvider == null) - { + if (defaultProvider == null) { throw new FileSystemException("vfs.impl/unknown-scheme.error", scheme, uri); } return defaultProvider.findFile(realBaseFile, uri, fileSystemOptions); } // Assume a relative name - use the supplied base file - if (realBaseFile == null) - { + if (realBaseFile == null) { throw new FileSystemException("vfs.impl/find-rel-file.error", uri); } @@ -833,19 +735,17 @@ public class DefaultFileSystemManager im } /** - * Resolves a name, relative to the file. If the supplied name is an - * absolute path, then it is resolved relative to the root of the file - * system that the file belongs to. If a relative name is supplied, then it - * is resolved relative to this file name. + * Resolves a name, relative to the file. If the supplied name is an absolute path, then it is resolved relative to + * the root of the file system that the file belongs to. If a relative name is supplied, then it is resolved + * relative to this file name. + * * @param root The base FileName. * @param path The path to the file relative to the base FileName or an absolute path. * @return The constructed FileName. * @throws FileSystemException if an error occurs constructing the FileName. */ @Override - public FileName resolveName(final FileName root, final String path) - throws FileSystemException - { + public FileName resolveName(final FileName root, final String path) throws FileSystemException { return resolveName(root, path, NameScope.FILE_SYSTEM); } @@ -859,19 +759,15 @@ public class DefaultFileSystemManager im * @throws FileSystemException if an error occurs. */ @Override - public FileName resolveName(final FileName base, final String name, - final NameScope scope) throws FileSystemException - { + public FileName resolveName(final FileName base, final String name, final NameScope scope) + throws FileSystemException { if (base == null) { throw new FileSystemException("Invalid base filename."); } final FileName realBase; - if (VFS.isUriStyle() && base.isFile()) - { + if (VFS.isUriStyle() && base.isFile()) { realBase = base.getParent(); - } - else - { + } else { realBase = base; } @@ -882,11 +778,9 @@ public class DefaultFileSystemManager im String scheme = UriParser.extractScheme(buffer.toString()); // Determine whether to prepend the base path - if (name.length() == 0 || (scheme == null && buffer.charAt(0) != FileName.SEPARATOR_CHAR)) - { + if (name.length() == 0 || (scheme == null && buffer.charAt(0) != FileName.SEPARATOR_CHAR)) { // Supplied path is not absolute - if (!VFS.isUriStyle()) - { + if (!VFS.isUriStyle()) { // when using uris the parent already do have the trailing "/" buffer.insert(0, FileName.SEPARATOR_CHAR); } @@ -898,26 +792,19 @@ public class DefaultFileSystemManager im // Check the name is ok final String resolvedPath = buffer.toString(); - if (!AbstractFileName - .checkName(realBase.getPath(), resolvedPath, scope)) - { - throw new FileSystemException( - "vfs.provider/invalid-descendent-name.error", name); + if (!AbstractFileName.checkName(realBase.getPath(), resolvedPath, scope)) { + throw new FileSystemException("vfs.provider/invalid-descendent-name.error", name); } String fullPath; - if (scheme != null) - { + if (scheme != null) { fullPath = resolvedPath; - } - else - { + } else { scheme = realBase.getScheme(); fullPath = realBase.getRootURI() + resolvedPath; } final FileProvider provider = providers.get(scheme); - if (provider != null) - { + if (provider != null) { // TODO: extend the filename parser to be able to parse // only a pathname and take the missing informations from // the base. Then we can get rid of the string operation. @@ -928,8 +815,7 @@ public class DefaultFileSystemManager im } // An unknown scheme - hand it to the default provider - if possible - if (scheme != null && defaultProvider != null) - { + if (scheme != null && defaultProvider != null) { return defaultProvider.parseUri(realBase, fullPath); } @@ -940,28 +826,25 @@ public class DefaultFileSystemManager im /** * Resolve the uri to a filename. + * * @param uri The URI to resolve. * @return The FileName of the file. * @throws FileSystemException if an error occurs. */ @Override - public FileName resolveURI(final String uri) throws FileSystemException - { + public FileName resolveURI(final String uri) throws FileSystemException { UriParser.checkUriEncoding(uri); - if (uri == null) - { + if (uri == null) { throw new IllegalArgumentException(); } // Extract the scheme final String scheme = UriParser.extractScheme(uri); - if (scheme != null) - { + if (scheme != null) { // An absolute URI - locate the provider final FileProvider provider = providers.get(scheme); - if (provider != null) - { + if (provider != null) { return provider.parseUri(null, uri); } @@ -969,25 +852,20 @@ public class DefaultFileSystemManager im } // Handle absolute file names - if (localFileProvider != null - && localFileProvider.isAbsoluteLocalName(uri)) - { + if (localFileProvider != null && localFileProvider.isAbsoluteLocalName(uri)) { return localFileProvider.parseUri(null, uri); } - if (scheme != null) - { + if (scheme != null) { // An unknown scheme - hand it to the default provider - if (defaultProvider == null) - { + if (defaultProvider == null) { throw new FileSystemException("vfs.impl/unknown-scheme.error", scheme, uri); } return defaultProvider.parseUri(null, uri); } // Assume a relative name - use the supplied base file - if (baseFile == null) - { + if (baseFile == null) { throw new FileSystemException("vfs.impl/find-rel-file.error", uri); } @@ -996,30 +874,28 @@ public class DefaultFileSystemManager im /** * Converts a local file into a {@link FileObject}. + * * @param file The input File. * @return the create FileObject * @throws FileSystemException if an error occurs creating the file. */ @Override - public FileObject toFileObject(final File file) throws FileSystemException - { + public FileObject toFileObject(final File file) throws FileSystemException { return getLocalFileProvider().findLocalFile(file); } /** * Creates a layered file system. + * * @param scheme The scheme to use. * @param file The FileObject. * @return The layered FileObject. * @throws FileSystemException if an error occurs. */ @Override - public FileObject createFileSystem(final String scheme, - final FileObject file) throws FileSystemException - { + public FileObject createFileSystem(final String scheme, final FileObject file) throws FileSystemException { final FileProvider provider = providers.get(scheme); - if (provider == null) - { + if (provider == null) { throw new FileSystemException("vfs.impl/unknown-provider.error", scheme, file); } return provider.createFileSystem(scheme, file, file.getFileSystem().getFileSystemOptions()); @@ -1027,19 +903,16 @@ public class DefaultFileSystemManager im /** * Creates a layered file system. + * * @param file The FileObject to use. * @return The layered FileObject. * @throws FileSystemException if an error occurs. */ @Override - public FileObject createFileSystem(final FileObject file) - throws FileSystemException - { + public FileObject createFileSystem(final FileObject file) throws FileSystemException { final String scheme = typeMap.getScheme(file); - if (scheme == null) - { - throw new FileSystemException( - "vfs.impl/no-provider-for-file.error", file); + if (scheme == null) { + throw new FileSystemException("vfs.impl/no-provider-for-file.error", file); } return createFileSystem(scheme, file); @@ -1053,65 +926,57 @@ public class DefaultFileSystemManager im * @throws FileSystemException if an error occurs. */ @Override - public boolean canCreateFileSystem(final FileObject file) - throws FileSystemException - { + public boolean canCreateFileSystem(final FileObject file) throws FileSystemException { return typeMap.getScheme(file) != null; } /** * Creates a virtual file system. + * * @param rootFile The FileObject to use. * @return The FileObject in the VirtualFileSystem. * @throws FileSystemException if an error occurs creating the file. */ @Override - public FileObject createVirtualFileSystem(final FileObject rootFile) - throws FileSystemException - { + public FileObject createVirtualFileSystem(final FileObject rootFile) throws FileSystemException { return vfsProvider.createFileSystem(rootFile); } /** * Creates an empty virtual file system. + * * @param rootUri The URI to use as the root of the FileSystem. * @return A FileObject in the virtual FileSystem. * @throws FileSystemException if an error occurs. */ @Override - public FileObject createVirtualFileSystem(final String rootUri) - throws FileSystemException - { + public FileObject createVirtualFileSystem(final String rootUri) throws FileSystemException { return vfsProvider.createFileSystem(rootUri); } /** * Locates the local file provider. * <p> - * The local file provider is the first - * {@linkplain #addProvider(String[], FileProvider) provider added} + * The local file provider is the first {@linkplain #addProvider(String[], FileProvider) provider added} * implementing {@link LocalFileProvider}. * * @return The LocalFileProvider. * @throws FileSystemException if no local file provider was set. */ - private LocalFileProvider getLocalFileProvider() throws FileSystemException - { - if (localFileProvider == null) - { - throw new FileSystemException( - "vfs.impl/no-local-file-provider.error"); + private LocalFileProvider getLocalFileProvider() throws FileSystemException { + if (localFileProvider == null) { + throw new FileSystemException("vfs.impl/no-local-file-provider.error"); } return localFileProvider; } /** * Get the URLStreamHandlerFactory. + * * @return The URLStreamHandlerFactory. */ @Override - public URLStreamHandlerFactory getURLStreamHandlerFactory() - { + public URLStreamHandlerFactory getURLStreamHandlerFactory() { return new VfsStreamHandlerFactory(); } @@ -1123,8 +988,7 @@ public class DefaultFileSystemManager im * @param filesystem The FileSystem to close. */ @Override - public void closeFileSystem(final FileSystem filesystem) - { + public void closeFileSystem(final FileSystem filesystem) { // inform the cache ... getFilesCache().clear(filesystem); @@ -1140,32 +1004,24 @@ public class DefaultFileSystemManager im * * @param filesystem The FileSystem to close. */ - public void _closeFileSystem(final FileSystem filesystem) - { + public void _closeFileSystem(final FileSystem filesystem) { final FileProvider provider = providers.get(filesystem.getRootName().getScheme()); - if (provider != null) - { + if (provider != null) { ((AbstractFileProvider) provider).closeFileSystem(filesystem); - } - else if (filesystem instanceof VirtualFileSystem) - { + } else if (filesystem instanceof VirtualFileSystem) { // vfsProvider does not implement AbstractFileProvider vfsProvider.closeFileSystem(filesystem); } } /** - * This is an internal class because it needs access to the private member - * providers. + * This is an internal class because it needs access to the private member providers. */ - final class VfsStreamHandlerFactory implements URLStreamHandlerFactory - { + final class VfsStreamHandlerFactory implements URLStreamHandlerFactory { @Override - public URLStreamHandler createURLStreamHandler(final String protocol) - { + public URLStreamHandler createURLStreamHandler(final String protocol) { final FileProvider provider = providers.get(protocol); - if (provider != null) - { + if (provider != null) { return new DefaultURLStreamHandler(context); } @@ -1176,11 +1032,11 @@ public class DefaultFileSystemManager im /** * Get the schemes currently available. + * * @return The array of scheme names. */ @Override - public String[] getSchemes() - { + public String[] getSchemes() { final String[] schemes = new String[providers.size()]; providers.keySet().toArray(schemes); return schemes; @@ -1194,12 +1050,9 @@ public class DefaultFileSystemManager im * @throws FileSystemException if the given scheme is not konwn */ @Override - public Collection<Capability> getProviderCapabilities(final String scheme) - throws FileSystemException - { + public Collection<Capability> getProviderCapabilities(final String scheme) throws FileSystemException { final FileProvider provider = providers.get(scheme); - if (provider == null) - { + if (provider == null) { throw new FileSystemException("vfs.impl/unknown-scheme.error", scheme); } @@ -1208,17 +1061,15 @@ public class DefaultFileSystemManager im /** * Get the configuration builder for the given scheme. + * * @param scheme The scheme to locate. * @return The FileSystemConfigBuilder for the scheme. * @throws FileSystemException if the given scheme is not konwn */ @Override - public FileSystemConfigBuilder getFileSystemConfigBuilder(final String scheme) - throws FileSystemException - { + public FileSystemConfigBuilder getFileSystemConfigBuilder(final String scheme) throws FileSystemException { final FileProvider provider = providers.get(scheme); - if (provider == null) - { + if (provider == null) { throw new FileSystemException("vfs.impl/unknown-scheme.error", scheme); } @@ -1228,9 +1079,8 @@ public class DefaultFileSystemManager im // -- OPERATIONS -- /** - * Adds the specified FileOperationProvider for the specified scheme. - * Several FileOperationProvider's might be registered for the same scheme. - * For example, for "file" scheme we can register SvnWsOperationProvider and + * Adds the specified FileOperationProvider for the specified scheme. Several FileOperationProvider's might be + * registered for the same scheme. For example, for "file" scheme we can register SvnWsOperationProvider and * CvsOperationProvider. * * @param scheme The scheme the provider should be registered for. @@ -1238,40 +1088,31 @@ public class DefaultFileSystemManager im * @throws FileSystemException if an error occurs adding the provider. */ @Override - public void addOperationProvider(final String scheme, - final FileOperationProvider operationProvider) - throws FileSystemException - { - addOperationProvider(new String[] {scheme}, operationProvider); + public void addOperationProvider(final String scheme, final FileOperationProvider operationProvider) + throws FileSystemException { + addOperationProvider(new String[] { scheme }, operationProvider); } /** - * @see FileSystemManager#addOperationProvider(String, - * org.apache.commons.vfs2.operations.FileOperationProvider) + * @see FileSystemManager#addOperationProvider(String, org.apache.commons.vfs2.operations.FileOperationProvider) * * @param schemes The array of schemes the provider should apply to. * @param operationProvider The FileOperationProvider. * @throws FileSystemException if an error occurs. */ @Override - public void addOperationProvider(final String[] schemes, - final FileOperationProvider operationProvider) - throws FileSystemException - { - for (final String scheme : schemes) - { - if (!operationProviders.containsKey(scheme)) - { + public void addOperationProvider(final String[] schemes, final FileOperationProvider operationProvider) + throws FileSystemException { + for (final String scheme : schemes) { + if (!operationProviders.containsKey(scheme)) { final List<FileOperationProvider> providers = new ArrayList<>(); operationProviders.put(scheme, providers); } final List<FileOperationProvider> providers = operationProviders.get(scheme); - if (providers.contains(operationProvider)) - { - throw new FileSystemException( - "vfs.operation/operation-provider-already-added.error", scheme); + if (providers.contains(operationProvider)) { + throw new FileSystemException("vfs.operation/operation-provider-already-added.error", scheme); } setupComponent(operationProvider); @@ -1281,24 +1122,18 @@ public class DefaultFileSystemManager im } /** - * @param scheme - * the scheme for wich we want to get the list af registered - * providers. - * - * @return the registered FileOperationProviders for the specified scheme. - * If there were no providers registered for the scheme, it returns - * null. + * @param scheme the scheme for wich we want to get the list af registered providers. + * + * @return the registered FileOperationProviders for the specified scheme. If there were no providers registered for + * the scheme, it returns null. * * @throws FileSystemException if an error occurs. */ @Override - public FileOperationProvider[] getOperationProviders(final String scheme) - throws FileSystemException - { + public FileOperationProvider[] getOperationProviders(final String scheme) throws FileSystemException { final List<?> providers = operationProviders.get(scheme); - if (providers == null || providers.size() == 0) - { + if (providers == null || providers.size() == 0) { return null; } return providers.toArray(new FileOperationProvider[] {}); @@ -1308,14 +1143,12 @@ public class DefaultFileSystemManager im * Converts a URI into a {@link FileObject}. * * @param uri The URI to convert. - * @return The {@link FileObject} that represents the URI. Never - * returns null. + * @return The {@link FileObject} that represents the URI. Never returns null. * @throws FileSystemException On error converting the URI. * @since 2.1 */ @Override - public FileObject resolveFile(final URI uri) throws FileSystemException - { + public FileObject resolveFile(final URI uri) throws FileSystemException { // TODO Push the URI deeper into VFS return resolveFile(baseFile, uri.toString(), null); } @@ -1324,20 +1157,15 @@ public class DefaultFileSystemManager im * Converts a URL into a {@link FileObject}. * * @param url The URL to convert. - * @return The {@link FileObject} that represents the URL. Never - * returns null. + * @return The {@link FileObject} that represents the URL. Never returns null. * @throws FileSystemException On error converting the URL. * @since 2.1 */ @Override - public FileObject resolveFile(final URL url) throws FileSystemException - { - try - { + public FileObject resolveFile(final URL url) throws FileSystemException { + try { return this.resolveFile(url.toURI()); - } - catch (final URISyntaxException e) - { + } catch (final URISyntaxException e) { throw new FileSystemException(e); } }
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultProviderConfiguration.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultProviderConfiguration.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultProviderConfiguration.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultProviderConfiguration.java Thu Sep 14 19:26:39 2017 @@ -16,15 +16,12 @@ */ package org.apache.commons.vfs2.impl; - /** * Same as {@link ProviderConfiguration} but for the default provider. */ -public class DefaultProviderConfiguration extends ProviderConfiguration -{ +public class DefaultProviderConfiguration extends ProviderConfiguration { @Override - public boolean isDefault() - { + public boolean isDefault() { return true; } } Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultVfsComponentContext.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultVfsComponentContext.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultVfsComponentContext.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultVfsComponentContext.java Thu Sep 14 19:26:39 2017 @@ -27,17 +27,13 @@ import org.apache.commons.vfs2.provider. import org.apache.commons.vfs2.provider.TemporaryFileStore; import org.apache.commons.vfs2.provider.VfsComponentContext; - /** * The default context implementation. */ -final class DefaultVfsComponentContext - implements VfsComponentContext -{ +final class DefaultVfsComponentContext implements VfsComponentContext { private final DefaultFileSystemManager manager; - public DefaultVfsComponentContext(final DefaultFileSystemManager manager) - { + public DefaultVfsComponentContext(final DefaultFileSystemManager manager) { this.manager = manager; } @@ -46,9 +42,7 @@ final class DefaultVfsComponentContext */ @Override public FileObject resolveFile(final FileObject baseFile, final String name, - final FileSystemOptions fileSystemOptions) - throws FileSystemException - { + final FileSystemOptions fileSystemOptions) throws FileSystemException { return manager.resolveFile(baseFile, name, fileSystemOptions); } @@ -57,14 +51,12 @@ final class DefaultVfsComponentContext */ @Override public FileObject resolveFile(final String name, final FileSystemOptions fileSystemOptions) - throws FileSystemException - { + throws FileSystemException { return manager.resolveFile(name, fileSystemOptions); } @Override - public FileName parseURI(final String uri) throws FileSystemException - { + public FileName parseURI(final String uri) throws FileSystemException { return manager.resolveURI(uri); } @@ -72,9 +64,7 @@ final class DefaultVfsComponentContext * Returns a {@link FileObject} for a local file. */ @Override - public FileObject toFileObject(final File file) - throws FileSystemException - { + public FileObject toFileObject(final File file) throws FileSystemException { return manager.toFileObject(file); } @@ -82,8 +72,7 @@ final class DefaultVfsComponentContext * Locates a file replicator for the provider to use. */ @Override - public FileReplicator getReplicator() throws FileSystemException - { + public FileReplicator getReplicator() throws FileSystemException { return manager.getReplicator(); } @@ -91,8 +80,7 @@ final class DefaultVfsComponentContext * Locates a temporary file store for the provider to use. */ @Override - public TemporaryFileStore getTemporaryFileStore() throws FileSystemException - { + public TemporaryFileStore getTemporaryFileStore() throws FileSystemException { return manager.getTemporaryFileStore(); } @@ -102,8 +90,7 @@ final class DefaultVfsComponentContext * @return the filesystem manager */ @Override - public FileSystemManager getFileSystemManager() - { + public FileSystemManager getFileSystemManager() { return manager; } } Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/FileContentInfoFilenameFactory.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/FileContentInfoFilenameFactory.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/FileContentInfoFilenameFactory.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/FileContentInfoFilenameFactory.java Thu Sep 14 19:26:39 2017 @@ -26,19 +26,15 @@ import org.apache.commons.vfs2.FileConte /** * The FileContentInfoFilenameFactory. * <p> - * Uses the filename extension to determine the content-type. - * The content-encoding is not resolved. + * Uses the filename extension to determine the content-type. The content-encoding is not resolved. */ -public class FileContentInfoFilenameFactory implements FileContentInfoFactory -{ +public class FileContentInfoFilenameFactory implements FileContentInfoFactory { @Override - public FileContentInfo create(final FileContent fileContent) - { + public FileContentInfo create(final FileContent fileContent) { String contentType = null; final String name = fileContent.getFile().getName().getBaseName(); - if (name != null) - { + if (name != null) { final FileNameMap fileNameMap = URLConnection.getFileNameMap(); contentType = fileNameMap.getContentTypeFor(name); } Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/FileTypeMap.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/FileTypeMap.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/FileTypeMap.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/FileTypeMap.java Thu Sep 14 19:26:39 2017 @@ -26,24 +26,21 @@ import org.apache.commons.vfs2.FileSyste /** * A helper class that determines the provider to use for a file. */ -class FileTypeMap -{ +class FileTypeMap { private final Map<String, String> mimeTypeMap = new HashMap<>(); private final Map<String, String> extensionMap = new HashMap<>(); /** * Adds a MIME type mapping. */ - public void addMimeType(final String mimeType, final String scheme) - { + public void addMimeType(final String mimeType, final String scheme) { mimeTypeMap.put(mimeType, scheme); } /** * Adds a filename extension mapping. */ - public void addExtension(final String extension, final String scheme) - { + public void addExtension(final String extension, final String scheme) { extensionMap.put(extension, scheme); } @@ -51,21 +48,19 @@ class FileTypeMap * Find the scheme for the provider of a layered file system. * <p> * This will check the FileContentInfo or file extension. + * * @return Scheme supporting the file type or null (if unknonw). */ - public String getScheme(final FileObject file) throws FileSystemException - { + public String getScheme(final FileObject file) throws FileSystemException { // Check the file's mime type for a match final FileContent content = file.getContent(); final String mimeType = content.getContentInfo().getContentType(); - if (mimeType != null) - { + if (mimeType != null) { return mimeTypeMap.get(mimeType); } // no specific mime-type - if it is a file also check the extension - if (!file.isFile()) - { + if (!file.isFile()) { return null; // VFS-490 folders don't use extensions for mime-type } final String extension = file.getName().getExtension(); @@ -75,8 +70,7 @@ class FileTypeMap /** * Removes all extensions and scheme mappings. */ - public void clear() - { + public void clear() { mimeTypeMap.clear(); extensionMap.clear(); } Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/PrivilegedFileReplicator.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/PrivilegedFileReplicator.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/PrivilegedFileReplicator.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/PrivilegedFileReplicator.java Thu Sep 14 19:26:39 2017 @@ -31,24 +31,17 @@ import org.apache.commons.vfs2.provider. import org.apache.commons.vfs2.provider.VfsComponentContext; /** - * A file replicator that wraps another file replicator, performing - * the replication as a privileged action. + * A file replicator that wraps another file replicator, performing the replication as a privileged action. */ -public class PrivilegedFileReplicator - implements FileReplicator, VfsComponent -{ +public class PrivilegedFileReplicator implements FileReplicator, VfsComponent { private final FileReplicator replicator; private final VfsComponent replicatorComponent; - public PrivilegedFileReplicator(final FileReplicator replicator) - { + public PrivilegedFileReplicator(final FileReplicator replicator) { this.replicator = replicator; - if (replicator instanceof VfsComponent) - { + if (replicator instanceof VfsComponent) { replicatorComponent = (VfsComponent) replicator; - } - else - { + } else { replicatorComponent = null; } } @@ -59,10 +52,8 @@ public class PrivilegedFileReplicator * @param logger The logger. */ @Override - public void setLogger(final Log logger) - { - if (replicatorComponent != null) - { + public void setLogger(final Log logger) { + if (replicatorComponent != null) { replicatorComponent.setLogger(logger); } } @@ -73,10 +64,8 @@ public class PrivilegedFileReplicator * @param context The component context. */ @Override - public void setContext(final VfsComponentContext context) - { - if (replicatorComponent != null) - { + public void setContext(final VfsComponentContext context) { + if (replicatorComponent != null) { replicatorComponent.setContext(context); } } @@ -87,16 +76,11 @@ public class PrivilegedFileReplicator * @throws FileSystemException if an error occurs. */ @Override - public void init() throws FileSystemException - { - if (replicatorComponent != null) - { - try - { + public void init() throws FileSystemException { + if (replicatorComponent != null) { + try { AccessController.doPrivileged(new InitAction()); - } - catch (final PrivilegedActionException e) - { + } catch (final PrivilegedActionException e) { throw new FileSystemException("vfs.impl/init-replicator.error", e); } } @@ -106,10 +90,8 @@ public class PrivilegedFileReplicator * Closes the replicator. */ @Override - public void close() - { - if (replicatorComponent != null) - { + public void close() { + if (replicatorComponent != null) { AccessController.doPrivileged(new CloseAction()); } } @@ -123,16 +105,11 @@ public class PrivilegedFileReplicator * @throws FileSystemException if an error occurs. */ @Override - public File replicateFile(final FileObject srcFile, final FileSelector selector) - throws FileSystemException - { - try - { + public File replicateFile(final FileObject srcFile, final FileSelector selector) throws FileSystemException { + try { final ReplicateAction action = new ReplicateAction(srcFile, selector); return AccessController.doPrivileged(action); - } - catch (final PrivilegedActionException e) - { + } catch (final PrivilegedActionException e) { throw new FileSystemException("vfs.impl/replicate-file.error", e, srcFile.getName()); } } @@ -140,14 +117,12 @@ public class PrivilegedFileReplicator /** * An action that initialises the wrapped replicator. */ - private class InitAction implements PrivilegedExceptionAction<Object> - { + private class InitAction implements PrivilegedExceptionAction<Object> { /** * Performs the action. */ @Override - public Object run() throws Exception - { + public Object run() throws Exception { replicatorComponent.init(); return null; } @@ -156,26 +131,23 @@ public class PrivilegedFileReplicator /** * An action that replicates a file using the wrapped replicator. */ - private class ReplicateAction implements PrivilegedExceptionAction<File> - { + private class ReplicateAction implements PrivilegedExceptionAction<File> { private final FileObject srcFile; private final FileSelector selector; - public ReplicateAction(final FileObject srcFile, - final FileSelector selector) - { + public ReplicateAction(final FileObject srcFile, final FileSelector selector) { this.srcFile = srcFile; this.selector = selector; } /** * Performs the action. + * * @throws Exception if an error occurs. */ @Override - public File run() throws Exception - { - // TODO - Do not pass the selector through. It is untrusted + public File run() throws Exception { + // TODO - Do not pass the selector through. It is untrusted // TODO - Need to determine which files can be read return replicator.replicateFile(srcFile, selector); } @@ -184,14 +156,12 @@ public class PrivilegedFileReplicator /** * An action that closes the wrapped replicator. */ - private class CloseAction implements PrivilegedAction<Object> - { + private class CloseAction implements PrivilegedAction<Object> { /** * Performs the action. */ @Override - public Object run() - { + public Object run() { replicatorComponent.close(); return null; } Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/ProviderConfiguration.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/ProviderConfiguration.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/ProviderConfiguration.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/ProviderConfiguration.java Thu Sep 14 19:26:39 2017 @@ -24,48 +24,39 @@ import java.util.List; * <p> * Used by digester in StandardFileSystemManager */ -public class ProviderConfiguration -{ +public class ProviderConfiguration { private String className; private final List<String> schemes = new ArrayList<>(10); private final List<String> dependenies = new ArrayList<>(10); - public ProviderConfiguration() - { + public ProviderConfiguration() { } - public String getClassName() - { + public String getClassName() { return className; } - public void setClassName(final String className) - { + public void setClassName(final String className) { this.className = className; } - public void setScheme(final String scheme) - { + public void setScheme(final String scheme) { schemes.add(scheme); } - public List<String> getSchemes() - { + public List<String> getSchemes() { return schemes; } - public void setDependency(final String dependency) - { + public void setDependency(final String dependency) { dependenies.add(dependency); } - public List<String> getDependencies() - { + public List<String> getDependencies() { return dependenies; } - public boolean isDefault() - { + public boolean isDefault() { return false; } } Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/Resource.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/Resource.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/Resource.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/Resource.java Thu Sep 14 19:26:39 2017 @@ -25,13 +25,11 @@ import org.apache.commons.vfs2.FileSyste import org.apache.commons.vfs2.FileUtil; /** - * Helper class for VFSClassLoader. - * This represents a resource loaded with the classloader. + * Helper class for VFSClassLoader. This represents a resource loaded with the classloader. * * @see VFSClassLoader */ -class Resource -{ +class Resource { private final FileObject root; private final FileObject resource; private final FileObject packageFolder; @@ -40,24 +38,17 @@ class Resource /** * Creates a new instance. * - * @param root The code source FileObject. + * @param root The code source FileObject. * @param resource The resource of the FileObject. */ - public Resource(final String name, - final FileObject root, - final FileObject resource) - throws FileSystemException - { + public Resource(final String name, final FileObject root, final FileObject resource) throws FileSystemException { this.root = root; this.resource = resource; packageFolder = resource.getParent(); final int pos = name.lastIndexOf('/'); - if (pos == -1) - { + if (pos == -1) { packageName = null; - } - else - { + } else { packageName = name.substring(0, pos).replace('/', '.'); } } @@ -65,56 +56,49 @@ class Resource /** * Returns the URL of the resource. */ - public URL getURL() throws FileSystemException - { + public URL getURL() throws FileSystemException { return resource.getURL(); } /** * Returns the name of the package containing the resource. */ - public String getPackageName() - { + public String getPackageName() { return packageName; } /** * Returns an attribute of the package containing the resource. */ - public String getPackageAttribute(final Attributes.Name attrName) throws FileSystemException - { + public String getPackageAttribute(final Attributes.Name attrName) throws FileSystemException { return (String) packageFolder.getContent().getAttribute(attrName.toString()); } /** * Returns the folder for the package containing the resource. */ - public FileObject getPackageFolder() - { + public FileObject getPackageFolder() { return packageFolder; } /** * Returns the FileObject of the resource. */ - public FileObject getFileObject() - { + public FileObject getFileObject() { return resource; } /** * Returns the code source as an URL. */ - public URL getCodeSourceURL() throws FileSystemException - { + public URL getCodeSourceURL() throws FileSystemException { return root.getURL(); } /** * Returns the data for this resource as a byte array. */ - public byte[] getBytes() throws IOException - { + public byte[] getBytes() throws IOException { return FileUtil.getContent(resource); } }
