org.extex.unit.base.file
Class AbstractFileCode

java.lang.Object
  extended by org.extex.interpreter.type.AbstractCode
      extended by org.extex.unit.base.file.AbstractFileCode
All Implemented Interfaces:
java.io.Serializable, Code
Direct Known Subclasses:
Input, Openin, Openout

public abstract class AbstractFileCode
extends AbstractCode

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

Version:
$Revision: 4770 $
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 org.extex.interpreter.type.AbstractCode
serialVersionUID
 
Constructor Summary
AbstractFileCode(CodeToken token)
          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 org.extex.interpreter.type.AbstractCode
execute, getLocalizer, getName, getToken, isIf, isOuter, readResolve, toString, toText, toText
 
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(CodeToken token)
Creates a new object.

Parameters:
token - the initial token for the primitive
Method Detail

scanInFileKey

public static java.lang.String scanInFileKey(Context context,
                                             TokenSource source,
                                             Typesetter typesetter)
                                      throws HelpingException,
                                             TypesetterException
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:
HelpingException - in case of a failure
TypesetterException - in case of an error in the typesetter

scanOutFileKey

public static java.lang.String scanOutFileKey(Context context,
                                              TokenSource source,
                                              Typesetter typesetter)
                                       throws HelpingException,
                                              TypesetterException
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:
HelpingException - in case of a failure
TypesetterException - in case of an error in the typesetter

configure

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

Parameters:
config - the configuration to use
Throws:
ConfigurationException - in case of an error
See Also:
org.extex.framework.configuration.Configurable#configure( org.extex.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 HelpingException,
                                        TypesetterException
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:
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetter