Package com.netflix.infix.lang.infix.antlr

Source Code of com.netflix.infix.lang.infix.antlr.BetweenTimeMillisTreeNode

package com.netflix.infix.lang.infix.antlr;

import com.google.common.base.Predicate;
import com.netflix.infix.Predicates;
import com.netflix.infix.PathValueEventFilter;
import com.netflix.infix.TimeMillisValuePredicate;

import org.antlr.runtime.Token;
import org.antlr.runtime.tree.Tree;

public class BetweenTimeMillisTreeNode extends PredicateBaseTreeNode implements PredicateTranslatable {

  @Override
  public Predicate<Object> translate() {
    ValueTreeNode xpathNode = (ValueTreeNode)getChild(0);
    String xpath = (String)xpathNode.getValue();
   
    TimeMillisValueTreeNode lowerBoundNode = (TimeMillisValueTreeNode)getChild(1);
   
    TimeMillisValueTreeNode upperBoundNode = (TimeMillisValueTreeNode)getChild(2);
   
    return Predicates.and(
                new PathValueEventFilter(
                        xpath,
                        new TimeMillisValuePredicate(lowerBoundNode.getValueFormat(), lowerBoundNode.getValue(), ">=")),
                new PathValueEventFilter(
                        xpath,
                        new TimeMillisValuePredicate(upperBoundNode.getValueFormat(), upperBoundNode.getValue(), "<"))
        );
   
  }

  public BetweenTimeMillisTreeNode(Token t) {
    super(t);
  }

  public BetweenTimeMillisTreeNode(BetweenTimeMillisTreeNode node) {
    super(node);
  }

  public Tree dupNode() {
    return new BetweenTimeMillisTreeNode(this);
  }
}
TOP

Related Classes of com.netflix.infix.lang.infix.antlr.BetweenTimeMillisTreeNode

TOP
Copyright © 2018 www.massapi.com. 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.