org.apache.wicket.util.file
Class Folder

java.lang.Object
  extended by java.io.File
      extended by org.apache.wicket.util.file.File
          extended by org.apache.wicket.util.file.Folder
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<java.io.File>, IModifiable

public class Folder
extends File

This folder subclass provides some type safety and extensibility for "files" that hold other files.

Author:
Jonathan Locke
See Also:
Serialized Form

Nested Class Summary
static interface Folder.FileFilter
          Filter for files
static interface Folder.FolderFilter
          Filter for folders
 
Field Summary
 
Fields inherited from class java.io.File
pathSeparator, pathSeparatorChar, separator, separatorChar
 
Constructor Summary
Folder(java.io.File file)
          Construct.
Folder(Folder parent, java.lang.String child)
          Constructor.
Folder(java.lang.String pathname)
          Constructor.
Folder(java.lang.String parent, java.lang.String child)
          Constructor.
Folder(java.net.URI uri)
          Constructor.
 
Method Summary
 void ensureExists()
          Does a mkdirs() on this folder if it does not exist.
 Folder folder(java.lang.String name)
           
 File[] getFiles()
           
 File[] getFiles(Folder.FileFilter filter)
           
 Folder[] getFolders()
          Gets all folders in this folder, except "." and ".."
 Folder[] getFolders(Folder.FolderFilter filter)
           
 File[] getNestedFiles()
           
 File[] getNestedFiles(Folder.FileFilter filter)
          Gets files in this folder matching a given filter recursively.
 boolean remove()
          Removes this folder and everything in it, recursively.
 boolean removeFiles()
          Removes all the files in this folder.
 
Methods inherited from class org.apache.wicket.util.file.File
file, getExtension, getParentFolder, inputStream, lastModifiedTime, outputStream, readObject, readString, sync, toQuotedString, write, write, write, writeObject
 
Methods inherited from class java.io.File
canExecute, canRead, canWrite, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, equals, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getFreeSpace, getName, getParent, getParentFile, getPath, getTotalSpace, getUsableSpace, hashCode, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, list, listFiles, listFiles, listFiles, listRoots, mkdir, mkdirs, renameTo, setExecutable, setExecutable, setLastModified, setReadable, setReadable, setReadOnly, setWritable, setWritable, toString, toURI, toURL
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Folder

public Folder(Folder parent,
              java.lang.String child)
Constructor.

Parameters:
parent - parent
child - child

Folder

public Folder(java.io.File file)
Construct.

Parameters:
file - File

Folder

public Folder(java.lang.String pathname)
Constructor.

Parameters:
pathname - path name

Folder

public Folder(java.lang.String parent,
              java.lang.String child)
Constructor.

Parameters:
parent - parent
child - child

Folder

public Folder(java.net.URI uri)
Constructor.

Parameters:
uri - folder uri
Method Detail

ensureExists

public void ensureExists()
                  throws java.io.IOException
Does a mkdirs() on this folder if it does not exist. If the folder cannot be created, an IOException is thrown.

Throws:
java.io.IOException - Thrown if folder cannot be created

folder

public Folder folder(java.lang.String name)
Parameters:
name - Name of child folder
Returns:
Child file object

getFiles

public File[] getFiles()
Returns:
Files in this folder

getNestedFiles

public File[] getNestedFiles()
Returns:
All files nested within this folder

getNestedFiles

public File[] getNestedFiles(Folder.FileFilter filter)
Gets files in this folder matching a given filter recursively.

Parameters:
filter - The filter
Returns:
The list of files

getFiles

public File[] getFiles(Folder.FileFilter filter)
Parameters:
filter - File filter
Returns:
Files

getFolders

public Folder[] getFolders()
Gets all folders in this folder, except "." and ".."

Returns:
Folders

getFolders

public Folder[] getFolders(Folder.FolderFilter filter)
Parameters:
filter - Folder filter
Returns:
Folders

remove

public boolean remove()
Removes this folder and everything in it, recursively. A best effort is made to remove nested folders and files in depth-first order.

Overrides:
remove in class File
Returns:
True if the folder was successfully removed
See Also:
File.delete()

removeFiles

public boolean removeFiles()
Removes all the files in this folder.

Returns:
True if any files were successfully removed


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.