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 [14/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/ap...
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpFileSystemConfigBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpFileSystemConfigBuilder.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpFileSystemConfigBuilder.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpFileSystemConfigBuilder.java Thu Sep 14 19:26:39 2017
@@ -27,8 +27,7 @@ import org.apache.commons.vfs2.UserAuthe
/**
* Configuration options for HTTP.
*/
-public class HttpFileSystemConfigBuilder extends FileSystemConfigBuilder
-{
+public class HttpFileSystemConfigBuilder extends FileSystemConfigBuilder {
protected static final String KEY_FOLLOW_REDIRECT = "followRedirect";
protected static final String KEY_USER_AGENT = "userAgent";
@@ -51,16 +50,15 @@ public class HttpFileSystemConfigBuilder
/**
* Create new config builder.
+ *
* @param prefix String for properties of this file system.
* @since 2.0
*/
- protected HttpFileSystemConfigBuilder(final String prefix)
- {
+ protected HttpFileSystemConfigBuilder(final String prefix) {
super(prefix);
}
- private HttpFileSystemConfigBuilder()
- {
+ private HttpFileSystemConfigBuilder() {
super("http.");
}
@@ -69,8 +67,7 @@ public class HttpFileSystemConfigBuilder
*
* @return the singleton builder.
*/
- public static HttpFileSystemConfigBuilder getInstance()
- {
+ public static HttpFileSystemConfigBuilder getInstance() {
return BUILDER;
}
@@ -80,8 +77,7 @@ public class HttpFileSystemConfigBuilder
* @param opts The FileSystem options.
* @param chaset the chaset
*/
- public void setUrlCharset(final FileSystemOptions opts, final String chaset)
- {
+ public void setUrlCharset(final FileSystemOptions opts, final String chaset) {
setParam(opts, "urlCharset", chaset);
}
@@ -91,8 +87,7 @@ public class HttpFileSystemConfigBuilder
* @param opts The FileSystem options.
* @return the chaset
*/
- public String getUrlCharset(final FileSystemOptions opts)
- {
+ public String getUrlCharset(final FileSystemOptions opts) {
return getString(opts, "urlCharset");
}
@@ -104,186 +99,174 @@ public class HttpFileSystemConfigBuilder
* @param proxyHost the host
* @see #setProxyPort
*/
- public void setProxyHost(final FileSystemOptions opts, final String proxyHost)
- {
+ public void setProxyHost(final FileSystemOptions opts, final String proxyHost) {
setParam(opts, "proxyHost", proxyHost);
}
/**
- * Set the proxy-port to use for http connection.
- * You have to set the ProxyHost too if you would like to have the proxy really used.
+ * Set the proxy-port to use for http connection. You have to set the ProxyHost too if you would like to have the
+ * proxy really used.
*
* @param opts The FileSystem options.
* @param proxyPort the port
* @see #setProxyHost
*/
- public void setProxyPort(final FileSystemOptions opts, final int proxyPort)
- {
+ public void setProxyPort(final FileSystemOptions opts, final int proxyPort) {
setParam(opts, "proxyPort", Integer.valueOf(proxyPort));
}
/**
- * Get the proxy to use for http connection.
- * You have to set the ProxyPort too if you would like to have the proxy really used.
+ * Get the proxy to use for http connection. You have to set the ProxyPort too if you would like to have the proxy
+ * really used.
*
* @param opts The FileSystem options.
* @return proxyHost
* @see #setProxyPort
*/
- public String getProxyHost(final FileSystemOptions opts)
- {
+ public String getProxyHost(final FileSystemOptions opts) {
return getString(opts, "proxyHost");
}
/**
- * Get the proxy-port to use for http the connection.
- * You have to set the ProxyHost too if you would like to have the proxy really used.
+ * Get the proxy-port to use for http the connection. You have to set the ProxyHost too if you would like to have
+ * the proxy really used.
*
* @param opts The FileSystem options.
* @return proxyPort: the port number or 0 if it is not set
* @see #setProxyHost
*/
- public int getProxyPort(final FileSystemOptions opts)
- {
+ public int getProxyPort(final FileSystemOptions opts) {
return getInteger(opts, "proxyPort", 0);
}
/**
* Set the proxy authenticator where the system should get the credentials from.
+ *
* @param opts The FileSystem options.
* @param authenticator The UserAuthenticator.
*/
- public void setProxyAuthenticator(final FileSystemOptions opts, final UserAuthenticator authenticator)
- {
+ public void setProxyAuthenticator(final FileSystemOptions opts, final UserAuthenticator authenticator) {
setParam(opts, "proxyAuthenticator", authenticator);
}
/**
* Get the proxy authenticator where the system should get the credentials from.
+ *
* @param opts The FileSystem options.
* @return The UserAuthenticator.
*/
- public UserAuthenticator getProxyAuthenticator(final FileSystemOptions opts)
- {
+ public UserAuthenticator getProxyAuthenticator(final FileSystemOptions opts) {
return (UserAuthenticator) getParam(opts, "proxyAuthenticator");
}
/**
* The cookies to add to the request.
+ *
* @param opts The FileSystem options.
* @param cookies An array of Cookies.
*/
- public void setCookies(final FileSystemOptions opts, final Cookie[] cookies)
- {
+ public void setCookies(final FileSystemOptions opts, final Cookie[] cookies) {
setParam(opts, "cookies", cookies);
}
/**
* Sets whether to follow redirects for the connection.
*
- * @param opts
- * The FileSystem options.
- * @param redirect
- * {@code true} to follow redirects, {@code false} not to.
+ * @param opts The FileSystem options.
+ * @param redirect {@code true} to follow redirects, {@code false} not to.
* @see #setFollowRedirect
* @since 2.1
*/
- public void setFollowRedirect(final FileSystemOptions opts, final boolean redirect)
- {
+ public void setFollowRedirect(final FileSystemOptions opts, final boolean redirect) {
setParam(opts, KEY_FOLLOW_REDIRECT, redirect);
}
/**
* The cookies to add to the request.
+ *
* @param opts The FileSystem options.
* @return the Cookie array.
*/
- public Cookie[] getCookies(final FileSystemOptions opts)
- {
+ public Cookie[] getCookies(final FileSystemOptions opts) {
return (Cookie[]) getParam(opts, "cookies");
}
/**
* Gets whether to follow redirects for the connection.
*
- * @param opts
- * The FileSystem options.
+ * @param opts The FileSystem options.
* @return {@code true} to follow redirects, {@code false} not to.
* @see #setFollowRedirect
* @since 2.1
*/
- public boolean getFollowRedirect(final FileSystemOptions opts)
- {
+ public boolean getFollowRedirect(final FileSystemOptions opts) {
return getBoolean(opts, KEY_FOLLOW_REDIRECT, DEFAULT_FOLLOW_REDIRECT);
}
/**
* The maximum number of connections allowed.
+ *
* @param opts The FileSystem options.
* @param maxTotalConnections The maximum number of connections.
* @since 2.0
*/
- public void setMaxTotalConnections(final FileSystemOptions opts, final int maxTotalConnections)
- {
+ public void setMaxTotalConnections(final FileSystemOptions opts, final int maxTotalConnections) {
setParam(opts, HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS, Integer.valueOf(maxTotalConnections));
}
/**
* Retrieve the maximum number of connections allowed.
+ *
* @param opts The FileSystemOptions.
* @return The maximum number of connections allowed.
* @since 2.0
*/
- public int getMaxTotalConnections(final FileSystemOptions opts)
- {
+ public int getMaxTotalConnections(final FileSystemOptions opts) {
return getInteger(opts, HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS, DEFAULT_MAX_CONNECTIONS);
}
/**
* The maximum number of connections allowed to any host.
+ *
* @param opts The FileSystem options.
* @param maxHostConnections The maximum number of connections to a host.
* @since 2.0
*/
- public void setMaxConnectionsPerHost(final FileSystemOptions opts, final int maxHostConnections)
- {
+ public void setMaxConnectionsPerHost(final FileSystemOptions opts, final int maxHostConnections) {
setParam(opts, HttpConnectionManagerParams.MAX_HOST_CONNECTIONS, Integer.valueOf(maxHostConnections));
}
/**
* Retrieve the maximum number of connections allowed per host.
+ *
* @param opts The FileSystemOptions.
* @return The maximum number of connections allowed per host.
* @since 2.0
*/
- public int getMaxConnectionsPerHost(final FileSystemOptions opts)
- {
+ public int getMaxConnectionsPerHost(final FileSystemOptions opts) {
return getInteger(opts, HttpConnectionManagerParams.MAX_HOST_CONNECTIONS, DEFAULT_MAX_HOST_CONNECTIONS);
}
/**
- * Determines if the FileSystemOptions indicate that preemptive
- * authentication is requested.
+ * Determines if the FileSystemOptions indicate that preemptive authentication is requested.
+ *
* @param opts The FileSystemOptions.
* @return true if preemptiveAuth is requested.
* @since 2.0
*/
- public boolean isPreemptiveAuth(final FileSystemOptions opts)
- {
+ public boolean isPreemptiveAuth(final FileSystemOptions opts) {
return getBoolean(opts, KEY_PREEMPTIVE_AUTHENTICATION, Boolean.FALSE).booleanValue();
}
/**
- * Sets the given value for preemptive HTTP authentication (using BASIC) on the
- * given FileSystemOptions object. Defaults to false if not set. It may be
- * appropriate to set to true in cases when the resulting chattiness of the
- * conversation outweighs any architectural desire to use a stronger authentication
- * scheme than basic/preemptive.
+ * Sets the given value for preemptive HTTP authentication (using BASIC) on the given FileSystemOptions object.
+ * Defaults to false if not set. It may be appropriate to set to true in cases when the resulting chattiness of the
+ * conversation outweighs any architectural desire to use a stronger authentication scheme than basic/preemptive.
+ *
* @param opts The FileSystemOptions.
* @param preemptiveAuth the desired setting; true=enabled and false=disabled.
*/
- public void setPreemptiveAuth(final FileSystemOptions opts, final boolean preemptiveAuth)
- {
+ public void setPreemptiveAuth(final FileSystemOptions opts, final boolean preemptiveAuth) {
setParam(opts, KEY_PREEMPTIVE_AUTHENTICATION, Boolean.valueOf(preemptiveAuth));
}
@@ -294,8 +277,7 @@ public class HttpFileSystemConfigBuilder
* @param connectionTimeout The connection timeout.
* @since 2.1
*/
- public void setConnectionTimeout(final FileSystemOptions opts, final int connectionTimeout)
- {
+ public void setConnectionTimeout(final FileSystemOptions opts, final int connectionTimeout) {
setParam(opts, HttpConnectionParams.CONNECTION_TIMEOUT, Integer.valueOf(connectionTimeout));
}
@@ -306,8 +288,7 @@ public class HttpFileSystemConfigBuilder
* @return The connection timeout.
* @since 2.1
*/
- public int getConnectionTimeout(final FileSystemOptions opts)
- {
+ public int getConnectionTimeout(final FileSystemOptions opts) {
return getInteger(opts, HttpConnectionParams.CONNECTION_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT);
}
@@ -318,8 +299,7 @@ public class HttpFileSystemConfigBuilder
* @param soTimeout socket timeout.
* @since 2.1
*/
- public void setSoTimeout(final FileSystemOptions opts, final int soTimeout)
- {
+ public void setSoTimeout(final FileSystemOptions opts, final int soTimeout) {
setParam(opts, HttpConnectionParams.SO_TIMEOUT, Integer.valueOf(soTimeout));
}
@@ -330,8 +310,7 @@ public class HttpFileSystemConfigBuilder
* @return The socket timeout.
* @since 2.1
*/
- public int getSoTimeout(final FileSystemOptions opts)
- {
+ public int getSoTimeout(final FileSystemOptions opts) {
return getInteger(opts, HttpConnectionParams.SO_TIMEOUT, DEFAULT_SO_TIMEOUT);
}
@@ -340,8 +319,7 @@ public class HttpFileSystemConfigBuilder
*
* @param userAgent User Agent String
*/
- public void setUserAgent(final FileSystemOptions opts, final String userAgent)
- {
+ public void setUserAgent(final FileSystemOptions opts, final String userAgent) {
setParam(opts, "userAgent", userAgent);
}
@@ -350,16 +328,13 @@ public class HttpFileSystemConfigBuilder
*
* @return User provided User-Agent string, otherwise default of: Jakarta-Commons-VFS
*/
- public String getUserAgent(final FileSystemOptions opts)
- {
+ public String getUserAgent(final FileSystemOptions opts) {
final String userAgent = (String) getParam(opts, KEY_USER_AGENT);
return userAgent != null ? userAgent : DEFAULT_USER_AGENT;
}
-
@Override
- protected Class<? extends FileSystem> getConfigClass()
- {
+ protected Class<? extends FileSystem> getConfigClass() {
return HttpFileSystem.class;
}
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpRandomAccessContent.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpRandomAccessContent.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpRandomAccessContent.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http/HttpRandomAccessContent.java Thu Sep 14 19:26:39 2017
@@ -30,8 +30,7 @@ import org.apache.commons.vfs2.util.Rand
/**
* RandomAccess content using HTTP.
*/
-class HttpRandomAccessContent extends AbstractRandomAccessStreamContent
-{
+class HttpRandomAccessContent extends AbstractRandomAccessStreamContent {
protected long filePointer = 0;
private final HttpFileObject fileObject;
@@ -40,8 +39,7 @@ class HttpRandomAccessContent extends Ab
private DataInputStream dis = null;
private MonitorInputStream mis = null;
- HttpRandomAccessContent(final HttpFileObject fileObject, final RandomAccessMode mode)
- {
+ HttpRandomAccessContent(final HttpFileObject fileObject, final RandomAccessMode mode) {
super(mode);
this.fileObject = fileObject;
@@ -49,27 +47,21 @@ class HttpRandomAccessContent extends Ab
}
@Override
- public long getFilePointer() throws IOException
- {
+ public long getFilePointer() throws IOException {
return filePointer;
}
@Override
- public void seek(final long pos) throws IOException
- {
- if (pos == filePointer)
- {
+ public void seek(final long pos) throws IOException {
+ if (pos == filePointer) {
// no change
return;
}
- if (pos < 0)
- {
- throw new FileSystemException("vfs.provider/random-access-invalid-position.error",
- Long.valueOf(pos));
+ if (pos < 0) {
+ throw new FileSystemException("vfs.provider/random-access-invalid-position.error", Long.valueOf(pos));
}
- if (dis != null)
- {
+ if (dis != null) {
close();
}
@@ -77,10 +69,8 @@ class HttpRandomAccessContent extends Ab
}
@Override
- protected DataInputStream getDataInputStream() throws IOException
- {
- if (dis != null)
- {
+ protected DataInputStream getDataInputStream() throws IOException {
+ if (dis != null) {
return dis;
}
@@ -88,57 +78,43 @@ class HttpRandomAccessContent extends Ab
fileObject.setupMethod(getMethod);
getMethod.setRequestHeader("Range", "bytes=" + filePointer + "-");
final int status = fileSystem.getClient().executeMethod(getMethod);
- if (status != HttpURLConnection.HTTP_PARTIAL && status != HttpURLConnection.HTTP_OK)
- {
- throw new FileSystemException("vfs.provider.http/get-range.error",
- fileObject.getName(),
- Long.valueOf(filePointer),
- Integer.valueOf(status));
+ if (status != HttpURLConnection.HTTP_PARTIAL && status != HttpURLConnection.HTTP_OK) {
+ throw new FileSystemException("vfs.provider.http/get-range.error", fileObject.getName(),
+ Long.valueOf(filePointer), Integer.valueOf(status));
}
mis = new HttpFileObject.HttpInputStream(getMethod);
// If the range request was ignored
- if (status == HttpURLConnection.HTTP_OK)
- {
+ if (status == HttpURLConnection.HTTP_OK) {
final long skipped = mis.skip(filePointer);
- if (skipped != filePointer)
- {
- throw new FileSystemException("vfs.provider.http/get-range.error",
- fileObject.getName(),
- Long.valueOf(filePointer),
- Integer.valueOf(status));
+ if (skipped != filePointer) {
+ throw new FileSystemException("vfs.provider.http/get-range.error", fileObject.getName(),
+ Long.valueOf(filePointer), Integer.valueOf(status));
}
}
- dis = new DataInputStream(new FilterInputStream(mis)
- {
+ dis = new DataInputStream(new FilterInputStream(mis) {
@Override
- public int read() throws IOException
- {
+ public int read() throws IOException {
final int ret = super.read();
- if (ret > -1)
- {
+ if (ret > -1) {
filePointer++;
}
return ret;
}
@Override
- public int read(final byte[] b) throws IOException
- {
+ public int read(final byte[] b) throws IOException {
final int ret = super.read(b);
- if (ret > -1)
- {
+ if (ret > -1) {
filePointer += ret;
}
return ret;
}
@Override
- public int read(final byte[] b, final int off, final int len) throws IOException
- {
+ public int read(final byte[] b, final int off, final int len) throws IOException {
final int ret = super.read(b, off, len);
- if (ret > -1)
- {
+ if (ret > -1) {
filePointer += ret;
}
return ret;
@@ -148,12 +124,9 @@ class HttpRandomAccessContent extends Ab
return dis;
}
-
@Override
- public void close() throws IOException
- {
- if (dis != null)
- {
+ public void close() throws IOException {
+ if (dis != null) {
dis.close();
dis = null;
mis = null;
@@ -161,8 +134,7 @@ class HttpRandomAccessContent extends Ab
}
@Override
- public long length() throws IOException
- {
+ public long length() throws IOException {
return fileObject.getContent().getSize();
}
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/https/HttpsFileNameParser.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/https/HttpsFileNameParser.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/https/HttpsFileNameParser.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/https/HttpsFileNameParser.java Thu Sep 14 19:26:39 2017
@@ -22,19 +22,16 @@ import org.apache.commons.vfs2.provider.
/**
* Implementation for https. set default port to 443.
*/
-public class HttpsFileNameParser extends URLFileNameParser
-{
+public class HttpsFileNameParser extends URLFileNameParser {
private static final int DEFAULT_PORT = 443;
private static final HttpsFileNameParser INSTANCE = new HttpsFileNameParser();
- public HttpsFileNameParser()
- {
+ public HttpsFileNameParser() {
super(DEFAULT_PORT);
}
- public static FileNameParser getInstance()
- {
+ public static FileNameParser getInstance() {
return INSTANCE;
}
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/https/HttpsFileProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/https/HttpsFileProvider.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/https/HttpsFileProvider.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/https/HttpsFileProvider.java Thu Sep 14 19:26:39 2017
@@ -21,11 +21,8 @@ import org.apache.commons.vfs2.provider.
/**
* An HTTPS provider that uses commons-httpclient.
*/
-public class HttpsFileProvider
- extends HttpFileProvider
-{
- public HttpsFileProvider()
- {
+public class HttpsFileProvider extends HttpFileProvider {
+ public HttpsFileProvider() {
super();
setFileNameParser(HttpsFileNameParser.getInstance());
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/jar/JarFileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/jar/JarFileObject.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/jar/JarFileObject.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/jar/JarFileObject.java Thu Sep 14 19:26:39 2017
@@ -34,26 +34,19 @@ import org.apache.commons.vfs2.provider.
/**
* A file in a Jar file system.
*/
-public class JarFileObject extends ZipFileObject
-{
+public class JarFileObject extends ZipFileObject {
private final JarFileSystem fs;
private Attributes attributes;
- protected JarFileObject(final AbstractFileName name,
- final ZipEntry entry,
- final JarFileSystem fs,
- final boolean zipExists) throws FileSystemException
- {
+ protected JarFileObject(final AbstractFileName name, final ZipEntry entry, final JarFileSystem fs,
+ final boolean zipExists) throws FileSystemException {
super(name, entry, fs, zipExists);
this.fs = fs;
- try
- {
+ try {
getAttributes(); // early get the attributes as the zip file might be closed
- }
- catch (final IOException e)
- {
+ } catch (final IOException e) {
throw new FileSystemException(e);
}
}
@@ -61,10 +54,8 @@ public class JarFileObject extends ZipFi
/**
* Returns the Jar manifest.
*/
- Manifest getManifest() throws IOException
- {
- if (fs.getZipFile() == null)
- {
+ Manifest getManifest() throws IOException {
+ if (fs.getZipFile() == null) {
return null;
}
@@ -74,19 +65,13 @@ public class JarFileObject extends ZipFi
/**
* Returns the attributes of this file.
*/
- Attributes getAttributes() throws IOException
- {
- if (attributes == null)
- {
- if (entry == null)
- {
+ Attributes getAttributes() throws IOException {
+ if (attributes == null) {
+ if (entry == null) {
attributes = new Attributes(1);
- }
- else
- {
+ } else {
attributes = ((JarEntry) entry).getAttributes();
- if (attributes == null)
- {
+ if (attributes == null) {
attributes = new Attributes(1);
}
}
@@ -99,9 +84,7 @@ public class JarFileObject extends ZipFi
* Returns the value of an attribute.
*/
@Override
- protected Map<String, Object> doGetAttributes()
- throws Exception
- {
+ protected Map<String, Object> doGetAttributes() throws Exception {
final Map<String, Object> attrs = new HashMap<>();
// Add the file system's attributes first
@@ -117,10 +100,8 @@ public class JarFileObject extends ZipFi
/**
* Adds the source attributes to the destination map.
*/
- private void addAll(final Attributes src, final Map<String, Object> dest)
- {
- for (final Entry<Object, Object> entry : src.entrySet())
- {
+ private void addAll(final Attributes src, final Map<String, Object> dest) {
+ for (final Entry<Object, Object> entry : src.entrySet()) {
// final String name = entry.getKey().toString().toLowerCase();
final String name = entry.getKey().toString();
dest.put(name, entry.getValue());
@@ -131,10 +112,8 @@ public class JarFileObject extends ZipFi
* Return the certificates of this JarEntry.
*/
@Override
- protected Certificate[] doGetCertificates()
- {
- if (entry == null)
- {
+ protected Certificate[] doGetCertificates() {
+ if (entry == null) {
return null;
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/jar/JarFileProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/jar/JarFileProvider.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/jar/JarFileProvider.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/jar/JarFileProvider.java Thu Sep 14 19:26:39 2017
@@ -33,56 +33,40 @@ import org.apache.commons.vfs2.provider.
import org.apache.commons.vfs2.provider.zip.ZipFileProvider;
/**
- * A file system provider for Jar files. Provides read-only file
- * systems. This provides access to Jar specific features like Signing and
- * Manifest Attributes.
+ * A file system provider for Jar files. Provides read-only file systems. This provides access to Jar specific features
+ * like Signing and Manifest Attributes.
*/
-public class JarFileProvider extends ZipFileProvider
-{
+public class JarFileProvider extends ZipFileProvider {
static final Collection<Capability> capabilities;
- static
- {
+ static {
final Collection<Capability> combined = new ArrayList<>();
combined.addAll(ZipFileProvider.capabilities);
- combined.addAll(Arrays.asList(new Capability[]
- {
- Capability.ATTRIBUTES,
- Capability.FS_ATTRIBUTES,
- Capability.SIGNING,
- Capability.MANIFEST_ATTRIBUTES,
- Capability.VIRTUAL
- }));
+ combined.addAll(Arrays.asList(new Capability[] { Capability.ATTRIBUTES, Capability.FS_ATTRIBUTES,
+ Capability.SIGNING, Capability.MANIFEST_ATTRIBUTES, Capability.VIRTUAL }));
capabilities = Collections.unmodifiableCollection(combined);
}
- public JarFileProvider()
- {
+ public JarFileProvider() {
super();
}
/**
- * Creates a layered file system. This method is called if the file system
- * is not cached.
+ * Creates a layered file system. 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.
* @return The file system.
*/
@Override
- protected FileSystem doCreateFileSystem(final String scheme,
- final FileObject file,
- final FileSystemOptions fileSystemOptions)
- throws FileSystemException
- {
- final AbstractFileName name =
- new LayeredFileName(scheme, file.getName(), FileName.ROOT_PATH, FileType.FOLDER);
+ protected FileSystem doCreateFileSystem(final String scheme, final FileObject file,
+ final FileSystemOptions fileSystemOptions) throws FileSystemException {
+ final AbstractFileName name = new LayeredFileName(scheme, file.getName(), FileName.ROOT_PATH, FileType.FOLDER);
return new JarFileSystem(name, file, fileSystemOptions);
}
@Override
- public Collection<Capability> getCapabilities()
- {
+ public Collection<Capability> getCapabilities() {
return capabilities;
}
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/jar/JarFileSystem.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/jar/JarFileSystem.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/jar/JarFileSystem.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/jar/JarFileSystem.java Thu Sep 14 19:26:39 2017
@@ -37,40 +37,32 @@ import org.apache.commons.vfs2.provider.
/**
* A read-only file system for Jar files.
*/
-public class JarFileSystem extends ZipFileSystem
-{
+public class JarFileSystem extends ZipFileSystem {
private Attributes attributes;
- protected JarFileSystem(final AbstractFileName rootName,
- final FileObject file,
- final FileSystemOptions fileSystemOptions) throws FileSystemException
- {
+ protected JarFileSystem(final AbstractFileName rootName, final FileObject file,
+ final FileSystemOptions fileSystemOptions) throws FileSystemException {
super(rootName, file, fileSystemOptions);
}
-// @Override
-// protected FileObject createFile(AbstractFileName name) throws FileSystemException
-// {
-// return new JarFileObject(name, null, this, false);
-// }
+ // @Override
+ // protected FileObject createFile(AbstractFileName name) throws FileSystemException
+ // {
+ // return new JarFileObject(name, null, this, false);
+ // }
@Override
- protected ZipFile createZipFile(final File file) throws FileSystemException
- {
- try
- {
+ protected ZipFile createZipFile(final File file) throws FileSystemException {
+ try {
return new JarFile(file);
- }
- catch (final IOException ioe)
- {
+ } catch (final IOException ioe) {
throw new FileSystemException("vfs.provider.jar/open-jar-file.error", file, ioe);
}
}
@Override
- protected ZipFileObject createZipFileObject(final AbstractFileName name,
- final ZipEntry entry) throws FileSystemException
- {
+ protected ZipFileObject createZipFileObject(final AbstractFileName name, final ZipEntry entry)
+ throws FileSystemException {
return new JarFileObject(name, entry, this, true);
}
@@ -78,26 +70,19 @@ public class JarFileSystem extends ZipFi
* Returns the capabilities of this file system.
*/
@Override
- protected void addCapabilities(final Collection<Capability> caps)
- {
+ protected void addCapabilities(final Collection<Capability> caps) {
// super.addCapabilities(caps);
caps.addAll(JarFileProvider.capabilities);
}
- Attributes getAttributes() throws IOException
- {
- if (attributes == null)
- {
+ Attributes getAttributes() throws IOException {
+ if (attributes == null) {
final Manifest man = ((JarFile) getZipFile()).getManifest();
- if (man == null)
- {
+ if (man == null) {
attributes = new Attributes(1);
- }
- else
- {
+ } else {
attributes = man.getMainAttributes();
- if (attributes == null)
- {
+ if (attributes == null) {
attributes = new Attributes(1);
}
}
@@ -106,115 +91,71 @@ public class JarFileSystem extends ZipFi
return attributes;
}
- Object getAttribute(final Name attrName)
- throws FileSystemException
- {
- try
- {
+ Object getAttribute(final Name attrName) throws FileSystemException {
+ try {
final Attributes attr = getAttributes();
final String value = attr.getValue(attrName);
return value;
- }
- catch (final IOException ioe)
- {
+ } catch (final IOException ioe) {
throw new FileSystemException(attrName.toString(), ioe);
}
}
- Name lookupName(final String attrName)
- {
- if (Name.CLASS_PATH.toString().equals(attrName))
- {
+ Name lookupName(final String attrName) {
+ if (Name.CLASS_PATH.toString().equals(attrName)) {
return Name.CLASS_PATH;
- }
- else if (Name.CONTENT_TYPE.toString().equals(attrName))
- {
+ } else if (Name.CONTENT_TYPE.toString().equals(attrName)) {
return Name.CONTENT_TYPE;
- }
- else if (Name.EXTENSION_INSTALLATION.toString().equals(attrName))
- {
+ } else if (Name.EXTENSION_INSTALLATION.toString().equals(attrName)) {
return Name.EXTENSION_INSTALLATION;
- }
- else if (Name.EXTENSION_LIST.toString().equals(attrName))
- {
+ } else if (Name.EXTENSION_LIST.toString().equals(attrName)) {
return Name.EXTENSION_LIST;
- }
- else if (Name.EXTENSION_NAME.toString().equals(attrName))
- {
+ } else if (Name.EXTENSION_NAME.toString().equals(attrName)) {
return Name.EXTENSION_NAME;
- }
- else if (Name.IMPLEMENTATION_TITLE.toString().equals(attrName))
- {
+ } else if (Name.IMPLEMENTATION_TITLE.toString().equals(attrName)) {
return Name.IMPLEMENTATION_TITLE;
- }
- else if (Name.IMPLEMENTATION_URL.toString().equals(attrName))
- {
+ } else if (Name.IMPLEMENTATION_URL.toString().equals(attrName)) {
return Name.IMPLEMENTATION_URL;
- }
- else if (Name.IMPLEMENTATION_VENDOR.toString().equals(attrName))
- {
+ } else if (Name.IMPLEMENTATION_VENDOR.toString().equals(attrName)) {
return Name.IMPLEMENTATION_VENDOR;
- }
- else if (Name.IMPLEMENTATION_VENDOR_ID.toString().equals(attrName))
- {
+ } else if (Name.IMPLEMENTATION_VENDOR_ID.toString().equals(attrName)) {
return Name.IMPLEMENTATION_VENDOR_ID;
- }
- else if (Name.IMPLEMENTATION_VERSION.toString().equals(attrName))
- {
+ } else if (Name.IMPLEMENTATION_VERSION.toString().equals(attrName)) {
return Name.IMPLEMENTATION_VENDOR;
- }
- else if (Name.MAIN_CLASS.toString().equals(attrName))
- {
+ } else if (Name.MAIN_CLASS.toString().equals(attrName)) {
return Name.MAIN_CLASS;
- }
- else if (Name.MANIFEST_VERSION.toString().equals(attrName))
- {
+ } else if (Name.MANIFEST_VERSION.toString().equals(attrName)) {
return Name.MANIFEST_VERSION;
- }
- else if (Name.SEALED.toString().equals(attrName))
- {
+ } else if (Name.SEALED.toString().equals(attrName)) {
return Name.SEALED;
- }
- else if (Name.SIGNATURE_VERSION.toString().equals(attrName))
- {
+ } else if (Name.SIGNATURE_VERSION.toString().equals(attrName)) {
return Name.SIGNATURE_VERSION;
- }
- else if (Name.SPECIFICATION_TITLE.toString().equals(attrName))
- {
+ } else if (Name.SPECIFICATION_TITLE.toString().equals(attrName)) {
return Name.SPECIFICATION_TITLE;
- }
- else if (Name.SPECIFICATION_VENDOR.toString().equals(attrName))
- {
+ } else if (Name.SPECIFICATION_VENDOR.toString().equals(attrName)) {
return Name.SPECIFICATION_VENDOR;
- }
- else if (Name.SPECIFICATION_VERSION.toString().equals(attrName))
- {
+ } else if (Name.SPECIFICATION_VERSION.toString().equals(attrName)) {
return Name.SPECIFICATION_VERSION;
- }
- else
- {
+ } else {
return new Name(attrName);
}
}
/**
- * Retrives the attribute with the specified name. The default
- * implementation simply throws an exception.
+ * Retrives the attribute with the specified name. The default implementation simply throws an exception.
+ *
* @param attrName The attiribute's name.
* @return The value of the attribute.
* @throws FileSystemException if an error occurs.
*/
@Override
- public Object getAttribute(final String attrName) throws FileSystemException
- {
+ public Object getAttribute(final String attrName) throws FileSystemException {
final Name name = lookupName(attrName);
return getAttribute(name);
}
-
@Override
- protected ZipFile getZipFile() throws FileSystemException
- {
+ protected ZipFile getZipFile() throws FileSystemException {
// make accessible
return super.getZipFile();
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/jar/JarURLConnectionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/jar/JarURLConnectionImpl.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/jar/JarURLConnectionImpl.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/jar/JarURLConnectionImpl.java Thu Sep 14 19:26:39 2017
@@ -34,9 +34,7 @@ import org.apache.commons.vfs2.FileSyste
/**
* A default URL connection that will work for most file systems.
*/
-public class JarURLConnectionImpl
- extends JarURLConnection
-{
+public class JarURLConnectionImpl extends JarURLConnection {
// This is because JarURLConnection SUCKS
private static final String HACK_URL = "jar:http://somehost/somejar.jar!/";
@@ -46,9 +44,8 @@ public class JarURLConnectionImpl
private final String entryName;
public JarURLConnectionImpl(final JarFileObject file, final FileContent content)
- throws MalformedURLException, FileSystemException
- {
- //This is because JarURLConnection SUCKS!!
+ throws MalformedURLException, FileSystemException {
+ // This is because JarURLConnection SUCKS!!
super(new URL(HACK_URL));
this.url = file.getURL();
@@ -58,85 +55,61 @@ public class JarURLConnectionImpl
this.file = file;
}
-
@Override
- public URL getJarFileURL()
- {
+ public URL getJarFileURL() {
return parentURL;
}
-
@Override
- public String getEntryName()
- {
+ public String getEntryName() {
return entryName;
}
-
@Override
- public JarFile getJarFile() throws IOException
- {
+ public JarFile getJarFile() throws IOException {
throw new FileSystemException("vfs.provider.jar/jar-file-no-access.error");
}
-
@Override
- public Manifest getManifest() throws IOException
- {
+ public Manifest getManifest() throws IOException {
return file.getManifest();
}
-
@Override
- public JarEntry getJarEntry() throws IOException
- {
+ public JarEntry getJarEntry() throws IOException {
throw new FileSystemException("vfs.provider.jar/jar-entry-no-access.error");
}
-
@Override
- public Attributes getAttributes() throws IOException
- {
+ public Attributes getAttributes() throws IOException {
return file.getAttributes();
}
-
@Override
- public Certificate[] getCertificates()
- {
+ public Certificate[] getCertificates() {
return file.doGetCertificates();
}
-
@Override
- public void connect()
- {
+ public void connect() {
connected = true;
}
@Override
- public InputStream getInputStream()
- throws IOException
- {
+ public InputStream getInputStream() throws IOException {
return content.getInputStream();
}
@Override
- public OutputStream getOutputStream()
- throws IOException
- {
+ public OutputStream getOutputStream() throws IOException {
return content.getOutputStream();
}
@Override
- public int getContentLength()
- {
- try
- {
+ public int getContentLength() {
+ try {
return (int) content.getSize();
- }
- catch (final FileSystemException ignored)
- {
+ } catch (final FileSystemException ignored) {
return -1;
}
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/DefaultLocalFileProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/DefaultLocalFileProvider.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/DefaultLocalFileProvider.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/DefaultLocalFileProvider.java Thu Sep 14 19:26:39 2017
@@ -35,69 +35,48 @@ import org.apache.commons.vfs2.util.Os;
/**
* A file system provider, which uses direct file access.
*/
-public class DefaultLocalFileProvider
- extends AbstractOriginatingFileProvider
- implements LocalFileProvider
-{
+public class DefaultLocalFileProvider extends AbstractOriginatingFileProvider implements LocalFileProvider {
/** The provider's capabilities. */
- public static final Collection<Capability> capabilities =
- Collections.unmodifiableCollection(Arrays.asList(new Capability[]
- {
- Capability.CREATE,
- Capability.DELETE,
- Capability.RENAME,
- Capability.GET_TYPE,
- Capability.GET_LAST_MODIFIED,
- Capability.SET_LAST_MODIFIED_FILE,
- Capability.SET_LAST_MODIFIED_FOLDER,
- Capability.LIST_CHILDREN,
- Capability.READ_CONTENT,
- Capability.URI,
- Capability.WRITE_CONTENT,
- Capability.APPEND_CONTENT,
- Capability.RANDOM_ACCESS_READ,
- Capability.RANDOM_ACCESS_SET_LENGTH,
- Capability.RANDOM_ACCESS_WRITE
- }));
+ public static final Collection<Capability> capabilities = Collections.unmodifiableCollection(
+ Arrays.asList(new Capability[] { Capability.CREATE, Capability.DELETE, Capability.RENAME,
+ Capability.GET_TYPE, Capability.GET_LAST_MODIFIED, Capability.SET_LAST_MODIFIED_FILE,
+ Capability.SET_LAST_MODIFIED_FOLDER, Capability.LIST_CHILDREN, Capability.READ_CONTENT,
+ Capability.URI, Capability.WRITE_CONTENT, Capability.APPEND_CONTENT, Capability.RANDOM_ACCESS_READ,
+ Capability.RANDOM_ACCESS_SET_LENGTH, Capability.RANDOM_ACCESS_WRITE }));
/**
* Constructs a new provider.
*/
- public DefaultLocalFileProvider()
- {
+ public DefaultLocalFileProvider() {
super();
- if (Os.isFamily(Os.OS_FAMILY_WINDOWS))
- {
+ if (Os.isFamily(Os.OS_FAMILY_WINDOWS)) {
setFileNameParser(new WindowsFileNameParser());
- }
- else
- {
+ } else {
setFileNameParser(new GenericFileNameParser());
}
}
/**
* Determines if a name is an absolute file name.
+ *
* @param name The file name.
* @return true if the name is absolute, false otherwise.
*/
@Override
- public boolean isAbsoluteLocalName(final String name)
- {
+ public boolean isAbsoluteLocalName(final String name) {
return ((LocalFileNameParser) getFileNameParser()).isAbsoluteName(name);
}
/**
* Finds a local file, from its local name.
+ *
* @param name The name of the file to locate.
* @return the located FileObject.
* @throws FileSystemException if an error occurs.
*/
@Override
- public FileObject findLocalFile(final String name)
- throws FileSystemException
- {
+ public FileObject findLocalFile(final String name) throws FileSystemException {
final String scheme = "file:";
final StringBuilder uri = new StringBuilder(name.length() + scheme.length());
uri.append(scheme);
@@ -108,14 +87,13 @@ public class DefaultLocalFileProvider
/**
* Finds a local file.
+ *
* @param file The File to locate.
* @return the located FileObject.
* @throws FileSystemException if an error occurs.
*/
@Override
- public FileObject findLocalFile(final File file)
- throws FileSystemException
- {
+ public FileObject findLocalFile(final File file) throws FileSystemException {
return findLocalFile(UriParser.encode(file.getAbsolutePath()));
// return findLocalFile(file.getAbsolutePath());
}
@@ -125,16 +103,14 @@ public class DefaultLocalFileProvider
*/
@Override
protected FileSystem doCreateFileSystem(final FileName name, final FileSystemOptions fileSystemOptions)
- throws FileSystemException
- {
+ throws FileSystemException {
// Create the file system
final LocalFileName rootName = (LocalFileName) name;
return new LocalFileSystem(rootName, rootName.getRootFile(), fileSystemOptions);
}
@Override
- public Collection<Capability> getCapabilities()
- {
+ public Collection<Capability> getCapabilities() {
return capabilities;
}
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/GenericFileNameParser.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/GenericFileNameParser.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/GenericFileNameParser.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/GenericFileNameParser.java Thu Sep 14 19:26:39 2017
@@ -23,9 +23,7 @@ import org.apache.commons.vfs2.FileType;
/**
* A general-purpose file name parser.
*/
-public class GenericFileNameParser
- extends LocalFileNameParser
-{
+public class GenericFileNameParser extends LocalFileNameParser {
private static final GenericFileNameParser INSTANCE = new GenericFileNameParser();
/**
@@ -33,8 +31,7 @@ public class GenericFileNameParser
*
* @return the parser
*/
- public static GenericFileNameParser getInstance()
- {
+ public static GenericFileNameParser getInstance() {
return INSTANCE;
}
@@ -42,15 +39,11 @@ public class GenericFileNameParser
* Pops the root prefix off a URI, which has had the scheme removed.
*/
@Override
- protected String extractRootPrefix(final String uri,
- final StringBuilder name)
- throws FileSystemException
- {
- // TODO - this class isn't generic at all. Need to fix this
+ protected String extractRootPrefix(final String uri, final StringBuilder name) throws FileSystemException {
+ // TODO - this class isn't generic at all. Need to fix this
// Looking for <sep>
- if (name.length() == 0 || name.charAt(0) != '/')
- {
+ if (name.length() == 0 || name.charAt(0) != '/') {
throw new FileSystemException("vfs.provider.local/not-absolute-file-name.error", uri);
}
@@ -59,14 +52,12 @@ public class GenericFileNameParser
}
/*
- * ... this is why whe need this:
- * here the rootFilename can only be "/" (see above) put this "/" is also in the pathname
- * so its of no value for the LocalFileName instance
+ * ... this is why whe need this: here the rootFilename can only be "/" (see above) put this "/" is also in the
+ * pathname so its of no value for the LocalFileName instance
*/
@Override
- protected FileName createFileName(final String scheme, final String rootFile,
- final String path, final FileType type)
- {
+ protected FileName createFileName(final String scheme, final String rootFile, final String path,
+ final FileType type) {
return new LocalFileName(scheme, "", path, type);
}
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFile.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFile.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFile.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFile.java Thu Sep 14 19:26:39 2017
@@ -36,8 +36,7 @@ import org.apache.commons.vfs2.util.Rand
/**
* A file object implementation which uses direct file access.
*/
-public class LocalFile extends AbstractFileObject<LocalFileSystem>
-{
+public class LocalFile extends AbstractFileObject<LocalFileSystem> {
private final String rootFile;
private File file;
@@ -50,10 +49,8 @@ public class LocalFile extends AbstractF
* @param name the file name on this file system.
* @throws FileSystemException if an error occurs.
*/
- protected LocalFile(final LocalFileSystem fileSystem,
- final String rootFile,
- final AbstractFileName name) throws FileSystemException
- {
+ protected LocalFile(final LocalFileSystem fileSystem, final String rootFile, final AbstractFileName name)
+ throws FileSystemException {
super(name, fileSystem);
this.rootFile = rootFile;
}
@@ -63,8 +60,7 @@ public class LocalFile extends AbstractF
*
* @return the local file that this file object represents.
*/
- protected File getLocalFile()
- {
+ protected File getLocalFile() {
return file;
}
@@ -72,10 +68,8 @@ public class LocalFile extends AbstractF
* Attaches this file object to its file resource.
*/
@Override
- protected void doAttach() throws Exception
- {
- if (file == null)
- {
+ protected void doAttach() throws Exception {
+ if (file == null) {
// Remove the "file:///"
// LocalFileName localFileName = (LocalFileName) getName();
final String fileName = rootFile + getName().getPathDecoded();
@@ -88,24 +82,21 @@ public class LocalFile extends AbstractF
* Returns the file's type.
*/
@Override
- protected FileType doGetType() throws Exception
- {
+ protected FileType doGetType() throws Exception {
// JDK BUG: 6192331
// if (!file.exists())
- if (!file.exists() && file.length() < 1)
- {
+ if (!file.exists() && file.length() < 1) {
return FileType.IMAGINARY;
}
- if (file.isDirectory())
- {
+ if (file.isDirectory()) {
return FileType.FOLDER;
}
// In doubt, treat an existing file as file
// if (file.isFile())
// {
- return FileType.FILE;
+ return FileType.FILE;
// }
// throw new FileSystemException("vfs.provider.local/get-type.error", file);
@@ -115,8 +106,7 @@ public class LocalFile extends AbstractF
* Returns the children of the file.
*/
@Override
- protected String[] doListChildren() throws Exception
- {
+ protected String[] doListChildren() throws Exception {
return UriParser.encode(file.list());
}
@@ -124,10 +114,8 @@ public class LocalFile extends AbstractF
* Deletes this file, and all children.
*/
@Override
- protected void doDelete() throws Exception
- {
- if (!file.delete())
- {
+ protected void doDelete() throws Exception {
+ if (!file.delete()) {
throw new FileSystemException("vfs.provider.local/delete-file.error", file);
}
}
@@ -136,14 +124,11 @@ public class LocalFile extends AbstractF
* rename this file
*/
@Override
- protected void doRename(final FileObject newFile) throws Exception
- {
+ protected void doRename(final FileObject newFile) throws Exception {
final LocalFile newLocalFile = (LocalFile) FileObjectUtils.getAbstractFileObject(newFile);
- if (!file.renameTo(newLocalFile.getLocalFile()))
- {
- throw new FileSystemException("vfs.provider.local/rename-file.error",
- file.toString(), newFile.toString());
+ if (!file.renameTo(newLocalFile.getLocalFile())) {
+ throw new FileSystemException("vfs.provider.local/rename-file.error", file.toString(), newFile.toString());
}
}
@@ -151,10 +136,8 @@ public class LocalFile extends AbstractF
* Creates this folder.
*/
@Override
- protected void doCreateFolder() throws Exception
- {
- if (!file.mkdirs())
- {
+ protected void doCreateFolder() throws Exception {
+ if (!file.mkdirs()) {
throw new FileSystemException("vfs.provider.local/create-folder.error", file);
}
}
@@ -163,14 +146,12 @@ public class LocalFile extends AbstractF
* Determines if this file can be written to.
*/
@Override
- protected boolean doIsWriteable() throws FileSystemException
- {
+ protected boolean doIsWriteable() throws FileSystemException {
return file.canWrite();
}
@Override
- protected boolean doSetWritable(final boolean writable, final boolean ownerOnly) throws Exception
- {
+ protected boolean doSetWritable(final boolean writable, final boolean ownerOnly) throws Exception {
return file.setWritable(writable, ownerOnly);
}
@@ -178,8 +159,7 @@ public class LocalFile extends AbstractF
* Determines if this file is hidden.
*/
@Override
- protected boolean doIsExecutable()
- {
+ protected boolean doIsExecutable() {
return file.canExecute();
}
@@ -187,8 +167,7 @@ public class LocalFile extends AbstractF
* Determines if this file is hidden.
*/
@Override
- protected boolean doIsHidden()
- {
+ protected boolean doIsHidden() {
return file.isHidden();
}
@@ -196,20 +175,17 @@ public class LocalFile extends AbstractF
* Determines if this file can be read.
*/
@Override
- protected boolean doIsReadable() throws FileSystemException
- {
+ protected boolean doIsReadable() throws FileSystemException {
return file.canRead();
}
@Override
- protected boolean doSetReadable(final boolean readable, final boolean ownerOnly) throws Exception
- {
+ protected boolean doSetReadable(final boolean readable, final boolean ownerOnly) throws Exception {
return file.setReadable(readable, ownerOnly);
}
@Override
- protected boolean doSetExecutable(final boolean executable, final boolean ownerOnly) throws Exception
- {
+ protected boolean doSetExecutable(final boolean executable, final boolean ownerOnly) throws Exception {
return file.setExecutable(executable, ownerOnly);
}
@@ -217,18 +193,17 @@ public class LocalFile extends AbstractF
* Gets the last modified time of this file.
*/
@Override
- protected long doGetLastModifiedTime() throws FileSystemException
- {
+ protected long doGetLastModifiedTime() throws FileSystemException {
return file.lastModified();
}
/**
* Sets the last modified time of this file.
+ *
* @since 2.0
*/
@Override
- protected boolean doSetLastModifiedTime(final long modtime) throws FileSystemException
- {
+ protected boolean doSetLastModifiedTime(final long modtime) throws FileSystemException {
return file.setLastModified(modtime);
}
@@ -236,8 +211,7 @@ public class LocalFile extends AbstractF
* Creates an input stream to read the content from.
*/
@Override
- protected InputStream doGetInputStream() throws Exception
- {
+ protected InputStream doGetInputStream() throws Exception {
return new FileInputStream(file);
}
@@ -245,9 +219,7 @@ public class LocalFile extends AbstractF
* Creates an output stream to write the file content to.
*/
@Override
- protected OutputStream doGetOutputStream(final boolean bAppend)
- throws Exception
- {
+ protected OutputStream doGetOutputStream(final boolean bAppend) throws Exception {
return new FileOutputStream(file.getPath(), bAppend);
}
@@ -255,56 +227,45 @@ public class LocalFile extends AbstractF
* Returns the size of the file content (in bytes).
*/
@Override
- protected long doGetContentSize() throws Exception
- {
+ protected long doGetContentSize() throws Exception {
return file.length();
}
@Override
- protected RandomAccessContent doGetRandomAccessContent(final RandomAccessMode mode) throws Exception
- {
+ protected RandomAccessContent doGetRandomAccessContent(final RandomAccessMode mode) throws Exception {
return new LocalFileRandomAccessContent(file, mode);
}
@Override
- protected boolean doIsSameFile(final FileObject destFile) throws FileSystemException
- {
- if (!FileObjectUtils.isInstanceOf(destFile, LocalFile.class))
- {
+ protected boolean doIsSameFile(final FileObject destFile) throws FileSystemException {
+ if (!FileObjectUtils.isInstanceOf(destFile, LocalFile.class)) {
return false;
}
final LocalFile destLocalFile = (LocalFile) FileObjectUtils.getAbstractFileObject(destFile);
- if (!exists() || !destLocalFile.exists())
- {
+ if (!exists() || !destLocalFile.exists()) {
return false;
}
- try
- {
+ try {
return file.getCanonicalPath().equals(destLocalFile.file.getCanonicalPath());
- }
- catch (final IOException e)
- {
+ } catch (final IOException e) {
throw new FileSystemException(e);
}
}
/**
* Returns the URI of the file.
+ *
* @return The URI of the file.
*/
@Override
- public String toString()
- {
- try
- {
+ public String toString() {
+ try {
// VFS-325: URI may contain percent-encoded values as part of filename, so decode
// those characters before returning
return UriParser.decode(getName().getURI());
- }
- catch (final FileSystemException e)
- {
+ } catch (final FileSystemException e) {
return getName().getURI();
}
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileName.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileName.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileName.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileName.java Thu Sep 14 19:26:39 2017
@@ -25,76 +25,66 @@ import org.apache.commons.vfs2.provider.
/**
* A local file URI.
*/
-public class LocalFileName extends AbstractFileName
-{
+public class LocalFileName extends AbstractFileName {
// URI Characters that are possible in local filenames, but must be escaped
// for proper URI handling.
//
// How reserved URI chars were selected:
//
- // URIs can contain :, /, ?, #, @
- // See http://download.oracle.com/javase/6/docs/api/java/net/URI.html
- // http://tools.ietf.org/html/rfc3986#section-2.2
+ // URIs can contain :, /, ?, #, @
+ // See http://download.oracle.com/javase/6/docs/api/java/net/URI.html
+ // http://tools.ietf.org/html/rfc3986#section-2.2
//
- // Since : and / occur before the path, only chars after path are escaped (i.e., # and ?)
- // ? is a reserved filesystem character for Windows and Unix, so can't be part of a filename.
- // Therefore only # is a reserved char in a URI as part of the path that can be in the filename.
- private static final char[] RESERVED_URI_CHARS = {'#'};
-
+ // Since : and / occur before the path, only chars after path are escaped (i.e., # and ?)
+ // ? is a reserved filesystem character for Windows and Unix, so can't be part of a filename.
+ // Therefore only # is a reserved char in a URI as part of the path that can be in the filename.
+ private static final char[] RESERVED_URI_CHARS = { '#' };
private final String rootFile;
- protected LocalFileName(final String scheme,
- final String rootFile,
- final String path,
- final FileType type)
- {
+ protected LocalFileName(final String scheme, final String rootFile, final String path, final FileType type) {
super(scheme, path, type);
this.rootFile = rootFile;
}
/**
* Returns the root file for this file.
+ *
* @return The root file name.
*/
- public String getRootFile()
- {
+ public String getRootFile() {
return rootFile;
}
/**
* Factory method for creating name instances.
+ *
* @param path The file path.
* @param type The file type.
* @return The FileName.
*/
@Override
- public FileName createName(final String path, final FileType type)
- {
+ public FileName createName(final String path, final FileType type) {
return new LocalFileName(getScheme(), rootFile, path, type);
}
/**
* Returns the absolute URI of the file.
+ *
* @return The absolute URI of the file.
*/
@Override
- public String getURI()
- {
+ public String getURI() {
String uri = super.getURI();
- if (uri != null && uri.length() > 0)
- {
- try
- {
+ if (uri != null && uri.length() > 0) {
+ try {
// VFS-325: Handle URI special characters in filename
// Decode the base uri and re-encode with URI special characters
uri = UriParser.decode(uri);
uri = UriParser.encode(uri, RESERVED_URI_CHARS);
- }
- catch (final FileSystemException e)
- {
+ } catch (final FileSystemException e) {
// Default to base uri value
}
}
@@ -104,25 +94,21 @@ public class LocalFileName extends Abstr
/**
* returns a "friendly path", this is a path without a password.
+ *
* @return The "friendly" URI.
*/
@Override
- public String getFriendlyURI()
- {
+ public String getFriendlyURI() {
String uri = super.getFriendlyURI();
- if (uri != null && uri.length() > 0)
- {
- try
- {
+ if (uri != null && uri.length() > 0) {
+ try {
// VFS-325: Handle URI special characters in filename
// Decode the base uri and re-encode with URI special characters
uri = UriParser.decode(uri);
uri = UriParser.encode(uri, RESERVED_URI_CHARS);
- }
- catch (final FileSystemException e)
- {
+ } catch (final FileSystemException e) {
// Default to base uri value
}
}
@@ -132,29 +118,23 @@ public class LocalFileName extends Abstr
/**
* Returns the decoded URI of the file.
+ *
* @return the FileName as a URI.
*/
@Override
- public String toString()
- {
- try
- {
+ public String toString() {
+ try {
return UriParser.decode(super.getURI());
- }
- catch (final FileSystemException e)
- {
+ } catch (final FileSystemException e) {
return super.getURI();
}
}
-
-
/**
* Builds the root URI for this file name.
*/
@Override
- protected void appendRootUri(final StringBuilder buffer, final boolean addPassword)
- {
+ protected void appendRootUri(final StringBuilder buffer, final boolean addPassword) {
buffer.append(getScheme());
buffer.append("://");
buffer.append(rootFile);
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileNameParser.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileNameParser.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileNameParser.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileNameParser.java Thu Sep 14 19:26:39 2017
@@ -26,25 +26,21 @@ import org.apache.commons.vfs2.provider.
/**
* A name parser.
*/
-public abstract class LocalFileNameParser extends AbstractFileNameParser
-{
+public abstract class LocalFileNameParser extends AbstractFileNameParser {
/**
* Determines if a name is an absolute file name.
+ *
* @param name The file name.
* @return true if the name is absolute, false otherwise.
*/
- public boolean isAbsoluteName(final String name)
- {
+ public boolean isAbsoluteName(final String name) {
// TODO - this is yucky
final StringBuilder b = new StringBuilder(name);
- try
- {
+ try {
UriParser.fixSeparators(b);
extractRootPrefix(name, b);
return true;
- }
- catch (final FileSystemException e)
- {
+ } catch (final FileSystemException e) {
return false;
}
}
@@ -57,21 +53,16 @@ public abstract class LocalFileNameParse
* @return the root prefix extracted.
* @throws FileSystemException if an error occurs.
*/
- protected abstract String extractRootPrefix(final String uri,
- final StringBuilder name)
- throws FileSystemException;
-
+ protected abstract String extractRootPrefix(final String uri, final StringBuilder name) throws FileSystemException;
@Override
public FileName parseUri(final VfsComponentContext context, final FileName base, final String uri)
- throws FileSystemException
- {
+ throws FileSystemException {
final StringBuilder name = new StringBuilder();
// Extract the scheme
String scheme = UriParser.extractScheme(uri, name);
- if (scheme == null)
- {
+ if (scheme == null) {
scheme = "file";
}
@@ -88,13 +79,9 @@ public abstract class LocalFileNameParse
final String path = name.toString();
- return createFileName(
- scheme,
- rootFile,
- path,
- fileType);
+ return createFileName(scheme, rootFile, path, fileType);
}
protected abstract FileName createFileName(String scheme, final String rootFile, final String path,
- final FileType type);
+ final FileType type);
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileRandomAccessContent.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileRandomAccessContent.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileRandomAccessContent.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileRandomAccessContent.java Thu Sep 14 19:26:39 2017
@@ -30,279 +30,229 @@ import org.apache.commons.vfs2.util.Rand
/**
* Implements {@link org.apache.commons.vfs2.RandomAccessContent RandomAccessContent} for local files.
*/
-class LocalFileRandomAccessContent extends AbstractRandomAccessContent
-{
+class LocalFileRandomAccessContent extends AbstractRandomAccessContent {
// private final LocalFile localFile;
private final RandomAccessFile raf;
private final InputStream rafis;
- LocalFileRandomAccessContent(final File localFile, final RandomAccessMode mode) throws FileSystemException
- {
+ LocalFileRandomAccessContent(final File localFile, final RandomAccessMode mode) throws FileSystemException {
super(mode);
- try
- {
+ try {
raf = new RandomAccessFile(localFile, mode.getModeString());
- rafis = new InputStream()
- {
+ rafis = new InputStream() {
@Override
- public int read() throws IOException
- {
- try
- {
+ public int read() throws IOException {
+ try {
return raf.readByte();
- }
- catch (final EOFException e)
- {
+ } catch (final EOFException e) {
return -1;
}
}
@Override
- public long skip(final long n) throws IOException
- {
+ public long skip(final long n) throws IOException {
raf.seek(raf.getFilePointer() + n);
return n;
}
@Override
- public void close() throws IOException
- {
+ public void close() throws IOException {
raf.close();
}
@Override
- public int read(final byte[] b) throws IOException
- {
+ public int read(final byte[] b) throws IOException {
return raf.read(b);
}
@Override
- public int read(final byte[] b, final int off, final int len) throws IOException
- {
+ public int read(final byte[] b, final int off, final int len) throws IOException {
return raf.read(b, off, len);
}
@Override
- public int available() throws IOException
- {
+ public int available() throws IOException {
final long available = raf.length() - raf.getFilePointer();
- if (available > Integer.MAX_VALUE)
- {
+ if (available > Integer.MAX_VALUE) {
return Integer.MAX_VALUE;
}
return (int) available;
}
};
- }
- catch (final FileNotFoundException e)
- {
+ } catch (final FileNotFoundException e) {
throw new FileSystemException("vfs.provider/random-access-open-failed.error", localFile);
}
}
@Override
- public long getFilePointer() throws IOException
- {
+ public long getFilePointer() throws IOException {
return raf.getFilePointer();
}
@Override
- public void seek(final long pos) throws IOException
- {
+ public void seek(final long pos) throws IOException {
raf.seek(pos);
}
@Override
- public long length() throws IOException
- {
+ public long length() throws IOException {
return raf.length();
}
@Override
- public void close() throws IOException
- {
+ public void close() throws IOException {
raf.close();
}
@Override
- public byte readByte() throws IOException
- {
+ public byte readByte() throws IOException {
return raf.readByte();
}
@Override
- public char readChar() throws IOException
- {
+ public char readChar() throws IOException {
return raf.readChar();
}
@Override
- public double readDouble() throws IOException
- {
+ public double readDouble() throws IOException {
return raf.readDouble();
}
@Override
- public float readFloat() throws IOException
- {
+ public float readFloat() throws IOException {
return raf.readFloat();
}
@Override
- public int readInt() throws IOException
- {
+ public int readInt() throws IOException {
return raf.readInt();
}
@Override
- public int readUnsignedByte() throws IOException
- {
+ public int readUnsignedByte() throws IOException {
return raf.readUnsignedByte();
}
@Override
- public int readUnsignedShort() throws IOException
- {
+ public int readUnsignedShort() throws IOException {
return raf.readUnsignedShort();
}
@Override
- public long readLong() throws IOException
- {
+ public long readLong() throws IOException {
return raf.readLong();
}
@Override
- public short readShort() throws IOException
- {
+ public short readShort() throws IOException {
return raf.readShort();
}
@Override
- public boolean readBoolean() throws IOException
- {
+ public boolean readBoolean() throws IOException {
return raf.readBoolean();
}
@Override
- public int skipBytes(final int n) throws IOException
- {
+ public int skipBytes(final int n) throws IOException {
return raf.skipBytes(n);
}
@Override
- public void readFully(final byte[] b) throws IOException
- {
+ public void readFully(final byte[] b) throws IOException {
raf.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 {
raf.readFully(b, off, len);
}
@Override
- public String readUTF() throws IOException
- {
+ public String readUTF() throws IOException {
return raf.readUTF();
}
@Override
- public void writeDouble(final double v) throws IOException
- {
+ public void writeDouble(final double v) throws IOException {
raf.writeDouble(v);
}
@Override
- public void writeFloat(final float v) throws IOException
- {
+ public void writeFloat(final float v) throws IOException {
raf.writeFloat(v);
}
@Override
- public void write(final int b) throws IOException
- {
+ public void write(final int b) throws IOException {
raf.write(b);
}
@Override
- public void writeByte(final int v) throws IOException
- {
+ public void writeByte(final int v) throws IOException {
raf.writeByte(v);
}
@Override
- public void writeChar(final int v) throws IOException
- {
+ public void writeChar(final int v) throws IOException {
raf.writeChar(v);
}
@Override
- public void writeInt(final int v) throws IOException
- {
+ public void writeInt(final int v) throws IOException {
raf.writeInt(v);
}
@Override
- public void writeShort(final int v) throws IOException
- {
+ public void writeShort(final int v) throws IOException {
raf.writeShort(v);
}
@Override
- public void writeLong(final long v) throws IOException
- {
+ public void writeLong(final long v) throws IOException {
raf.writeLong(v);
}
@Override
- public void writeBoolean(final boolean v) throws IOException
- {
+ public void writeBoolean(final boolean v) throws IOException {
raf.writeBoolean(v);
}
@Override
- public void write(final byte[] b) throws IOException
- {
+ public void write(final byte[] b) throws IOException {
raf.write(b);
}
@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 {
raf.write(b, off, len);
}
@Override
- public void writeBytes(final String s) throws IOException
- {
+ public void writeBytes(final String s) throws IOException {
raf.writeBytes(s);
}
@Override
- public void writeChars(final String s) throws IOException
- {
+ public void writeChars(final String s) throws IOException {
raf.writeChars(s);
}
@Override
- public void writeUTF(final String str) throws IOException
- {
+ public void writeUTF(final String str) throws IOException {
raf.writeUTF(str);
}
@Override
- public InputStream getInputStream() throws IOException
- {
+ public InputStream getInputStream() throws IOException {
return rafis;
}
@Override
- public void setLength(final long newLength) throws IOException
- {
+ public void setLength(final long newLength) throws IOException {
raf.setLength(newLength);
}
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileSystem.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileSystem.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileSystem.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/LocalFileSystem.java Thu Sep 14 19:26:39 2017
@@ -33,15 +33,10 @@ import org.apache.commons.vfs2.util.File
/**
* A local file system.
*/
-public class LocalFileSystem
- extends AbstractFileSystem
-{
+public class LocalFileSystem extends AbstractFileSystem {
private final String rootFile;
- public LocalFileSystem(final FileName rootName,
- final String rootFile,
- final FileSystemOptions opts)
- {
+ public LocalFileSystem(final FileName rootName, final String rootFile, final FileSystemOptions opts) {
super(rootName, null, opts);
this.rootFile = rootFile;
}
@@ -50,8 +45,7 @@ public class LocalFileSystem
* Creates a file object.
*/
@Override
- protected FileObject createFile(final AbstractFileName name) throws FileSystemException
- {
+ protected FileObject createFile(final AbstractFileName name) throws FileSystemException {
// Create the file
return new LocalFile(this, rootFile, name);
}
@@ -60,8 +54,7 @@ public class LocalFileSystem
* Returns the capabilities of this file system.
*/
@Override
- protected void addCapabilities(final Collection<Capability> caps)
- {
+ protected void addCapabilities(final Collection<Capability> caps) {
caps.addAll(DefaultLocalFileProvider.capabilities);
}
@@ -69,15 +62,11 @@ public class LocalFileSystem
* Creates a temporary local copy of a file and its descendants.
*/
@Override
- protected File doReplicateFile(final FileObject fileObject,
- final FileSelector selector)
- throws Exception
- {
+ protected File doReplicateFile(final FileObject fileObject, final FileSelector selector) throws Exception {
final LocalFile localFile = (LocalFile) FileObjectUtils.getAbstractFileObject(fileObject);
final File file = localFile.getLocalFile();
final SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- {
+ if (sm != null) {
final FilePermission requiredPerm = new FilePermission(file.getAbsolutePath(), "read");
sm.checkPermission(requiredPerm);
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/WindowsFileName.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/WindowsFileName.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/WindowsFileName.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/local/WindowsFileName.java Thu Sep 14 19:26:39 2017
@@ -22,25 +22,20 @@ import org.apache.commons.vfs2.FileType;
/**
* A local file URI.
*/
-public class WindowsFileName extends LocalFileName
-{
- protected WindowsFileName(final String scheme,
- final String rootFile,
- final String path,
- final FileType type)
- {
+public class WindowsFileName extends LocalFileName {
+ protected WindowsFileName(final String scheme, final String rootFile, final String path, final FileType type) {
super(scheme, rootFile, path, type);
}
/**
* Factory method for creating name instances.
+ *
* @param path The file path.
* @param type The file type.
* @return The FileName.
*/
@Override
- public FileName createName(final String path, final FileType type)
- {
+ public FileName createName(final String path, final FileType type) {
return new WindowsFileName(getScheme(), getRootFile(), path, type);
}
@@ -48,12 +43,10 @@ public class WindowsFileName extends Loc
* Builds the root URI for this file name.
*/
@Override
- protected void appendRootUri(final StringBuilder buffer, final boolean addPassword)
- {
+ protected void appendRootUri(final StringBuilder buffer, final boolean addPassword) {
buffer.append(getScheme());
buffer.append("://");
- if (getRootFile() != null && !getRootFile().startsWith("/"))
- {
+ if (getRootFile() != null && !getRootFile().startsWith("/")) {
// next is drive-letter (else unc name)
buffer.append("/");
}