TPTP 4.2.0 Platform Project
Public API Specification

org.eclipse.tptp.platform.provisional.fastxpath
Interface IFastXPathEngine

All Known Implementing Classes:
FastXPathEngine, FastXPathEngine

public interface IFastXPathEngine

Since:
4.2

Method Summary
 CompiledExpressionEvaluator compile(java.lang.String expression, java.lang.Object object, boolean verifyExpression, FastXPathContext fastXPathContext, ICompilerContext compilationContext, CompilerPostProcessor compilerPostProcessor, ICompilerHelper cHelper)
           
 CompiledExpressionEvaluator compile(java.lang.String expression, java.lang.Object object, ICompilerHelper cHelper)
          Generates a Java expression equivalent to the XPath expression.
 ICompilerHelper createCompilerHelper(java.lang.Class targetClass)
           
 java.lang.Object eval(java.lang.String expression, java.lang.Object object)
          Perform XPath query on an EObject.
 java.lang.Object evalCompiled(CompiledExpressionEvaluator evaluator, java.lang.Object object)
          Executes the compiled expression on EObject.
 java.util.Map getClassesAsByteArrays()
           
 FastXPathClassGenerator getClassGenerator()
           
 java.lang.Object getExpression(java.lang.String expression)
           
 char[] getExpressionJavaSource(java.lang.String expression, java.lang.Object object, boolean verifyExpression, FastXPathContext fastXPathContext, ICompilerContext compilationContext, CompilerPostProcessor compilerPostProcessor, ICompilerHelper cHelper)
          Generates the source code of a Java expression equivalent to the XPath expression.
 java.lang.Class getExtensionFunctionClass(java.lang.String key)
          Returns the Class of the extension function
 FastXPathContextFactory getFastXPathContextFactory()
           
 java.lang.String getVariable(java.lang.String key)
           
 void registerFunctionClass(java.lang.Class functionClass, java.lang.String key)
          * Registers a Class that contains extension functions.
 void registerVariable(java.lang.String key, java.lang.String newValue)
          registers a new variable
 void resetDeclaredVariables()
          Resets the declared variables map
 void resetExpressions()
          Resets the known expressions cache
 java.lang.Object[] selectNodes(java.lang.String expression, java.lang.Object object)
          Perform XPath query on an EObject.
 void setFastXPathContextFactory(FastXPathContextFactory fastXPathContextFactory)
           
 void unRegisterFunctionClass(java.lang.String key)
          unregisters a registered extension function class
 void unRegisterVariable(java.lang.String key)
          unregisters a variable
 

Method Detail

selectNodes

public java.lang.Object[] selectNodes(java.lang.String expression,
                                      java.lang.Object object)
                               throws javax.xml.transform.TransformerException,
                                      ExpressionEvaluationException
Perform XPath query on an EObject. The result may be several node

Parameters:
expression - the XPath expression to evaluate
object - the EObject to be evaluated
Returns:
Result of the query. If no node match, an empty array is returned.
Throws:
javax.xml.transform.TransformerException
ExpressionEvaluationException

eval

public java.lang.Object eval(java.lang.String expression,
                             java.lang.Object object)
                      throws javax.xml.transform.TransformerException,
                             ExpressionEvaluationException
Perform XPath query on an EObject. If several node match the query, only the first is returned

Parameters:
expression - the XPath expression to evaluate
object - the EObject to be evaluated
Returns:
Result of the query. null if there is no match.
Throws:
javax.xml.transform.TransformerException
ExpressionEvaluationException

evalCompiled

public java.lang.Object evalCompiled(CompiledExpressionEvaluator evaluator,
                                     java.lang.Object object)
                              throws ExpressionEvaluationException
Executes the compiled expression on EObject. CompiledExpressionEvaluator are generated by calling FastXPathEngine#compile(String, Object, CompilerHelper). It is up to the user to cache the different CompiledExpressionEvaluators

Parameters:
evaluator -
object - the EObject to be evaluated
Returns:
Result of the query. null if there is no match.
Throws:
ExpressionEvaluationException

compile

public CompiledExpressionEvaluator compile(java.lang.String expression,
                                           java.lang.Object object,
                                           ICompilerHelper cHelper)
                                    throws javax.xml.transform.TransformerException,
                                           CodeGenerationError,
                                           CompilerNotAvailableException
Generates a Java expression equivalent to the XPath expression. This compiled expression can later be evaluated using evalCompiled(CompiledExpressionEvaluator, Object)

Parameters:
expression - the XPath expression to generate code from
object - The compiiler needs an instance of the type of Object that the CompiledExpressionEvaluator will be specialized for.
cHelper - A helper Class to configure the compilation process. Can be null.
Returns:
A (@link CompiledExpressionEvaluator} specialized for the expressionobject and the object type.
Throws:
javax.xml.transform.TransformerException
CodeGenerationError
CompilerNotAvailableException

compile

public CompiledExpressionEvaluator compile(java.lang.String expression,
                                           java.lang.Object object,
                                           boolean verifyExpression,
                                           FastXPathContext fastXPathContext,
                                           ICompilerContext compilationContext,
                                           CompilerPostProcessor compilerPostProcessor,
                                           ICompilerHelper cHelper)
                                    throws javax.xml.transform.TransformerException,
                                           CodeGenerationError,
                                           CompilerNotAvailableException
Throws:
javax.xml.transform.TransformerException
CodeGenerationError
CompilerNotAvailableException

getExpressionJavaSource

public char[] getExpressionJavaSource(java.lang.String expression,
                                      java.lang.Object object,
                                      boolean verifyExpression,
                                      FastXPathContext fastXPathContext,
                                      ICompilerContext compilationContext,
                                      CompilerPostProcessor compilerPostProcessor,
                                      ICompilerHelper cHelper)
                               throws javax.xml.transform.TransformerException,
                                      CodeGenerationError,
                                      CompilerNotAvailableException
Generates the source code of a Java expression equivalent to the XPath expression.

Parameters:
expression - the XPath expression to generate code from
object - The compiler needs an instance of the type of Object that the CompiledExpressionEvaluator will be specialized for.
verifyExpression - If true the expression is evaluated to check if it is a valid expression.
fastXPathContext - If not null will be used otherwise a new one will be created.
compilationContext - If not null will be used otherwise a new one will be created.
compilerPostProcessor - If not null will be initialized and used otherwise a new one will be created.
Returns:
A String that contains the Java body of the expresion.
Throws:
javax.xml.transform.TransformerException
CodeGenerationError
CompilerNotAvailableException

resetExpressions

public void resetExpressions()
Resets the known expressions cache


resetDeclaredVariables

public void resetDeclaredVariables()
Resets the declared variables map


getVariable

public java.lang.String getVariable(java.lang.String key)
Parameters:
key - name of the variable to return
Returns:
Returns the variable named key

registerVariable

public void registerVariable(java.lang.String key,
                             java.lang.String newValue)
registers a new variable

Parameters:
key - name of the variable
newValue - value of the variable

unRegisterVariable

public void unRegisterVariable(java.lang.String key)
unregisters a variable

Parameters:
key - name of the variable

getExtensionFunctionClass

public java.lang.Class getExtensionFunctionClass(java.lang.String key)
Returns the Class of the extension function

Parameters:
key - the key by which the Class is registered
Returns:
the Class of the extension function

registerFunctionClass

public void registerFunctionClass(java.lang.Class functionClass,
                                  java.lang.String key)
* Registers a Class that contains extension functions.

Parameters:
functionClass - name of the class
key - the key it is registered by. The same key is used in the XPath expressions referencing to this class

unRegisterFunctionClass

public void unRegisterFunctionClass(java.lang.String key)
unregisters a registered extension function class

Parameters:
key - the key the class was registered as.

getExpression

public java.lang.Object getExpression(java.lang.String expression)
                               throws javax.xml.transform.TransformerException
Parameters:
expression -
Returns:
EXPath
Throws:
javax.xml.transform.TransformerException

getFastXPathContextFactory

public FastXPathContextFactory getFastXPathContextFactory()
Returns:
the fastXPathContextFactory

setFastXPathContextFactory

public void setFastXPathContextFactory(FastXPathContextFactory fastXPathContextFactory)

createCompilerHelper

public ICompilerHelper createCompilerHelper(java.lang.Class targetClass)

getClassesAsByteArrays

public java.util.Map getClassesAsByteArrays()

getClassGenerator

public FastXPathClassGenerator getClassGenerator()
                                          throws CompilerNotAvailableException
Throws:
CompilerNotAvailableException

TPTP 4.2.0 Platform Project
Public API Specification