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

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void addDSLMapping​(DSLMapping mapping)
      Add the new mapping to this expander.
      java.lang.String expand​(java.io.Reader drl)
      Expands (process) the expression Just-In-Time for the parser.
      java.lang.String expand​(java.lang.String source)
      Expands (process) the expression Just-In-Time for the parser.
      java.util.List<ExpanderException> getErrors()
      Returns the list of errors from the last expansion made
      boolean hasErrors()
      Returns true in case the last expansion had any errors
    • Method Detail

      • expand

        java.lang.String expand​(java.io.Reader drl)
                         throws java.io.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:
        java.io.IOException
      • expand

        java.lang.String expand​(java.lang.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

        java.util.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: