Search in sources :

Example 1 with DotEvaluator

use of org.apache.nifi.hl7.query.evaluator.message.DotEvaluator in project nifi by apache.

the class HL7Query method buildReferenceEvaluator.

private Evaluator<?> buildReferenceEvaluator(final Tree tree) {
    switch(tree.getType()) {
        case MESSAGE:
            return new MessageEvaluator();
        case SEGMENT_NAME:
            return new SegmentEvaluator(new StringLiteralEvaluator(tree.getText()));
        case IDENTIFIER:
            return new DeclaredReferenceEvaluator(new StringLiteralEvaluator(tree.getText()));
        case DOT:
            final Tree firstChild = tree.getChild(0);
            final Tree secondChild = tree.getChild(1);
            return new DotEvaluator(buildReferenceEvaluator(firstChild), buildIntegerEvaluator(secondChild));
        case STRING_LITERAL:
            return new StringLiteralEvaluator(tree.getText());
        case NUMBER:
            return new IntegerLiteralEvaluator(Integer.parseInt(tree.getText()));
        default:
            throw new HL7QueryParsingException("Failed to build evaluator for " + tree.getText());
    }
}
Also used : StringLiteralEvaluator(org.apache.nifi.hl7.query.evaluator.literal.StringLiteralEvaluator) DotEvaluator(org.apache.nifi.hl7.query.evaluator.message.DotEvaluator) MessageEvaluator(org.apache.nifi.hl7.query.evaluator.message.MessageEvaluator) HL7QueryParsingException(org.apache.nifi.hl7.query.exception.HL7QueryParsingException) DeclaredReferenceEvaluator(org.apache.nifi.hl7.query.evaluator.message.DeclaredReferenceEvaluator) Tree(org.antlr.runtime.tree.Tree) SegmentEvaluator(org.apache.nifi.hl7.query.evaluator.message.SegmentEvaluator) IntegerLiteralEvaluator(org.apache.nifi.hl7.query.evaluator.literal.IntegerLiteralEvaluator)

Aggregations

Tree (org.antlr.runtime.tree.Tree)1 IntegerLiteralEvaluator (org.apache.nifi.hl7.query.evaluator.literal.IntegerLiteralEvaluator)1 StringLiteralEvaluator (org.apache.nifi.hl7.query.evaluator.literal.StringLiteralEvaluator)1 DeclaredReferenceEvaluator (org.apache.nifi.hl7.query.evaluator.message.DeclaredReferenceEvaluator)1 DotEvaluator (org.apache.nifi.hl7.query.evaluator.message.DotEvaluator)1 MessageEvaluator (org.apache.nifi.hl7.query.evaluator.message.MessageEvaluator)1 SegmentEvaluator (org.apache.nifi.hl7.query.evaluator.message.SegmentEvaluator)1 HL7QueryParsingException (org.apache.nifi.hl7.query.exception.HL7QueryParsingException)1