/** * Parse and build a rule package from a DRL source with a domain specific * language. * * @param source * As Text. * @param dsl * @return * @throws DroolsParserException */ public PackageDescr parse(boolean isEditor, final String source, final Reader dsl) throws DroolsParserException { DefaultExpanderResolver resolver = getDefaultResolver( dsl ); final Expander expander = resolver.get( "*", null ); final String expanded = expander.expand( source ); if ( expander.hasErrors() ) { this.results.addAll( expander.getErrors() ); } return this.parse( isEditor, expanded ); }
/** * This will expand the DRL using the given expander resolver. useful for * debugging. * * @param source - * the source which use a DSL * @param resolver - * the DSL expander resolver itself. * @throws DroolsParserException * If unable to expand in any way. */ public String getExpandedDRL(final String source, final DefaultExpanderResolver resolver) throws DroolsParserException { final Expander expander = resolver.get( "*", null ); final String expanded = expander.expand( source ); if ( expander.hasErrors() ) { String err = ""; for ( ExpanderException ex : expander.getErrors() ) { err = err + "\n Line:[" + ex.getLine() + "] " + ex.getMessage(); } throw new DroolsParserException( err ); } return expanded; }