org.extex.unit.omega.ocp.util
Class Ocp

java.lang.Object
  extended by org.extex.unit.omega.ocp.util.Ocp
All Implemented Interfaces:
java.io.Serializable, Code, Showable, OcpConvertible

public class Ocp
extends java.lang.Object
implements Code, Showable, OcpConvertible, java.io.Serializable

This class represents a loaded OCP instance. It encapsulates an ΩCP program.

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

Field Summary
protected static long serialVersionUID
          The field serialVersionUID contains the version number for serialization.
 
Constructor Summary
Ocp(java.lang.String resource, OcpProgram program)
          Creates a new object.
 
Method Summary
 Ocp convertOcp(Context context, TokenSource source, Typesetter typesetter)
          Convert the value into an ΩPC.
 void execute(Flags prefix, Context context, TokenSource source, Typesetter typesetter)
          This method takes the first token and executes it.
 java.lang.String getName()
          Getter for the name.
 OcpProgram getProgram()
          Getter for program.
 CodeToken getToken()
          Getter for the token.
 boolean isIf()
          This simple little method distinguishes the conditionals from the other primitives.
 boolean isOuter()
          Getter for the outer flag.
static Ocp load(java.lang.String resource, ResourceFinder finder)
          This is a factory method for OCPs.
 void setName(java.lang.String name)
          Setter for the name.
 void setProgram(OcpProgram program)
          Setter for program.
 Tokens show(Context context)
          This method is the getter for the description of the primitive.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

protected static final long serialVersionUID
The field serialVersionUID contains the version number for serialization.

See Also:
Constant Field Values
Constructor Detail

Ocp

public Ocp(java.lang.String resource,
           OcpProgram program)
    throws HelpingException
Creates a new object.

Parameters:
resource - the name of the resource
program - the program
Throws:
HelpingException - in case of an error
Method Detail

load

public static Ocp load(java.lang.String resource,
                       ResourceFinder finder)
                throws HelpingException,
                       ConfigurationException
This is a factory method for OCPs.

Parameters:
resource - the name of the resource
finder - the resource finder
Returns:
the OCP encountered or null if none is found
Throws:
HelpingException - in case of an error
ConfigurationException - in case of an configuration error

convertOcp

public Ocp convertOcp(Context context,
                      TokenSource source,
                      Typesetter typesetter)
Convert the value into an ΩPC. Some tokens may be read from the input stream to perform the job.

Specified by:
convertOcp in interface OcpConvertible
Parameters:
context - the interpreter context
source - the source for new tokens
typesetter - the typesetter
Returns:
the Ocp encountered
See Also:
OcpConvertible.convertOcp( org.extex.interpreter.context.Context, org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)

execute

public void execute(Flags prefix,
                    Context context,
                    TokenSource source,
                    Typesetter typesetter)
             throws HelpingException,
                    TypesetterException
This method takes the first token and executes it. The result is placed on the stack. This operation might have side effects. To execute a token it might be necessary to consume further tokens.

Specified by:
execute in interface Code
Parameters:
prefix - the prefix controlling the execution
context - the interpreter context
source - the token source
typesetter - the typesetter
Throws:
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetter
See Also:
Code.execute( org.extex.interpreter.Flags, org.extex.interpreter.context.Context, org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)

getName

public java.lang.String getName()
Getter for the name.

Specified by:
getName in interface Code
Returns:
the name
See Also:
Code.getName()

getProgram

public OcpProgram getProgram()
Getter for program.

Returns:
the program

isIf

public boolean isIf()
This simple little method distinguishes the conditionals from the other primitives. This is necessary for the processing of all \if* primitives.

Specified by:
isIf in interface Code
Returns:
true iff this is some sort if \if.
See Also:
Code.isIf()

isOuter

public boolean isOuter()
Getter for the outer flag.

Specified by:
isOuter in interface Code
Returns:
true iff the code is defined outer.
See Also:
Code.isOuter()

setName

public void setName(java.lang.String name)
Setter for the name.

Parameters:
name - the name to set

setProgram

public void setProgram(OcpProgram program)
Setter for program.

Parameters:
program - the program to set

show

public Tokens show(Context context)
            throws HelpingException
This method is the getter for the description of the primitive.

Specified by:
show in interface Showable
Parameters:
context - the interpreter context
Returns:
the description of the primitive as list of Tokens
Throws:
HelpingException - in case of an error
See Also:
Showable.show( org.extex.interpreter.context.Context)

getToken

public CodeToken getToken()
Getter for the token.

Specified by:
getToken in interface Code
Returns:
the token
See Also:
Code.getToken()