Interface Expander

All Known Implementing Classes:
DefaultExpander

public interface Expander
Expanders are extension points for expanding expressions in DRL at parse time. This is just-in-time translation, or macro expansion, or whatever you want. The important thing is that it happens at the last possible moment, so any errors in expansion are included in the parsers errors. Just-in-time expansions may include complex pre-compilers, or just macros, and everything in between. Expanders should ideally not make presumptions on any embedded semantic language. For instance, java aware pre processing should be done in drools-java semantic module, not in the parser itself. Expanders should be reusable across semantic languages.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Add the new mapping to this expander.
    Expands (process) the expression Just-In-Time for the parser.
    expand(String source)
    Expands (process) the expression Just-In-Time for the parser.
    Returns the list of errors from the last expansion made
    boolean
    Returns true in case the last expansion had any errors
  • Method Details

    • expand

      String expand(Reader drl) throws IOException
      Expands (process) the expression Just-In-Time for the parser. If the source is not meant to be expanded, or if no appropriate match was found for expansion, it will echo back the same expression.
      Parameters:
      drl - the source code to be pre-processed
      Returns:
      source code after running pre-processors
      Throws:
      IOException
    • expand

      String expand(String source)
      Expands (process) the expression Just-In-Time for the parser. If the source is not meant to be expanded, or if no appropriate match was found for expansion, it will echo back the same expression.
      Parameters:
      source - the source code to be expanded
      Returns:
      source code after running pre-processors
    • addDSLMapping

      void addDSLMapping(DSLMapping mapping)
      Add the new mapping to this expander.
      Parameters:
      mapping -
    • getErrors

      List<ExpanderException> getErrors()
      Returns the list of errors from the last expansion made
      Returns:
      A list of ExpanderException
    • hasErrors

      boolean hasErrors()
      Returns true in case the last expansion had any errors
      Returns: