|
Apache Tomcat 7.0.28 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.tomcat.util.http.fileupload.FileDeleteStrategy
public class FileDeleteStrategy
Strategy for deleting files.
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.
This class captures the strategy to use and is designed for user subclassing.
Field Summary | |
---|---|
static FileDeleteStrategy |
FORCE
The singleton instance for forced file deletion, which always deletes, even if the file represents a non-empty directory. |
static FileDeleteStrategy |
NORMAL
The singleton instance for normal file deletion, which does not permit the deletion of directories that are not empty. |
Constructor Summary | |
---|---|
protected |
FileDeleteStrategy(String name)
Restricted constructor. |
Method Summary | |
---|---|
void |
delete(File fileToDelete)
Deletes the file object, which may be a file or a directory. |
boolean |
deleteQuietly(File fileToDelete)
Deletes the file object, which may be a file or a directory. |
protected boolean |
doDelete(File fileToDelete)
Actually deletes the file object, which may be a file or a directory. |
String |
toString()
Gets a string describing the delete strategy. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final FileDeleteStrategy NORMAL
public static final FileDeleteStrategy FORCE
Constructor Detail |
---|
protected FileDeleteStrategy(String name)
name
- the name by which the strategy is knownMethod Detail |
---|
public boolean deleteQuietly(File fileToDelete)
IOException
s are caught and false returned instead.
If the file does not exist or is null, true is returned.
Subclass writers should override doDelete(File)
, not this method.
fileToDelete
- the file to delete, null returns true
public void delete(File fileToDelete) throws IOException
Subclass writers should override doDelete(File)
, not this method.
fileToDelete
- the file to delete, not null
NullPointerException
- if the file is null
IOException
- if an error occurs during file deletionprotected boolean doDelete(File fileToDelete) throws IOException
This method is designed for subclasses to override.
The implementation may return either false or an IOException
when deletion fails. The delete(File)
and deleteQuietly(File)
methods will handle either response appropriately.
A check has been made to ensure that the file will exist.
This implementation uses File.delete()
.
fileToDelete
- the file to delete, exists, not null
NullPointerException
- if the file is null
IOException
- if an error occurs during file deletionpublic String toString()
toString
in class Object
|
Apache Tomcat 7.0.28 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |