de.dante.extex
Class ExTeX

java.lang.Object
  extended byde.dante.extex.ExTeX
Direct Known Subclasses:
TeX

public class ExTeX
extends java.lang.Object

This is the programmatic interface to the ExTeX functionality. A program may use this functionality to perform all necessary actions without the burden of the traditional TeX command line interface.

The programmatic interface provides the following features:

Settings

Settings can be stored in properties files. Those settings are the fallback if none are provided otherwise.

The properties are stored in a file named .extex. It is sought in the users home directory. This determined by the system property user.home. Afterwards it is sought in the current directory. The local settings of a directory overwrite the user's setting. The user's setting overwrite the compiled in defaults

The following properties are recognized:

extex.code
This parameter contains ExTeX code to be executed directly. The execution is performed after any code specified in an input file. on the command line the code has to start with a backslash. This restriction does not hold for the property settings.
Command line: ⟨code⟩
extex.color.converter
This parameter contains the name of the configuration resource to use for the color converter.
Default:
extex.config
This parameter contains the name of the configuration resource to use. This configuration resource is sought on the class path.
Command line: -configuration ⟨resource⟩
Default: extex.xml
extex.encoding
This parameter contains the name of the property for the standard encoding to use.
Default: ISO-8859-1
extex.error.handler
This parameter contains the logical name of the error handler.
extex.error.handler
This parameter contains the logical name of the error handler.
extex.fonts
This parameter contains the name of the property indicating where to find font files. The value is a path similar to extex.texinputs.
extex.halt.on.error
This parameter contains the name of the property indicating whether the processing should stop after the first error.
extex.file
This parameter contains the file to read from. It has no default
extex.format
This parameter contains the name of the format to read. An empty string denotes that no format should be read. This is the default.
extex.ini
If set to true then act as initex. This command line option is defined for compatibility to TeX only. In ExTeX it has no effect at all.
extex.interaction
This parameter contains the interaction mode. possible values are the numbers 0..3 and the symbolic names batchmode (0), nonstopmode (1), scrollmode (2), and errorstopmode (3).
Default: 3
extex.jobname
This parameter contains the name of the job. It is overwritten if a file is given to read from. In this case the base name of the input file is used instead.
Default: texput
extex.jobname.master
This parameter contains the name of the job to be used with high priority.
Default: texput
extex.lang
This parameter contains the name of the locale to be used for the messages.
extex.name
This parameter contains the name of the program for messages.
extex.nobanner
This parameter contains a Boolean indicating that the banner should be suppressed.
extex.output
This parameter contains the output format. This logical name is resolved via the configuration.
Default: pdf
extex.output.directories
This parameter contains a colon separated list of directories where output files should be created. The directories are tried in turn until one is found where the creation of the output file succeeds.
Default: .
extex.paper
This parameter contains the default size of the paper. It can be one of the symbolic names defined in paper/paper.xml. Otherwise the value is interpreted as a pair of width and height separated by a space.
extex.progname
This parameter can be used to overrule the name of the program shown in the banner and the version information.
Default: ExTeX
extex.stacktrace.on.internal.error
This boolean parameter contains indicator that a stack trace should be written to the log stream on internal errors.
extex.texinputs
This parameter contains the additional directories for searching TeX input files.
extex.token.stream
This string parameter contains the logical name of the configuration to use for the token stream.
extex.trace.input.files
This Boolean parameter contains the indicator whether or not to trace the search for input files.
extex.trace.font.filess
This Boolean parameter contains the indicator whether or not to trace the search for font files.
extex.trace.macros
This Boolean parameter contains the indicator whether or not to trace the execution of macros.
extex.trace.tokenizer
This Boolean parameter contains the indicator whether or not to trace the work of the tokenizer.
extex.typesetter
This parameter contains the name of the typesetter to use. If it is not set then the default from the configuration file is used.
extex.units
This parameter contains a colon separated list of units to be loaded into ExTeX.

There is another level of properties which is considered between the compiled in defaults and the user's properties. Those are the system properties of the Java system. In those properties system wide settings can be stored. Nevertheless, you should use this feature sparsely.

Configuration Resources

The configuration of ExTeX is controlled by several configuration resources. The fallback for those configuration resources are contained in the ExTeX jar file. In this section we will describe how to overwrite the settings in the default configuration resource.

TODO gene: doc incomplete

Programmatical Use

This class is the central point for using an instance of ExTeX from within a program. For this purpose the class has been specially designed. The class can be used as is. This is not the normal way to apply ExTeX. The configuration via configuration files and properties can be used to influence the behavior of the instance. Nevertheless the fine points in the live cycle can not be accessed this way. This can be achieved via deriving another class from it.

The class provides several protected methods which are solemnly made accessible to extend the functionality of the class. To do so you need insight into the live cycle of the class.

Starting ExTeX

Mainly there are two steps in using this class. The first step is the creation of a new instance. This phase is depicted in the figure above. Note that no interpreter is created during this phase. Thus the possibilities to influence the run-time behavior is rather limited.

propertyDefault()
This method is invoked several times to provide the compiled-in defaults for certain properties.
applyLanguage()
This method is invoked to adjust the setting for the language.
applyInteraction()
This method is invoked to adjust the setting for the interaction mode.

The major activities are carried out when the method run() is invoked. The methods used i n this phase are shown in the figure below.

Running ExTeX
makeLogFile()
Creates the log file.
makeLogHandler()
Creates the log handler.
showBanner()
Presents the banner if necessary.
makeOutputFactory()
Creates the output factory.
makeResourceFinder()
Creates the resource finder.
makeInterpreter()
Start to create the interpreter. In the course of this operation some more methods are invoked:
makeFontFactory()
Creates the font factory.
makeTokenFactory()
Creates the token factory.
makeContext()
Creates the initial context and optionally loads a format:
makeDefaultFont()
Creates the default font from the specification in the configuration.
makeLanguageManager()
Creates the language manager.
loadFormat()
Loads a format if one is given.
initializeStreams()
Initialize the input and output streams.
makeTypesetter()
Creates the typesetter.
run()
Runs the processing loop of the interpreter until it reaches an end.
logPages()
Do everything necessary to log the pages.

Version:
$Revision: 1.150 $
Author:
Gerd Neugebauer, Michael Niedermair

Field Summary
protected static java.lang.String PROP_BANNER
          The constant PROP_BANNER contains the name of the property for the banner.
protected static java.lang.String PROP_CODE
          The constant PROP_CODE contains the name of the property for the TeX code to be inserted at the beginning of the job.
protected static java.lang.String PROP_COLOR_CONVERTER
          The constant PROP_COLOR_CONVERTER contains the name of the property for the color converter to use.
protected static java.lang.String PROP_CONFIG
          The constant PROP_CONFIG contains the name of the property for the configuration resource to use.
protected static java.lang.String PROP_ENCODING
          The constant PROP_ENCODING contains the name of the property for the standard encoding to use.
protected static java.lang.String PROP_ERROR_HANDLER
          The constant PROP_ERROR_HANDLER contains the name of the property for the error handler type to use.
protected static java.lang.String PROP_FILE
          The constant PROP_FILE contains the name of the property for the input file to read.
protected static java.lang.String PROP_FMT
          The constant PROP_FMT contains the name of the property for the name of the format file to use.
protected static java.lang.String PROP_HALT_ON_ERROR
          The constant PROP_HALT_ON_ERROR contains the name of the property indicating whether the processing should stop at the first error.
protected static java.lang.String PROP_INI
          The constant PROP_INI contains the name of the property for the Boolean value indicating that some kind of emulations for iniTeX should be provided.
protected static java.lang.String PROP_INTERACTION
          The constant PROP_INTERACTION contains the name of the property for the interaction mode.
protected static java.lang.String PROP_INTERNAL_STACKTRACE
          The constant PROP_INTERNAL_STACKTRACE contains the name of the property indicating that a stack trace should be written for internal errors.
protected static java.lang.String PROP_JOBNAME
          The constant PROP_JOBNAME contains the name of the property for the job name.
protected static java.lang.String PROP_JOBNAME_MASTER
          The constant PROP_JOBNAME_MASTER contains the name of the property for the job name to be used with high priority.
protected static java.lang.String PROP_LANG
          The constant PROP_LANG contains the name of the property for the language to use for messages.
protected static java.lang.String PROP_NAME
          The constant PROP_NAME contains the name of the property for the program name used in messages.
protected static java.lang.String PROP_NO_BANNER
          The constant PROP_NO_BANNER contains the name of the property for the Boolean value indicating whether or not to show a program banner.
protected static java.lang.String PROP_OUTPUT_DIRS
          The constant PROP_OUTPUT_DIRS contains the name of the property for the output directory path.
protected static java.lang.String PROP_OUTPUT_TYPE
          The constant PROP_OUTPUT_TYPE contains the name of the property for the output driver.
protected static java.lang.String PROP_PAGE
          The constant PROP_PAGE contains the name of the property for the default page dimensions.
protected static java.lang.String PROP_PROGNAME
          The constant PROP_PROGNAME contains the name of the property for the program name used in format loading.
protected static java.lang.String PROP_TEXINPUTS
          The constant PROP_TEXINPUTS contains the name of the property for the additional texinputs specification of directories.
protected static java.lang.String PROP_TOKEN_STREAM
          The constant PROP_TOKEN_STREAM contains the name of the property for the token stream class to use.
protected static java.lang.String PROP_TRACE_FONT_FILES
          The constant PROP_TRACE_FONT_FILES contains the name of the property for the Boolean determining whether or not the searching for font files should produce tracing output.
protected static java.lang.String PROP_TRACE_INPUT_FILES
          The constant PROP_TRACE_INPUT_FILES contains the name of the property for the Boolean determining whether or not the searching for input files should produce tracing output.
protected static java.lang.String PROP_TRACE_MACROS
          The constant PROP_TRACE_MACROS contains the name of the property for the Boolean determining whether or not the execution of macros should produce tracing output.
protected static java.lang.String PROP_TRACE_TOKENIZER
          The constant PROP_TRACE_TOKENIZER contains the name of the property for the Boolean determining whether or not the tokenizer should produce tracing output.
protected static java.lang.String PROP_TRACING_ONLINE
          The constant PROP_TRACING_ONLINE contains the name of the property for the Boolean determining whether or not the tracing should produce log output in the log file only.
protected static java.lang.String PROP_TYPESETTER_TYPE
          The constant PROP_TYPESETTER_TYPE contains the name of the property for the typesetter to use.
 
Constructor Summary
ExTeX(java.util.Properties theProperties)
          Creates a new object and supplies some properties for those keys which are not contained in the properties already.
ExTeX(java.util.Properties theProperties, java.lang.String dotFile)
          Creates a new object and initializes the properties from given properties and possibly from a user's properties in the file .extex.
 
Method Summary
protected  void applyInteraction()
          Propagate the settings for the interaction mode to the interactionObserver.
protected  void applyLanguage()
          Try to determine which language to use and configure the localizer accordingly.
 boolean getBooleanProperty(java.lang.String key)
          Getter for a named property as boolean.
protected  Localizer getLocalizer()
          Getter for localizer.
 java.util.logging.Logger getLogger()
          Getter for logger.
 java.io.OutputStream getOutStream()
          Getter for outStream.
 java.util.Properties getProperties()
          Getter for properties.
 java.lang.String getProperty(java.lang.String key)
          Getter for a named property.
static java.lang.String getVersion()
          Getter for the version.
protected  boolean initializeStreams(Interpreter interpreter, java.util.Properties prop)
          Initialize the input streams.
protected  Context loadFormat(java.lang.String fmt, Interpreter interpreter, ResourceFinder finder, java.lang.String jobname, Configuration config, OutputStreamFactory outFactory, TokenFactory tokenFactory)
          Load a format if a non-empty name of a format is given.
protected  void loadUserProperties(java.io.File file)
          Load properties from a given file if it exists.
protected static void logException(java.util.logging.Logger logger, java.lang.String text, java.lang.Throwable e)
          Log a Throwable including its stack trace to the logger.
protected  void logInternalError(java.lang.Throwable e)
          Log a Throwable including its stack trace to the logger.
protected  void logPages(BackendDriver backend)
          This method can be overwritten to provide logging functionality for the pages produced.
protected  BackendDriver makeBackend(Configuration config, OutputStreamFactory outFactory, DocumentWriterOptions options, Configuration colorConfig, ResourceFinder finder, FontFactory fontFactory)
          Create a new document writer.
protected  ColorConverter makeColorConverter(Configuration config)
          Make a new instance of a color converter.
protected  Context makeContext(Configuration config, TokenFactory tokenFactory, FontFactory fontFactory, Interpreter interpreter, ResourceFinder finder, java.lang.String jobname, OutputStreamFactory outFactory)
          Prepare the context according to its configuration.
protected  Font makeDefaultFont(Configuration config, FontFactory fontFactory)
          Create a default font for the interpreter context.
protected  FontFactory makeFontFactory(Configuration config, ResourceFinder finder)
          Create a new font factory.
protected  Interpreter makeInterpreter(Configuration config, OutputStreamFactory outFactory, ResourceFinder finder, java.lang.String jobname)
          Create a new interpreter.
protected  LanguageManager makeLanguageManager(Configuration config, OutputStreamFactory outFactory, ResourceFinder finder)
          Prepare the hyphenation manager according to its configuration.
protected  java.io.File makeLogFile(java.lang.String jobname)
          Find the name for the log file.
protected  java.util.logging.Handler makeLogHandler(java.io.File logFile)
          Create a new Handler for the log file.
protected  OutputFactory makeOutputFactory(java.lang.String jobname, Configuration config)
          Create the output factory.
protected  ResourceFinder makeResourceFinder(Configuration config)
          Create a ResourceFinder.
protected  TokenFactory makeTokenFactory(Configuration config)
          Prepare the token factory according to its configuration.
protected  TokenStreamFactory makeTokenStreamFactory(Configuration config, ResourceFinder finder)
          Create a TokenStreamFactory.
protected  Typesetter makeTypesetter(Interpreter interpreter, Configuration config, OutputStreamFactory outFactory, ResourceFinder finder, FontFactory fontFactory)
          Create a new typesetter.
protected  void propertyDefault(java.lang.String name, java.lang.String value)
          Set a property to a given value if not set yet.
 Interpreter run()
          Run the program with the parameters already stored in the properties.
 void setErrorHandler(ErrorHandler handler)
          Setter for errorHandler.
 void setLogger(java.util.logging.Logger logger)
          Setter for logger.
 void setOutStream(java.io.OutputStream outputStream)
          Setter for outStream.
protected  void setProperty(java.lang.String key, java.lang.String value)
          Setter for a named property.
protected  void showBanner(Configuration configuration, java.util.logging.Level priority)
          Print the program banner to the logger stream and remember that this has been done already to avoid repetition.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_BANNER

protected static final java.lang.String PROP_BANNER
The constant PROP_BANNER contains the name of the property for the banner.

See Also:
Constant Field Values

PROP_CODE

protected static final java.lang.String PROP_CODE
The constant PROP_CODE contains the name of the property for the TeX code to be inserted at the beginning of the job.

See Also:
Constant Field Values

PROP_COLOR_CONVERTER

protected static final java.lang.String PROP_COLOR_CONVERTER
The constant PROP_COLOR_CONVERTER contains the name of the property for the color converter to use.

See Also:
Constant Field Values

PROP_CONFIG

protected static final java.lang.String PROP_CONFIG
The constant PROP_CONFIG contains the name of the property for the configuration resource to use.

See Also:
Constant Field Values

PROP_ENCODING

protected static final java.lang.String PROP_ENCODING
The constant PROP_ENCODING contains the name of the property for the standard encoding to use.

See Also:
Constant Field Values

PROP_ERROR_HANDLER

protected static final java.lang.String PROP_ERROR_HANDLER
The constant PROP_ERROR_HANDLER contains the name of the property for the error handler type to use. Possible values are resolved via the configuration.

See Also:
Constant Field Values

PROP_FILE

protected static final java.lang.String PROP_FILE
The constant PROP_FILE contains the name of the property for the input file to read.

See Also:
Constant Field Values

PROP_FMT

protected static final java.lang.String PROP_FMT
The constant PROP_FMT contains the name of the property for the name of the format file to use.

See Also:
Constant Field Values

PROP_HALT_ON_ERROR

protected static final java.lang.String PROP_HALT_ON_ERROR
The constant PROP_HALT_ON_ERROR contains the name of the property indicating whether the processing should stop at the first error.

See Also:
Constant Field Values

PROP_INI

protected static final java.lang.String PROP_INI
The constant PROP_INI contains the name of the property for the Boolean value indicating that some kind of emulations for iniTeX should be provided. Currently this has no effect in ExTeX.

See Also:
Constant Field Values

PROP_INTERACTION

protected static final java.lang.String PROP_INTERACTION
The constant PROP_INTERACTION contains the name of the property for the interaction mode.

See Also:
Constant Field Values

PROP_INTERNAL_STACKTRACE

protected static final java.lang.String PROP_INTERNAL_STACKTRACE
The constant PROP_INTERNAL_STACKTRACE contains the name of the property indicating that a stack trace should be written for internal errors.

See Also:
Constant Field Values

PROP_JOBNAME

protected static final java.lang.String PROP_JOBNAME
The constant PROP_JOBNAME contains the name of the property for the job name. The value can be overruled by the property named in PROP_JOBNAME_MASTER.

See Also:
Constant Field Values

PROP_JOBNAME_MASTER

protected static final java.lang.String PROP_JOBNAME_MASTER
The constant PROP_JOBNAME_MASTER contains the name of the property for the job name to be used with high priority.

See Also:
Constant Field Values

PROP_LANG

protected static final java.lang.String PROP_LANG
The constant PROP_LANG contains the name of the property for the language to use for messages.

See Also:
Constant Field Values

PROP_NAME

protected static final java.lang.String PROP_NAME
The constant PROP_NAME contains the name of the property for the program name used in messages.

See Also:
Constant Field Values

PROP_NO_BANNER

protected static final java.lang.String PROP_NO_BANNER
The constant PROP_NO_BANNER contains the name of the property for the Boolean value indicating whether or not to show a program banner.

See Also:
Constant Field Values

PROP_OUTPUT_DIRS

protected static final java.lang.String PROP_OUTPUT_DIRS
The constant PROP_OUTPUT_DIRS contains the name of the property for the output directory path.

See Also:
Constant Field Values

PROP_OUTPUT_TYPE

protected static final java.lang.String PROP_OUTPUT_TYPE
The constant PROP_OUTPUT_TYPE contains the name of the property for the output driver. This value is resolved by the DocumentWriterFactory to find the appropriate class.

See Also:
Constant Field Values

PROP_PAGE

protected static final java.lang.String PROP_PAGE
The constant PROP_PAGE contains the name of the property for the default page dimensions.

See Also:
Constant Field Values

PROP_PROGNAME

protected static final java.lang.String PROP_PROGNAME
The constant PROP_PROGNAME contains the name of the property for the program name used in format loading.

See Also:
Constant Field Values

PROP_TEXINPUTS

protected static final java.lang.String PROP_TEXINPUTS
The constant PROP_TEXINPUTS contains the name of the property for the additional texinputs specification of directories.

See Also:
Constant Field Values

PROP_TOKEN_STREAM

protected static final java.lang.String PROP_TOKEN_STREAM
The constant PROP_TOKEN_STREAM contains the name of the property for the token stream class to use.

See Also:
Constant Field Values

PROP_TRACE_FONT_FILES

protected static final java.lang.String PROP_TRACE_FONT_FILES
The constant PROP_TRACE_FONT_FILES contains the name of the property for the Boolean determining whether or not the searching for font files should produce tracing output.

See Also:
Constant Field Values

PROP_TRACE_INPUT_FILES

protected static final java.lang.String PROP_TRACE_INPUT_FILES
The constant PROP_TRACE_INPUT_FILES contains the name of the property for the Boolean determining whether or not the searching for input files should produce tracing output.

See Also:
Constant Field Values

PROP_TRACE_MACROS

protected static final java.lang.String PROP_TRACE_MACROS
The constant PROP_TRACE_MACROS contains the name of the property for the Boolean determining whether or not the execution of macros should produce tracing output.

See Also:
Constant Field Values

PROP_TRACE_TOKENIZER

protected static final java.lang.String PROP_TRACE_TOKENIZER
The constant PROP_TRACE_TOKENIZER contains the name of the property for the Boolean determining whether or not the tokenizer should produce tracing output.

See Also:
Constant Field Values

PROP_TRACING_ONLINE

protected static final java.lang.String PROP_TRACING_ONLINE
The constant PROP_TRACING_ONLINE contains the name of the property for the Boolean determining whether or not the tracing should produce log output in the log file only.

See Also:
Constant Field Values

PROP_TYPESETTER_TYPE

protected static final java.lang.String PROP_TYPESETTER_TYPE
The constant PROP_TYPESETTER_TYPE contains the name of the property for the typesetter to use. This value is resolved by the TypesetterFactory to find the appropriate class.

See Also:
Constant Field Values
Constructor Detail

ExTeX

public ExTeX(java.util.Properties theProperties)
      throws InterpreterException
Creates a new object and supplies some properties for those keys which are not contained in the properties already. A detailed list of the properties supported can be found in section Settings.

Parameters:
theProperties - the properties to start with. This object is used and modified. The caller should provide a new instance if this is not desirable.
Throws:
InterpreterException - in case of an error

ExTeX

public ExTeX(java.util.Properties theProperties,
             java.lang.String dotFile)
      throws InterpreterException,
             java.io.IOException
Creates a new object and initializes the properties from given properties and possibly from a user's properties in the file .extex. The user properties are loaded from the users home directory and the current directory.

Parameters:
theProperties - the properties to consider
dotFile - the name of the local configuration file. In the case that this value is null no user properties will be considered.
Throws:
InterpreterException - in case of an invalid interaction mode
java.io.IOException - in case of an IO Error during the reading of the properties file
See Also:
ExTeX(java.util.Properties)
Method Detail

getVersion

public static java.lang.String getVersion()
Getter for the version.

Returns:
the version number for this class

logException

protected static void logException(java.util.logging.Logger logger,
                                   java.lang.String text,
                                   java.lang.Throwable e)
Log a Throwable including its stack trace to the logger.

Parameters:
logger - the target logger
text - the prefix text to log
e - the Throwable to log

applyInteraction

protected void applyInteraction()
                         throws InteractionUnknownException
Propagate the settings for the interaction mode to the interactionObserver.

Throws:
InteractionUnknownException - in case that the interaction is not set properly

applyLanguage

protected void applyLanguage()
Try to determine which language to use and configure the localizer accordingly. If no locale has been given then the default locale is used. If the given locale is not supported then the default locale is used and a warning is logged.


getBooleanProperty

public boolean getBooleanProperty(java.lang.String key)
Getter for a named property as boolean.

Parameters:
key - the property name
Returns:
the value of the named property

getLocalizer

protected Localizer getLocalizer()
Getter for localizer.

Returns:
the localizer

getLogger

public java.util.logging.Logger getLogger()
Getter for logger.

Returns:
the logger.

getOutStream

public java.io.OutputStream getOutStream()
Getter for outStream.

Returns:
the outStream.

getProperties

public java.util.Properties getProperties()
Getter for properties.

Returns:
the properties

getProperty

public java.lang.String getProperty(java.lang.String key)
Getter for a named property.

Parameters:
key - the property name
Returns:
the value of the named property or null

initializeStreams

protected boolean initializeStreams(Interpreter interpreter,
                                    java.util.Properties prop)
                             throws ConfigurationException
Initialize the input streams. If the property extex.file is set and not the empty string, (e.g. from the command line) then this value is used as file name to read from. If the property extex.code is set and not the empty string (e.g. from the command line) then this value is used as initial input after the input file has been processed.

Parameters:
interpreter - the interpreter context
prop - the properties
Returns:
true if the stream have not been initialized
Throws:
ConfigurationException - in case of a configuration error

loadFormat

protected Context loadFormat(java.lang.String fmt,
                             Interpreter interpreter,
                             ResourceFinder finder,
                             java.lang.String jobname,
                             Configuration config,
                             OutputStreamFactory outFactory,
                             TokenFactory tokenFactory)
                      throws java.io.IOException,
                             GeneralException,
                             ConfigurationException
Load a format if a non-empty name of a format is given.

Parameters:
fmt - the name of the format to use or null or the empty string to suppress loading
interpreter - the interpreter to delegate the loading to
finder - the resource finder to use for locating the format file
jobname - the name of the job
config - the interpreter configuration
outFactory - the output stream factory
tokenFactory - the token factory to assign to the context or null if no assignment should be performed
Returns:
the context
Throws:
GeneralException - in case of some error
java.io.IOException - in case, well, you guess it
ConfigurationException - in case of a configuration error

loadUserProperties

protected void loadUserProperties(java.io.File file)
                           throws java.io.IOException
Load properties from a given file if it exists.

Parameters:
file - the file to consider
Throws:
java.io.IOException - in case of an IO Error during the reading of the properties file

logInternalError

protected void logInternalError(java.lang.Throwable e)
Log a Throwable including its stack trace to the logger.

Parameters:
e - the Throwable to log

logPages

protected void logPages(BackendDriver backend)
This method can be overwritten to provide logging functionality for the pages produced.

Parameters:
backend - the back-end driver

makeBackend

protected BackendDriver makeBackend(Configuration config,
                                    OutputStreamFactory outFactory,
                                    DocumentWriterOptions options,
                                    Configuration colorConfig,
                                    ResourceFinder finder,
                                    FontFactory fontFactory)
                             throws DocumentWriterException,
                                    ConfigurationException
Create a new document writer.

Parameters:
config - the configuration object for the document writer
outFactory - the output factory
options - the options to be passed to the document writer
colorConfig - the configuration for the color converter
finder - the resource finder if one is requested
fontFactory - the font factory
Returns:
the new document writer
Throws:
DocumentWriterException - in case of an error
ConfigurationException - in case of a configuration problem

makeColorConverter

protected ColorConverter makeColorConverter(Configuration config)
                                     throws ConfigurationException
Make a new instance of a color converter.

Parameters:
config - the configuration to use
Returns:
the new color converter
Throws:
ConfigurationException - in case of a configuration problem

makeContext

protected Context makeContext(Configuration config,
                              TokenFactory tokenFactory,
                              FontFactory fontFactory,
                              Interpreter interpreter,
                              ResourceFinder finder,
                              java.lang.String jobname,
                              OutputStreamFactory outFactory)
                       throws ConfigurationException,
                              GeneralException,
                              FontException,
                              java.io.IOException
Prepare the context according to its configuration.

Parameters:
config - the configuration of the interpreter
tokenFactory - the token factory to inject
fontFactory - the font factory
interpreter - the interpreter
finder - the resoruce finder
jobname - the job name
outFactory - the output stream factory
Returns:
the newly created context
Throws:
ConfigurationException - in case of a configuration error
FontException - in case of a font error
GeneralException - in case of an error
java.io.IOException - in case of an IO error

makeDefaultFont

protected Font makeDefaultFont(Configuration config,
                               FontFactory fontFactory)
                        throws GeneralException,
                               ConfigurationException,
                               FontException
Create a default font for the interpreter context.

Parameters:
config - the configuration object for the font. This can be null
fontFactory - the font factory to request the font from
Returns:
the default font
Throws:
GeneralException - in case of an error of some other kind
ConfigurationException - in case that some kind of problems have been detected in the configuration
FontException - in case of problems with the font itself

makeFontFactory

protected FontFactory makeFontFactory(Configuration config,
                                      ResourceFinder finder)
                               throws ConfigurationException
Create a new font factory.

Parameters:
config - the configuration object for the font factory
finder - the resource finder to use
Returns:
the new font factory
Throws:
ConfigurationException - in case that some kind of problems have been detected in the configuration

makeInterpreter

protected Interpreter makeInterpreter(Configuration config,
                                      OutputStreamFactory outFactory,
                                      ResourceFinder finder,
                                      java.lang.String jobname)
                               throws ConfigurationException,
                                      GeneralException,
                                      FontException,
                                      java.io.IOException
Create a new interpreter.

Parameters:
config - the configuration object for the interpreter
outFactory - the factory for new output streams
finder - the resource finder
jobname - the job name
Returns:
the new interpreter
Throws:
ConfigurationException - in case that some kind of problems have been detected in the configuration
GeneralException - in case of an error of some other kind
FontException - in case of problems with the font itself
java.io.IOException - in case of an IO error

makeLanguageManager

protected LanguageManager makeLanguageManager(Configuration config,
                                              OutputStreamFactory outFactory,
                                              ResourceFinder finder)
                                       throws ConfigurationException
Prepare the hyphenation manager according to its configuration.

This method can be overwritten in derived classes to perform additional tasks. In this case it might be a good idea to invoke this method from the super-class to do its job.

Parameters:
config - the configuration
outFactory - the output stream factory
finder - the resource finder
Returns:
the language manager created
Throws:
ConfigurationException - in case of a configuration error

makeLogFile

protected java.io.File makeLogFile(java.lang.String jobname)
Find the name for the log file.

This method can be overwritten in derived classes to perform additional tasks. In this case it might be a good idea to invoke this method from the super-class to do its job.

Parameters:
jobname - the name of the job
Returns:
the new file

makeLogHandler

protected java.util.logging.Handler makeLogHandler(java.io.File logFile)
Create a new Handler for the log file.

This method can be overwritten in derived classes to perform additional tasks. In this case it might be a good idea to invoke this method from the super-class to do its job.

Parameters:
logFile - the name of the log file
Returns:
the new handler

makeOutputFactory

protected OutputFactory makeOutputFactory(java.lang.String jobname,
                                          Configuration config)
                                   throws ConfigurationException
Create the output factory.

Parameters:
jobname - the job name
config - the configuration
Returns:
the output factory
Throws:
ConfigurationException - in case of a configuration error

makeResourceFinder

protected ResourceFinder makeResourceFinder(Configuration config)
                                     throws ConfigurationException
Create a ResourceFinder. Implicitly the logger and the properties are used.

This method can be overwritten in derived classes to perform additional tasks. In this case it might be a good idea to invoke this method from the super-class to do its job.

Parameters:
config - the configuration
Returns:
the new resource finder
Throws:
ConfigurationException - in case of an configuration error

makeTokenFactory

protected TokenFactory makeTokenFactory(Configuration config)
                                 throws ConfigurationException
Prepare the token factory according to its configuration.

This method can be overwritten in derived classes to perform additional tasks. In this case it might be a good idea to invoke this method from the super-class to do its job.

Parameters:
config - the configuration
Returns:
the token factory
Throws:
ConfigurationException - in case of a configuration error

makeTokenStreamFactory

protected TokenStreamFactory makeTokenStreamFactory(Configuration config,
                                                    ResourceFinder finder)
                                             throws ConfigurationException,
                                                    NotObservableException
Create a TokenStreamFactory. The logger is used implicitly.

This method can be overwritten in derived classes to perform additional tasks. In this case it might be a good idea to invoke this method from the super-class to do its job.

Parameters:
config - the configuration object for the token stream factory
finder - the file finder for the token stream factory
Returns:
the token stream factory
Throws:
ConfigurationException - in case that some kind of problems have been detected in the configuration
NotObservableException - in case that the observer for file events could not be registered

makeTypesetter

protected Typesetter makeTypesetter(Interpreter interpreter,
                                    Configuration config,
                                    OutputStreamFactory outFactory,
                                    ResourceFinder finder,
                                    FontFactory fontFactory)
                             throws TypesetterException,
                                    ConfigurationException,
                                    CatcodeException,
                                    DocumentWriterException
Create a new typesetter.

This method can be overwritten in derived classes to perform additional tasks. In this case it might be a good idea to invoke this method from the super-class to do its job.

Parameters:
interpreter - the interpreter
config - the global configuration object
outFactory - the output stream factory
finder - the resource finder
fontFactory - the font factory
Returns:
the new typesetter
Throws:
ConfigurationException - in case that some kind of problems have been detected in the configuration
TypesetterException - in case of an error
CatcodeException - in case of a problem with catcodes
DocumentWriterException - just in case

propertyDefault

protected void propertyDefault(java.lang.String name,
                               java.lang.String value)
Set a property to a given value if not set yet.

Parameters:
name - the name of the property
value - the default value

run

public Interpreter run()
                throws ConfigurationException,
                       java.io.IOException,
                       InterpreterException
Run the program with the parameters already stored in the properties.

Returns:
the interpreter used for running
Throws:
java.io.IOException - in case of a reading error
Especially
CharacterCodingException in case of problems with the character encoding
ConfigurationException - in case of a configuration error
InterpreterException - in case of another error
Especially
ErrorLimitException in case that the error limit has been reached

setErrorHandler

public void setErrorHandler(ErrorHandler handler)
Setter for errorHandler.

Parameters:
handler - the errorHandler to set.

setLogger

public void setLogger(java.util.logging.Logger logger)
Setter for logger.

Parameters:
logger - the logger to set.

setOutStream

public void setOutStream(java.io.OutputStream outputStream)
Setter for outStream.

Parameters:
outputStream - the outStream to set.

setProperty

protected void setProperty(java.lang.String key,
                           java.lang.String value)
Setter for a named property.

Parameters:
key - the property name
value - the new value of the named property

showBanner

protected void showBanner(Configuration configuration,
                          java.util.logging.Level priority)
Print the program banner to the logger stream and remember that this has been done already to avoid repetition. The property extex.nobanner can be used to suppress the banner.

Parameters:
configuration - the configuration to use. The configuration may contain a tag banner. If present then the value is used. The configuration can be null. Then it is ignored.
priority - the log level