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 [10/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/DefaultFileContent.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/DefaultFileContent.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/DefaultFileContent.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/DefaultFileContent.java Thu Sep 14 19:26:39 2017
@@ -38,14 +38,11 @@ import org.apache.commons.vfs2.util.Rand
/**
* The content of a file.
*/
-public final class DefaultFileContent implements FileContent
-{
+public final class DefaultFileContent implements FileContent {
/*
- static final int STATE_NONE = 0;
- static final int STATE_READING = 1;
- static final int STATE_WRITING = 2;
- static final int STATE_RANDOM_ACCESS = 3;
- */
+ * static final int STATE_NONE = 0; static final int STATE_READING = 1; static final int STATE_WRITING = 2; static
+ * final int STATE_RANDOM_ACCESS = 3;
+ */
static final int STATE_CLOSED = 0;
static final int STATE_OPENED = 1;
@@ -69,41 +66,32 @@ public final class DefaultFileContent im
*/
private int openStreams;
- public DefaultFileContent(final AbstractFileObject file, final FileContentInfoFactory fileContentInfoFactory)
- {
+ public DefaultFileContent(final AbstractFileObject file, final FileContentInfoFactory fileContentInfoFactory) {
this.fileObject = file;
this.fileContentInfoFactory = fileContentInfoFactory;
}
- private FileContentThreadData getOrCreateThreadData()
- {
+ private FileContentThreadData getOrCreateThreadData() {
FileContentThreadData data = this.threadData.get();
- if (data == null)
- {
+ if (data == null) {
data = new FileContentThreadData();
this.threadData.set(data);
}
return data;
}
- void streamOpened()
- {
- synchronized (this)
- {
+ void streamOpened() {
+ synchronized (this) {
openStreams++;
}
((AbstractFileSystem) fileObject.getFileSystem()).streamOpened();
}
- void streamClosed()
- {
- synchronized (this)
- {
- if (openStreams > 0)
- {
+ void streamClosed() {
+ synchronized (this) {
+ if (openStreams > 0) {
openStreams--;
- if (openStreams < 1)
- {
+ if (openStreams < 1) {
fileObject.notifyAllStreamsClosed();
}
}
@@ -113,116 +101,96 @@ public final class DefaultFileContent im
/**
* Returns the file that this is the content of.
+ *
* @return the FileObject.
*/
@Override
- public FileObject getFile()
- {
+ public FileObject getFile() {
return fileObject;
}
/**
* Returns the size of the content (in bytes).
+ *
* @return The size of the content (in bytes).
* @throws FileSystemException if an error occurs.
*/
@Override
- public long getSize() throws FileSystemException
- {
+ public long getSize() throws FileSystemException {
// Do some checking
- if (!fileObject.getType().hasContent())
- {
+ if (!fileObject.getType().hasContent()) {
throw new FileSystemException("vfs.provider/get-size-not-file.error", fileObject);
}
/*
- if (getThreadData().getState() == STATE_WRITING || getThreadData().getState() == STATE_RANDOM_ACCESS)
- {
- throw new FileSystemException("vfs.provider/get-size-write.error", file);
- }
- */
+ * if (getThreadData().getState() == STATE_WRITING || getThreadData().getState() == STATE_RANDOM_ACCESS) { throw
+ * new FileSystemException("vfs.provider/get-size-write.error", file); }
+ */
- try
- {
+ try {
// Get the size
return fileObject.doGetContentSize();
- }
- catch (final Exception exc)
- {
+ } catch (final Exception exc) {
throw new FileSystemException("vfs.provider/get-size.error", exc, fileObject);
}
}
/**
* Returns the last-modified timestamp.
+ *
* @return The last modified timestamp.
* @throws FileSystemException if an error occurs.
*/
@Override
- public long getLastModifiedTime() throws FileSystemException
- {
+ public long getLastModifiedTime() throws FileSystemException {
/*
- if (getThreadData().getState() == STATE_WRITING || getThreadData().getState() == STATE_RANDOM_ACCESS)
- {
- throw new FileSystemException("vfs.provider/get-last-modified-writing.error", file);
- }
- */
- if (!fileObject.getType().hasAttributes())
- {
+ * if (getThreadData().getState() == STATE_WRITING || getThreadData().getState() == STATE_RANDOM_ACCESS) { throw
+ * new FileSystemException("vfs.provider/get-last-modified-writing.error", file); }
+ */
+ if (!fileObject.getType().hasAttributes()) {
throw new FileSystemException("vfs.provider/get-last-modified-no-exist.error", fileObject);
}
- try
- {
+ try {
return fileObject.doGetLastModifiedTime();
- }
- catch (final Exception e)
- {
+ } catch (final Exception e) {
throw new FileSystemException("vfs.provider/get-last-modified.error", fileObject, e);
}
}
/**
* Sets the last-modified timestamp.
+ *
* @param modTime The last modified timestamp.
* @throws FileSystemException if an error occurs.
*/
@Override
- public void setLastModifiedTime(final long modTime) throws FileSystemException
- {
+ public void setLastModifiedTime(final long modTime) throws FileSystemException {
/*
- if (getThreadData().getState() == STATE_WRITING || getThreadData().getState() == STATE_RANDOM_ACCESS)
- {
- throw new FileSystemException("vfs.provider/set-last-modified-writing.error", file);
- }
- */
- if (!fileObject.getType().hasAttributes())
- {
+ * if (getThreadData().getState() == STATE_WRITING || getThreadData().getState() == STATE_RANDOM_ACCESS) { throw
+ * new FileSystemException("vfs.provider/set-last-modified-writing.error", file); }
+ */
+ if (!fileObject.getType().hasAttributes()) {
throw new FileSystemException("vfs.provider/set-last-modified-no-exist.error", fileObject);
}
- try
- {
- if (!fileObject.doSetLastModifiedTime(modTime))
- {
+ try {
+ if (!fileObject.doSetLastModifiedTime(modTime)) {
throw new FileSystemException("vfs.provider/set-last-modified.error", fileObject);
}
- }
- catch (final Exception e)
- {
+ } catch (final Exception e) {
throw new FileSystemException("vfs.provider/set-last-modified.error", fileObject, e);
}
}
/**
* Checks if an attribute exists.
+ *
* @param attrName The name of the attribute to check.
* @return true if the attribute is associated with the file.
* @throws FileSystemException if an error occurs.
* @since 2.0
*/
@Override
- public boolean hasAttribute(final String attrName) throws FileSystemException
- {
- if (!fileObject.getType().hasAttributes())
- {
+ public boolean hasAttribute(final String attrName) throws FileSystemException {
+ if (!fileObject.getType().hasAttributes()) {
throw new FileSystemException("vfs.provider/exists-attributes-no-exist.error", fileObject);
}
getAttributes();
@@ -231,29 +199,23 @@ public final class DefaultFileContent im
/**
* Returns a read-only map of this file's attributes.
+ *
* @return a Map of the file's attributes.
* @throws FileSystemException if an error occurs.
*/
@Override
- public Map<String, Object> getAttributes() throws FileSystemException
- {
- if (!fileObject.getType().hasAttributes())
- {
+ public Map<String, Object> getAttributes() throws FileSystemException {
+ if (!fileObject.getType().hasAttributes()) {
throw new FileSystemException("vfs.provider/get-attributes-no-exist.error", fileObject);
}
- if (resetAttributes || roAttrs == null)
- {
- try
- {
- synchronized (this)
- {
+ if (resetAttributes || roAttrs == null) {
+ try {
+ synchronized (this) {
attrs = fileObject.doGetAttributes();
roAttrs = Collections.unmodifiableMap(attrs);
resetAttributes = false;
}
- }
- catch (final Exception e)
- {
+ } catch (final Exception e) {
throw new FileSystemException("vfs.provider/get-attributes.error", fileObject, e);
}
}
@@ -261,23 +223,22 @@ public final class DefaultFileContent im
}
/**
- * Used internally to flag situations where the file attributes should be
- * reretrieved.
+ * Used internally to flag situations where the file attributes should be reretrieved.
+ *
* @since 2.0
*/
- public void resetAttributes()
- {
+ public void resetAttributes() {
resetAttributes = true;
}
/**
* Lists the attributes of this file.
+ *
* @return An array of attribute names.
* @throws FileSystemException if an error occurs.
*/
@Override
- public String[] getAttributeNames() throws FileSystemException
- {
+ public String[] getAttributeNames() throws FileSystemException {
getAttributes();
final Set<String> names = attrs.keySet();
return names.toArray(new String[names.size()]);
@@ -285,124 +246,103 @@ public final class DefaultFileContent im
/**
* Gets the value of an attribute.
+ *
* @param attrName The attribute name.
* @return The value of the attribute or null.
* @throws FileSystemException if an error occurs.
*/
@Override
- public Object getAttribute(final String attrName)
- throws FileSystemException
- {
+ public Object getAttribute(final String attrName) throws FileSystemException {
getAttributes();
return attrs.get(attrName);
}
/**
* Sets the value of an attribute.
+ *
* @param attrName The name of the attribute to add.
* @param value The value of the attribute.
* @throws FileSystemException if an error occurs.
*/
@Override
- public void setAttribute(final String attrName, final Object value)
- throws FileSystemException
- {
- if (!fileObject.getType().hasAttributes())
- {
+ public void setAttribute(final String attrName, final Object value) throws FileSystemException {
+ if (!fileObject.getType().hasAttributes()) {
throw new FileSystemException("vfs.provider/set-attribute-no-exist.error", attrName, fileObject);
}
- try
- {
+ try {
fileObject.doSetAttribute(attrName, value);
- }
- catch (final Exception e)
- {
+ } catch (final Exception e) {
throw new FileSystemException("vfs.provider/set-attribute.error", e, attrName, fileObject);
}
- if (attrs != null)
- {
+ if (attrs != null) {
attrs.put(attrName, value);
}
}
/**
* Removes an attribute.
+ *
* @param attrName The name of the attribute to remove.
* @throws FileSystemException if an error occurs.
* @since 2.0
*/
@Override
- public void removeAttribute(final String attrName) throws FileSystemException
- {
- if (!fileObject.getType().hasAttributes())
- {
+ public void removeAttribute(final String attrName) throws FileSystemException {
+ if (!fileObject.getType().hasAttributes()) {
throw new FileSystemException("vfs.provider/remove-attribute-no-exist.error", fileObject);
}
- try
- {
+ try {
fileObject.doRemoveAttribute(attrName);
- }
- catch (final Exception e)
- {
+ } catch (final Exception e) {
throw new FileSystemException("vfs.provider/remove-attribute.error", e, attrName, fileObject);
}
- if (attrs != null)
- {
+ if (attrs != null) {
attrs.remove(attrName);
}
}
/**
* Returns the certificates used to sign this file.
+ *
* @return An array of Certificates.
* @throws FileSystemException if an error occurs.
*/
@Override
- public Certificate[] getCertificates() throws FileSystemException
- {
- if (!fileObject.exists())
- {
+ public Certificate[] getCertificates() throws FileSystemException {
+ if (!fileObject.exists()) {
throw new FileSystemException("vfs.provider/get-certificates-no-exist.error", fileObject);
}
/*
- if (getThreadData().getState() == STATE_WRITING || getThreadData().getState() == STATE_RANDOM_ACCESS)
- {
- throw new FileSystemException("vfs.provider/get-certificates-writing.error", file);
- }
- */
+ * if (getThreadData().getState() == STATE_WRITING || getThreadData().getState() == STATE_RANDOM_ACCESS) { throw
+ * new FileSystemException("vfs.provider/get-certificates-writing.error", file); }
+ */
- try
- {
+ try {
final Certificate[] certs = fileObject.doGetCertificates();
- if (certs != null)
- {
+ if (certs != null) {
return certs;
}
return new Certificate[0];
- }
- catch (final Exception e)
- {
+ } catch (final Exception e) {
throw new FileSystemException("vfs.provider/get-certificates.error", fileObject, e);
}
}
/**
* Returns an input stream for reading the content.
+ *
* @return The InputStream
* @throws FileSystemException if an error occurs.
*/
@Override
- public InputStream getInputStream() throws FileSystemException
- {
+ public InputStream getInputStream() throws FileSystemException {
/*
- if (getThreadData().getState() == STATE_WRITING || getThreadData().getState() == STATE_RANDOM_ACCESS)
- {
- throw new FileSystemException("vfs.provider/read-in-use.error", file);
- }
- */
+ * if (getThreadData().getState() == STATE_WRITING || getThreadData().getState() == STATE_RANDOM_ACCESS) { throw
+ * new FileSystemException("vfs.provider/read-in-use.error", file); }
+ */
// Get the raw input stream
final InputStream inputStream = fileObject.getInputStream();
@@ -416,21 +356,18 @@ public final class DefaultFileContent im
}
/**
- * Returns an input/output stream to use to read and write the content of the file in an
- * random manner.
+ * Returns an input/output stream to use to read and write the content of the file in an random manner.
+ *
* @param mode The RandomAccessMode.
* @return A RandomAccessContent object to access the file.
* @throws FileSystemException if an error occurs.
*/
@Override
- public RandomAccessContent getRandomAccessContent(final RandomAccessMode mode) throws FileSystemException
- {
+ public RandomAccessContent getRandomAccessContent(final RandomAccessMode mode) throws FileSystemException {
/*
- if (getThreadData().getState() != STATE_NONE)
- {
- throw new FileSystemException("vfs.provider/read-in-use.error", file);
- }
- */
+ * if (getThreadData().getState() != STATE_NONE) { throw new
+ * FileSystemException("vfs.provider/read-in-use.error", file); }
+ */
// Get the content
final RandomAccessContent rastr = fileObject.getRandomAccessContent(mode);
@@ -445,30 +382,29 @@ public final class DefaultFileContent im
/**
* Returns an output stream for writing the content.
+ *
* @return The OutputStream for the file.
* @throws FileSystemException if an error occurs.
*/
@Override
- public OutputStream getOutputStream() throws FileSystemException
- {
+ public OutputStream getOutputStream() throws FileSystemException {
return getOutputStream(false);
}
/**
* Returns an output stream for writing the content in append mode.
+ *
* @param bAppend true if the data written should be appended.
* @return The OutputStream for the file.
* @throws FileSystemException if an error occurs.
*/
@Override
- public OutputStream getOutputStream(final boolean bAppend) throws FileSystemException
- {
+ public OutputStream getOutputStream(final boolean bAppend) throws FileSystemException {
/*
- if (getThreadData().getState() != STATE_NONE)
- */
+ * if (getThreadData().getState() != STATE_NONE)
+ */
final FileContentThreadData streams = getOrCreateThreadData();
- if (streams.getOutstr() != null)
- {
+ if (streams.getOutstr() != null) {
throw new FileSystemException("vfs.provider/write-in-use.error", fileObject);
}
@@ -484,70 +420,53 @@ public final class DefaultFileContent im
}
/**
- * Closes all resources used by the content, including all streams, readers
- * and writers.
+ * Closes all resources used by the content, including all streams, readers and writers.
+ *
* @throws FileSystemException if an error occurs.
*/
@Override
- public void close() throws FileSystemException
- {
+ public void close() throws FileSystemException {
FileSystemException caught = null;
- try
- {
+ try {
final FileContentThreadData streams = getOrCreateThreadData();
// Close the input stream
- while (streams.getInstrsSize() > 0)
- {
+ while (streams.getInstrsSize() > 0) {
final FileContentInputStream instr = (FileContentInputStream) streams.removeInstr(0);
- try
- {
+ try {
instr.close();
- }
- catch (final FileSystemException ex)
- {
+ } catch (final FileSystemException ex) {
caught = ex;
}
}
// Close the randomAccess stream
- while (streams.getRastrsSize() > 0)
- {
+ while (streams.getRastrsSize() > 0) {
final FileRandomAccessContent ra = (FileRandomAccessContent) streams.removeRastr(0);
- try
- {
+ try {
ra.close();
- }
- catch (final FileSystemException ex)
- {
+ } catch (final FileSystemException ex) {
caught = ex;
}
}
// Close the output stream
final FileContentOutputStream outstr = streams.getOutstr();
- if (outstr != null)
- {
+ if (outstr != null) {
streams.setOutstr(null);
- try
- {
+ try {
outstr.close();
- }
- catch (final FileSystemException ex)
- {
+ } catch (final FileSystemException ex) {
caught = ex;
}
}
- }
- finally
- {
+ } finally {
threadData.remove();
}
// throw last error (out >> rac >> input) after all closes have been tried
- if (caught != null)
- {
+ if (caught != null) {
throw caught;
}
}
@@ -555,15 +474,12 @@ public final class DefaultFileContent im
/**
* Handles the end of input stream.
*/
- private void endInput(final FileContentInputStream instr)
- {
+ private void endInput(final FileContentInputStream instr) {
final FileContentThreadData streams = threadData.get();
- if (streams != null)
- {
+ if (streams != null) {
streams.removeInstr(instr);
}
- if (streams == null || !streams.hasStreams())
- {
+ if (streams == null || !streams.hasStreams()) {
// remove even when no value is set to remove key
threadData.remove();
}
@@ -573,15 +489,12 @@ public final class DefaultFileContent im
/**
* Handles the end of random access.
*/
- private void endRandomAccess(final RandomAccessContent rac)
- {
+ private void endRandomAccess(final RandomAccessContent rac) {
final FileContentThreadData streams = threadData.get();
- if (streams != null)
- {
+ if (streams != null) {
streams.removeRastr(rac);
}
- if (streams == null || !streams.hasStreams())
- {
+ if (streams == null || !streams.hasStreams()) {
// remove even when no value is set to remove key
threadData.remove();
}
@@ -591,15 +504,12 @@ public final class DefaultFileContent im
/**
* Handles the end of output stream.
*/
- private void endOutput() throws Exception
- {
+ private void endOutput() throws Exception {
final FileContentThreadData streams = threadData.get();
- if (streams != null)
- {
+ if (streams != null) {
streams.setOutstr(null);
}
- if (streams == null || !streams.hasStreams())
- {
+ if (streams == null || !streams.hasStreams()) {
// remove even when no value is set to remove key
threadData.remove();
}
@@ -615,11 +525,9 @@ public final class DefaultFileContent im
* @return true if this is the case
*/
@Override
- public boolean isOpen()
- {
+ public boolean isOpen() {
final FileContentThreadData streams = threadData.get();
- if (streams != null && streams.hasStreams())
- {
+ if (streams != null && streams.hasStreams()) {
return true;
}
// threadData.get() created empty entry
@@ -628,30 +536,24 @@ public final class DefaultFileContent im
}
/**
- * Check if a input and/or output stream is open.
- * This checks all threads.
+ * Check if a input and/or output stream is open. This checks all threads.
*
* @return true if this is the case
*/
- public boolean isOpenGlobal()
- {
- synchronized (this)
- {
+ public boolean isOpenGlobal() {
+ synchronized (this) {
return openStreams > 0;
}
}
/**
- * An input stream for reading content. Provides buffering, and
- * end-of-stream monitoring.
+ * An input stream for reading content. Provides buffering, and end-of-stream monitoring.
*/
- private final class FileContentInputStream extends MonitorInputStream
- {
+ private final class FileContentInputStream extends MonitorInputStream {
// avoid gc
private final FileObject file;
- FileContentInputStream(final FileObject file, final InputStream instr)
- {
+ FileContentInputStream(final FileObject file, final InputStream instr) {
super(instr);
this.file = file;
}
@@ -660,14 +562,10 @@ public final class DefaultFileContent im
* Closes this input stream.
*/
@Override
- public void close() throws FileSystemException
- {
- try
- {
+ public void close() throws FileSystemException {
+ try {
super.close();
- }
- catch (final IOException e)
- {
+ } catch (final IOException e) {
throw new FileSystemException("vfs.provider/close-instr.error", file, e);
}
}
@@ -676,14 +574,10 @@ public final class DefaultFileContent im
* Called after the stream has been closed.
*/
@Override
- protected void onClose() throws IOException
- {
- try
- {
+ protected void onClose() throws IOException {
+ try {
super.onClose();
- }
- finally
- {
+ } finally {
endInput(this);
}
}
@@ -692,13 +586,11 @@ public final class DefaultFileContent im
/**
* An input/output stream for reading/writing content on random positions
*/
- private final class FileRandomAccessContent extends MonitorRandomAccessContent
- {
+ private final class FileRandomAccessContent extends MonitorRandomAccessContent {
// also avoids gc
private final FileObject file;
- FileRandomAccessContent(final FileObject file, final RandomAccessContent content)
- {
+ FileRandomAccessContent(final FileObject file, final RandomAccessContent content) {
super(content);
this.file = file;
}
@@ -707,27 +599,19 @@ public final class DefaultFileContent im
* Called after the stream has been closed.
*/
@Override
- protected void onClose() throws IOException
- {
- try
- {
+ protected void onClose() throws IOException {
+ try {
super.onClose();
- }
- finally
- {
+ } finally {
endRandomAccess(this);
}
}
@Override
- public void close() throws FileSystemException
- {
- try
- {
+ public void close() throws FileSystemException {
+ try {
super.close();
- }
- catch (final IOException e)
- {
+ } catch (final IOException e) {
throw new FileSystemException("vfs.provider/close-rac.error", file, e);
}
}
@@ -736,13 +620,11 @@ public final class DefaultFileContent im
/**
* An output stream for writing content.
*/
- final class FileContentOutputStream extends MonitorOutputStream
- {
+ final class FileContentOutputStream extends MonitorOutputStream {
// avoid gc
private final FileObject file;
- FileContentOutputStream(final FileObject file, final OutputStream outstr)
- {
+ FileContentOutputStream(final FileObject file, final OutputStream outstr) {
super(outstr);
this.file = file;
}
@@ -751,14 +633,10 @@ public final class DefaultFileContent im
* Closes this output stream.
*/
@Override
- public void close() throws FileSystemException
- {
- try
- {
+ public void close() throws FileSystemException {
+ try {
super.close();
- }
- catch (final IOException e)
- {
+ } catch (final IOException e) {
throw new FileSystemException("vfs.provider/close-outstr.error", file, e);
}
}
@@ -767,20 +645,13 @@ public final class DefaultFileContent im
* Called after this stream is closed.
*/
@Override
- protected void onClose() throws IOException
- {
- try
- {
+ protected void onClose() throws IOException {
+ try {
super.onClose();
- }
- finally
- {
- try
- {
+ } finally {
+ try {
endOutput();
- }
- catch (final Exception e)
- {
+ } catch (final Exception e) {
throw new FileSystemException("vfs.provider/close-outstr.error", file, e);
}
}
@@ -789,14 +660,13 @@ public final class DefaultFileContent im
/**
* get the content info. e.g. content-type, content-encoding
+ *
* @return The FileContentInfo.
* @throws FileSystemException if an error occurs.
*/
@Override
- public FileContentInfo getContentInfo() throws FileSystemException
- {
- if (fileContentInfo == null)
- {
+ public FileContentInfo getContentInfo() throws FileSystemException {
+ if (fileContentInfo == null) {
fileContentInfo = fileContentInfoFactory.create(this);
}
@@ -806,23 +676,17 @@ public final class DefaultFileContent im
/**
* Writes this content to another FileContent.
*
- * @param fileContent
- * The target FileContent.
+ * @param fileContent The target FileContent.
* @return the total number of bytes written
- * @throws IOException
- * if an error occurs writing the content.
+ * @throws IOException if an error occurs writing the content.
* @since 2.1
*/
@Override
- public long write(final FileContent fileContent) throws IOException
- {
+ public long write(final FileContent fileContent) throws IOException {
final OutputStream output = fileContent.getOutputStream();
- try
- {
+ try {
return this.write(output);
- }
- finally
- {
+ } finally {
output.close();
}
}
@@ -830,65 +694,51 @@ public final class DefaultFileContent im
/**
* Writes this content to another FileObject.
*
- * @param file
- * The target FileObject.
+ * @param file The target FileObject.
* @return the total number of bytes written
- * @throws IOException
- * if an error occurs writing the content.
+ * @throws IOException if an error occurs writing the content.
* @since 2.1
*/
@Override
- public long write(final FileObject file) throws IOException
- {
+ public long write(final FileObject file) throws IOException {
return write(file.getContent());
}
/**
* Writes this content to an OutputStream.
*
- * @param output
- * The target OutputStream.
+ * @param output The target OutputStream.
* @return the total number of bytes written
- * @throws IOException
- * if an error occurs writing the content.
+ * @throws IOException if an error occurs writing the content.
* @since 2.1
*/
@Override
- public long write(final OutputStream output) throws IOException
- {
+ public long write(final OutputStream output) throws IOException {
return write(output, WRITE_BUFFER_SIZE);
}
/**
* Writes this content to an OutputStream.
*
- * @param output
- * The target OutputStream.
- * @param bufferSize
- * The buffer size to write data chunks.
+ * @param output The target OutputStream.
+ * @param bufferSize The buffer size to write data chunks.
* @return the total number of bytes written
- * @throws IOException
- * if an error occurs writing the file.
+ * @throws IOException if an error occurs writing the file.
* @since 2.1
*/
@Override
- public long write(final OutputStream output, final int bufferSize) throws IOException
- {
+ public long write(final OutputStream output, final int bufferSize) throws IOException {
final InputStream input = this.getInputStream();
long count = 0;
- try
- {
+ try {
// This read/write code from Apache Commons IO
final byte[] buffer = new byte[bufferSize];
int n = 0;
- while (-1 != (n = input.read(buffer)))
- {
+ while (-1 != (n = input.read(buffer))) {
output.write(buffer, 0, n);
count += n;
}
- }
- finally
- {
+ } finally {
input.close();
}
return count;
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/DefaultFileSelectorInfo.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/DefaultFileSelectorInfo.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/DefaultFileSelectorInfo.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/DefaultFileSelectorInfo.java Thu Sep 14 19:26:39 2017
@@ -23,7 +23,7 @@ import org.apache.commons.vfs2.FileSelec
* A default {@link FileSelectInfo} implementation.
*/
final class DefaultFileSelectorInfo implements FileSelectInfo {
-
+
private FileObject baseFolder;
private FileObject file;
private int depth;
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/DefaultURLConnection.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/DefaultURLConnection.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/DefaultURLConnection.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/DefaultURLConnection.java Thu Sep 14 19:26:39 2017
@@ -28,111 +28,70 @@ import org.apache.commons.vfs2.FileSyste
/**
* A default URL connection that will work for most file systems.
*/
-public final class DefaultURLConnection
- extends URLConnection
-{
+public final class DefaultURLConnection extends URLConnection {
private final FileContent content;
- public DefaultURLConnection(final URL url,
- final FileContent content)
- {
+ public DefaultURLConnection(final URL url, final FileContent content) {
super(url);
this.content = content;
}
@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 long getLastModified()
- {
- try
- {
+ public long getLastModified() {
+ try {
return content.getLastModifiedTime();
- }
- catch (final FileSystemException ignored)
- {
+ } catch (final FileSystemException ignored) {
return -1; // TODO: report?
}
}
@Override
- public int getContentLength()
- {
- try
- {
+ public int getContentLength() {
+ try {
return (int) content.getSize();
- }
- catch (final FileSystemException fse)
- {
+ } catch (final FileSystemException fse) {
return -1; // TODO: report?
}
}
@Override
- public String getContentType()
- {
- try
- {
+ public String getContentType() {
+ try {
return content.getContentInfo().getContentType();
- }
- catch (final FileSystemException e)
- {
+ } catch (final FileSystemException e) {
throw new RuntimeException(e.getMessage());
}
}
@Override
- public String getContentEncoding()
- {
- try
- {
+ public String getContentEncoding() {
+ try {
return content.getContentInfo().getContentEncoding();
- }
- catch (final FileSystemException e)
- {
+ } catch (final FileSystemException e) {
throw new RuntimeException(e.getMessage());
}
}
/*
- public String getHeaderField(String name)
- {
- try
- {
- if (content.getFile().getFileSystem().hasCapability(Capability.ATTRIBUTES))
- {
- String value = (String) content.getAttribute(name);
- if (value != null)
- {
- return value;
- }
- }
-
- return null;
- }
- catch (FileSystemException e)
- {
- throw new RuntimeException(e);
- }
- }
- */
+ * public String getHeaderField(String name) { try { if
+ * (content.getFile().getFileSystem().hasCapability(Capability.ATTRIBUTES)) { String value = (String)
+ * content.getAttribute(name); if (value != null) { return value; } }
+ *
+ * return null; } catch (FileSystemException e) { throw new RuntimeException(e); } }
+ */
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/DefaultURLStreamHandler.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/DefaultURLStreamHandler.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/DefaultURLStreamHandler.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/DefaultURLStreamHandler.java Thu Sep 14 19:26:39 2017
@@ -28,55 +28,38 @@ import org.apache.commons.vfs2.FileSyste
/**
* A default URL stream handler that will work for most file systems.
*/
-public class DefaultURLStreamHandler
- extends URLStreamHandler
-{
+public class DefaultURLStreamHandler extends URLStreamHandler {
private final VfsComponentContext context;
private final FileSystemOptions fileSystemOptions;
- public DefaultURLStreamHandler(final VfsComponentContext context)
- {
+ public DefaultURLStreamHandler(final VfsComponentContext context) {
this(context, null);
}
- public DefaultURLStreamHandler(final VfsComponentContext context, final FileSystemOptions fileSystemOptions)
- {
+ public DefaultURLStreamHandler(final VfsComponentContext context, final FileSystemOptions fileSystemOptions) {
this.context = context;
this.fileSystemOptions = fileSystemOptions;
}
@Override
- protected URLConnection openConnection(final URL url)
- throws IOException
- {
+ protected URLConnection openConnection(final URL url) throws IOException {
final FileObject entry = context.resolveFile(url.toExternalForm(), fileSystemOptions);
return new DefaultURLConnection(url, entry.getContent());
}
@Override
- protected void parseURL(final URL u,
- final String spec,
- final int start,
- final int limit)
- {
- try
- {
+ protected void parseURL(final URL u, final String spec, final int start, final int limit) {
+ try {
final FileObject old = context.resolveFile(u.toExternalForm(), fileSystemOptions);
FileObject newURL;
- if (start > 0 && spec.charAt(start - 1) == ':')
- {
+ if (start > 0 && spec.charAt(start - 1) == ':') {
newURL = context.resolveFile(old, spec, fileSystemOptions);
- }
- else
- {
- if (old.isFile() && old.getParent() != null)
- {
+ } else {
+ if (old.isFile() && old.getParent() != null) {
// for files we have to resolve relative
newURL = old.getParent().resolveFile(spec);
- }
- else
- {
+ } else {
newURL = old.resolveFile(spec);
}
}
@@ -86,17 +69,14 @@ public class DefaultURLStreamHandler
final String protocolPart = UriParser.extractScheme(url, filePart);
setURL(u, protocolPart, "", -1, null, null, filePart.toString(), null, null);
- }
- catch (final FileSystemException fse)
- {
+ } catch (final FileSystemException fse) {
// This is rethrown to MalformedURLException in URL anyway
throw new RuntimeException(fse.getMessage());
}
}
@Override
- protected String toExternalForm(final URL u)
- {
+ protected String toExternalForm(final URL u) {
return u.getProtocol() + ":" + u.getFile();
}
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/DelegateFileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/DelegateFileObject.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/DelegateFileObject.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/DelegateFileObject.java Thu Sep 14 19:26:39 2017
@@ -40,47 +40,43 @@ import org.apache.commons.vfs2.util.Weak
* <p>
* TODO - Extract subclass that overlays the children.
*
- * @param <AFS> A subclass of AbstractFileSystem.
+ * @param <AFS> A subclass of AbstractFileSystem.
*/
-public class DelegateFileObject<AFS extends AbstractFileSystem> extends AbstractFileObject<AFS> implements FileListener
-{
+public class DelegateFileObject<AFS extends AbstractFileSystem> extends AbstractFileObject<AFS>
+ implements FileListener {
private FileObject file;
private final Set<String> children = new HashSet<>();
private boolean ignoreEvent;
- public DelegateFileObject(final AbstractFileName name,
- final AFS fileSystem,
- final FileObject file) throws FileSystemException
- {
+ public DelegateFileObject(final AbstractFileName name, final AFS fileSystem, final FileObject file)
+ throws FileSystemException {
super(name, fileSystem);
this.file = file;
- if (file != null)
- {
+ if (file != null) {
WeakRefFileListener.installListener(file, this);
}
}
/**
* Get access to the delegated file.
+ *
* @return The FileObject.
* @since 2.0
*/
- public FileObject getDelegateFile()
- {
+ public FileObject getDelegateFile() {
return file;
}
/**
* Adds a child to this file.
+ *
* @param baseName The base FileName.
* @param type The FileType.
* @throws Exception if an error occurs.
*/
- public void attachChild(final FileName baseName, final FileType type) throws Exception
- {
+ public void attachChild(final FileName baseName, final FileType type) throws Exception {
final FileType oldType = doGetType();
- if (children.add(baseName.getBaseName()))
- {
+ if (children.add(baseName.getBaseName())) {
childrenChanged(baseName, type);
}
maybeTypeChanged(oldType);
@@ -88,15 +84,14 @@ public class DelegateFileObject<AFS exte
/**
* Attaches or detaches the target file.
+ *
* @param file The FileObject.
* @throws Exception if an error occurs.
*/
- public void setFile(final FileObject file) throws Exception
- {
+ public void setFile(final FileObject file) throws Exception {
final FileType oldType = doGetType();
- if (file != null)
- {
+ if (file != null) {
WeakRefFileListener.installListener(file, this);
}
this.file = file;
@@ -104,41 +99,30 @@ public class DelegateFileObject<AFS exte
}
/**
- * Checks whether the file's type has changed, and fires the appropriate
- * events.
+ * Checks whether the file's type has changed, and fires the appropriate events.
+ *
* @param oldType The old FileType.
* @throws Exception if an error occurs.
*/
- private void maybeTypeChanged(final FileType oldType) throws Exception
- {
+ private void maybeTypeChanged(final FileType oldType) throws Exception {
final FileType newType = doGetType();
- if (oldType == FileType.IMAGINARY && newType != FileType.IMAGINARY)
- {
+ if (oldType == FileType.IMAGINARY && newType != FileType.IMAGINARY) {
handleCreate(newType);
- }
- else if (oldType != FileType.IMAGINARY && newType == FileType.IMAGINARY)
- {
+ } else if (oldType != FileType.IMAGINARY && newType == FileType.IMAGINARY) {
handleDelete();
}
}
/**
- * Determines the type of the file, returns null if the file does not
- * exist.
+ * Determines the type of the file, returns null if the file does not exist.
*/
@Override
- protected FileType doGetType() throws FileSystemException
- {
- if (file != null)
- {
+ protected FileType doGetType() throws FileSystemException {
+ if (file != null) {
return file.getType();
- }
- else if (children.size() > 0)
- {
+ } else if (children.size() > 0) {
return FileType.FOLDER;
- }
- else
- {
+ } else {
return FileType.IMAGINARY;
}
}
@@ -147,10 +131,8 @@ public class DelegateFileObject<AFS exte
* Determines if this file can be read.
*/
@Override
- protected boolean doIsReadable() throws FileSystemException
- {
- if (file != null)
- {
+ protected boolean doIsReadable() throws FileSystemException {
+ if (file != null) {
return file.isReadable();
}
return true;
@@ -160,10 +142,8 @@ public class DelegateFileObject<AFS exte
* Determines if this file can be written to.
*/
@Override
- protected boolean doIsWriteable() throws FileSystemException
- {
- if (file != null)
- {
+ protected boolean doIsWriteable() throws FileSystemException {
+ if (file != null) {
return file.isWriteable();
}
return false;
@@ -173,10 +153,8 @@ public class DelegateFileObject<AFS exte
* Determines if this file is executable.
*/
@Override
- protected boolean doIsExecutable() throws FileSystemException
- {
- if (file != null)
- {
+ protected boolean doIsExecutable() throws FileSystemException {
+ if (file != null) {
return file.isExecutable();
}
return false;
@@ -186,10 +164,8 @@ public class DelegateFileObject<AFS exte
* Determines if this file is hidden.
*/
@Override
- protected boolean doIsHidden() throws FileSystemException
- {
- if (file != null)
- {
+ protected boolean doIsHidden() throws FileSystemException {
+ if (file != null) {
return file.isHidden();
}
return false;
@@ -199,25 +175,20 @@ public class DelegateFileObject<AFS exte
* Lists the children of the file.
*/
@Override
- protected String[] doListChildren() throws Exception
- {
- if (file != null)
- {
+ protected String[] doListChildren() throws Exception {
+ if (file != null) {
final FileObject[] children;
- try
- {
+ try {
children = file.getChildren();
}
// VFS-210
- catch (final FileNotFolderException e)
- {
+ catch (final FileNotFolderException e) {
throw new FileNotFolderException(getName(), e);
}
final String[] childNames = new String[children.length];
- for (int i = 0; i < children.length; i++)
- {
+ for (int i = 0; i < children.length; i++) {
childNames[i] = children[i].getName().getBaseName();
}
return childNames;
@@ -229,15 +200,11 @@ public class DelegateFileObject<AFS exte
* Creates this file as a folder.
*/
@Override
- protected void doCreateFolder() throws Exception
- {
+ protected void doCreateFolder() throws Exception {
ignoreEvent = true;
- try
- {
+ try {
file.createFolder();
- }
- finally
- {
+ } finally {
ignoreEvent = false;
}
}
@@ -246,26 +213,21 @@ public class DelegateFileObject<AFS exte
* Deletes the file.
*/
@Override
- protected void doDelete() throws Exception
- {
+ protected void doDelete() throws Exception {
ignoreEvent = true;
- try
- {
+ try {
file.delete();
- }
- finally
- {
+ } finally {
ignoreEvent = false;
}
}
/**
- * Returns the size of the file content (in bytes). Is only called if
- * {@link #doGetType} returns {@link FileType#FILE}.
+ * Returns the size of the file content (in bytes). Is only called if {@link #doGetType} returns
+ * {@link FileType#FILE}.
*/
@Override
- protected long doGetContentSize() throws Exception
- {
+ protected long doGetContentSize() throws Exception {
return file.getContent().getSize();
}
@@ -273,9 +235,7 @@ public class DelegateFileObject<AFS exte
* Returns the attributes of this file.
*/
@Override
- protected Map<String, Object> doGetAttributes()
- throws Exception
- {
+ protected Map<String, Object> doGetAttributes() throws Exception {
return file.getContent().getAttributes();
}
@@ -283,10 +243,7 @@ public class DelegateFileObject<AFS exte
* Sets an attribute of this file.
*/
@Override
- protected void doSetAttribute(final String atttrName,
- final Object value)
- throws Exception
- {
+ protected void doSetAttribute(final String atttrName, final Object value) throws Exception {
file.getContent().setAttribute(atttrName, value);
}
@@ -294,8 +251,7 @@ public class DelegateFileObject<AFS exte
* Returns the certificates of this file.
*/
@Override
- protected Certificate[] doGetCertificates() throws Exception
- {
+ protected Certificate[] doGetCertificates() throws Exception {
return file.getContent().getCertificates();
}
@@ -303,19 +259,17 @@ public class DelegateFileObject<AFS exte
* Returns the last-modified time of this file.
*/
@Override
- protected long doGetLastModifiedTime() throws Exception
- {
+ protected long doGetLastModifiedTime() throws Exception {
return file.getContent().getLastModifiedTime();
}
/**
* Sets the last-modified time of this file.
+ *
* @since 2.0
*/
@Override
- protected boolean doSetLastModifiedTime(final long modtime)
- throws Exception
- {
+ protected boolean doSetLastModifiedTime(final long modtime) throws Exception {
file.getContent().setLastModifiedTime(modtime);
return true;
}
@@ -324,8 +278,7 @@ public class DelegateFileObject<AFS exte
* Creates an input stream to read the file content from.
*/
@Override
- protected InputStream doGetInputStream() throws Exception
- {
+ protected InputStream doGetInputStream() throws Exception {
return file.getContent().getInputStream();
}
@@ -333,43 +286,38 @@ public class DelegateFileObject<AFS exte
* 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 file.getContent().getOutputStream(bAppend);
}
/**
* Called when a file is created.
+ *
* @param event The FileChangeEvent.
* @throws Exception if an error occurs.
*/
@Override
- public void fileCreated(final FileChangeEvent event) throws Exception
- {
- if (event.getFile() != file)
- {
+ public void fileCreated(final FileChangeEvent event) throws Exception {
+ if (event.getFile() != file) {
return;
}
- if (!ignoreEvent)
- {
+ if (!ignoreEvent) {
handleCreate(file.getType());
}
}
/**
* Called when a file is deleted.
+ *
* @param event The FileChangeEvent.
* @throws Exception if an error occurs.
*/
@Override
- public void fileDeleted(final FileChangeEvent event) throws Exception
- {
- if (event.getFile() != file)
- {
+ public void fileDeleted(final FileChangeEvent event) throws Exception {
+ if (event.getFile() != file) {
return;
}
- if (!ignoreEvent)
- {
+ if (!ignoreEvent) {
handleDelete();
}
}
@@ -383,56 +331,51 @@ public class DelegateFileObject<AFS exte
* @throws Exception if an error occurs.
*/
@Override
- public void fileChanged(final FileChangeEvent event) throws Exception
- {
- if (event.getFile() != file)
- {
+ public void fileChanged(final FileChangeEvent event) throws Exception {
+ if (event.getFile() != file) {
return;
}
- if (!ignoreEvent)
- {
+ if (!ignoreEvent) {
handleChanged();
}
}
/**
* Close the delegated file.
+ *
* @throws FileSystemException if an error occurs.
*/
@Override
- public void close() throws FileSystemException
- {
+ public void close() throws FileSystemException {
super.close();
- if (file != null)
- {
+ if (file != null) {
file.close();
}
}
/**
* Refresh file information.
+ *
* @throws FileSystemException if an error occurs.
* @since 2.0
*/
@Override
- public void refresh() throws FileSystemException
- {
+ public void refresh() throws FileSystemException {
super.refresh();
- if (file != null)
- {
+ if (file != null) {
file.refresh();
}
}
/**
* Return file content info.
+ *
* @return the file content info of the delegee.
* @throws Exception Any thrown Exception is wrapped in FileSystemException.
* @since 2.0
*/
- protected FileContentInfo doGetContentInfo() throws Exception
- {
+ protected FileContentInfo doGetContentInfo() throws Exception {
return file.getContent().getContentInfo();
}
@@ -444,30 +387,27 @@ public class DelegateFileObject<AFS exte
* @since 2.0
*/
@Override
- protected void doRename(final FileObject newFile)
- throws Exception
- {
+ protected void doRename(final FileObject newFile) throws Exception {
file.moveTo(((DelegateFileObject) newFile).file);
}
/**
* Removes an attribute of this file.
+ *
* @since 2.0
*/
@Override
- protected void doRemoveAttribute(final String atttrName)
- throws Exception
- {
+ protected void doRemoveAttribute(final String atttrName) throws Exception {
file.getContent().removeAttribute(atttrName);
}
/**
* Creates access to the file for random i/o.
+ *
* @since 2.0
*/
@Override
- protected RandomAccessContent doGetRandomAccessContent(final RandomAccessMode mode) throws Exception
- {
+ protected RandomAccessContent doGetRandomAccessContent(final RandomAccessMode mode) throws Exception {
return file.getContent().getRandomAccessContent(mode);
}
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/FileContentThreadData.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/FileContentThreadData.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/FileContentThreadData.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/FileContentThreadData.java Thu Sep 14 19:26:39 2017
@@ -25,88 +25,68 @@ import org.apache.commons.vfs2.RandomAcc
/**
* Holds the data which needs to be local to the current thread
*/
-class FileContentThreadData
-{
+class FileContentThreadData {
// private int state = DefaultFileContent.STATE_CLOSED;
private final ArrayList<InputStream> inputStreamList = new ArrayList<>();
private final ArrayList<RandomAccessContent> randomAccessContentList = new ArrayList<>();
private DefaultFileContent.FileContentOutputStream outputStream;
- FileContentThreadData()
- {
+ FileContentThreadData() {
}
/*
- int getState()
- {
- return state;
- }
-
- void setState(int state)
- {
- this.state = state;
- }
- */
+ * int getState() { return state; }
+ *
+ * void setState(int state) { this.state = state; }
+ */
- void addInstr(final InputStream inputStream)
- {
+ void addInstr(final InputStream inputStream) {
this.inputStreamList.add(inputStream);
}
- void setOutstr(final DefaultFileContent.FileContentOutputStream outputStream)
- {
+ void setOutstr(final DefaultFileContent.FileContentOutputStream outputStream) {
this.outputStream = outputStream;
}
- DefaultFileContent.FileContentOutputStream getOutstr()
- {
+ DefaultFileContent.FileContentOutputStream getOutstr() {
return this.outputStream;
}
- void addRastr(final RandomAccessContent randomAccessContent)
- {
+ void addRastr(final RandomAccessContent randomAccessContent) {
this.randomAccessContentList.add(randomAccessContent);
}
- int getInstrsSize()
- {
+ int getInstrsSize() {
return this.inputStreamList.size();
}
- public Object removeInstr(final int pos)
- {
+ public Object removeInstr(final int pos) {
return this.inputStreamList.remove(pos);
}
- public void removeInstr(final InputStream inputStream)
- {
+ public void removeInstr(final InputStream inputStream) {
this.inputStreamList.remove(inputStream);
}
- public Object removeRastr(final int pos)
- {
+ public Object removeRastr(final int pos) {
return this.randomAccessContentList.remove(pos);
}
- public void removeRastr(final RandomAccessContent randomAccessContent)
- {
+ public void removeRastr(final RandomAccessContent randomAccessContent) {
this.randomAccessContentList.remove(randomAccessContent);
}
- public boolean hasStreams()
- {
+ public boolean hasStreams() {
return inputStreamList.size() > 0 || outputStream != null || randomAccessContentList.size() > 0;
}
- public void closeOutstr() throws FileSystemException
- {
+ public void closeOutstr() throws FileSystemException {
outputStream.close();
outputStream = null;
}
- int getRastrsSize()
- {
+ int getRastrsSize() {
return randomAccessContentList.size();
}
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/FileNameParser.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/FileNameParser.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/FileNameParser.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/FileNameParser.java Thu Sep 14 19:26:39 2017
@@ -22,10 +22,10 @@ import org.apache.commons.vfs2.FileSyste
/**
* Provides methods to parse a filename into a {@link org.apache.commons.vfs2.FileName}.
*/
-public interface FileNameParser
-{
+public interface FileNameParser {
/**
* Check if a character needs encoding (%nn).
+ *
* @param ch the character
* @return true if character should be encoded
*/
@@ -33,6 +33,7 @@ public interface FileNameParser
/**
* parses a String into a filename.
+ *
* @param context The component context.
* @param base The base FileName.
* @param uri The target file name.
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/FileProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/FileProvider.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/FileProvider.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/FileProvider.java Thu Sep 14 19:26:39 2017
@@ -25,56 +25,54 @@ import org.apache.commons.vfs2.FileSyste
import org.apache.commons.vfs2.FileSystemException;
import org.apache.commons.vfs2.FileSystemOptions;
-
/**
- * A file provider. Each file provider is responsible for handling files for
- * a particular URI scheme.
+ * A file provider. Each file provider is responsible for handling files for a particular URI scheme.
* <p>
* A file provider may also implement {@link VfsComponent}.
*/
-public interface FileProvider
-{
+public interface FileProvider {
/**
* Locates a file object, by absolute URI.
*
- * @param baseFile The base file to use for resolving the individual parts of
- * a compound URI.
- * @param uri The absolute URI of the file to find.
+ * @param baseFile The base file to use for resolving the individual parts of a compound URI.
+ * @param uri The absolute URI of the file to find.
* @param fileSystemOptions The FileSystemOptions
* @return The FileObject.
* @throws FileSystemException if an error occurs locating the file.
*/
FileObject findFile(final FileObject baseFile, final String uri, final FileSystemOptions fileSystemOptions)
- throws FileSystemException;
+ throws FileSystemException;
/**
* Creates a layered file system.
*
- * @param scheme The URI scheme for the layered file system.
- * @param file The file to build the file system on.
+ * @param scheme The URI scheme for the layered file system.
+ * @param file The file to build the file system on.
* @param fileSystemOptions The FileSystemOptions.
* @return A FileObject in the file system.
* @throws FileSystemException if an error occurs.
*/
FileObject createFileSystem(String scheme, FileObject file, FileSystemOptions fileSystemOptions)
- throws FileSystemException;
+ throws FileSystemException;
/**
* Gets the configbuilder useable to collect the needed fileSystemOptions.
+ *
* @return a FileSystemConfigBuilder for the particular file system.
*/
FileSystemConfigBuilder getConfigBuilder();
/**
* Get the filesystem capabilities.<br>
- * These are the same as on the filesystem, but available before the first filesystem was
- * instanciated.
+ * These are the same as on the filesystem, but available before the first filesystem was instanciated.
+ *
* @return a Collection of the file systems Capabilities.
*/
Collection<Capability> getCapabilities();
/**
* Parse the URI into a FileName.
+ *
* @param root The base FileName.
* @param uri The file to be accessed.
* @return A FileName representing the target file.
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/FileReplicator.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/FileReplicator.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/FileReplicator.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/FileReplicator.java Thu Sep 14 19:26:39 2017
@@ -27,16 +27,14 @@ import org.apache.commons.vfs2.FileSyste
* <p>
* A file replicator may also implement {@link VfsComponent}.
*/
-public interface FileReplicator
-{
+public interface FileReplicator {
/**
* Creates a local copy of the file, and all its descendants.
*
- * @param srcFile The file to copy.
+ * @param srcFile The file to copy.
* @param selector Selects the files to copy.
* @return The local copy of the source file.
* @throws FileSystemException If the source files does not exist, or on error copying.
*/
- File replicateFile(FileObject srcFile, FileSelector selector)
- throws FileSystemException;
+ File replicateFile(FileObject srcFile, FileSelector selector) throws FileSystemException;
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/FileSystemKey.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/FileSystemKey.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/FileSystemKey.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/FileSystemKey.java Thu Sep 14 19:26:39 2017
@@ -22,7 +22,7 @@ import org.apache.commons.vfs2.FileSyste
* Used to identify a filesystem
*/
class FileSystemKey implements Comparable<FileSystemKey> {
-
+
private static final FileSystemOptions EMPTY_OPTIONS = new FileSystemOptions();
private final Comparable<?> key;
@@ -31,10 +31,8 @@ class FileSystemKey implements Comparabl
/**
* Create the FS key.
*
- * @param key
- * must implement Comparable, and must be self-comparable
- * @param fileSystemOptions
- * the required options
+ * @param key must implement Comparable, and must be self-comparable
+ * @param fileSystemOptions the required options
*/
FileSystemKey(final Comparable<?> key, final FileSystemOptions fileSystemOptions) {
this.key = key;
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/GenericFileName.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/GenericFileName.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/GenericFileName.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/GenericFileName.java Thu Sep 14 19:26:39 2017
@@ -94,10 +94,8 @@ public class GenericFileName extends Abs
/**
* Create a FileName.
*
- * @param absPath
- * The absolute path.
- * @param type
- * The FileType.
+ * @param absPath The absolute path.
+ * @param type The FileType.
* @return The created FileName.
*/
@Override
@@ -125,10 +123,8 @@ public class GenericFileName extends Abs
* <p>
* If anything was added, it will be '@' terminated.
*
- * @param buffer
- * the string buffer to modify.
- * @param addPassword
- * flag if password should be added or replaced with placeholder (false).
+ * @param buffer the string buffer to modify.
+ * @param addPassword flag if password should be added or replaced with placeholder (false).
*/
protected void appendCredentials(final StringBuilder buffer, final boolean addPassword) {
if (userName != null && userName.length() != 0) {
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/HostFileNameParser.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/HostFileNameParser.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/HostFileNameParser.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/HostFileNameParser.java Thu Sep 14 19:26:39 2017
@@ -25,29 +25,24 @@ import org.apache.commons.vfs2.util.Cryp
/**
* Implementation for any url based filesystem.
* <p>
- * Parses the url into user/password/host/port/path.
- * Does not handle a query string (after ?)
+ * Parses the url into user/password/host/port/path. Does not handle a query string (after ?)
*
* @see URLFileNameParser URLFileNameParser for the implementation which also handles the query string too
*/
-public class HostFileNameParser extends AbstractFileNameParser
-{
+public class HostFileNameParser extends AbstractFileNameParser {
private final int defaultPort;
- public HostFileNameParser(final int defaultPort)
- {
+ public HostFileNameParser(final int defaultPort) {
this.defaultPort = defaultPort;
}
- public int getDefaultPort()
- {
+ public int getDefaultPort() {
return defaultPort;
}
@Override
public FileName parseUri(final VfsComponentContext context, final FileName base, final String filename)
- throws FileSystemException
- {
+ throws FileSystemException {
// FTP URI are generic URI (as per RFC 2396)
final StringBuilder name = new StringBuilder();
@@ -60,38 +55,26 @@ public class HostFileNameParser extends
final FileType fileType = UriParser.normalisePath(name);
final String path = name.toString();
- return new GenericFileName(
- auth.scheme,
- auth.hostName,
- auth.port,
- defaultPort,
- auth.userName,
- auth.password,
- path,
- fileType);
+ return new GenericFileName(auth.scheme, auth.hostName, auth.port, defaultPort, auth.userName, auth.password,
+ path, fileType);
}
/**
- * Extracts the scheme, userinfo, hostname and port components of a
- * generic URI.
+ * Extracts the scheme, userinfo, hostname and port components of a generic URI.
*
- * @param uri The absolute URI to parse.
+ * @param uri The absolute URI to parse.
* @param name Used to return the remainder of the URI.
* @return Authority extracted host authority, never null.
* @throws FileSystemException if authority cannot be extracted.
*/
- protected Authority extractToPath(final String uri,
- final StringBuilder name)
- throws FileSystemException
- {
+ protected Authority extractToPath(final String uri, final StringBuilder name) throws FileSystemException {
final Authority auth = new Authority();
// Extract the scheme
auth.scheme = UriParser.extractScheme(uri, name);
// Expecting "//"
- if (name.length() < 2 || name.charAt(0) != '/' || name.charAt(1) != '/')
- {
+ if (name.length() < 2 || name.charAt(0) != '/' || name.charAt(1) != '/') {
throw new FileSystemException("vfs.provider/missing-double-slashes.error", uri);
}
name.delete(0, 2);
@@ -100,45 +83,34 @@ public class HostFileNameParser extends
final String userInfo = extractUserInfo(name);
final String userName;
final String password;
- if (userInfo != null)
- {
+ if (userInfo != null) {
final int idx = userInfo.indexOf(':');
- if (idx == -1)
- {
+ if (idx == -1) {
userName = userInfo;
password = null;
- }
- else
- {
+ } else {
userName = userInfo.substring(0, idx);
password = userInfo.substring(idx + 1);
}
- }
- else
- {
+ } else {
userName = null;
password = null;
}
auth.userName = UriParser.decode(userName);
auth.password = UriParser.decode(password);
- if (auth.password != null && auth.password.startsWith("{") && auth.password.endsWith("}"))
- {
- try
- {
+ if (auth.password != null && auth.password.startsWith("{") && auth.password.endsWith("}")) {
+ try {
final Cryptor cryptor = CryptorFactory.getCryptor();
auth.password = cryptor.decrypt(auth.password.substring(1, auth.password.length() - 1));
- }
- catch (final Exception ex)
- {
+ } catch (final Exception ex) {
throw new FileSystemException("Unable to decrypt password", ex);
}
}
// Extract hostname, and normalise (lowercase)
final String hostName = extractHostName(name);
- if (hostName == null)
- {
+ if (hostName == null) {
throw new FileSystemException("vfs.provider/missing-hostname.error", uri);
}
auth.hostName = hostName.toLowerCase();
@@ -147,8 +119,7 @@ public class HostFileNameParser extends
auth.port = extractPort(name, uri);
// Expecting '/' or empty name
- if (name.length() > 0 && name.charAt(0) != '/')
- {
+ if (name.length() > 0 && name.charAt(0) != '/') {
throw new FileSystemException("vfs.provider/missing-hostname-path-sep.error", uri);
}
@@ -161,21 +132,17 @@ public class HostFileNameParser extends
* @param name string buffer with the "scheme://" part has been removed already. Will be modified.
* @return the user information up to the '@' or null.
*/
- protected String extractUserInfo(final StringBuilder name)
- {
+ protected String extractUserInfo(final StringBuilder name) {
final int maxlen = name.length();
- for (int pos = 0; pos < maxlen; pos++)
- {
+ for (int pos = 0; pos < maxlen; pos++) {
final char ch = name.charAt(pos);
- if (ch == '@')
- {
+ if (ch == '@') {
// Found the end of the user info
final String userInfo = name.substring(0, pos);
name.delete(0, pos + 1);
return userInfo;
}
- if (ch == '/' || ch == '?')
- {
+ if (ch == '/' || ch == '?') {
// Not allowed in user info
break;
}
@@ -189,24 +156,19 @@ public class HostFileNameParser extends
* Extracts the hostname from a URI.
*
* @param name string buffer with the "scheme://[userinfo@]" part has been removed already. Will be modified.
- * @return the host name or null.
+ * @return the host name or null.
*/
- protected String extractHostName(final StringBuilder name)
- {
+ protected String extractHostName(final StringBuilder name) {
final int maxlen = name.length();
int pos = 0;
- for (; pos < maxlen; pos++)
- {
+ for (; pos < maxlen; pos++) {
final char ch = name.charAt(pos);
- if (ch == '/' || ch == ';' || ch == '?' || ch == ':'
- || ch == '@' || ch == '&' || ch == '=' || ch == '+'
- || ch == '$' || ch == ',')
- {
+ if (ch == '/' || ch == ';' || ch == '?' || ch == ':' || ch == '@' || ch == '&' || ch == '=' || ch == '+'
+ || ch == '$' || ch == ',') {
break;
}
}
- if (pos == 0)
- {
+ if (pos == 0) {
return null;
}
@@ -217,35 +179,31 @@ public class HostFileNameParser extends
/**
* Extracts the port from a URI.
- * @param name string buffer with the "scheme://[userinfo@]hostname" part has been removed already.
- * Will be modified.
+ *
+ * @param name string buffer with the "scheme://[userinfo@]hostname" part has been removed already. Will be
+ * modified.
* @param uri full URI for error reporting.
* @return The port, or -1 if the URI does not contain a port.
* @throws FileSystemException if URI is malformed.
* @throws NumberFormatException if port number cannot be parsed.
*/
- protected int extractPort(final StringBuilder name, final String uri) throws FileSystemException
- {
- if (name.length() < 1 || name.charAt(0) != ':')
- {
+ protected int extractPort(final StringBuilder name, final String uri) throws FileSystemException {
+ if (name.length() < 1 || name.charAt(0) != ':') {
return -1;
}
final int maxlen = name.length();
int pos = 1;
- for (; pos < maxlen; pos++)
- {
+ for (; pos < maxlen; pos++) {
final char ch = name.charAt(pos);
- if (ch < '0' || ch > '9')
- {
+ if (ch < '0' || ch > '9') {
break;
}
}
final String port = name.substring(1, pos);
name.delete(0, pos);
- if (port.length() == 0)
- {
+ if (port.length() == 0) {
throw new FileSystemException("vfs.provider/missing-port.error", uri);
}
@@ -255,8 +213,7 @@ public class HostFileNameParser extends
/**
* Parsed authority info (scheme, hostname, username/password, port).
*/
- protected static class Authority
- {
+ protected static class Authority {
private String scheme;
private String hostName;
private String userName;
@@ -265,101 +222,101 @@ public class HostFileNameParser extends
/**
* Get the connection schema.
+ *
* @return the connection scheme.
* @since 2.0
*/
- public String getScheme()
- {
+ public String getScheme() {
return scheme;
}
/**
* Set the connection schema.
+ *
* @param scheme the connection scheme.
* @since 2.0
*/
- public void setScheme(final String scheme)
- {
+ public void setScheme(final String scheme) {
this.scheme = scheme;
}
/**
* Get the host name.
+ *
* @return the host name.
* @since 2.0
*/
- public String getHostName()
- {
+ public String getHostName() {
return hostName;
}
/**
* Set the host name.
+ *
* @param hostName the host name.
* @since 2.0
*/
- public void setHostName(final String hostName)
- {
+ public void setHostName(final String hostName) {
this.hostName = hostName;
}
/**
* Get the user name.
+ *
* @return the user name or null.
* @since 2.0
*/
- public String getUserName()
- {
+ public String getUserName() {
return userName;
}
/**
* Set the user name.
+ *
* @param userName the user name.
* @since 2.0
*/
- public void setUserName(final String userName)
- {
+ public void setUserName(final String userName) {
this.userName = userName;
}
/**
* Get the user password.
+ *
* @return the password or null.
* @since 2.0
*/
- public String getPassword()
- {
+ public String getPassword() {
return password;
}
/**
* Set the user password.
+ *
* @param password the user password.
* @since 2.0
*/
- public void setPassword(final String password)
- {
+ public void setPassword(final String password) {
this.password = password;
}
/**
* Get the port.
+ *
* @return the port or -1.
* @since 2.0
*/
- public int getPort()
- {
+ public int getPort() {
return port;
}
/**
* Set the connection port.
+ *
* @param port the port number or -1.
* @since 2.0
*/
- public void setPort(final int port)
- {
+ public void setPort(final int port) {
this.port = port;
}
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/LayeredFileName.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/LayeredFileName.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/LayeredFileName.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/LayeredFileName.java Thu Sep 14 19:26:39 2017
@@ -22,43 +22,37 @@ import org.apache.commons.vfs2.FileType;
/**
* A file name for layered files.
*/
-public class LayeredFileName extends AbstractFileName
-{
+public class LayeredFileName extends AbstractFileName {
private final FileName outerUri;
- public LayeredFileName(final String scheme,
- final FileName outerUri,
- final String path,
- final FileType type)
- {
+ public LayeredFileName(final String scheme, final FileName outerUri, final String path, final FileType type) {
super(scheme, path, type);
this.outerUri = outerUri;
}
/**
* Returns the URI of the outer file.
+ *
* @return The FileName.
*/
- public FileName getOuterName()
- {
+ public FileName getOuterName() {
return outerUri;
}
/**
* Create a FileName.
+ *
* @param path The file URI.
* @param type The FileType.
* @return The FileName.
*/
@Override
- public FileName createName(final String path, final FileType type)
- {
+ public FileName createName(final String path, final FileType type) {
return new LayeredFileName(getScheme(), getOuterName(), path, type);
}
@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(getOuterName().getURI());
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/LayeredFileNameParser.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/LayeredFileNameParser.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/LayeredFileNameParser.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/LayeredFileNameParser.java Thu Sep 14 19:26:39 2017
@@ -25,32 +25,32 @@ import org.apache.commons.vfs2.FileType;
* <p>
* Additionally encodes the '!' character.
*/
-public class LayeredFileNameParser extends AbstractFileNameParser
-{
+public class LayeredFileNameParser extends AbstractFileNameParser {
private static final LayeredFileNameParser INSTANCE = new LayeredFileNameParser();
/**
* Return the Parser.
+ *
* @return The Parser.
*/
- public static LayeredFileNameParser getInstance()
- {
+ public static LayeredFileNameParser getInstance() {
return INSTANCE;
}
/**
* Determines if a character should be encoded.
+ *
* @param ch The character to check.
* @return true if the character should be encoded.
*/
@Override
- public boolean encodeCharacter(final char ch)
- {
+ public boolean encodeCharacter(final char ch) {
return super.encodeCharacter(ch) || ch == '!';
}
/**
* Parse the base and name into a FileName.
+ *
* @param context The component context.
* @param base The base FileName.
* @param filename The target file name.
@@ -59,8 +59,7 @@ public class LayeredFileNameParser exten
*/
@Override
public FileName parseUri(final VfsComponentContext context, final FileName base, final String filename)
- throws FileSystemException
- {
+ throws FileSystemException {
final StringBuilder name = new StringBuilder();
// Extract the scheme
@@ -69,8 +68,7 @@ public class LayeredFileNameParser exten
// Extract the Layered file URI
final String rootUriName = extractRootName(name);
FileName rootUri = null;
- if (rootUriName != null)
- {
+ if (rootUriName != null) {
rootUri = context.parseURI(rootUriName);
}
@@ -90,18 +88,14 @@ public class LayeredFileNameParser exten
* @return the extracted root name.
* @throws FileSystemException if error occurs.
*/
- protected String extractRootName(final StringBuilder uri)
- throws FileSystemException
- {
+ protected String extractRootName(final StringBuilder uri) throws FileSystemException {
// Looking for <name>!<abspath> (staring at the end)
final int maxlen = uri.length();
int pos = maxlen - 1;
- for (; pos > 0 && uri.charAt(pos) != '!'; pos--)
- {
+ for (; pos > 0 && uri.charAt(pos) != '!'; pos--) {
}
- if (pos == 0 && uri.charAt(pos) != '!')
- {
+ if (pos == 0 && uri.charAt(pos) != '!') {
// not ! found, so take the whole path a root
// e.g. zip:/my/zip/file.zip
pos = maxlen;
@@ -109,12 +103,9 @@ public class LayeredFileNameParser exten
// Extract the name
final String prefix = uri.substring(0, pos);
- if (pos < maxlen)
- {
+ if (pos < maxlen) {
uri.delete(0, pos + 1);
- }
- else
- {
+ } else {
uri.setLength(0);
}