dk.apaq.vfs
Interface Directory

All Superinterfaces:
Comparable, Node, Serializable
All Known Implementing Classes:
CifsDirectory, LayeredDirectory, NativeDirectory, RamDirectory, SftpDirectory, SubDirectory

public interface Directory
extends Node

Author:
mzk

Method Summary
 Directory createDirectory(String name)
          Creates a new directory.
 File createFile(String name)
          Creates a new File.
 void delete(boolean recursive)
          Deletes the current directory.
 Node getChild(String name)
          Retrieves a child with the given name.
 List<Node> getChildren()
          Retrieves a list of all children in the directory.
 List<Node> getChildren(NodeFilter filter)
          Retrieves a list of children in the directory.
 List<Directory> getDirectories()
          Retrieves a list of all directories in the directory.
 List<Directory> getDirectories(NodeFilter filter)
          Retrieves a list of directories in the directory.
 Directory getDirectory(String name)
          Retrieves a directory with the given name.
 Directory getDirectory(String name, boolean createIfNeeded)
          Retrieves a directory with the given name.
 File getFile(String name)
          Retrieves a file with the given name.
 File getFile(String name, boolean createIfNeeded)
          Retrieves a file with the given name.
 List<File> getFiles()
          Retrieves a list of all files in the directory.
 List<File> getFiles(NodeFilter filter)
          Retrieves a list of files in the directory.
 boolean hasChild(String name)
          Checks wether the directory contains a child(File of Directory) with the given name.
 boolean hasDirectory(String name)
          Checks wether the directory contains a directory with the given name.
 boolean hasFile(String name)
          Checks wether the directory contains a file with the given name.
 boolean isBundle()
          Wether this directory is a bundle or not.
 boolean isRoot()
          Checks wether this directory is the root of the filesystem.
 
Methods inherited from interface dk.apaq.vfs.Node
canRead, canWrite, compareTo, delete, equals, getBaseName, getFileSystem, getLastModified, getName, getParent, getPath, getSuffix, isDirectory, isFile, isHidden, moveTo, moveTo, setLastModified, setName, toUri
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Method Detail

createDirectory

Directory createDirectory(String name)
                          throws IOException
Creates a new directory.

Parameters:
name - The name of the new directory.
Returns:
Returns the new directory.
Throws:
IOException - Throws if an error occurs while creating the directory.

createFile

File createFile(String name)
                throws IOException
Creates a new File.

Parameters:
name - The name of the new file.
Returns:
Returns the new file.
Throws:
IOException - Thrown if an error occurs while creating the new file.

isRoot

boolean isRoot()
Checks wether this directory is the root of the filesystem.

Returns:
True/False wether the directory is the root.

hasChild

boolean hasChild(String name)
Checks wether the directory contains a child(File of Directory) with the given name.

Parameters:
name - The name of the child.
Returns:
True/False wether the directory contains a child with the given name.

hasFile

boolean hasFile(String name)
Checks wether the directory contains a file with the given name.

Parameters:
name - The name of the file.
Returns:
True/False wether the directory contains a file with the given name. If the directory holds a directory with the given name, the method returns false.

hasDirectory

boolean hasDirectory(String name)
Checks wether the directory contains a directory with the given name.

Parameters:
name - The name of the directory.
Returns:
True/False wether the directory contains a directory with the given name. If the directory holds a file with the given name, the method returns false.

getChild

Node getChild(String name)
              throws FileNotFoundException
Retrieves a child with the given name.

Parameters:
name - The name of the child to retrieve.
Returns:
Returns the child as a Node.
Throws:
FileNotFoundException - Thrown if no child with the given name exists.

getFile

File getFile(String name)
             throws FileNotFoundException
Retrieves a file with the given name.

Parameters:
name - The name of the file to retrieve.
Returns:
Returns the file.
Throws:
FileNotFoundException - Thrown if no file with the given name exists or the child with the given name is a directory.

getDirectory

Directory getDirectory(String name)
                       throws FileNotFoundException
Retrieves a directory with the given name.

Parameters:
name - The name of the directory to retrieve.
Returns:
Returns the directory.
Throws:
FileNotFoundException - Thrown if no directory with the given name exists or the child with the given name is a file.

getFile

File getFile(String name,
             boolean createIfNeeded)
             throws FileNotFoundException,
                    IOException
Retrieves a file with the given name.

Parameters:
name - The name of the file to retrieve.
createIfNeeded - Wether the file should be created if it does not exist.
Returns:
Returns the file.
Throws:
FileNotFoundException - Thrown if no file with the given name exists or the child with the given name is a directory.
IOException - Thrown if an error occurs while creating file.

getDirectory

Directory getDirectory(String name,
                       boolean createIfNeeded)
                       throws FileNotFoundException,
                              IOException
Retrieves a directory with the given name.

Parameters:
name - The name of the directory to retrieve.
createIfNeeded - Wether the directory should be created if it does not exist.
Returns:
Returns the directory.
Throws:
FileNotFoundException - Thrown if no directory with the given name exists or the child with the given name is a file.
IOException - Thrown if an error occurs while creating directory.

getChildren

List<Node> getChildren()
Retrieves a list of all children in the directory.

Returns:
The list of all children.

getDirectories

List<Directory> getDirectories()
Retrieves a list of all directories in the directory.

Returns:
The list of directories.

getFiles

List<File> getFiles()
Retrieves a list of all files in the directory.

Returns:
The list of files.

getChildren

List<Node> getChildren(NodeFilter filter)
Retrieves a list of children in the directory.

Parameters:
filer - The filter to use for listing children or null to list all children.
Returns:
The list of children.

getDirectories

List<Directory> getDirectories(NodeFilter filter)
Retrieves a list of directories in the directory.

Parameters:
filer - The filter to use for listing directories or null to list all directories.
Returns:
The list of directories.

getFiles

List<File> getFiles(NodeFilter filter)
Retrieves a list of files in the directory.

Parameters:
filer - The filter to use for listing files or null to list all files.
Returns:
The list of files.

delete

void delete(boolean recursive)
            throws IOException
Deletes the current directory.

Parameters:
recursive - Wether the deletion should be recursive.
Throws:
IOException - Thrown if an error occurs during deletion.

isBundle

boolean isBundle()
Wether this directory is a bundle or not. A bundle is a normal directory, but its contents is not intended to be shown in a GUI. It can be treated kinda like a ZIP-file(a single unit containing files and directories) except this is not really packed in anyway. It is only a logical boundary. Bundles are identied by the directory name having a suffix. Mac OS uses this a lot for Applications etc. (Safari.app)

Returns:
Wether its a bundle.


Copyright © 2011. All Rights Reserved.