Sort methods; close Javadoc tags.
MODIFY
src/main/java/org/apache/commons/io/FileDeleteStrategy.java
src/main/java/org/apache/commons/io/FileDeleteStrategy.java
* There is more than one way to delete a file.
* You may want to limit access to certain directories, to only delete
* directories if they are empty, or maybe to force deletion.
+ * </p>
* <p>
* This class captures the strategy to use and is designed for user subclassing.
+ * </p>
*
* @since 1.3
*/
public class FileDeleteStrategy {
+ /**
+ * Force file deletion strategy.
+ */
+ static class ForceFileDeleteStrategy extends FileDeleteStrategy {
+ /** Default Constructor */
+ ForceFileDeleteStrategy() {
+ super("Force");
+ }
+
+ /**
+ * Deletes the file object.
+ * <p>
+ * This implementation uses <code>FileUtils.forceDelete()</code>
+ * if the file exists.
+ * </p>
+ *
+ * @param fileToDelete the file to delete, not null
+ * @return Always returns {@code true}
+ * @throws NullPointerException if the file is null
+ * @throws IOException if an error occurs during file deletion
+ */
+ @Override
+ protected boolean doDelete(final File fileToDelete) throws IOException {
+ FileUtils.forceDelete(fileToDelete);
+ return true;
+ }
+ }
+
/**
* The singleton instance for normal file deletion, which does not permit
* the deletion of directories that are not empty.
*/
public static final FileDeleteStrategy NORMAL = new FileDeleteStrategy("Normal");
+
/**
* The singleton instance for forced file deletion, which always deletes,
* even if the file represents a non-empty directory.
/** The name of the strategy. */
private final String name;
- //-----------------------------------------------------------------------
/**
* Restricted constructor.
*
@@ -56,13 +86,30 @@ protected FileDeleteStrategy(final String name) {
this.name = name;
}
- //-----------------------------------------------------------------------
+ /**
+ * Deletes the file object, which may be a file or a directory.
+ * If the file does not exist, the method just returns.
+ * <p>
+ * Subclass writers should override {@link #doDelete(File)}, not this method.
+ * </p>
+ *
+ * @param fileToDelete the file to delete, not null
+ * @throws NullPointerException if the file is null
+ * @throws IOException if an error occurs during file deletion
+ */
+ public void delete(final File fileToDelete) throws IOException {
+ if (fileToDelete.exists() && doDelete(fileToDelete) == false) {
+ throw new IOException("Deletion failed: " + fileToDelete);
+ }
+ }
+
/**
* Deletes the file object, which may be a file or a directory.
* All <code>IOException</code>s are caught and false returned instead.
* If the file does not exist or is null, true is returned.
* <p>
* Subclass writers should override {@link #doDelete(File)}, not this method.
+ * </p>
*
* @param fileToDelete the file to delete, null returns true
* @return true if the file was deleted, or there was no such file
@@ -78,22 +125,6 @@ public boolean deleteQuietly(final File fileToDelete) {
}
}
- /**
- * Deletes the file object, which may be a file or a directory.
- * If the file does not exist, the method just returns.
- * <p>
- * Subclass writers should override {@link #doDelete(File)}, not this method.
- *
- * @param fileToDelete the file to delete, not null
- * @throws NullPointerException if the file is null
- * @throws IOException if an error occurs during file deletion
- */
- public void delete(final File fileToDelete) throws IOException {
- if (fileToDelete.exists() && doDelete(fileToDelete) == false) {
- throw new IOException("Deletion failed: " + fileToDelete);
- }
- }
-
/**
* Actually deletes the file object, which may be a file or a directory.
* <p>
@@ -102,8 +133,10 @@ public void delete(final File fileToDelete) throws IOException {
* when deletion fails. The {@link #delete(File)} and {@link #deleteQuietly(File)}
* methods will handle either response appropriately.
* A check has been made to ensure that the file will exist.
+ * </p>
* <p>
* This implementation uses {@link File#delete()}.
+ * </p>
*
* @param fileToDelete the file to delete, exists, not null
* @return true if the file was deleted
@@ -114,7 +147,6 @@ protected boolean doDelete(final File fileToDelete) throws IOException {
return fileToDelete.delete();
}
- //-----------------------------------------------------------------------
/**
* Gets a string describing the delete strategy.
*
@@ -125,32 +157,4 @@ public String toString() {
return "FileDeleteStrategy[" + name + "]";
}
- //-----------------------------------------------------------------------
- /**
- * Force file deletion strategy.
- */
- static class ForceFileDeleteStrategy extends FileDeleteStrategy {
- /** Default Constructor */
- ForceFileDeleteStrategy() {
- super("Force");
- }
-
- /**
- * Deletes the file object.
- * <p>
- * This implementation uses <code>FileUtils.forceDelete()</code>
- * if the file exists.
- *
- * @param fileToDelete the file to delete, not null
- * @return Always returns {@code true}
- * @throws NullPointerException if the file is null
- * @throws IOException if an error occurs during file deletion
- */
- @Override
- protected boolean doDelete(final File fileToDelete) throws IOException {
- FileUtils.forceDelete(fileToDelete);
- return true;
- }
- }
-
}

Sort methods; close Javadoc tags.