org.hecl.files
Class HeclFile

java.lang.Object
  extended by org.hecl.files.HeclFile
All Implemented Interfaces:
HeclModule

public class HeclFile
extends java.lang.Object
implements HeclModule

HeclFile implements all the filesystem interaction methods. It's not used in J2ME code, so we can add all we like here.

Version:
1.0
Author:
David N. Welton

Field Summary
static java.lang.String currentFile
           
 
Constructor Summary
HeclFile()
           
 
Method Summary
static void changeDir(java.lang.String dirname)
          changeDir changes where Java thinks the current directory is, but DOES NOT CHANGE the process' actual working directory, so this may cause problems if you exec something.
static java.util.Vector fileToList(java.lang.String filename)
          fileToList splits a path like /a/b/c into the list {/ a b c} so that it's easy to manipulate programatically.
static java.lang.String listToFile(java.util.Vector filenamelist)
          listToFile takes a list like {a b c} and converts it to a filename such as a/b/c.
 void loadModule(Interp interp)
          The loadModule method usually takes care of creating commands that are present in this module.
static java.lang.StringBuffer readFile(java.lang.String filename)
          readFile reads in a text file, given a filename, and returns its contents as a StringBuffer.
static void sourceFile(Interp interp, java.lang.String filename)
          The sourceFile method is the equivalent of the "source" command.
 void unloadModule(Interp interp)
          The unloadModule method takes care of any clean up that's necessary, such as unloading commands created by this module.
static void writeFile(java.lang.String filename, java.lang.String data)
          The writeFile method writes the 'data' String to the file given by 'filename'.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentFile

public static java.lang.String currentFile
Constructor Detail

HeclFile

public HeclFile()
Method Detail

changeDir

public static void changeDir(java.lang.String dirname)
changeDir changes where Java thinks the current directory is, but DOES NOT CHANGE the process' actual working directory, so this may cause problems if you exec something.

Parameters:
dirname - a String value

readFile

public static java.lang.StringBuffer readFile(java.lang.String filename)
                                       throws HeclException
readFile reads in a text file, given a filename, and returns its contents as a StringBuffer. FIXME - we probably ought to do this better, by making it more configurable.

Parameters:
filename - a String value
Returns:
a StringBuffer value
Throws:
HeclException - if an error occurs

writeFile

public static void writeFile(java.lang.String filename,
                             java.lang.String data)
                      throws HeclException
The writeFile method writes the 'data' String to the file given by 'filename'.

Parameters:
filename - a String value
data - a String value
Throws:
HeclException - if an error occurs

listToFile

public static java.lang.String listToFile(java.util.Vector filenamelist)
listToFile takes a list like {a b c} and converts it to a filename such as a/b/c.

Parameters:
filenamelist - a Vector value
Returns:
a String value

fileToList

public static java.util.Vector fileToList(java.lang.String filename)
fileToList splits a path like /a/b/c into the list {/ a b c} so that it's easy to manipulate programatically.

Parameters:
filename - a String value
Returns:
a Vector value

sourceFile

public static void sourceFile(Interp interp,
                              java.lang.String filename)
                       throws HeclException
The sourceFile method is the equivalent of the "source" command.

Parameters:
interp - an Interp value
filename - a String value
Throws:
HeclException - if an error occurs

loadModule

public void loadModule(Interp interp)
                throws HeclException
Description copied from interface: HeclModule
The loadModule method usually takes care of creating commands that are present in this module.

Specified by:
loadModule in interface HeclModule
Parameters:
interp - an Interp value
Throws:
HeclException - if an error occurs

unloadModule

public void unloadModule(Interp interp)
                  throws HeclException
Description copied from interface: HeclModule
The unloadModule method takes care of any clean up that's necessary, such as unloading commands created by this module.

Specified by:
unloadModule in interface HeclModule
Parameters:
interp - an Interp value
Throws:
HeclException - if an error occurs