org.mvel2

Class ParserContext

    • Constructor Detail

      • ParserContext

        public ParserContext()
      • ParserContext

        public ParserContext(boolean debugSymbols)
      • ParserContext

        public ParserContext(java.lang.Object rootParser)
      • ParserContext

        public ParserContext(java.util.Map<java.lang.String,java.lang.Object> imports,
                     java.util.Map<java.lang.String,Interceptor> interceptors,
                     java.lang.String sourceFile)
    • Method Detail

      • hasVarOrInput

        public boolean hasVarOrInput(java.lang.String name)
        Tests whether or not a variable or input exists in the current parser context.
        Parameters:
        name - The name of the identifier.
        Returns:
        boolean
      • getVarOrInputType

        public java.lang.Class getVarOrInputType(java.lang.String name)
        Return the variable or input type froom the current parser context. Returns Object.class if the type cannot be determined.
        Parameters:
        name - The name of the identifier
        Returns:
        boolean
      • getVarOrInputTypeOrNull

        public java.lang.Class getVarOrInputTypeOrNull(java.lang.String name)
      • getLineCount

        public int getLineCount()
        Get total number of lines declared in the current context.
        Returns:
        int of lines
      • setLineCount

        public int setLineCount(int lineCount)
        Set the current number of lines in the current context. (Generally only used by the compiler)
        Parameters:
        lineCount - The number of lines
        Returns:
        int of lines
      • incrementLineCount

        public int incrementLineCount(int increment)
        Increments the current line count by the specified amount
        Parameters:
        increment - The number of lines to increment
        Returns:
        int of lines
      • getLineOffset

        public int getLineOffset()
        Get the current line offset. This measures the number of cursor positions back to the beginning of the line.
        Returns:
        int offset
      • setLineOffset

        public void setLineOffset(short lineOffset)
        Sets the current line offset. (Generally only used by the compiler)
        Parameters:
        lineOffset - The offset amount
      • setLineAndOffset

        public void setLineAndOffset(int lineCount,
                            int lineOffset)
        Sets both the current line count and line offset
        Parameters:
        lineCount - The line count
        lineOffset - The line offset
      • getImport

        public java.lang.Class getImport(java.lang.String name)
        Get an import that has been declared, either in the parsed script or programatically
        Parameters:
        name - The name identifier for the imported class (ie. "HashMap")
        Returns:
        An instance of Class denoting the imported class.
      • getStaticImport

        public MethodStub getStaticImport(java.lang.String name)
        Get a MethodStub which wraps a static method import.
        Parameters:
        name - The name identifier
        Returns:
        An instance of MethodStub
      • getStaticOrClassImport

        public java.lang.Object getStaticOrClassImport(java.lang.String name)
        Returns either an instance of Class or MethodStub (whichever matches).
        Parameters:
        name - The name identifier.
        Returns:
        An instance of Class or MethodStub
      • addPackageImport

        public void addPackageImport(java.lang.String packageName)
        Adds a package import to a parse session.
        Parameters:
        packageName - A fully qualified package (eg. java.util.concurrent).
      • hasImport

        public boolean hasImport(java.lang.String name)
        Tests to see if the specified import exists.
        Parameters:
        name - A name identifier
        Returns:
        boolean
      • hasProtoImport

        public boolean hasProtoImport(java.lang.String name)
      • getProtoImport

        public Proto getProtoImport(java.lang.String name)
      • addImport

        public void addImport(java.lang.Class cls)
        Adds an import for the specified Class.
        Parameters:
        cls - The instance of the Class which represents the imported class.
      • addImport

        public void addImport(Proto proto)
      • addImport

        public void addImport(java.lang.String name,
                     java.lang.Class cls)
        Adds an import for a specified Class using an alias. For example:
        
         parserContext.addImport("sys", System.class);
         
        ... doing this would allow an MVEL script to be written as such:
        
         sys.currentTimeMillis();
         
        Parameters:
        name - The alias to use
        cls - The instance of the Class which represents the imported class.
      • addImport

        public void addImport(java.lang.String name,
                     java.lang.reflect.Method method)
        Adds an import for a specified Method representing a static method import using an alias. For example:
        
         parserContext.addImport("time", MVEL.getStaticMethod(System.class, "currentTimeMillis", new Class[0]));
         
        ... doing this allows the System.currentTimeMillis() method to be executed in a script simply by writing time().
        Parameters:
        name - The alias to use
        method - The instance of Method which represents the static import.
      • initializeTables

        public void initializeTables()
        Initializes internal Maps. Called by the compiler.
      • addVariable

        public void addVariable(java.lang.String name,
                       java.lang.Class type,
                       boolean failIfNewAssignment)
      • addVariable

        public void addVariable(java.lang.String name,
                       java.lang.Class type)
      • addVariables

        public void addVariables(java.util.Map<java.lang.String,java.lang.Class> variables)
      • addInput

        public void addInput(java.lang.String name,
                    java.lang.Class type)
      • addInput

        public void addInput(java.lang.String name,
                    java.lang.Class type,
                    java.lang.Class[] typeParameters)
      • addInputs

        public void addInputs(java.util.Map<java.lang.String,java.lang.Class> inputs)
      • processTables

        public void processTables()
      • getInputs

        public java.util.Map<java.lang.String,java.lang.Class> getInputs()
      • setInputs

        public void setInputs(java.util.Map<java.lang.String,java.lang.Class> inputs)
      • getErrorList

        public java.util.List<ErrorDetail> getErrorList()
      • setErrorList

        public void setErrorList(java.util.List<ErrorDetail> errorList)
      • addError

        public void addError(ErrorDetail errorDetail)
      • isFatalError

        public boolean isFatalError()
      • setFatalError

        public void setFatalError(boolean fatalError)
      • isStrictTypeEnforcement

        public boolean isStrictTypeEnforcement()
      • setStrictTypeEnforcement

        public void setStrictTypeEnforcement(boolean strictTypeEnforcement)
        Enables strict type enforcement -
        Parameters:
        strictTypeEnforcement - -
      • isStrongTyping

        public boolean isStrongTyping()
      • setStrongTyping

        public void setStrongTyping(boolean strongTyping)
        Enables strong type enforcement.
        Parameters:
        strongTyping -
      • isRetainParserState

        public boolean isRetainParserState()
      • setRetainParserState

        public void setRetainParserState(boolean retainParserState)
      • getRootParser

        public java.lang.Object getRootParser()
      • setRootParser

        public void setRootParser(java.lang.Object rootParser)
      • getSourceFile

        public java.lang.String getSourceFile()
      • setSourceFile

        public void setSourceFile(java.lang.String sourceFile)
      • getInterceptors

        public java.util.Map<java.lang.String,Interceptor> getInterceptors()
      • setInterceptors

        public void setInterceptors(java.util.Map<java.lang.String,Interceptor> interceptors)
      • getImports

        public java.util.Map<java.lang.String,java.lang.Object> getImports()
      • setImports

        public void setImports(java.util.Map<java.lang.String,java.lang.Object> imports)
      • getVariables

        public java.util.HashMap<java.lang.String,java.lang.Class> getVariables()
      • setVariables

        public void setVariables(java.util.HashMap<java.lang.String,java.lang.Class> variables)
      • isCompiled

        public boolean isCompiled()
      • setCompiled

        public void setCompiled(boolean compiled)
      • isDebugSymbols

        public boolean isDebugSymbols()
      • setDebugSymbols

        public void setDebugSymbols(boolean debugSymbols)
      • isKnownLine

        public boolean isKnownLine(java.lang.String sourceName,
                          int lineNumber)
      • addKnownLine

        public void addKnownLine(java.lang.String sourceName,
                        int lineNumber)
      • addKnownLine

        public void addKnownLine(int lineNumber)
      • getLastLineLabel

        public LineLabel getLastLineLabel()
      • hasImports

        public boolean hasImports()
      • declareFunction

        public void declareFunction(Function function)
      • getFunction

        public Function getFunction(java.lang.String name)
      • getFunctions

        public java.util.Map getFunctions()
      • hasFunction

        public boolean hasFunction(java.lang.String name)
      • hasFunction

        public boolean hasFunction()
      • addTypeParameters

        public void addTypeParameters(java.lang.String name,
                             java.lang.Class type)
      • addTypeParameters

        public void addTypeParameters(java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Class>> typeParameters)
      • getTypeParameters

        public java.util.Map<java.lang.String,java.lang.Class> getTypeParameters(java.lang.String name)
      • getTypeParametersAsArray

        public java.lang.reflect.Type[] getTypeParametersAsArray(java.lang.String name)
      • isBlockSymbols

        public boolean isBlockSymbols()
      • setBlockSymbols

        public void setBlockSymbols(boolean blockSymbols)
      • isExecutableCodeReached

        public boolean isExecutableCodeReached()
      • setExecutableCodeReached

        public void setExecutableCodeReached(boolean executableCodeReached)
      • getIndexedVariables

        public java.util.ArrayList<java.lang.String> getIndexedVariables()
      • addIndexedVariables

        public void addIndexedVariables(java.lang.String[] variables)
      • addIndexedVariable

        public void addIndexedVariable(java.lang.String variable)
      • addIndexedVariables

        public void addIndexedVariables(java.util.Collection<java.lang.String> variables)
      • variableIndexOf

        public int variableIndexOf(java.lang.String name)
      • hasIndexedVariables

        public boolean hasIndexedVariables()
      • isIndexAllocation

        public boolean isIndexAllocation()
      • setIndexAllocation

        public void setIndexAllocation(boolean indexAllocation)
      • getLastTypeParameters

        public java.lang.reflect.Type[] getLastTypeParameters()
      • setLastTypeParameters

        public void setLastTypeParameters(java.lang.reflect.Type[] lastTypeParameters)
      • isAllowBootstrapBypass

        public boolean isAllowBootstrapBypass()
      • setAllowBootstrapBypass

        public void setAllowBootstrapBypass(boolean allowBootstrapBypass)
      • getIndexedVarNames

        public java.lang.String[] getIndexedVarNames()
      • withInput

        public ParserContext withInput(java.lang.String name,
                              java.lang.Class type)
      • withInputs

        public ParserContext withInputs(java.util.Map<java.lang.String,java.lang.Class> inputs)
      • withTypeParameter

        public ParserContext withTypeParameter(java.lang.String name,
                                      java.lang.Class type)
      • withTypeParameters

        public ParserContext withTypeParameters(java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Class>> typeParameters)
      • withImport

        public ParserContext withImport(java.lang.Class clazz)
      • withIndexedVars

        public ParserContext withIndexedVars(java.lang.String[] varNames)

Copyright © 2012. All Rights Reserved.