com.plotnix.jex
Class Compiler

java.lang.Object
  |
  +--com.plotnix.jex.Compiler
Direct Known Subclasses:
Compiler, Compiler, InterpretingCompiler, MultilingualCompiler

public abstract class Compiler
extends java.lang.Object

A compiler translates an expression string into an executable form. It validates the syntax of the expression and throws an exception if the syntax is invalid.

In order to introduce a new compiler, create a class called "com.plotnix.jex.language-prefix.Compiler" that inherits from this class. Put it on the classpath. That's it. Jex will find thenew class by the prefix and invoke it to compile expressions in that language.

Version:
$Revision$ $Date$
Author:
Dmitri Plotnikov

Constructor Summary
Compiler()
           
 
Method Summary
abstract  Expression compileExpression(java.lang.String expression)
          Compiles an expression intended for evaluation that produces a value.
abstract  IterationExpression compileIterationExpression(java.lang.String expression)
          Compiles an expression describing an iteration.
abstract  VariableExpression compileVariableExpression(java.lang.String expression)
          Compiles an expression describing the left hand side of an assignment.
static Compiler getCompiler(java.lang.String language)
          Locates and returns a Compiler for the specified language.
protected static Compiler getCompilerImplementation(java.lang.String language)
          Locates and returns a Compiler for the specified language.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Compiler

public Compiler()
Method Detail

getCompiler

public static final Compiler getCompiler(java.lang.String language)
Locates and returns a Compiler for the specified language. If there is not such compiler, looks up an Interpreter for this language. If one is found, returns an adapter Compiler that makes an interpreter look like a Compiler. If neither a Compiler nor Interpreter exists for the specified language, returns null.
Parameters:
language - is the name of an expression language (no colon at the end)
Returns:
the Compiler for that language

getCompilerImplementation

protected static final Compiler getCompilerImplementation(java.lang.String language)
Locates and returns a Compiler for the specified language. If no Compiler exists for the specified language, returns null.
Parameters:
language - is the name of an expression language (no colon at the end)
Returns:
the Compiler for that language

compileExpression

public abstract Expression compileExpression(java.lang.String expression)
Compiles an expression intended for evaluation that produces a value. For example, "2+2" will be a valid argument for this method for many expression languages.

May throw an UnsupportedOperationException.

Parameters:
expression - is an expression in the corresponding language
Returns:
an executable object that can be used to compute the value of this expression in a Context.

compileIterationExpression

public abstract IterationExpression compileIterationExpression(java.lang.String expression)
Compiles an expression describing an iteration. For example, "addressBook//phone" is a valid argument for this method for an XPath compiler.

May throw an UnsupportedOperationException.

Parameters:
expression - is an iteration expression in the corresponding language
Returns:
an executable object that can be used to iterate over some values in a Context.

compileVariableExpression

public abstract VariableExpression compileVariableExpression(java.lang.String expression)
Compiles an expression describing the left hand side of an assignment. For example, "addressBook/contact[name="John Doe"]/phone" is a valid argument for this method for an XPath compiler.

May throw an UnsupportedOperationException.

Parameters:
expression - is a variable expression in the corresponding language
Returns:
an executable object that can be used to modify a value in a Context.


Copyright (c) 2002 - Plotnix, Inc