Package org.mvel2

Class SandboxedParserContext

    • Method Detail

      • addImport

        public void addImport​(Class cls)
        Description copied from class: ParserContext
        Adds an import for the specified Class.
        Overrides:
        addImport in class ParserContext
        Parameters:
        cls - The instance of the Class which represents the imported class.
      • addImport

        public void addImport​(String name,
                              Class cls)
        Description copied from class: ParserContext
        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();
         
        Overrides:
        addImport in class ParserContext
        Parameters:
        name - The alias to use
        cls - The instance of the Class which represents the imported class.
      • addImport

        public void addImport​(String name,
                              Method method)
        Description copied from class: ParserContext
        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().
        Overrides:
        addImport in class ParserContext
        Parameters:
        name - The alias to use
        method - The instance of Method which represents the static import.