Package hu.sztaki.ilab.longneck.process.constraint

Examples of hu.sztaki.ilab.longneck.process.constraint.CheckResult


        this.ifObj = ifObj;
    }

    @Override
    public void beforeChildren(KernelState kernelState, Record record) throws RedirectException {
        CheckResult result = ifObj.getCondition().check(
                record, kernelState.getLastExecutionFrame().getVariables());

        if (result.isPassed() && ifObj.getThenBranch() != null) {
            throw new RedirectException(ifObj.getThenBranch().getFrameAddress(), false);
        } else if (!result.isPassed() && ifObj.getElseBranch() != null) {
            throw new RedirectException(ifObj.getElseBranch().getFrameAddress(), false);
        } else {
            throw new RedirectException(FrameAddress.RETURN, false);
        }
    }
View Full Code Here


            // Increase case counter
            ++lastCase;
           
            if (lastCase >= switchObj.getCases().size()) {
                throw new CheckError(
                        new CheckResult(switchObj, false, null, null, "All cases failed.", errors));
            }
        }
View Full Code Here

           
            // Match against pattern and assign matched parts
            Matcher m = pattern.matcher(value);
            if (! m.find()) {
                throw new CheckError(
                        new CheckResult(this, false, fieldName, value,
                        String.format("Regular expression: '%1$s'", regexp)));
            }
           
            // Populate variable scope with matched parts
            MatchResult res = m.toMatchResult();
View Full Code Here

           
            for (String fieldName : applyTo) {
                BlockUtils.setValue(fieldName, outValue, record, parentScope);
            }
        } catch (IllegalArgumentException ex) {
            throw new CheckError(new CheckResult(this, false, from, dateValue,
                    String.format("Field '%1$s' content '%2$s' does not match date pattern '%3$s'.",
                    from, dateValue, fromPattern)));
        } catch (UnsupportedOperationException ex) {
            log.error("joda-time pattern-based parsing is unsupported.", ex);
        }
View Full Code Here

        VariableSpace scope = new VariableSpace();
        scope.setVariable("a1", "aaa");
        Record r = new RecordImpl();
       
        c.check(r, scope);
        CheckResult res = c.check(r, scope);
        Assert.assertTrue(res.isPassed());
    }
View Full Code Here

        c.setApplyTo(Arrays.asList(new String[] { "$a1" }));
       
        VariableSpace scope = new VariableSpace();
        Record r = new RecordImpl();

        CheckResult res = c.check(r, scope);
        Assert.assertFalse(res.isPassed());
    }
View Full Code Here

    /** The contained constraints. */
    private AndOperator constraints = new AndOperator();
   
    @Override
    public void apply(Record record, VariableSpace parentScope) throws CheckError {
        CheckResult res;
        if (checkedField == null || !BlockUtils.exists(checkedField, record, parentScope)) {
            res = new CheckResult(constraints.check(record, parentScope), this, summary);
        } else {
            CheckResult andresult = constraints.check(record, parentScope);
            res = new CheckResult(this, andresult.isPassed(), checkedField, BlockUtils.getValue(checkedField, record, parentScope), summary, andresult.getCauses());
        }
        if (! res.isPassed()) {
            throw new CheckError(res);           
        }
    }
View Full Code Here

    /* The checked field, what we want to test in the check box.*/
    private String faildField;
   
    @Override
    public void apply(Record record, VariableSpace parentScope) throws FailException {
        record.addError(new CheckResult(this, false,
                faildField == null || !BlockUtils.exists(faildField, record, parentScope)?null:faildField,
                faildField == null? null:BlockUtils.getValue(faildField, record, parentScope),
                summary == null?"Intentional failure.":summary));
       
        throw new FailException(summary == null?"Intentional failure.":summary);
View Full Code Here

TOP

Related Classes of hu.sztaki.ilab.longneck.process.constraint.CheckResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.