net.sf.cotta
Class TDirectory

java.lang.Object
  extended by net.sf.cotta.TEntry
      extended by net.sf.cotta.TDirectory
All Implemented Interfaces:
java.lang.Comparable<TEntry>

public class TDirectory
extends TEntry

The class that represent the directory. To create TDirectory, use TFile, TDirectory, and TFileFactory

See Also:
TFileFactory.physicalDir(java.io.File), TFileFactory.dir(String), TFileFactory.dir(TPath), TEntry.parent(), TEntry.parent(), dir(String), dir(TPath)

Field Summary
 
Fields inherited from class net.sf.cotta.TEntry
path
 
Constructor Summary
TDirectory(FileSystem fileSystem, TPath path)
          Deprecated. Use the other constructor for default encoding support in TFileFactory
TDirectory(TFileFactory factory, TPath path)
           
 
Method Summary
 void delete()
          Delete the current directory.
 void deleteAll()
          Delete the whole directory tree
 TDirectory dir(java.lang.String relativePath)
          Constructs a subdirectory given the directory name
 TDirectory dir(TPath path)
          Constructs a directory given the relative path to the current directory
 TDirectory ensureExists()
           
 boolean exists()
           
 TFile file(java.lang.String path)
          Constucts a file given the path.
 TFile file(TPath path)
          Constructs a file given the relative path.
 java.io.File getJavaFile()
          Deprecated. use #toJavaFile()
 TDirectoryListing list()
          List the current directory
 TDirectoryListing list(TDirectoryFilter filter)
          List the current directory with directory filter
 TDirectoryListing list(TDirectoryFilter directoryFilter, TFileFilter fileFilter)
          List the current directory with file filter and directory filter
 TDirectoryListing list(TEntryFilter filter)
          List the current directory with entry filter
 TDirectoryListing list(TFileFilter filter)
          List the current directory with file filter
 TDirectory[] listDirs()
          Deprecated. use list().dirs()
 TDirectory[] listDirs(TDirectoryFilter directoryFilter)
          Deprecated. use list(directoryFilter).dirs()
 TFile[] listFiles()
          Deprecated.  
 TFile[] listFiles(TFileFilter fileFilter)
          Deprecated. use list(fileFilter).files()
 void mergeTo(TDirectory target)
           
 void moveTo(TDirectory target)
           
 TDirectory toCanonicalDir()
           
 void visit(FileVisitor fileVisitor)
           
 void zipTo(TFile file)
          Zip the current directory to a file, with the files and directories of current directory at the root level
 
Methods inherited from class net.sf.cotta.TEntry
compareTo, equals, factory, filesystem, hashCode, isChildOf, name, parent, path, pathFrom, toCanonicalPath, toJavaFile, toPath, toPathString, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TDirectory

public TDirectory(FileSystem fileSystem,
                  TPath path)
Deprecated. Use the other constructor for default encoding support in TFileFactory

Constructor that creates the directory to be mainly used internally.

Parameters:
fileSystem - The file system that backs the file
path - The path to the file
See Also:
TDirectory(TFileFactory, TPath)

TDirectory

public TDirectory(TFileFactory factory,
                  TPath path)
Method Detail

exists

public boolean exists()
Specified by:
exists in class TEntry

ensureExists

public TDirectory ensureExists()
                        throws TIoException
Throws:
TIoException

file

public TFile file(java.lang.String path)
Constucts a file given the path. If the path is relative path, it will be constructed based on the current directory

Parameters:
path - the path of the file
Returns:
The file that is under the directory with the name
See Also:
file(TPath)

file

public TFile file(TPath path)
Constructs a file given the relative path. If the path is relative, it will be constructed based on the current direcotry

Parameters:
path - path to the file
Returns:
The file that is of the relative to the current directory

dir

public TDirectory dir(java.lang.String relativePath)
Constructs a subdirectory given the directory name

Parameters:
relativePath - the relative path of the sub-directory
Returns:
The directory that is under the current directory with the given name

dir

public TDirectory dir(TPath path)
Constructs a directory given the relative path to the current directory

Parameters:
path - the relative path of the target directory to current directory
Returns:
The target directory that is of the given the relative path

listDirs

@Deprecated
public TDirectory[] listDirs()
                      throws TIoException
Deprecated. use list().dirs()

List the sub-directories of the current directory

Returns:
mutable list of TDirectory that can be sorted
Throws:
TIoException - for error in reading the directory

listDirs

@Deprecated
public TDirectory[] listDirs(TDirectoryFilter directoryFilter)
                      throws TIoException
Deprecated. use list(directoryFilter).dirs()

List the sub-directories of the current directory that can be accepted by the filter

Parameters:
directoryFilter - filter for the directory
Returns:
list of sub-directories
Throws:
TIoException - for error in reading the directory

list

public TDirectoryListing list()
                       throws TIoException
List the current directory

Returns:
list of TEntry that are either TFile or TDirectory
Throws:
TIoException - for error in reading current directory

list

public TDirectoryListing list(TEntryFilter filter)
                       throws TIoException
List the current directory with entry filter

Parameters:
filter - entry filter
Returns:
directory listing that has file filter and directory filter set to the filterd passed in
Throws:
TIoException - for error in reading current directory

list

public TDirectoryListing list(TFileFilter filter)
                       throws TIoException
List the current directory with file filter

Parameters:
filter - file filter
Returns:
filted directory listing with the directory filter set to ALL and file filter set to the filter passed in
Throws:
TIoException - for error in reading current directory

list

public TDirectoryListing list(TDirectoryFilter filter)
                       throws TIoException
List the current directory with directory filter

Parameters:
filter - directory filter
Returns:
filted direcotry listing with the directory filter set to the filter passed on, and file filter set to ALL
Throws:
TIoException - for error in reading current directory

list

public TDirectoryListing list(TDirectoryFilter directoryFilter,
                              TFileFilter fileFilter)
                       throws TIoException
List the current directory with file filter and directory filter

Parameters:
directoryFilter - directory filter
fileFilter - file filter
Returns:
filted direcotry listing with the directory filter set to the filter passed on, and file filter set to ALL
Throws:
TIoException - for error in reading current directory

listFiles

@Deprecated
public TFile[] listFiles()
                  throws TIoException
Deprecated. 

List files under current directory

Returns:
a mutable list of files under current directory
Throws:
TIoException - error in reading from current directory

listFiles

@Deprecated
public TFile[] listFiles(TFileFilter fileFilter)
                  throws TIoException
Deprecated. use list(fileFilter).files()

List files under current directory that accepted by the file filter

Parameters:
fileFilter - file filter for the list
Returns:
a mutable list of files
Throws:
TIoException - error in reading from current directory

delete

public void delete()
            throws TIoException
Delete the current directory. Most file system will fail if the current directory is not empty

Throws:
TIoException - error in deleting the directory (most file system will fail when directory is not empty)

deleteAll

public void deleteAll()
               throws TIoException
Delete the whole directory tree

Throws:
TIoException - error in the operation

mergeTo

public void mergeTo(TDirectory target)
             throws TIoException
Throws:
TIoException

moveTo

public void moveTo(TDirectory target)
            throws TIoException
Throws:
TIoException

getJavaFile

@Deprecated
public java.io.File getJavaFile()
Deprecated. use #toJavaFile()

Returns:
java.io.File presentation of the directory

zipTo

public void zipTo(TFile file)
           throws TIoException
Zip the current directory to a file, with the files and directories of current directory at the root level

Parameters:
file - the target file
Throws:
TIoException - error in reading from the directory or writing to the file

visit

public void visit(FileVisitor fileVisitor)
           throws TIoException
Throws:
TIoException

toCanonicalDir

public TDirectory toCanonicalDir()