org.jext.dawn.io
Class FileManager

java.lang.Object
  extended byorg.jext.dawn.io.FileManager

public class FileManager
extends java.lang.Object

Manages the files for the whole IO package. This class provides functions to open/close files and also to read/write into them. Each opened file is stored as a property in DawnParser. Each file is designed by a given ID.


Field Summary
static java.lang.String NEW_LINE
          Default line separator (system's one) used by the file manager.
 
Constructor Summary
FileManager()
           
 
Method Summary
static void closeFile(java.lang.String ID, Function function, DawnParser parser)
          Closes a given file.
static boolean isFileAvailable(java.lang.String ID, DawnParser parser)
          Checks if a given file is still available or not.
static void openFileForInput(java.lang.String ID, java.lang.String file, Function function, DawnParser parser)
          Opens a file for input (i.e to read from it).
static void openFileForOutput(java.lang.String ID, java.lang.String file, Function function, DawnParser parser)
          Opens a file for output (i.e to write into it).
static java.lang.String read(boolean line, java.lang.String ID, Function function, DawnParser parser)
          Reads from a file according to the line parameter..
static java.lang.String read(java.lang.String ID, Function function, DawnParser parser)
          Reads a character from a given file.
static java.lang.String readLine(java.lang.String ID, Function function, DawnParser parser)
          Reads a line from a given file.
static void write(boolean isLine, java.lang.String ID, java.lang.String line, Function function, DawnParser parser)
          Writes a line into a given file.
static void write(java.lang.String ID, java.lang.String line, Function function, DawnParser parser)
          Writes a line into a given file (does not add a return char).
static void writeLine(java.lang.String ID, java.lang.String line, Function function, DawnParser parser)
          Writes a line into a given file (write the text then adds a return char).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NEW_LINE

public static final java.lang.String NEW_LINE
Default line separator (system's one) used by the file manager.

Constructor Detail

FileManager

public FileManager()
Method Detail

openFileForInput

public static void openFileForInput(java.lang.String ID,
                                    java.lang.String file,
                                    Function function,
                                    DawnParser parser)
                             throws DawnRuntimeException
Opens a file for input (i.e to read from it).

Parameters:
ID - The file internal ID
file - The path, relative or absolute, to the file to be opened
function - The Function which is opening the file
parser - The DawnParser which is executing the above function
Throws:
DawnRuntimeException

openFileForOutput

public static void openFileForOutput(java.lang.String ID,
                                     java.lang.String file,
                                     Function function,
                                     DawnParser parser)
                              throws DawnRuntimeException
Opens a file for output (i.e to write into it).

Parameters:
ID - The file internal ID
file - The path, relative or absolute, to the file to be opened/created
function - The Function which is opening the file
parser - The DawnParser which is executing the above function
Throws:
DawnRuntimeException

readLine

public static java.lang.String readLine(java.lang.String ID,
                                        Function function,
                                        DawnParser parser)
                                 throws DawnRuntimeException
Reads a line from a given file.

Parameters:
ID - The file internal ID
function - The Function which is opening the file
parser - The DawnParser which is executing the above function
Throws:
DawnRuntimeException

read

public static java.lang.String read(java.lang.String ID,
                                    Function function,
                                    DawnParser parser)
                             throws DawnRuntimeException
Reads a character from a given file.

Parameters:
ID - The file internal ID
function - The Function which is opening the file
parser - The DawnParser which is executing the above function
Throws:
DawnRuntimeException

read

public static java.lang.String read(boolean line,
                                    java.lang.String ID,
                                    Function function,
                                    DawnParser parser)
                             throws DawnRuntimeException
Reads from a file according to the line parameter..

Parameters:
line - If true, a whole line is read. Otherwise, only a char is read.
ID - The file internal ID
function - The Function which is opening the file
parser - The DawnParser which is executing the above function
Throws:
DawnRuntimeException

writeLine

public static void writeLine(java.lang.String ID,
                             java.lang.String line,
                             Function function,
                             DawnParser parser)
                      throws DawnRuntimeException
Writes a line into a given file (write the text then adds a return char).

Parameters:
ID - The file internal ID
line - The line to be written
function - The Function which is opening the file
parser - The DawnParser which is executing the above function
Throws:
DawnRuntimeException

write

public static void write(java.lang.String ID,
                         java.lang.String line,
                         Function function,
                         DawnParser parser)
                  throws DawnRuntimeException
Writes a line into a given file (does not add a return char).

Parameters:
ID - The file internal ID
line - The line to be written
function - The Function which is opening the file
parser - The DawnParser which is executing the above function
Throws:
DawnRuntimeException

write

public static void write(boolean isLine,
                         java.lang.String ID,
                         java.lang.String line,
                         Function function,
                         DawnParser parser)
                  throws DawnRuntimeException
Writes a line into a given file. The return char is added according to the isLine parameter.

Parameters:
isLine - If true, the NEW_LINE value is added to the line
ID - The file internal ID
line - The line to be written
function - The Function which is opening the file
parser - The DawnParser which is executing the above function
Throws:
DawnRuntimeException

closeFile

public static void closeFile(java.lang.String ID,
                             Function function,
                             DawnParser parser)
                      throws DawnRuntimeException
Closes a given file.

Parameters:
ID - The file internal ID
function - The Function which is opening the file
parser - The DawnParser which is executing the above function
Throws:
DawnRuntimeException

isFileAvailable

public static boolean isFileAvailable(java.lang.String ID,
                                      DawnParser parser)
Checks if a given file is still available or not.

Parameters:
ID - The file internal ID
parser - The DawnParser which is executing the above function


Copyright ? 2002 Romain Guy.