|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfi.hu.cs.titokone.FileHandler
This class transforms files into various sorts of buffer classes depending on who needs them, and saves these buffer classes to files when needed. The buffer classes will not be dependent on files and I/O operations anymore, and therefore will not throw eg. IOExceptions when read.
Field Summary | |
static int |
APPEND_ACCESS
Append access to file |
private java.util.logging.Logger |
logger
This logger will be used for logging the I/O activities. |
static java.lang.String |
loggerName
This class has its own logger. |
static int |
READ_ACCESS
Read only access to file |
static int |
WRITE_ACCESS
Write access to file |
Constructor Summary | |
FileHandler()
This class sets up a new FileHandler and sets up its Logger. |
Method Summary | |
void |
appendDataToStdOut(java.lang.String dataItem,
java.io.File stdoutFile)
This method appends data to a stdout file. |
java.io.File |
changeExtension(java.io.File f,
java.lang.String newExtension)
This method changes the extension of the given filename to newExtension and returns the new filename as a File object. |
private java.lang.String |
changeExtensionStr(java.lang.String filename,
java.lang.String newExtension)
This method returns the first string modified so that the part of it following the last period is removed, including the period, and the result is this modified followed by newExtension. |
Binary |
loadBinary(java.io.File binaryFile)
This function loads a Binary from a binary .b91 file and returns the result. |
private java.lang.StringBuffer |
loadFileContentsToString(java.io.File loadFile)
This function is a private assistant method for FileHandler and it loads the contents of the given file into a string and returns that string. |
private java.lang.StringBuffer |
loadReaderContentsToString(java.io.BufferedReader reader)
This function is a private assistant method, which loads the contents of a given reader into a string and returns that string. |
java.util.ResourceBundle |
loadResourceBundle(java.io.File rbFile)
This method attempts to load a resource bundle from a file (with an URLClassLoader). |
java.lang.StringBuffer |
loadSettings(java.io.File settingsFile)
This function loads a settings file into a StringBuffer. |
java.lang.StringBuffer |
loadSettings(java.io.InputStream settingsStream)
This function loads a settings input stream to a StringBuffer. |
Source |
loadSource(java.io.File srcFile)
This function loads up a Source file from a given file. |
java.lang.StringBuffer |
loadStdIn(java.io.File stdinFile)
This method loads a "stdin" file representing the disk into a string. |
void |
saveBinary(Binary bin,
java.io.File binarySaveFile)
This method saves a Binary to file in a .b91 binary format. |
void |
saveSettings(java.lang.String settingsData,
java.io.File settingsFile)
This method saves settings data from a StringBuffer to a file. |
void |
saveSource(Source src,
java.io.File srcFile)
This method is used to save a source that has been modified. |
private void |
saveStringToFile(java.lang.String str,
java.io.File saveFile)
This method is a private helper method which handles saving strings to files. |
void |
testAccess(java.io.File accessedFile,
int accessType)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private java.util.logging.Logger logger
public static java.lang.String loggerName
public static final int READ_ACCESS
public static final int APPEND_ACCESS
public static final int WRITE_ACCESS
Constructor Detail |
public FileHandler()
Method Detail |
public Source loadSource(java.io.File srcFile) throws java.io.IOException
srcFile
- The identifier of the file to read from.
java.io.IOException
- If an I/O error occurs. Eg. one of the possible
IOExceptions is FileNotFoundException.public void saveSource(Source src, java.io.File srcFile) throws java.io.IOException
src
- The source object to save to file.srcFile
- The file to save the source to.
java.io.IOException
- If an I/O error occurds.public java.lang.StringBuffer loadSettings(java.io.File settingsFile) throws java.io.IOException
settingsFile
- The identifier of the file to read from.
java.io.IOException
- If an I/O error occurs. Eg. one of the possible
IOExceptions is FileNotFoundException.public java.lang.StringBuffer loadSettings(java.io.InputStream settingsStream) throws java.io.IOException
settingsStream
- An input stream to read the contents
from.
java.io.IOException
- If an I/O error occurs while reading or
closing the stream.public void saveSettings(java.lang.String settingsData, java.io.File settingsFile) throws java.io.IOException
settingsData
- The settings data in a StringBuffer in the
form it is to be saved in. The linebreaks in the file will be \ns.settingsFile
- The identifier of the file to save to.
java.io.IOException
- If an I/O error occurs, eg. the directory
the file should be in does not exist or we cannot write to it.public Binary loadBinary(java.io.File binaryFile) throws java.io.IOException, java.text.ParseException
binaryFile
- Identifier of the file to read from.
java.io.IOException
- If an I/O error occurs. Eg. one of the possible
IOExceptions is FileNotFoundException.
java.text.ParseException
- If the file does not contain a valid
binary.public void saveBinary(Binary bin, java.io.File binarySaveFile) throws java.io.IOException
bin
- The binary to save to file.binarySaveFile
- The identifier for the file to save to.
java.io.IOException
- If an I/O error occurs, eg. the given file
cannot be written to.public java.lang.StringBuffer loadStdIn(java.io.File stdinFile) throws java.io.IOException
stdinFile
- The identifier for the file to read from.
java.io.IOException
- If an I/O error occurs, eg. the given
file is not found.public void appendDataToStdOut(java.lang.String dataItem, java.io.File stdoutFile) throws java.io.IOException
dataItem
- The data to append to the file (a newline is
added automagically).stdoutFile
- The file to append to.
java.io.IOException
- If an I/O error occurs.public java.util.ResourceBundle loadResourceBundle(java.io.File rbFile) throws ResourceLoadFailedException
rbFile
- The filename to load and instantiate the
ResourceBundle from.
ResourceLoadFailedException
- If the file load would cast
an IOException, or the class loading would cast a
ClassNotFoundException or the instantiation would cast a
InstantiationException or the cast a ClassCastException.private java.lang.StringBuffer loadFileContentsToString(java.io.File loadFile) throws java.io.IOException
java.io.IOException
private java.lang.StringBuffer loadReaderContentsToString(java.io.BufferedReader reader) throws java.io.IOException
java.io.IOException
- If an I/O error occurs while reading the file.private void saveStringToFile(java.lang.String str, java.io.File saveFile) throws java.io.IOException
java.io.IOException
public java.io.File changeExtension(java.io.File f, java.lang.String newExtension)
private java.lang.String changeExtensionStr(java.lang.String filename, java.lang.String newExtension)
public void testAccess(java.io.File accessedFile, int accessType) throws java.io.IOException
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |