com.wewebu.expression.language
Class OwExprExpression

java.lang.Object
  extended by com.wewebu.expression.language.OwExprExpression
Direct Known Subclasses:
OwExprArgumentsSuffix, OwExprArraySelectorSuffix, OwExprBinaryExpression, OwExprConditionalExpression, OwExprDebugBracketsExpression, OwExprLiteral, OwExprPrimaryPrefixExpression, OwExprScopeSelector, OwExprStaticArray, OwExprUnaryExpression, OwExprUnparsableExpression

public abstract class OwExprExpression
extends Object

An expression language compiled expression. Expressions can be obtained from literal representations of expression language expressions. An expression can be evaluated on different scopes.

Alfresco Workdesk
Copyright (c) Alfresco Software, Inc.
All rights reserved.

For licensing information read the license.txt file or
go to: http://wiki.alfresco.com


Field Summary
protected  OwExprErrorTable m_errorTable
          Global error table reference
protected  OwExprSymbolTable m_symbolTable
          Global symbol table reference
protected  boolean m_typeError
          Type error indicating flag - a type error was detected in this expression
 
Constructor Summary
OwExprExpression(OwExprSymbolTable symbolTable_p, OwExprErrorTable errorTable_p)
           
 
Method Summary
 int errCount()
          Number of errors discovered at compile time
 OwExprValue evaluate()
          A no external scopes evaluation routine.
 OwExprValue evaluate(OwExprExternalScope[] externalScopes_p)
          Evaluates this expression.
abstract  OwExprValue evaluate(OwExprScope scope_p)
          Evaluates this expression on the OwExprScope (scope) provided as argument.
 OwExprErrorTable getErrorTable()
          Global error table accessor
 OwExprSymbol getSymbol(String symbolName_p)
          Symbol accessor.
 OwExprSymbolTable getSymbolTable()
          m_symbolTable getter
 boolean hasErrors()
          Compile time errors indicator
protected  void initType()
          Standard expression type initialization method.
 boolean symbolsVisibleInScopes(OwExprExternalScope[] externalScopes_p)
          Pre-evaluation optional symbol visibility check method.
abstract  OwExprExpressionType type()
          Type check method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_symbolTable

protected OwExprSymbolTable m_symbolTable
Global symbol table reference


m_errorTable

protected OwExprErrorTable m_errorTable
Global error table reference


m_typeError

protected boolean m_typeError
Type error indicating flag - a type error was detected in this expression

Constructor Detail

OwExprExpression

public OwExprExpression(OwExprSymbolTable symbolTable_p,
                        OwExprErrorTable errorTable_p)
Parameters:
symbolTable_p - global symbol table reference
errorTable_p - global error table reference
Method Detail

initType

protected final void initType()
Standard expression type initialization method. If an error is detected during type checking the type error flag is set (m_typeError) and the type error is added to the error table (m_errorTable).


evaluate

public OwExprValue evaluate()
                     throws OwExprEvaluationException
A no external scopes evaluation routine. This method delegates to evaluate(OwExprExternalScope[])

Returns:
the value resulted from the scopeless evaluation
Throws:
OwExprEvaluationException - in case of evaluation failure

evaluate

public OwExprValue evaluate(OwExprExternalScope[] externalScopes_p)
                     throws OwExprEvaluationException
Evaluates this expression. The OwExprSystem scope (the default top level scope) is added by default (it is not necessary to be amongs t the exte).

Parameters:
externalScopes_p - the external scopes this expression is evaluated against
Returns:
the value resulted from the evaluation of this expression
Throws:
OwExprEvaluationException - in case of evaluation failure

evaluate

public abstract OwExprValue evaluate(OwExprScope scope_p)
                              throws OwExprEvaluationException
Evaluates this expression on the OwExprScope (scope) provided as argument.

Parameters:
scope_p - external scope to be used during evaluation
Returns:
the value resulted from the evaluation of this expression
Throws:
OwExprEvaluationException - in case of evaluation failure

type

public abstract OwExprExpressionType type()
                                   throws OwExprTypeMissmatchException
Type check method. If type errors are encountered during type computation the m_typeError should be set to true

Returns:
the expression type for this expression
Throws:
OwExprTypeMissmatchException - if type errors are encountered during type computation

getSymbolTable

public final OwExprSymbolTable getSymbolTable()
m_symbolTable getter

Returns:
the global symbol table

symbolsVisibleInScopes

public final boolean symbolsVisibleInScopes(OwExprExternalScope[] externalScopes_p)
                                     throws OwExprEvaluationException
Pre-evaluation optional symbol visibility check method. This method should be used on non erroneous expressions to check whether all symbols are visible in certain scopes. Not all symbols are verifiable though (TODO)

Parameters:
externalScopes_p -
Returns:
true if are verifiable symbols are found in the given scopes false otherwise
Throws:
OwExprEvaluationException - if symbols visibility check fails

getErrorTable

public final OwExprErrorTable getErrorTable()
Global error table accessor

Returns:
the global error table

hasErrors

public final boolean hasErrors()
Compile time errors indicator

Returns:
true if the expression that resulted in this object had compilation errors (either semantic - type errors or lexical errors), false otherwise

errCount

public final int errCount()
Number of errors discovered at compile time

Returns:
int number of errors found at compile time

getSymbol

public final OwExprSymbol getSymbol(String symbolName_p)
Symbol accessor.

Parameters:
symbolName_p - requested symbol's name
Returns:
the top level symbol identified with the given name


Copyright © 2013 Alfresco Business Solutions. All Rights Reserved.