com.plotnix.jex
Class MultilingualCompiler

java.lang.Object
  |
  +--com.plotnix.jex.Compiler
        |
        +--com.plotnix.jex.MultilingualCompiler

public class MultilingualCompiler
extends Compiler

A MultilingualCompiler determines the language for each expression and then compiles it using that language's compiler.

If the expression string passed to this compiler starts with "language:", the compiler strips the prefix off and passes the remainder of the expression to the compiler for the corresponding language.

The prefix is required if the MultilingualCompiler's default language is null.

If the default language is not null and the expression is missing a prefix, or the prefix does not match an existing compiler, the multilingual compiler passes the expression unchanged to the default language compiler.

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

Method Summary
 Expression compileExpression(java.lang.String expression)
          Compiles an expression intended for evaluation using the appropriate compiler.
 IterationExpression compileIterationExpression(java.lang.String expression)
          Compiles an expression that describes an iteration.
 VariableExpression compileVariableExpression(java.lang.String expression)
          Compiles an expression intended to serve as the left hand side of an assignment.
static Compiler getMultilingualCompiler(java.lang.String defaultLanguage)
          Returns a MultilingualCompiler with the specified default language.
 
Methods inherited from class com.plotnix.jex.Compiler
getCompiler, getCompilerImplementation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getMultilingualCompiler

public static final Compiler getMultilingualCompiler(java.lang.String defaultLanguage)
Returns a MultilingualCompiler with the specified default language. If the specified default language is not null, a compiler (or an interpreter) for that language should be available.
Parameters:
defaultLanguage - is the default language or null
Returns:
A MultilingualCompiler

compileExpression

public Expression compileExpression(java.lang.String expression)
Compiles an expression intended for evaluation using the appropriate compiler. If the expression has the syntax "lang:expr" and a compiler is available for the language "lang", passes the expression to that compiler. Otherwise, passes the whole unparsed expression to the default language compiler.
Overrides:
compileExpression in class Compiler
Parameters:
expression - is the expression to be compiled with an optional "lang:" prefix
Returns:
the compiled expression

compileIterationExpression

public IterationExpression compileIterationExpression(java.lang.String expression)
Compiles an expression that describes an iteration.
Overrides:
compileIterationExpression in class Compiler
See Also:
compileExpression(String)

compileVariableExpression

public VariableExpression compileVariableExpression(java.lang.String expression)
Compiles an expression intended to serve as the left hand side of an assignment.
Overrides:
compileVariableExpression in class Compiler
See Also:
compileExpression(String)


Copyright (c) 2002 - Plotnix, Inc