Search in sources :

Example 6 with ConnectiveDescr

use of org.drools.drl.ast.descr.ConnectiveDescr in project drools by kiegroup.

the class RestrictionConnectiveHandler method end.

public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    final Element element = parser.endElementBuilder();
    Object op = parser.getParent();
    ConnectiveDescr c = (ConnectiveDescr) parser.getCurrent();
    if (op instanceof PatternDescr) {
        StringBuilder sb = new StringBuilder();
        c.buildExpression(sb);
        ExprConstraintDescr expr = new ExprConstraintDescr();
        expr.setExpression(sb.toString());
        final PatternDescr patternDescr = (PatternDescr) op;
        patternDescr.addConstraint(expr);
    } else {
        ConnectiveDescr p = (ConnectiveDescr) op;
        p.add(c);
    }
    return c;
}
Also used : PatternDescr(org.drools.drl.ast.descr.PatternDescr) Element(org.w3c.dom.Element) ConnectiveDescr(org.drools.drl.ast.descr.ConnectiveDescr) RestrictionConnectiveDescr(org.drools.drl.ast.descr.RestrictionConnectiveDescr) ExprConstraintDescr(org.drools.drl.ast.descr.ExprConstraintDescr)

Example 7 with ConnectiveDescr

use of org.drools.drl.ast.descr.ConnectiveDescr in project drools by kiegroup.

the class FieldConstraintHandler method start.

public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
    parser.startElementBuilder(localName, attrs);
    final String fieldName = attrs.getValue("field-name");
    emptyAttributeCheck(localName, "field-name", fieldName, parser);
    final ConnectiveDescr connective = new ConnectiveDescr(RestrictionConnectiveType.AND);
    connective.setParen(false);
    connective.setPrefix(fieldName);
    return connective;
}
Also used : ConnectiveDescr(org.drools.drl.ast.descr.ConnectiveDescr)

Example 8 with ConnectiveDescr

use of org.drools.drl.ast.descr.ConnectiveDescr in project drools by kiegroup.

the class VariableRestrictionsHandler method end.

public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    final Element element = parser.endElementBuilder();
    ConnectiveDescr c = (ConnectiveDescr) parser.getParent();
    String s = (String) parser.getCurrent();
    c.add(s);
    return null;
}
Also used : Element(org.w3c.dom.Element) ConnectiveDescr(org.drools.drl.ast.descr.ConnectiveDescr)

Aggregations

ConnectiveDescr (org.drools.drl.ast.descr.ConnectiveDescr)8 Element (org.w3c.dom.Element)6 ExprConstraintDescr (org.drools.drl.ast.descr.ExprConstraintDescr)2 PatternDescr (org.drools.drl.ast.descr.PatternDescr)2 RestrictionConnectiveDescr (org.drools.drl.ast.descr.RestrictionConnectiveDescr)1 Test (org.junit.Test)1