edu.sdsc.grid.io
Class FileFactory

java.lang.Object
  extended by edu.sdsc.grid.io.FileFactory

public final class FileFactory
extends java.lang.Object

Operations include creating appropriately typed GeneralFile and GeneralRandomAccessFile objects. Creating a file object can use a "URI" (not a "URL").


Constructor Summary
FileFactory()
           
 
Method Summary
static GeneralFile newFile(GeneralAccount account, java.lang.String path)
          Creates an abstract pathname using a GeneralAccount object to first create a GeneralFileSystem connection.
static GeneralFile newFile(GeneralAccount account, java.lang.String parent, java.lang.String child)
          Creates an abstract pathname using a GeneralAccount object to first create a GeneralFileSystem connection.
static GeneralFile newFile(GeneralFile parent, java.lang.String child)
          Creates an abstract pathname using a GeneralFileSystem object.
static GeneralFile newFile(GeneralFileSystem fs, java.lang.String path)
          Creates an abstract pathname using a GeneralFileSystem object.
static GeneralFile newFile(GeneralFileSystem fs, java.lang.String parent, java.lang.String child)
          Creates an abstract pathname using a GeneralFileSystem object.
static GeneralFile newFile(java.net.URI uri)
          Creates an abstract pathname using this uri.
static GeneralFile newFile(java.net.URI uri, java.lang.Object credential)
          Creates an abstract pathname using this uri.
static GeneralFile newFile(java.net.URI uri, java.lang.String password)
          Creates an abstract pathname using this uri.
static GeneralFileInputStream newFileInputStream(GeneralFile file)
          Opens an input stream for the file on an arbitrary file system.
static GeneralFileInputStream newFileInputStream(java.net.URI uri)
          Opens an input stream for the file on an arbitrary file system.
static GeneralFileOutputStream newFileOutputStream(GeneralFile file)
          Opens an output stream for the file on an arbitrary file system.
static GeneralFileOutputStream newFileOutputStream(java.net.URI uri)
          Opens an output stream for the file on an arbitrary file system.
static GeneralFileSystem newFileSystem(GeneralAccount account)
          Creates a filesystem appropriate to the account object.
static GeneralFileSystem newFileSystem(java.net.URI uri)
          Creates a filesystem based on the URI.
static GeneralFileSystem newFileSystem(java.net.URI uri, java.lang.Object gssCredential)
          Creates a filesystem based on the URI.
static MetaDataRecordList newMetaDataRecordList(GeneralFileSystem fileSystem, MetaDataField field, float recordValue)
          Opens an output stream for the file on an arbitrary file system.
static MetaDataRecordList newMetaDataRecordList(GeneralFileSystem fileSystem, MetaDataField field, int recordValue)
          Opens an output stream for the file on an arbitrary file system.
static MetaDataRecordList newMetaDataRecordList(GeneralFileSystem fileSystem, MetaDataField field, MetaDataTable recordValue)
          Opens an output stream for the file on an arbitrary file system.
static MetaDataRecordList newMetaDataRecordList(GeneralFileSystem fileSystem, MetaDataField field, java.lang.String recordValue)
          Opens an output stream for the file on an arbitrary file system.
static GeneralRandomAccessFile newRandomAccessFile(GeneralFile file, java.lang.String mode)
          Opens a random accecss connection to the file on an arbitrary file system.
static GeneralRandomAccessFile newRandomAccessFile(GeneralFileSystem fileSystem, java.lang.String filePath, java.lang.String mode)
          Opens a random accecss connection to the file on an arbitrary file system.
static GeneralRandomAccessFile newRandomAccessFile(java.net.URI uri, java.lang.String mode)
          Opens a random accecss connection to the file on an arbitrary file system.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileFactory

public FileFactory()
Method Detail

newFileSystem

public static GeneralFileSystem newFileSystem(GeneralAccount account)
                                       throws java.io.IOException
Creates a filesystem appropriate to the account object.

Parameters:
account - the account object used to initialize the filesystem.
Returns:
a GeneralFileSystem object instanced from the appropriate subclass. null will return a LocalFileSystem object.
Throws:
java.io.IOException - If an IO error occurs during the connection to the filesystem.

newFileSystem

public static GeneralFileSystem newFileSystem(java.net.URI uri)
                                       throws java.io.IOException
Creates a filesystem based on the URI.

Parameters:
uri - the uri used to initialize the filesystem.
Returns:
a GeneralFileSystem object instanced from the appropriate subclass. null will return a LocalFileSystem object.
Throws:
java.io.IOException - If an IO error occurs during the connection to the filesystem.

newFileSystem

public static GeneralFileSystem newFileSystem(java.net.URI uri,
                                              java.lang.Object gssCredential)
                                       throws java.io.IOException
Creates a filesystem based on the URI.

Parameters:
uri - the uri used to initialize the filesystem.
Returns:
a GeneralFileSystem object instanced from the appropriate subclass. null will return a LocalFileSystem object.
Throws:
java.io.IOException - If an IO error occurs during the connection to the filesystem.

newFile

public static GeneralFile newFile(java.net.URI uri)
                           throws java.io.IOException
Creates an abstract pathname using this uri. Currently supported URI schemes are "file://" and "srb://".

Parameters:
uri - A URI object of the supported schemes.
Returns:
a GeneralFile object instanced from the appropriate subclass.
Throws:
java.lang.SecurityException - The most likely cause is the URI did not include a password. For security reasons, uri's are generally given without the password. Acquire a new password and
java.lang.NullPointerException - If uri argument is null.
java.io.IOException - If an IO error occurs testing the connection to the filesystem.
See Also:
newFile( URI uri, String password )

newFile

public static GeneralFile newFile(java.net.URI uri,
                                  java.lang.String password)
                           throws java.io.IOException
Creates an abstract pathname using this uri. Currently supported URI schemes are "file://" and "srb://".

Including a text password in a URI string is not advisable for security reasons. This method allows the password to obtained by more secure methods. The connection to the file will then be made through the default authorization method of the file's filesystem.

Parameters:
uri - A URI object of the supported schemes.
password - The user's password.
Returns:
a GeneralFile object instanced from the appropriate subclass.
Throws:
java.lang.IllegalArgumentException - If the password contains illegal charaters.
java.lang.NullPointerException - If uri argument is null.
java.io.IOException - If an IO error occurs testing the connection to the filesystem.

newFile

public static GeneralFile newFile(java.net.URI uri,
                                  java.lang.Object credential)
                           throws java.io.IOException
Creates an abstract pathname using this uri. Currently supported URI schemes are "file://" and "srb://".

Parameters:
uri - A URI object of the supported schemes. A URI including a password component will be overridden by the credential authorization.
Returns:
a GeneralFile object instanced from the appropriate subclass.
Throws:
java.lang.SecurityException - The most likely cause is the URI did not include a password. For security reasons, uri's are generally given without the password. *
java.lang.NullPointerException - If uri argument is null.
java.io.IOException - If an IO error occurs testing the connection to the filesystem.

newFile

public static GeneralFile newFile(GeneralAccount account,
                                  java.lang.String path)
                           throws java.io.IOException
Creates an abstract pathname using a GeneralAccount object to first create a GeneralFileSystem connection. Useful if you have some account info, but you don't know which the file system the file is on. Calls the constructor( FileSystem, String ) of the appropriate subclass.

Parameters:
account - A generic account object.
path - The path to the file.
Returns:
a GeneralFile object instanced from the appropriate subclass.
Throws:
java.lang.NullPointerException - If the path argument is null.
java.io.IOException

newFile

public static GeneralFile newFile(GeneralAccount account,
                                  java.lang.String parent,
                                  java.lang.String child)
                           throws java.io.IOException
Creates an abstract pathname using a GeneralAccount object to first create a GeneralFileSystem connection. Useful if you have some account info, but you don't know which the file system the file is on. Calls the constructor( FileSystem, String ) of the appropriate subclass.

Parameters:
account - A generic account object.
parent - The directory path to the file.
child - The file name string.
Returns:
a GeneralFile object instanced from the appropriate subclass.
Throws:
java.lang.NullPointerException - If the path argument is null.
java.io.IOException

newFile

public static GeneralFile newFile(GeneralFileSystem fs,
                                  java.lang.String path)
Creates an abstract pathname using a GeneralFileSystem object. Useful for when you don't know which the file system the file is on. Calls the constructor( FileSystem, String ) of the appropriate subclass.

Parameters:
fs - A generic file system reference object.
path - The path to the file.
Returns:
a GeneralFile object instanced from the appropriate subclass.
Throws:
java.lang.NullPointerException - If the path argument is null.

newFile

public static GeneralFile newFile(GeneralFileSystem fs,
                                  java.lang.String parent,
                                  java.lang.String child)
Creates an abstract pathname using a GeneralFileSystem object. Useful for when you don't know which the file system the file is on. Calls the constructor( FileSystem, String, String ) of the appropriate subclass.

Parameters:
fs - A generic file system reference object.
parent - The directory path to the file.
child - The file name string.
Returns:
a GeneralFile object instanced from the appropriate subclass.
Throws:
java.lang.NullPointerException - If the child argument is null.

newFile

public static GeneralFile newFile(GeneralFile parent,
                                  java.lang.String child)
Creates an abstract pathname using a GeneralFileSystem object. Useful for when you don't know which the file system the file is on. Calls the constructor( File, String ) of the appropriate subclass.

Parameters:
parent - An abstract pathname to the file.
child - The file name string.
Returns:
a GeneralFile object instanced from the appropriate subclass.
Throws:
java.lang.NullPointerException - If the child argument is null.

newRandomAccessFile

public static GeneralRandomAccessFile newRandomAccessFile(GeneralFileSystem fileSystem,
                                                          java.lang.String filePath,
                                                          java.lang.String mode)
                                                   throws java.io.IOException
Opens a random accecss connection to the file on an arbitrary file system. Useful for when you don't know which the file system the file is on.

Returns:
a GeneralRandomAccessFile object instanced from the appropriate subclass.
Throws:
java.lang.NullPointerException - If the file argument is null.
java.io.IOException - If an IO error occurs opening the file.

newRandomAccessFile

public static GeneralRandomAccessFile newRandomAccessFile(GeneralFile file,
                                                          java.lang.String mode)
                                                   throws java.io.IOException
Opens a random accecss connection to the file on an arbitrary file system. Useful for when you don't know which the file system the file is on.

Returns:
a GeneralRandomAccessFile object instanced from the appropriate subclass.
Throws:
java.lang.NullPointerException - If the file argument is null.
java.io.IOException - If an IO error occurs opening the file.

newRandomAccessFile

public static GeneralRandomAccessFile newRandomAccessFile(java.net.URI uri,
                                                          java.lang.String mode)
                                                   throws java.io.IOException
Opens a random accecss connection to the file on an arbitrary file system. Useful for when you don't know which the file system the file is on.

Returns:
a GeneralRandomAccessFile object instanced from the appropriate subclass.
Throws:
java.lang.NullPointerException - If the file argument is null.
java.io.IOException - If an IO error occurs opening the file.

newFileInputStream

public static GeneralFileInputStream newFileInputStream(GeneralFile file)
                                                 throws java.io.IOException
Opens an input stream for the file on an arbitrary file system. Useful for when you don't know which the file system the file is on.

Returns:
a GeneralFileInputStream object instanced from the appropriate subclass.
Throws:
java.lang.NullPointerException - If the file argument is null.
java.io.IOException - If an IO error occurs opening the file.

newFileInputStream

public static GeneralFileInputStream newFileInputStream(java.net.URI uri)
                                                 throws java.io.IOException
Opens an input stream for the file on an arbitrary file system. Useful for when you don't know which the file system the file is on.

Returns:
a GeneralFileInputStream object instanced from the appropriate subclass.
Throws:
java.lang.NullPointerException - If the file argument is null.
java.io.IOException - If an IO error occurs opening the file.

newFileOutputStream

public static GeneralFileOutputStream newFileOutputStream(GeneralFile file)
                                                   throws java.io.IOException
Opens an output stream for the file on an arbitrary file system. Useful for when you don't know which the file system the file is on.

Returns:
a GeneralFileOutputStream object instanced from the appropriate subclass.
Throws:
java.lang.NullPointerException - If the file argument is null.
java.io.IOException - If an IO error occurs opening the file.

newFileOutputStream

public static GeneralFileOutputStream newFileOutputStream(java.net.URI uri)
                                                   throws java.io.IOException
Opens an output stream for the file on an arbitrary file system. Useful for when you don't know which the file system the file is on.

Returns:
a GeneralFileOutputStream object instanced from the appropriate subclass.
Throws:
java.lang.NullPointerException - If the file argument is null.
java.io.IOException - If an IO error occurs opening the file.

newMetaDataRecordList

public static MetaDataRecordList newMetaDataRecordList(GeneralFileSystem fileSystem,
                                                       MetaDataField field,
                                                       int recordValue)
Opens an output stream for the file on an arbitrary file system. Useful for when you don't know which the file system the file is on.

Returns:
a GeneralFileOutputStream object instanced from the appropriate subclass.
Throws:
java.lang.NullPointerException - If the file argument is null.
java.io.IOException - If an IO error occurs opening the file.

newMetaDataRecordList

public static MetaDataRecordList newMetaDataRecordList(GeneralFileSystem fileSystem,
                                                       MetaDataField field,
                                                       float recordValue)
Opens an output stream for the file on an arbitrary file system. Useful for when you don't know which the file system the file is on.

Returns:
a GeneralFileOutputStream object instanced from the appropriate subclass.
Throws:
java.lang.NullPointerException - If the file argument is null.
java.io.IOException - If an IO error occurs opening the file.

newMetaDataRecordList

public static MetaDataRecordList newMetaDataRecordList(GeneralFileSystem fileSystem,
                                                       MetaDataField field,
                                                       java.lang.String recordValue)
Opens an output stream for the file on an arbitrary file system. Useful for when you don't know which the file system the file is on.

Returns:
a GeneralFileOutputStream object instanced from the appropriate subclass.
Throws:
java.lang.NullPointerException - If the file argument is null.
java.io.IOException - If an IO error occurs opening the file.

newMetaDataRecordList

public static MetaDataRecordList newMetaDataRecordList(GeneralFileSystem fileSystem,
                                                       MetaDataField field,
                                                       MetaDataTable recordValue)
Opens an output stream for the file on an arbitrary file system. Useful for when you don't know which the file system the file is on.

Returns:
a GeneralFileOutputStream object instanced from the appropriate subclass.
Throws:
java.lang.NullPointerException - If the file argument is null.
java.io.IOException - If an IO error occurs opening the file.