dk.apaq.vfs.impl.nativefs
Class NativeDirectory

java.lang.Object
  extended by dk.apaq.vfs.impl.nativefs.NativeNode
      extended by dk.apaq.vfs.impl.nativefs.NativeDirectory
All Implemented Interfaces:
Directory, Node, Serializable, Comparable

public class NativeDirectory
extends NativeNode
implements Directory

Author:
mzk
See Also:
Serialized Form

Field Summary
 
Fields inherited from class dk.apaq.vfs.impl.nativefs.NativeNode
file, fs
 
Constructor Summary
NativeDirectory(NativeFileSystem fs, File file)
           
 
Method Summary
 Directory createDirectory(String name)
          Creates a new directory.
 File createFile(String name)
          Creates a new File.
 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.
 
Methods inherited from class dk.apaq.vfs.impl.nativefs.NativeNode
canRead, canWrite, compareTo, compareTo, delete, delete, equals, equals, getBaseName, getFileSystem, getLastModified, getName, getParent, getPath, getSuffix, isDirectory, isFile, isHidden, isRoot, moveTo, moveTo, setLastModified, setName, toUri
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface dk.apaq.vfs.Directory
delete, isRoot
 
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
 

Constructor Detail

NativeDirectory

public NativeDirectory(NativeFileSystem fs,
                       File file)
                throws FileNotFoundException
Throws:
FileNotFoundException
Method Detail

createDirectory

public Directory createDirectory(String name)
                          throws IOException
Description copied from interface: Directory
Creates a new directory.

Specified by:
createDirectory in interface 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

public File createFile(String name)
                throws IOException
Description copied from interface: Directory
Creates a new File.

Specified by:
createFile in interface Directory
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.

getChildren

public List<Node> getChildren()
Description copied from interface: Directory
Retrieves a list of all children in the directory.

Specified by:
getChildren in interface Directory
Returns:
The list of all children.

getDirectories

public List<Directory> getDirectories()
Description copied from interface: Directory
Retrieves a list of all directories in the directory.

Specified by:
getDirectories in interface Directory
Returns:
The list of directories.

getFiles

public List<File> getFiles()
Description copied from interface: Directory
Retrieves a list of all files in the directory.

Specified by:
getFiles in interface Directory
Returns:
The list of files.

getChildren

public List<Node> getChildren(NodeFilter filter)
Description copied from interface: Directory
Retrieves a list of children in the directory.

Specified by:
getChildren in interface Directory
Returns:
The list of children.

getDirectories

public List<Directory> getDirectories(NodeFilter filter)
Description copied from interface: Directory
Retrieves a list of directories in the directory.

Specified by:
getDirectories in interface Directory
Returns:
The list of directories.

getFiles

public List<File> getFiles(NodeFilter filter)
Description copied from interface: Directory
Retrieves a list of files in the directory.

Specified by:
getFiles in interface Directory
Returns:
The list of files.

hasChild

public boolean hasChild(String name)
Description copied from interface: Directory
Checks wether the directory contains a child(File of Directory) with the given name.

Specified by:
hasChild in interface Directory
Parameters:
name - The name of the child.
Returns:
True/False wether the directory contains a child with the given name.

hasFile

public boolean hasFile(String name)
Description copied from interface: Directory
Checks wether the directory contains a file with the given name.

Specified by:
hasFile in interface Directory
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

public boolean hasDirectory(String name)
Description copied from interface: Directory
Checks wether the directory contains a directory with the given name.

Specified by:
hasDirectory in interface Directory
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

public Node getChild(String name)
              throws FileNotFoundException
Description copied from interface: Directory
Retrieves a child with the given name.

Specified by:
getChild in interface Directory
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

public File getFile(String name)
             throws FileNotFoundException
Description copied from interface: Directory
Retrieves a file with the given name.

Specified by:
getFile in interface Directory
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.

getFile

public File getFile(String name,
                    boolean createIfNeeded)
             throws FileNotFoundException,
                    IOException
Description copied from interface: Directory
Retrieves a file with the given name.

Specified by:
getFile in interface Directory
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

public Directory getDirectory(String name)
                       throws FileNotFoundException
Description copied from interface: Directory
Retrieves a directory with the given name.

Specified by:
getDirectory in interface Directory
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.

getDirectory

public Directory getDirectory(String name,
                              boolean createIfNeeded)
                       throws FileNotFoundException,
                              IOException
Description copied from interface: Directory
Retrieves a directory with the given name.

Specified by:
getDirectory in interface Directory
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.

isBundle

public boolean isBundle()
Description copied from interface: Directory
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)

Specified by:
isBundle in interface Directory
Returns:
Wether its a bundle.


Copyright © 2011. All Rights Reserved.