commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1808381 [4/25] - in /commons/proper/vfs/trunk/commons-vfs2/src: main/java/org/apache/commons/vfs2/ main/java/org/apache/commons/vfs2/auth/ main/java/org/apache/commons/vfs2/cache/ main/java/org/apache/commons/vfs2/events/ main/java/org/apa...
Date Thu, 14 Sep 2017 19:26:44 GMT
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/events/AbstractFileChangeEvent.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/events/AbstractFileChangeEvent.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/events/AbstractFileChangeEvent.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/events/AbstractFileChangeEvent.java Thu Sep 14 19:26:39 2017
@@ -23,10 +23,8 @@ import org.apache.commons.vfs2.FileObjec
 /**
  * A change event that knows how to notify a listener.
  */
-public abstract class AbstractFileChangeEvent extends FileChangeEvent
-{
-    public AbstractFileChangeEvent(final FileObject file)
-    {
+public abstract class AbstractFileChangeEvent extends FileChangeEvent {
+    public AbstractFileChangeEvent(final FileObject file) {
         super(file);
     }
 

Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/events/ChangedEvent.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/events/ChangedEvent.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/events/ChangedEvent.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/events/ChangedEvent.java Thu Sep 14 19:26:39 2017
@@ -22,16 +22,13 @@ import org.apache.commons.vfs2.FileObjec
 /**
  * File changed event.
  */
-public class ChangedEvent extends AbstractFileChangeEvent
-{
-    public ChangedEvent(final FileObject file)
-    {
+public class ChangedEvent extends AbstractFileChangeEvent {
+    public ChangedEvent(final FileObject file) {
         super(file);
     }
 
     @Override
-    public void notify(final FileListener listener) throws Exception
-    {
+    public void notify(final FileListener listener) throws Exception {
         listener.fileChanged(this);
     }
 }

Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/events/CreateEvent.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/events/CreateEvent.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/events/CreateEvent.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/events/CreateEvent.java Thu Sep 14 19:26:39 2017
@@ -22,16 +22,13 @@ import org.apache.commons.vfs2.FileObjec
 /**
  * File creation event.
  */
-public class CreateEvent extends AbstractFileChangeEvent
-{
-    public CreateEvent(final FileObject file)
-    {
+public class CreateEvent extends AbstractFileChangeEvent {
+    public CreateEvent(final FileObject file) {
         super(file);
     }
 
     @Override
-    public void notify(final FileListener listener) throws Exception
-    {
+    public void notify(final FileListener listener) throws Exception {
         listener.fileCreated(this);
     }
 }

Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/events/DeleteEvent.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/events/DeleteEvent.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/events/DeleteEvent.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/events/DeleteEvent.java Thu Sep 14 19:26:39 2017
@@ -22,16 +22,13 @@ import org.apache.commons.vfs2.FileObjec
 /**
  * File deletion event.
  */
-public class DeleteEvent extends AbstractFileChangeEvent
-{
-    public DeleteEvent(final FileObject file)
-    {
+public class DeleteEvent extends AbstractFileChangeEvent {
+    public DeleteEvent(final FileObject file) {
         super(file);
     }
 
     @Override
-    public void notify(final FileListener listener) throws Exception
-    {
+    public void notify(final FileListener listener) throws Exception {
         listener.fileDeleted(this);
     }
 }

Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DecoratedFileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DecoratedFileObject.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DecoratedFileObject.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DecoratedFileObject.java Thu Sep 14 19:26:39 2017
@@ -33,255 +33,212 @@ import org.apache.commons.vfs2.operation
 /**
  * Base class to build a fileObject decoration.
  */
-public class DecoratedFileObject implements FileObject
-{
+public class DecoratedFileObject implements FileObject {
     private final FileObject decoratedFileObject;
 
-    public DecoratedFileObject(final FileObject decoratedFileObject)
-    {
+    public DecoratedFileObject(final FileObject decoratedFileObject) {
         super();
         this.decoratedFileObject = decoratedFileObject;
     }
 
     @Override
-    public boolean canRenameTo(final FileObject newfile)
-    {
+    public boolean canRenameTo(final FileObject newfile) {
         return decoratedFileObject.canRenameTo(newfile);
     }
 
     @Override
-    public void close() throws FileSystemException
-    {
+    public void close() throws FileSystemException {
         decoratedFileObject.close();
     }
 
     @Override
-    public int compareTo(final FileObject fo)
-    {
+    public int compareTo(final FileObject fo) {
         return decoratedFileObject.compareTo(fo);
     }
 
     @Override
-    public void copyFrom(final FileObject srcFile, final FileSelector selector) throws FileSystemException
-    {
+    public void copyFrom(final FileObject srcFile, final FileSelector selector) throws FileSystemException {
         decoratedFileObject.copyFrom(srcFile, selector);
     }
 
     @Override
-    public void createFile() throws FileSystemException
-    {
+    public void createFile() throws FileSystemException {
         decoratedFileObject.createFile();
     }
 
     @Override
-    public void createFolder() throws FileSystemException
-    {
+    public void createFolder() throws FileSystemException {
         decoratedFileObject.createFolder();
     }
 
     @Override
-    public boolean delete() throws FileSystemException
-    {
+    public boolean delete() throws FileSystemException {
         return decoratedFileObject.delete();
     }
 
     @Override
-    public int delete(final FileSelector selector) throws FileSystemException
-    {
+    public int delete(final FileSelector selector) throws FileSystemException {
         return decoratedFileObject.delete(selector);
     }
 
     @Override
-    public int deleteAll() throws FileSystemException
-    {
+    public int deleteAll() throws FileSystemException {
         return decoratedFileObject.deleteAll();
     }
 
     @Override
-    public boolean exists() throws FileSystemException
-    {
+    public boolean exists() throws FileSystemException {
         return decoratedFileObject.exists();
     }
 
     @Override
-    public FileObject[] findFiles(final FileSelector selector) throws FileSystemException
-    {
+    public FileObject[] findFiles(final FileSelector selector) throws FileSystemException {
         return decoratedFileObject.findFiles(selector);
     }
 
     @Override
     public void findFiles(final FileSelector selector, final boolean depthwise, final List<FileObject> selected)
-        throws FileSystemException
-    {
+            throws FileSystemException {
         decoratedFileObject.findFiles(selector, depthwise, selected);
     }
 
     @Override
-    public FileObject getChild(final String name) throws FileSystemException
-    {
+    public FileObject getChild(final String name) throws FileSystemException {
         return decoratedFileObject.getChild(name);
     }
 
     @Override
-    public FileObject[] getChildren() throws FileSystemException
-    {
+    public FileObject[] getChildren() throws FileSystemException {
         return decoratedFileObject.getChildren();
     }
 
     @Override
-    public FileContent getContent() throws FileSystemException
-    {
+    public FileContent getContent() throws FileSystemException {
         return decoratedFileObject.getContent();
     }
 
-    public FileObject getDecoratedFileObject()
-    {
+    public FileObject getDecoratedFileObject() {
         return decoratedFileObject;
     }
 
     @Override
-    public FileOperations getFileOperations() throws FileSystemException
-    {
+    public FileOperations getFileOperations() throws FileSystemException {
         return decoratedFileObject.getFileOperations();
     }
 
     @Override
-    public FileSystem getFileSystem()
-    {
+    public FileSystem getFileSystem() {
         return decoratedFileObject.getFileSystem();
     }
 
     @Override
-    public String getPublicURIString()
-    {
+    public String getPublicURIString() {
         return decoratedFileObject.getPublicURIString();
     }
 
     @Override
-    public FileName getName()
-    {
+    public FileName getName() {
         return decoratedFileObject.getName();
     }
 
     @Override
-    public FileObject getParent() throws FileSystemException
-    {
+    public FileObject getParent() throws FileSystemException {
         return decoratedFileObject.getParent();
     }
 
     @Override
-    public FileType getType() throws FileSystemException
-    {
+    public FileType getType() throws FileSystemException {
         return decoratedFileObject.getType();
     }
 
     @Override
-    public URL getURL() throws FileSystemException
-    {
+    public URL getURL() throws FileSystemException {
         return decoratedFileObject.getURL();
     }
 
     @Override
-    public boolean isAttached()
-    {
+    public boolean isAttached() {
         return decoratedFileObject.isAttached();
     }
 
     @Override
-    public boolean isContentOpen()
-    {
+    public boolean isContentOpen() {
         return decoratedFileObject.isContentOpen();
     }
 
     @Override
-    public boolean isExecutable() throws FileSystemException
-    {
+    public boolean isExecutable() throws FileSystemException {
         return decoratedFileObject.isExecutable();
     }
 
     @Override
-    public boolean isFile() throws FileSystemException
-    {
+    public boolean isFile() throws FileSystemException {
         return decoratedFileObject.isFile();
     }
 
     @Override
-    public boolean isFolder() throws FileSystemException
-    {
+    public boolean isFolder() throws FileSystemException {
         return decoratedFileObject.isFolder();
     }
 
     @Override
-    public boolean isHidden() throws FileSystemException
-    {
+    public boolean isHidden() throws FileSystemException {
         return decoratedFileObject.isHidden();
     }
 
     @Override
-    public boolean isReadable() throws FileSystemException
-    {
+    public boolean isReadable() throws FileSystemException {
         return decoratedFileObject.isReadable();
     }
 
     @Override
-    public boolean isWriteable() throws FileSystemException
-    {
+    public boolean isWriteable() throws FileSystemException {
         return decoratedFileObject.isWriteable();
     }
 
     @Override
-    public Iterator<FileObject> iterator()
-    {
+    public Iterator<FileObject> iterator() {
         return decoratedFileObject.iterator();
     }
 
     @Override
-    public void moveTo(final FileObject destFile) throws FileSystemException
-    {
+    public void moveTo(final FileObject destFile) throws FileSystemException {
         decoratedFileObject.moveTo(destFile);
     }
 
     @Override
-    public void refresh() throws FileSystemException
-    {
+    public void refresh() throws FileSystemException {
         decoratedFileObject.refresh();
     }
 
     @Override
-    public FileObject resolveFile(final String path) throws FileSystemException
-    {
+    public FileObject resolveFile(final String path) throws FileSystemException {
         return decoratedFileObject.resolveFile(path);
     }
 
     @Override
-    public FileObject resolveFile(final String name, final NameScope scope) throws FileSystemException
-    {
+    public FileObject resolveFile(final String name, final NameScope scope) throws FileSystemException {
         return decoratedFileObject.resolveFile(name, scope);
     }
 
     @Override
-    public boolean setExecutable(final boolean executable, final boolean ownerOnly) throws FileSystemException
-    {
+    public boolean setExecutable(final boolean executable, final boolean ownerOnly) throws FileSystemException {
         return decoratedFileObject.setExecutable(executable, ownerOnly);
     }
 
     @Override
-    public boolean setReadable(final boolean readable, final boolean ownerOnly) throws FileSystemException
-    {
+    public boolean setReadable(final boolean readable, final boolean ownerOnly) throws FileSystemException {
         return decoratedFileObject.setReadable(readable, ownerOnly);
     }
 
     @Override
-    public boolean setWritable(final boolean writable, final boolean ownerOnly) throws FileSystemException
-    {
+    public boolean setWritable(final boolean writable, final boolean ownerOnly) throws FileSystemException {
         return decoratedFileObject.setWritable(writable, ownerOnly);
     }
 
     @Override
-    public String toString()
-    {
+    public String toString() {
         return decoratedFileObject.toString();
     }
 
-
 }

Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileContentInfo.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileContentInfo.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileContentInfo.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileContentInfo.java Thu Sep 14 19:26:39 2017
@@ -21,26 +21,22 @@ import org.apache.commons.vfs2.FileConte
 /**
  * The default file content information.
  */
-public class DefaultFileContentInfo implements FileContentInfo
-{
+public class DefaultFileContentInfo implements FileContentInfo {
     private final String contentType;
     private final String contentEncoding;
 
-    public DefaultFileContentInfo(final String contentType, final String contentEncoding)
-    {
+    public DefaultFileContentInfo(final String contentType, final String contentEncoding) {
         this.contentType = contentType;
         this.contentEncoding = contentEncoding;
     }
 
     @Override
-    public String getContentType()
-    {
+    public String getContentType() {
         return contentType;
     }
 
     @Override
-    public String getContentEncoding()
-    {
+    public String getContentEncoding() {
         return contentEncoding;
     }
 }

Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileMonitor.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileMonitor.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileMonitor.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileMonitor.java Thu Sep 14 19:26:39 2017
@@ -32,48 +32,42 @@ import org.apache.commons.vfs2.provider.
 /**
  * A polling {@link FileMonitor} implementation.
  * <p>
- * The DefaultFileMonitor is a Thread based polling file system monitor with a 1
- * second delay.
+ * The DefaultFileMonitor is a Thread based polling file system monitor with a 1 second delay.
  *
  * <h2>Design:</h2>
  *
- * There is a Map of monitors known as FileMonitorAgents. With the thread running,
- * each FileMonitorAgent object is asked to "check" on the file it is
- * responsible for. To do this check, the cache is cleared.
+ * There is a Map of monitors known as FileMonitorAgents. With the thread running, each FileMonitorAgent object is asked
+ * to "check" on the file it is responsible for. To do this check, the cache is cleared.
  * <ul>
- * <li>If the file existed before the refresh and it no longer exists, a delete
- * event is fired.</li>
- * <li>If the file existed before the refresh and it still exists, check the
- * last modified timestamp to see if that has changed.</li>
+ * <li>If the file existed before the refresh and it no longer exists, a delete event is fired.</li>
+ * <li>If the file existed before the refresh and it still exists, check the last modified timestamp to see if that has
+ * changed.</li>
  * <li>If it has, fire a change event.</li>
  * </ul>
- * With each file delete, the FileMonitorAgent of the parent is asked to
- * re-build its
- * list of children, so that they can be accurately checked when there are new
- * children.
+ * With each file delete, the FileMonitorAgent of the parent is asked to re-build its list of children, so that they can
+ * be accurately checked when there are new children.
  * <p>
- * New files are detected during each "check" as each file does a check for new
- * children.
- * If new children are found, create events are fired recursively if recursive
- * descent is enabled.
+ * New files are detected during each "check" as each file does a check for new children. If new children are found,
+ * create events are fired recursively if recursive descent is enabled.
  * <p>
- * For performance reasons, added a delay that increases as the number of files
- * monitored
- * increases. The default is a delay of 1 second for every 1000 files processed.
+ * For performance reasons, added a delay that increases as the number of files monitored increases. The default is a
+ * delay of 1 second for every 1000 files processed.
  *
- * <h2>Example usage:</h2><pre>
+ * <h2>Example usage:</h2>
+ * 
+ * <pre>
  * FileSystemManager fsManager = VFS.getManager();
  * FileObject listendir = fsManager.resolveFile("/home/username/monitored/");
  *
  * DefaultFileMonitor fm = new DefaultFileMonitor(new CustomFileListener());
  * fm.setRecursive(true);
  * fm.addFile(listendir);
- * fm.start();</pre>
- * <i>(where CustomFileListener is a class that implements the FileListener
- * interface.)</i>
+ * fm.start();
+ * </pre>
+ * 
+ * <i>(where CustomFileListener is a class that implements the FileListener interface.)</i>
  */
-public class DefaultFileMonitor implements Runnable, FileMonitor
-{
+public class DefaultFileMonitor implements Runnable, FileMonitor {
     private static final Log LOG = LogFactory.getLog(DefaultFileMonitor.class);
 
     private static final long DEFAULT_DELAY = 1000;
@@ -125,99 +119,83 @@ public class DefaultFileMonitor implemen
      */
     private final FileListener listener;
 
-    public DefaultFileMonitor(final FileListener listener)
-    {
+    public DefaultFileMonitor(final FileListener listener) {
         this.listener = listener;
     }
 
     /**
      * Access method to get the recursive setting when adding files for monitoring.
+     * 
      * @return true if monitoring is enabled for children.
      */
-    public boolean isRecursive()
-    {
+    public boolean isRecursive() {
         return this.recursive;
     }
 
     /**
      * Access method to set the recursive setting when adding files for monitoring.
+     * 
      * @param newRecursive true if monitoring should be enabled for children.
      */
-    public void setRecursive(final boolean newRecursive)
-    {
+    public void setRecursive(final boolean newRecursive) {
         this.recursive = newRecursive;
     }
 
     /**
-     * Access method to get the current FileListener object notified when there
-     * are changes with the files added.
+     * Access method to get the current FileListener object notified when there are changes with the files added.
+     * 
      * @return The FileListener.
      */
-    FileListener getFileListener()
-    {
+    FileListener getFileListener() {
         return this.listener;
     }
 
     /**
      * Adds a file to be monitored.
+     * 
      * @param file The FileObject to monitor.
      */
     @Override
-    public void addFile(final FileObject file)
-    {
+    public void addFile(final FileObject file) {
         doAddFile(file);
-        try
-        {
+        try {
             // add all direct children too
-            if (file.getType().hasChildren())
-            {
+            if (file.getType().hasChildren()) {
                 // Traverse the children
                 final FileObject[] children = file.getChildren();
-                for (final FileObject element : children)
-                {
+                for (final FileObject element : children) {
                     doAddFile(element);
                 }
             }
-        }
-        catch (final FileSystemException fse)
-        {
+        } catch (final FileSystemException fse) {
             LOG.error(fse.getLocalizedMessage(), fse);
         }
     }
 
     /**
      * Adds a file to be monitored.
+     * 
      * @param file The FileObject to add.
      */
-    private void doAddFile(final FileObject file)
-    {
-        synchronized (this.monitorMap)
-        {
-            if (this.monitorMap.get(file.getName()) == null)
-            {
-                this.monitorMap.put(file.getName(), new FileMonitorAgent(this,
-                    file));
-
-                try
-                {
-                    if (this.listener != null)
-                    {
+    private void doAddFile(final FileObject file) {
+        synchronized (this.monitorMap) {
+            if (this.monitorMap.get(file.getName()) == null) {
+                this.monitorMap.put(file.getName(), new FileMonitorAgent(this, file));
+
+                try {
+                    if (this.listener != null) {
                         file.getFileSystem().addListener(file, this.listener);
                     }
 
-                    if (file.getType().hasChildren() && this.recursive)
-                    {
+                    if (file.getType().hasChildren() && this.recursive) {
                         // Traverse the children
                         final FileObject[] children = file.getChildren();
-                        for (final FileObject element : children)
-                        {
+                        for (final FileObject element : children) {
                             this.addFile(element); // Add depth first
                         }
                     }
 
-                }
-                catch (final FileSystemException fse)
-                {
+                } catch (final FileSystemException fse) {
                     LOG.error(fse.getLocalizedMessage(), fse);
                 }
 
@@ -227,34 +205,26 @@ public class DefaultFileMonitor implemen
 
     /**
      * Removes a file from being monitored.
+     * 
      * @param file The FileObject to remove from monitoring.
      */
     @Override
-    public void removeFile(final FileObject file)
-    {
-        synchronized (this.monitorMap)
-        {
+    public void removeFile(final FileObject file) {
+        synchronized (this.monitorMap) {
             final FileName fn = file.getName();
-            if (this.monitorMap.get(fn) != null)
-            {
+            if (this.monitorMap.get(fn) != null) {
                 FileObject parent;
-                try
-                {
+                try {
                     parent = file.getParent();
-                }
-                catch (final FileSystemException fse)
-                {
+                } catch (final FileSystemException fse) {
                     parent = null;
                 }
 
                 this.monitorMap.remove(fn);
 
-                if (parent != null)
-                { // Not the root
-                    final FileMonitorAgent parentAgent =
-                        this.monitorMap.get(parent.getName());
-                    if (parentAgent != null)
-                    {
+                if (parent != null) { // Not the root
+                    final FileMonitorAgent parentAgent = this.monitorMap.get(parent.getName());
+                    if (parentAgent != null) {
                         parentAgent.resetChildrenList();
                     }
                 }
@@ -264,74 +234,67 @@ public class DefaultFileMonitor implemen
 
     /**
      * Queues a file for removal from being monitored.
+     * 
      * @param file The FileObject to be removed from being monitored.
      */
-    protected void queueRemoveFile(final FileObject file)
-    {
+    protected void queueRemoveFile(final FileObject file) {
         this.deleteStack.push(file);
     }
 
     /**
      * Get the delay between runs.
+     * 
      * @return The delay period.
      */
-    public long getDelay()
-    {
+    public long getDelay() {
         return delay;
     }
 
     /**
      * Set the delay between runs.
+     * 
      * @param delay The delay period.
      */
-    public void setDelay(final long delay)
-    {
-        if (delay > 0)
-        {
+    public void setDelay(final long delay) {
+        if (delay > 0) {
             this.delay = delay;
-        }
-        else
-        {
+        } else {
             this.delay = DEFAULT_DELAY;
         }
     }
 
     /**
      * get the number of files to check per run.
+     * 
      * @return The number of files to check per iteration.
      */
-    public int getChecksPerRun()
-    {
+    public int getChecksPerRun() {
         return checksPerRun;
     }
 
     /**
-     * set the number of files to check per run.
-     * a additional delay will be added if there are more files to check
+     * set the number of files to check per run. a additional delay will be added if there are more files to check
      *
      * @param checksPerRun a value less than 1 will disable this feature
      */
-    public void setChecksPerRun(final int checksPerRun)
-    {
+    public void setChecksPerRun(final int checksPerRun) {
         this.checksPerRun = checksPerRun;
     }
 
     /**
      * Queues a file for addition to be monitored.
+     * 
      * @param file The FileObject to add.
      */
-    protected void queueAddFile(final FileObject file)
-    {
+    protected void queueAddFile(final FileObject file) {
         this.addStack.push(file);
     }
 
     /**
      * Starts monitoring the files that have been added.
      */
-    public void start()
-    {
-        if (this.monitorThread == null)
-        {
+    public void start() {
+        if (this.monitorThread == null) {
             this.monitorThread = new Thread(this);
             this.monitorThread.setDaemon(true);
             this.monitorThread.setPriority(Thread.MIN_PRIORITY);
@@ -342,8 +305,7 @@ public class DefaultFileMonitor implemen
     /**
      * Stops monitoring the files that have been added.
      */
-    public void stop()
-    {
+    public void stop() {
         this.shouldRun = false;
     }
 
@@ -351,65 +313,47 @@ public class DefaultFileMonitor implemen
      * Asks the agent for each file being monitored to check its file for changes.
      */
     @Override
-    public void run()
-    {
-        mainloop:
-        while (!monitorThread.isInterrupted() && this.shouldRun)
-        {
+    public void run() {
+        mainloop: while (!monitorThread.isInterrupted() && this.shouldRun) {
             // For each entry in the map
             Object[] fileNames;
-            synchronized (this.monitorMap)
-            {
+            synchronized (this.monitorMap) {
                 fileNames = this.monitorMap.keySet().toArray();
             }
-            for (int iterFileNames = 0; iterFileNames < fileNames.length;
-                 iterFileNames++)
-            {
+            for (int iterFileNames = 0; iterFileNames < fileNames.length; iterFileNames++) {
                 final FileName fileName = (FileName) fileNames[iterFileNames];
                 FileMonitorAgent agent;
-                synchronized (this.monitorMap)
-                {
+                synchronized (this.monitorMap) {
                     agent = this.monitorMap.get(fileName);
                 }
-                if (agent != null)
-                {
+                if (agent != null) {
                     agent.check();
                 }
 
-                if (getChecksPerRun() > 0 && (iterFileNames + 1) % getChecksPerRun() == 0)
-                {
-                    try
-                    {
+                if (getChecksPerRun() > 0 && (iterFileNames + 1) % getChecksPerRun() == 0) {
+                    try {
                         Thread.sleep(getDelay());
-                    }
-                    catch (final InterruptedException e)
-                    {
+                    } catch (final InterruptedException e) {
                         // Woke up.
                     }
                 }
 
-                if (monitorThread.isInterrupted() || !this.shouldRun)
-                {
+                if (monitorThread.isInterrupted() || !this.shouldRun) {
                     continue mainloop;
                 }
             }
 
-            while (!this.addStack.empty())
-            {
+            while (!this.addStack.empty()) {
                 this.addFile(this.addStack.pop());
             }
 
-            while (!this.deleteStack.empty())
-            {
+            while (!this.deleteStack.empty()) {
                 this.removeFile(this.deleteStack.pop());
             }
 
-            try
-            {
+            try {
                 Thread.sleep(getDelay());
-            }
-            catch (final InterruptedException e)
-            {
+            } catch (final InterruptedException e) {
                 continue;
             }
         }
@@ -420,8 +364,7 @@ public class DefaultFileMonitor implemen
     /**
      * File monitor agent.
      */
-    private static final class FileMonitorAgent
-    {
+    private static final class FileMonitorAgent {
         private final FileObject file;
         private final DefaultFileMonitor fm;
 
@@ -429,142 +372,103 @@ public class DefaultFileMonitor implemen
         private long timestamp;
         private Map<FileName, Object> children;
 
-        private FileMonitorAgent(final DefaultFileMonitor fm, final FileObject file)
-        {
+        private FileMonitorAgent(final DefaultFileMonitor fm, final FileObject file) {
             this.fm = fm;
             this.file = file;
 
             this.refresh();
             this.resetChildrenList();
 
-            try
-            {
+            try {
                 this.exists = this.file.exists();
-            }
-            catch (final FileSystemException fse)
-            {
+            } catch (final FileSystemException fse) {
                 this.exists = false;
                 this.timestamp = -1;
             }
 
-            if (this.exists)
-            {
-                try
-                {
+            if (this.exists) {
+                try {
                     this.timestamp = this.file.getContent().getLastModifiedTime();
-                }
-                catch (final FileSystemException fse)
-                {
+                } catch (final FileSystemException fse) {
                     this.timestamp = -1;
                 }
             }
         }
 
-        private void resetChildrenList()
-        {
-            try
-            {
-                if (this.file.getType().hasChildren())
-                {
+        private void resetChildrenList() {
+            try {
+                if (this.file.getType().hasChildren()) {
                     this.children = new HashMap<>();
                     final FileObject[] childrenList = this.file.getChildren();
-                    for (final FileObject element : childrenList)
-                    {
-                        this.children.put(element.getName(), new
-                            Object()); // null?
+                    for (final FileObject element : childrenList) {
+                        this.children.put(element.getName(), new Object()); // null?
                     }
                 }
-            }
-            catch (final FileSystemException fse)
-            {
+            } catch (final FileSystemException fse) {
                 this.children = null;
             }
         }
 
-
         /**
          * Clear the cache and re-request the file object
          */
-        private void refresh()
-        {
-            try
-            {
+        private void refresh() {
+            try {
                 this.file.refresh();
-            }
-            catch (final FileSystemException fse)
-            {
+            } catch (final FileSystemException fse) {
                 LOG.error(fse.getLocalizedMessage(), fse);
             }
         }
 
-
         /**
-         * Recursively fires create events for all children if recursive descent is
-         * enabled. Otherwise the create event is only fired for the initial
-         * FileObject.
+         * Recursively fires create events for all children if recursive descent is enabled. Otherwise the create event
+         * is only fired for the initial FileObject.
+         * 
          * @param child The child to add.
          */
-        private void fireAllCreate(final FileObject child)
-        {
+        private void fireAllCreate(final FileObject child) {
             // Add listener so that it can be triggered
-            if (this.fm.getFileListener() != null)
-            {
+            if (this.fm.getFileListener() != null) {
                 child.getFileSystem().addListener(child, this.fm.getFileListener());
             }
 
             ((AbstractFileSystem) child.getFileSystem()).fireFileCreated(child);
 
             // Remove it because a listener is added in the queueAddFile
-            if (this.fm.getFileListener() != null)
-            {
-                child.getFileSystem().removeListener(child,
-                    this.fm.getFileListener());
+            if (this.fm.getFileListener() != null) {
+                child.getFileSystem().removeListener(child, this.fm.getFileListener());
             }
 
             this.fm.queueAddFile(child); // Add
 
-            try
-            {
-                if (this.fm.isRecursive() && child.getType().hasChildren())
-                {
+            try {
+                if (this.fm.isRecursive() && child.getType().hasChildren()) {
                     final FileObject[] newChildren = child.getChildren();
-                    for (final FileObject element : newChildren)
-                    {
+                    for (final FileObject element : newChildren) {
                         fireAllCreate(element);
                     }
                 }
-            }
-            catch (final FileSystemException fse)
-            {
+            } catch (final FileSystemException fse) {
                 LOG.error(fse.getLocalizedMessage(), fse);
             }
         }
 
         /**
-         * Only checks for new children. If children are removed, they'll
-         * eventually be checked.
+         * Only checks for new children. If children are removed, they'll eventually be checked.
          */
-        private void checkForNewChildren()
-        {
-            try
-            {
-                if (this.file.getType().hasChildren())
-                {
+        private void checkForNewChildren() {
+            try {
+                if (this.file.getType().hasChildren()) {
                     final FileObject[] newChildren = this.file.getChildren();
-                    if (this.children != null)
-                    {
+                    if (this.children != null) {
                         // See which new children are not listed in the current children map.
                         final Map<FileName, Object> newChildrenMap = new HashMap<>();
                         final Stack<FileObject> missingChildren = new Stack<>();
 
-                        for (int i = 0; i < newChildren.length; i++)
-                        {
-                            newChildrenMap.put(newChildren[i].getName(), new
-                                Object()); // null ?
+                        for (int i = 0; i < newChildren.length; i++) {
+                            newChildrenMap.put(newChildren[i].getName(), new Object()); // null ?
                             // If the child's not there
-                            if
-                                (!this.children.containsKey(newChildren[i].getName()))
-                            {
+                            if (!this.children.containsKey(newChildren[i].getName())) {
                                 missingChildren.push(newChildren[i]);
                             }
                         }
@@ -572,103 +476,77 @@ public class DefaultFileMonitor implemen
                         this.children = newChildrenMap;
 
                         // If there were missing children
-                        if (!missingChildren.empty())
-                        {
+                        if (!missingChildren.empty()) {
 
-                            while (!missingChildren.empty())
-                            {
+                            while (!missingChildren.empty()) {
                                 final FileObject child = missingChildren.pop();
                                 this.fireAllCreate(child);
                             }
                         }
 
-                    }
-                    else
-                    {
+                    } else {
                         // First set of children - Break out the cigars
-                        if (newChildren.length > 0)
-                        {
+                        if (newChildren.length > 0) {
                             this.children = new HashMap<>();
                         }
-                        for (final FileObject element : newChildren)
-                        {
-                            this.children.put(element.getName(), new
-                                Object()); // null?
+                        for (final FileObject element : newChildren) {
+                            this.children.put(element.getName(), new Object()); // null?
                             this.fireAllCreate(element);
                         }
                     }
                 }
-            }
-            catch (final FileSystemException fse)
-            {
+            } catch (final FileSystemException fse) {
                 LOG.error(fse.getLocalizedMessage(), fse);
             }
         }
 
-        private void check()
-        {
+        private void check() {
             this.refresh();
 
-            try
-            {
+            try {
                 // If the file existed and now doesn't
-                if (this.exists && !this.file.exists())
-                {
+                if (this.exists && !this.file.exists()) {
                     this.exists = this.file.exists();
                     this.timestamp = -1;
 
                     // Fire delete event
 
-                    ((AbstractFileSystem)
-                        this.file.getFileSystem()).fireFileDeleted(this.file);
+                    ((AbstractFileSystem) this.file.getFileSystem()).fireFileDeleted(this.file);
 
                     // Remove listener in case file is re-created. Don't want to fire twice.
-                    if (this.fm.getFileListener() != null)
-                    {
-                        this.file.getFileSystem().removeListener(this.file,
-                            this.fm.getFileListener());
+                    if (this.fm.getFileListener() != null) {
+                        this.file.getFileSystem().removeListener(this.file, this.fm.getFileListener());
                     }
 
                     // Remove from map
                     this.fm.queueRemoveFile(this.file);
-                }
-                else if (this.exists && this.file.exists())
-                {
+                } else if (this.exists && this.file.exists()) {
 
                     // Check the timestamp to see if it has been modified
-                    if (this.timestamp != this.file.getContent().getLastModifiedTime())
-                    {
+                    if (this.timestamp != this.file.getContent().getLastModifiedTime()) {
                         this.timestamp = this.file.getContent().getLastModifiedTime();
                         // Fire change event
 
                         // Don't fire if it's a folder because new file children
                         // and deleted files in a folder have their own event triggered.
-                        if (!this.file.getType().hasChildren())
-                        {
-                            ((AbstractFileSystem)
-                                this.file.getFileSystem()).fireFileChanged(this.file);
+                        if (!this.file.getType().hasChildren()) {
+                            ((AbstractFileSystem) this.file.getFileSystem()).fireFileChanged(this.file);
                         }
                     }
 
-                }
-                else if (!this.exists && this.file.exists())
-                {
+                } else if (!this.exists && this.file.exists()) {
                     this.exists = this.file.exists();
                     this.timestamp = this.file.getContent().getLastModifiedTime();
                     // Don't fire if it's a folder because new file children
                     // and deleted files in a folder have their own event triggered.
-                    if (!this.file.getType().hasChildren())
-                    {
-                        ((AbstractFileSystem)
-                                this.file.getFileSystem()).fireFileCreated(this.file);
+                    if (!this.file.getType().hasChildren()) {
+                        ((AbstractFileSystem) this.file.getFileSystem()).fireFileCreated(this.file);
                     }
                 }
 
                 this.checkForNewChildren();
 
-            }
-            catch (final FileSystemException fse)
-            {
+            } catch (final FileSystemException fse) {
                 LOG.error(fse.getLocalizedMessage(), fse);
             }
         }

Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileReplicator.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileReplicator.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileReplicator.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileReplicator.java Thu Sep 14 19:26:39 2017
@@ -35,27 +35,21 @@ import org.apache.commons.vfs2.util.Mess
 /**
  * A simple file replicator and temporary file store.
  */
-public class DefaultFileReplicator
-    extends AbstractVfsComponent
-    implements FileReplicator, TemporaryFileStore
-{
+public class DefaultFileReplicator extends AbstractVfsComponent implements FileReplicator, TemporaryFileStore {
     private static final Log log = LogFactory.getLog(DefaultFileReplicator.class);
     private static final int MASK = 0xffff;
 
     private static final Random random = new Random();
 
-    private static final char[] TMP_RESERVED_CHARS = new char[]
-        {
-            '?', '/', '\\', ' ', '&', '"', '\'', '*', '#', ';', ':', '<', '>', '|'
-        };
+    private static final char[] TMP_RESERVED_CHARS = new char[] { '?', '/', '\\', ' ', '&', '"', '\'', '*', '#', ';',
+            ':', '<', '>', '|' };
 
     private final ArrayList<Object> copies = new ArrayList<>();
     private long filecount;
     private File tempDir;
     private boolean tempDirMessageLogged;
 
-    public DefaultFileReplicator()
-    {
+    public DefaultFileReplicator() {
     }
 
     /**
@@ -63,15 +57,12 @@ public class DefaultFileReplicator
      *
      * @param tempDir The temporary directory.
      */
-    public DefaultFileReplicator(final File tempDir)
-    {
+    public DefaultFileReplicator(final File tempDir) {
         this.tempDir = tempDir;
     }
 
-    protected void addFile(final Object file)
-    {
-        synchronized (copies)
-        {
+    protected void addFile(final Object file) {
+        synchronized (copies) {
             copies.add(file);
         }
     }
@@ -84,12 +75,10 @@ public class DefaultFileReplicator
      * @throws FileSystemException if an error occurs.
      */
     @Override
-    public File allocateFile(final String baseName) throws FileSystemException
-    {
+    public File allocateFile(final String baseName) throws FileSystemException {
         // Create a unique-ish file name
         final String basename = createFilename(baseName);
-        synchronized (this)
-        {
+        synchronized (this) {
             filecount++;
         }
 
@@ -100,28 +89,23 @@ public class DefaultFileReplicator
      * Closes the replicator, deleting all temporary files.
      */
     @Override
-    public void close()
-    {
+    public void close() {
         // Delete the temporary files
-        synchronized (copies)
-        {
-            while (copies.size() > 0)
-            {
+        synchronized (copies) {
+            while (copies.size() > 0) {
                 final File file = (File) removeFile();
                 deleteFile(file);
             }
         }
 
         // Clean up the temp directory, if it is empty
-        if (tempDir != null && tempDir.exists() && tempDir.list().length == 0)
-        {
+        if (tempDir != null && tempDir.exists() && tempDir.list().length == 0) {
             tempDir.delete();
             tempDir = null;
         }
     }
 
-    protected File createAndAddFile(final File parent, final String basename) throws FileSystemException
-    {
+    protected File createAndAddFile(final File parent, final String basename) throws FileSystemException {
         final File file = createFile(tempDir, basename);
 
         // Keep track to delete later
@@ -138,8 +122,7 @@ public class DefaultFileReplicator
      * @return The File that was created.
      * @throws FileSystemException if an error occurs creating the file.
      */
-    protected File createFile(final File parent, final String name) throws FileSystemException
-    {
+    protected File createFile(final File parent, final String name) throws FileSystemException {
         return new File(parent, UriParser.decode(name));
     }
 
@@ -149,8 +132,7 @@ public class DefaultFileReplicator
      * @param baseName The base to prepend to the file name being created.
      * @return the name of the File.
      */
-    protected String createFilename(final String baseName)
-    {
+    protected String createFilename(final String baseName) {
         // BUG29007
         // return baseName + "_" + getFilecount() + ".tmp";
 
@@ -165,22 +147,17 @@ public class DefaultFileReplicator
      *
      * @param file The File to delete.
      */
-    protected void deleteFile(final File file)
-    {
-        try
-        {
+    protected void deleteFile(final File file) {
+        try {
             final FileObject fileObject = getContext().toFileObject(file);
             fileObject.deleteAll();
-        }
-        catch (final FileSystemException e)
-        {
+        } catch (final FileSystemException e) {
             final String message = Messages.getString("vfs.impl/delete-temp.warn", file.getName());
             VfsLog.warn(getLogger(), log, message, e);
         }
     }
 
-    protected long getFilecount()
-    {
+    protected long getFilecount() {
         return filecount;
     }
 
@@ -190,10 +167,8 @@ public class DefaultFileReplicator
      * @throws FileSystemException if an error occurs.
      */
     @Override
-    public void init() throws FileSystemException
-    {
-        if (tempDir == null)
-        {
+    public void init() throws FileSystemException {
+        if (tempDir == null) {
             final String baseTmpDir = System.getProperty("java.io.tmpdir");
 
             tempDir = new File(baseTmpDir, "vfs_cache").getAbsoluteFile();
@@ -201,8 +176,7 @@ public class DefaultFileReplicator
 
         filecount = random.nextInt() & MASK;
 
-        if (!tempDirMessageLogged)
-        {
+        if (!tempDirMessageLogged) {
             final String message = Messages.getString("vfs.impl/temp-dir.debug", tempDir);
             VfsLog.debug(getLogger(), log, message);
 
@@ -217,10 +191,8 @@ public class DefaultFileReplicator
      *
      * @return the File that was removed.
      */
-    protected Object removeFile()
-    {
-        synchronized (copies)
-        {
+    protected Object removeFile() {
+        synchronized (copies) {
             return copies.remove(0);
         }
     }
@@ -230,10 +202,8 @@ public class DefaultFileReplicator
      *
      * @param file The File to remove.
      */
-    protected void removeFile(final Object file)
-    {
-        synchronized (copies)
-        {
+    protected void removeFile(final Object file) {
+        synchronized (copies) {
             copies.remove(file);
         }
     }
@@ -247,10 +217,7 @@ public class DefaultFileReplicator
      * @throws FileSystemException if an error occurs copying the file.
      */
     @Override
-    public File replicateFile(final FileObject srcFile,
-                              final FileSelector selector)
-        throws FileSystemException
-    {
+    public File replicateFile(final FileObject srcFile, final FileSelector selector) throws FileSystemException {
         final String basename = srcFile.getName().getBaseName();
         final File file = allocateFile(basename);
 

Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileSystemConfigBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileSystemConfigBuilder.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileSystemConfigBuilder.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/DefaultFileSystemConfigBuilder.java Thu Sep 14 19:26:39 2017
@@ -25,8 +25,7 @@ import org.apache.commons.vfs2.UserAuthe
 /**
  * Default options usable for all file systems.
  */
-public class DefaultFileSystemConfigBuilder extends FileSystemConfigBuilder
-{
+public class DefaultFileSystemConfigBuilder extends FileSystemConfigBuilder {
     /** The default FileSystemConfigBuilder */
     private static final DefaultFileSystemConfigBuilder BUILDER = new DefaultFileSystemConfigBuilder();
 
@@ -35,20 +34,19 @@ public class DefaultFileSystemConfigBuil
      *
      * @return the singleton builder.
      */
-    public static DefaultFileSystemConfigBuilder getInstance()
-    {
+    public static DefaultFileSystemConfigBuilder getInstance() {
         return BUILDER;
     }
 
     /**
      * Sets the user authenticator to get authentication informations.
+     * 
      * @param opts The FileSystemOptions.
      * @param userAuthenticator The UserAuthenticator.
      * @throws FileSystemException if an error occurs setting the UserAuthenticator.
      */
     public void setUserAuthenticator(final FileSystemOptions opts, final UserAuthenticator userAuthenticator)
-            throws FileSystemException
-    {
+            throws FileSystemException {
         setParam(opts, "userAuthenticator", userAuthenticator);
     }
 
@@ -57,21 +55,18 @@ public class DefaultFileSystemConfigBuil
      * @param opts The FileSystemOptions.
      * @return The UserAuthenticator.
      */
-    public UserAuthenticator getUserAuthenticator(final FileSystemOptions opts)
-    {
+    public UserAuthenticator getUserAuthenticator(final FileSystemOptions opts) {
         return (UserAuthenticator) getParam(opts, "userAuthenticator");
     }
 
     /**
      * Dummy class that implements FileSystem.
      */
-    abstract static class DefaultFileSystem implements FileSystem
-    {
+    abstract static class DefaultFileSystem implements FileSystem {
     }
 
     @Override
-    protected Class<? extends FileSystem> getConfigClass()
-    {
+    protected Class<? extends FileSystem> getConfigClass() {
         return DefaultFileSystem.class;
     }
 }



Mime
View raw message