Search in sources :

Example 1 with DescrResource

use of org.drools.core.io.impl.DescrResource in project drools by kiegroup.

the class KnowledgeBuilderImpl method drlToPackageDescr.

PackageDescr drlToPackageDescr(Resource resource) throws DroolsParserException, IOException {
    PackageDescr pkg;
    boolean hasErrors = false;
    if (resource instanceof DescrResource) {
        pkg = (PackageDescr) ((DescrResource) resource).getDescr();
    } else {
        final DrlParser parser = new DrlParser(configuration.getLanguageLevel());
        pkg = parser.parse(resource);
        this.results.addAll(parser.getErrors());
        if (pkg == null) {
            addBuilderResult(new ParserError(resource, "Parser returned a null Package", 0, 0));
        }
        hasErrors = parser.hasErrors();
    }
    if (pkg != null) {
        pkg.setResource(resource);
    }
    return hasErrors ? null : pkg;
}
Also used : ParserError(org.drools.compiler.compiler.ParserError) DescrResource(org.drools.core.io.impl.DescrResource) DrlParser(org.drools.compiler.compiler.DrlParser) PackageDescr(org.drools.compiler.lang.descr.PackageDescr) CompositePackageDescr(org.drools.compiler.lang.descr.CompositePackageDescr)

Aggregations

DrlParser (org.drools.compiler.compiler.DrlParser)1 ParserError (org.drools.compiler.compiler.ParserError)1 CompositePackageDescr (org.drools.compiler.lang.descr.CompositePackageDescr)1 PackageDescr (org.drools.compiler.lang.descr.PackageDescr)1 DescrResource (org.drools.core.io.impl.DescrResource)1