de.dante.extex.interpreter.primitives.file
Class AbstractFileCode

java.lang.Object
  extended byde.dante.extex.interpreter.type.AbstractCode
      extended byde.dante.extex.interpreter.primitives.file.AbstractFileCode
All Implemented Interfaces:
Code, Configurable, Localizable, java.io.Serializable
Direct Known Subclasses:
Input, InputXslt, OcpPrimitive, Openin, Openout

public abstract class AbstractFileCode
extends AbstractCode
implements Configurable

This abstract class provides some common methods for primitives dealing with files.

Version:
$Revision: 1.34 $
Author:
Gerd Neugebauer
See Also:
Serialized Form

Field Summary
static int MAX_IN_FILE_NO
          The constant MAX_OUT_FILE_NO contains the maximum number of input files.
static int MAX_OUT_FILE_NO
          The constant MAX_OUT_FILE_NO contains the maximal number of output files.
 
Fields inherited from class de.dante.extex.interpreter.type.AbstractCode
serialVersionUID
 
Constructor Summary
AbstractFileCode(java.lang.String name)
          Creates a new object.
 
Method Summary
 void configure(Configuration config)
          Configure an object according to a given Configuration.
protected  java.lang.String getEncoding(Context context)
          Return the encoding for the AbstractFileCode file.
protected  java.lang.String scanFileName(Context context, TokenSource source)
          Scan the file name.
static java.lang.String scanInFileKey(Context context, TokenSource source, Typesetter typesetter)
          Scan the input source for some tokens making up the key for an infile register.
static java.lang.String scanOutFileKey(Context context, TokenSource source, Typesetter typesetter)
          Scan the input source for some tokens making up the key for an outfile register.
 
Methods inherited from class de.dante.extex.interpreter.type.AbstractCode
enableLocalization, execute, getLocalizer, getName, isIf, isOuter, printable, printableControlSequence, readResolve, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_IN_FILE_NO

public static final int MAX_IN_FILE_NO
The constant MAX_OUT_FILE_NO contains the maximum number of input files.

See Also:
Constant Field Values

MAX_OUT_FILE_NO

public static final int MAX_OUT_FILE_NO
The constant MAX_OUT_FILE_NO contains the maximal number of output files.

See Also:
Constant Field Values
Constructor Detail

AbstractFileCode

public AbstractFileCode(java.lang.String name)
Creates a new object.

Parameters:
name - the name for debugging
Method Detail

scanInFileKey

public static java.lang.String scanInFileKey(Context context,
                                             TokenSource source,
                                             Typesetter typesetter)
                                      throws InterpreterException
Scan the input source for some tokens making up the key for an infile register. Currently only numbers in a certain range are allowed.

The Infile Name

The infile name is a symbolic key to reference an input file. This is a number in the range from 0 to 15.

Syntax

The formal description of this primitive is the following:
    ⟨infile name⟩
      → ⟨number⟩ 

Parameters:
context - the interpreter context
source - the token source to read from
typesetter - the typesetter
Returns:
the key read in the form of a String
Throws:
InterpreterException - in case of a failure

scanOutFileKey

public static java.lang.String scanOutFileKey(Context context,
                                              TokenSource source,
                                              Typesetter typesetter)
                                       throws InterpreterException
Scan the input source for some tokens making up the key for an outfile register. Currently only numbers are allowed.

The Outfile Name

The outfile name is a symbolic key to reference an output file. This is a number in the range from 0 to 15.

Syntax

The formal description of this primitive is the following:
    ⟨infile name⟩
      → ⟨number⟩ 

Parameters:
context - the interpreter context
source - the token source to read from
typesetter - the typesetter
Returns:
the key read in the form of a String
Throws:
InterpreterException - in case of a failure

configure

public void configure(Configuration config)
               throws ConfigurationException
Configure an object according to a given Configuration.

Specified by:
configure in interface Configurable
Parameters:
config - the configuration to use
Throws:
ConfigurationException - in case of an error
See Also:
Configurable.configure( de.dante.util.framework.configuration.Configuration)

getEncoding

protected java.lang.String getEncoding(Context context)
Return the encoding for the AbstractFileCode file.

First of all, \fileencoding is used, if there is no value, then the property extex.encoding is used, or ISO8859-1, if no entry exists.

Parameters:
context - the context
Returns:
the encoding for the AbstractFileCodefile

scanFileName

protected java.lang.String scanFileName(Context context,
                                        TokenSource source)
                                 throws InterpreterException
Scan the file name. This method parses the following syntactic entity:
   ⟨file name⟩ 
The scanning is performed in one of two ways:
  • If the first token is a left brace then a block is read until the matching right brace is found. On the way the tokens are expanded.
  • Otherwise tokens are read until a space token is encountered.

Parameters:
context - the processing context
source - the source for new tokens
Returns:
the file name as string
Throws:
InterpreterException - in case of an error