net.sf.cotta
Class TFileFactory

java.lang.Object
  extended by net.sf.cotta.TFileFactory

public class TFileFactory
extends java.lang.Object

The factory class for creating TFile and TDirectory. The static methods are used for a quick way to create TFile and TDirectory with PhysicalFileSystem. There are two sets of static factories, one for factory creation and one for file/directory ceration

File factory creation:

File/Directory creation:

See Also:
TFile, TDirectory

Field Summary
static TFileFactory PHYSICAL_FILE_FACTORY
          Deprecated. use TFileFactory#phylical instead. This will become private
 
Constructor Summary
TFileFactory()
          Creat the factory using physical file system
TFileFactory(FileSystem fileSystem)
           
TFileFactory(FileSystem fileSystem, java.lang.String defaultEncoding)
           
 
Method Summary
static boolean canConvertUrl(java.net.URL url)
          The method to check is an URL can be converted to TFile or TDirectory
 java.lang.String defaultEncoding()
           
static TDirectory dir(java.io.File file)
           
 TDirectory dir(java.lang.String pathString)
          Create the TDirectory that is represented by the path and backed by the file system
 TDirectory dir(TPath path)
          Create the TDirectory that is repersented by the path and backed by the file system
static TDirectory directoryFromJavaFile(java.io.File file)
          Deprecated. use #physicalDir
static TFile file(java.io.File file)
           
 TFile file(java.lang.String pathString)
          Create the TFile that is represented by the path and backed by the file system
 TFile file(TPath path)
          Create the TFile that is repsented by the path and backed by the file system
static TFile fileFromJavaFile(java.io.File file)
          Deprecated. use file(java.io.File)
static TFile fileFromUrl(java.net.URL url)
          Create a TFile instance is represented by URL.
static TFileFactory inMemory()
          Creates a file factory with in-memory file system.
static TFileFactory physical()
          Retruns the shared file factory for the physical file system
static TDirectory physicalDir(java.io.File file)
           
static TDirectory physicalDir(java.lang.String path)
           
static TFile physicalFile(java.io.File file)
           
static TFile physicalFile(java.lang.String path)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PHYSICAL_FILE_FACTORY

@Deprecated
public static final TFileFactory PHYSICAL_FILE_FACTORY
Deprecated. use TFileFactory#phylical instead. This will become private
File factory backed by a physical file system

Constructor Detail

TFileFactory

public TFileFactory()
Creat the factory using physical file system

See Also:
PhysicalFileSystem

TFileFactory

public TFileFactory(FileSystem fileSystem)

TFileFactory

public TFileFactory(FileSystem fileSystem,
                    java.lang.String defaultEncoding)
Method Detail

file

public TFile file(java.lang.String pathString)
Create the TFile that is represented by the path and backed by the file system

Parameters:
pathString - The path string that represents the file
Returns:
The TFile object
See Also:
TPath.parse(java.lang.String), file(TPath)

file

public TFile file(TPath path)
Create the TFile that is repsented by the path and backed by the file system

Parameters:
path - the path that represents the file
Returns:
the TFile object

dir

public TDirectory dir(java.lang.String pathString)
Create the TDirectory that is represented by the path and backed by the file system

Parameters:
pathString - The pat string that represento the directory
Returns:
The TDirectory object
See Also:
TPath.parse(String), dir(TPath)

dir

public TDirectory dir(TPath path)
Create the TDirectory that is repersented by the path and backed by the file system

Parameters:
path - the path that represents the directory
Returns:
the TDirectory object

fileFromUrl

public static TFile fileFromUrl(java.net.URL url)
Create a TFile instance is represented by URL. The supported URL are:
Protocol Sample code
jar getClass().getResource(this.resourceString);
file new java.io.File("/tmp/file.txt").toURL();

Parameters:
url - The url that points to a zipTo entry in a zipTo file
Returns:
The TFile instance
Throws:
java.lang.IllegalArgumentException - if the url is not a zipTo file url

fileFromJavaFile

public static TFile fileFromJavaFile(java.io.File file)
Deprecated. use file(java.io.File)

Convert the Java file to a TFile directly by using a physical file system

Parameters:
file - the Java file object
Returns:
The TFile that represents the Java file
See Also:
PhysicalFileSystem, physicalFile(java.io.File)

directoryFromJavaFile

@Deprecated
public static TDirectory directoryFromJavaFile(java.io.File file)
Deprecated. use #physicalDir

Convert the Java file to a TDirectory directly by using a physical file system

Parameters:
file - the Java file object
Returns:
The TDirectory that represents the Java file
See Also:
PhysicalFileSystem, physicalDir(java.io.File)

canConvertUrl

public static boolean canConvertUrl(java.net.URL url)
The method to check is an URL can be converted to TFile or TDirectory

Parameters:
url - The url
Returns:
true if the url protocol is supported

physicalFile

public static TFile physicalFile(java.lang.String path)

physicalFile

public static TFile physicalFile(java.io.File file)

file

public static TFile file(java.io.File file)

physicalDir

public static TDirectory physicalDir(java.lang.String path)

physicalDir

public static TDirectory physicalDir(java.io.File file)

dir

public static TDirectory dir(java.io.File file)

defaultEncoding

public java.lang.String defaultEncoding()

inMemory

public static TFileFactory inMemory()
Creates a file factory with in-memory file system. Please note that this method returns a new in-memory file factory each time

Returns:
in-memory file factory

physical

public static TFileFactory physical()
Retruns the shared file factory for the physical file system

Returns:
phylical file factory