jatha
Class Expander

java.lang.Object
  |
  +--jatha.Expander

public class Expander
extends java.lang.Object

This is the class that does the actual macro expansion. It can get its input from a file or from a LineNumberReader.

Note: when an Expander is created, it has no registered MacroFactories. If you want it to use a DefaultMacroFactory, you'll have to register it yourself.


Constructor Summary
Expander()
           
 
Method Summary
 void error(java.lang.String msg)
          Prints an error message and throws a MacroError.
 void expandMacro(java.lang.String macroName, java.lang.String args, java.io.Writer out)
           
 java.io.File getFile()
          Returns the name of the file currently being processed.
 int getLine()
          Returns the current line number in the current file.
 java.lang.Object getMessage(java.lang.String description)
          Allows a macro to retrieve a message left by a previous macro.
 void leaveMessage(java.lang.String description, java.lang.Object message)
          Allows a macro to leave a message that can be retrieved by later macros.
 void processFile(java.io.File inFile, java.io.File outFile, boolean force, boolean quiet)
           
 void processFile(java.io.LineNumberReader in, java.io.Writer out)
           
 void registerMacroFactory(MacroFactory factory, boolean justThisFile)
          Registers a new MacroFactory which will be used to lookup Macros.
 void trace(java.lang.String msg)
          Prints an error message, but doesn't throw a MacroError like error() does.
 boolean unregisterMacroFactory(MacroFactory factory)
          Unregister a macro factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Expander

public Expander()
Method Detail

processFile

public void processFile(java.io.File inFile,
                        java.io.File outFile,
                        boolean force,
                        boolean quiet)

processFile

public void processFile(java.io.LineNumberReader in,
                        java.io.Writer out)
                 throws java.io.IOException,
                        jatha.MacroError

expandMacro

public void expandMacro(java.lang.String macroName,
                        java.lang.String args,
                        java.io.Writer out)

registerMacroFactory

public void registerMacroFactory(MacroFactory factory,
                                 boolean justThisFile)
Registers a new MacroFactory which will be used to lookup Macros.
Parameters:
justThisFile - if true, the macro factory will only be in effect for the current file.

unregisterMacroFactory

public boolean unregisterMacroFactory(MacroFactory factory)
Unregister a macro factory. Returns false if the factory was not registered.

getFile

public java.io.File getFile()
Returns the name of the file currently being processed. If the version of processFile() that takes a filename was not called, returns null (ie if you called the version of processFile() that just takes a LineNumberReader).

getLine

public int getLine()
Returns the current line number in the current file. This is determined from the LineNumberReader passed to processFile(), but is adjusted so the first line is line 1, instead of line 0.

leaveMessage

public void leaveMessage(java.lang.String description,
                         java.lang.Object message)
Allows a macro to leave a message that can be retrieved by later macros.

getMessage

public java.lang.Object getMessage(java.lang.String description)
Allows a macro to retrieve a message left by a previous macro.

error

public void error(java.lang.String msg)
Prints an error message and throws a MacroError.

trace

public void trace(java.lang.String msg)
Prints an error message, but doesn't throw a MacroError like error() does.