de.dante.extex.interpreter.primitives.dynamic.java
Class JavaLoad

java.lang.Object
  extended byde.dante.extex.interpreter.type.AbstractCode
      extended byde.dante.extex.interpreter.primitives.dynamic.java.JavaLoad
All Implemented Interfaces:
Code, Loader, Localizable, java.io.Serializable

public class JavaLoad
extends AbstractCode
implements Loader

This primitive initiates the loading of Java code and implements the primitive \javaload

The Primitive \javaload

The primitive \javaload loads a java class and invokes its init() method. With this method it is possible to load larger extensions of ExTeX in one junk. There is no need to declare each single macro with \javadef.

Syntax

The general form of this primitive is
   ⟨javaload⟩
       → \javaload ⟨tokens⟩  

The ⟨tokens⟩ is any specification of a list of tokens like a constant list enclosed in braces or a token register. The value of these tokens are taken and interpreted as the name of a Java class. This class is loaded if needed, instantiated, and its method init() is invoked. The instantiation requires the empty constructor to be visible.

Examples

The following example illustrates the use of this primitive:

   \javaload{de.dante.extex.extensions.Basic} 

For the loading of the Java class it is necessary that this Java class implements the interface Loadable.

   package my.package;

   import de.dante.extex.interpreter.contect.Context;
   import de.dante.extex.interpreter.primitives.dynamic.java.Loadable;
   import de.dante.extex.typesetter.Typesetter;
   import de.dante.util.GeneralException;

   class MyModule implements Loadable {

     public MyModule() {
       super();
       // initialization code – if required
     }

     public void init(final Context context,
                      final Typesetter typesetter
                     ) throws GeneralException {
       // implement the initialization code here
     }
   } 

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

Field Summary
protected static long serialVersionUID
          The constant serialVersionUID contains the id for serialization.
 
Constructor Summary
JavaLoad()
          Creates a new object.
JavaLoad(java.lang.String codeName)
          Creates a new object.
 
Method Summary
 void execute(Flags prefix, Context context, TokenSource source, Typesetter typesetter)
          This method takes the first token and executes it.
 void load(Context context, TokenSource source, Typesetter typesetter)
          Perform a load operation.
 
Methods inherited from class de.dante.extex.interpreter.type.AbstractCode
enableLocalization, 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

serialVersionUID

protected static final long serialVersionUID
The constant serialVersionUID contains the id for serialization.

See Also:
Constant Field Values
Constructor Detail

JavaLoad

public JavaLoad()
Creates a new object. This method is needed for the nativeload wrapper.


JavaLoad

public JavaLoad(java.lang.String codeName)
Creates a new object.

Parameters:
codeName - the name for debugging
Method Detail

execute

public void execute(Flags prefix,
                    Context context,
                    TokenSource source,
                    Typesetter typesetter)
             throws InterpreterException
Description copied from interface: Code
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
Overrides:
execute in class AbstractCode
Throws:
InterpreterException
See Also:
Code.execute( de.dante.extex.interpreter.Flags, de.dante.extex.interpreter.context.Context, de.dante.extex.interpreter.TokenSource, de.dante.extex.typesetter.Typesetter)

load

public void load(Context context,
                 TokenSource source,
                 Typesetter typesetter)
          throws InterpreterException
Description copied from interface: Loader
Perform a load operation.

Specified by:
load in interface Loader
Parameters:
context - the interpreter context
source - the source for new tokens
typesetter - the typesetter
Throws:
InterpreterException - in case of an error
See Also:
Loader.load( de.dante.extex.interpreter.context.Context, de.dante.extex.interpreter.TokenSource, de.dante.extex.typesetter.Typesetter)