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

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

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

import com.google.common.base.Predicate;
import com.netflix.infix.PathValueEventFilter;
import com.netflix.infix.RegexValuePredicate;

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

import static com.netflix.infix.lang.infix.antlr.TreeNodeUtil.getXPath;

public class MatchesTreeNode extends PredicateBaseTreeNode implements PredicateTranslatable {

  @Override
  public Predicate<Object> translate() {
    String xpath = getXPath(getChild(0));
     
    StringTreeNode valueNode = (StringTreeNode)getChild(1);
     
      return new PathValueEventFilter(xpath, new RegexValuePredicate(valueNode.getValue(), RegexValuePredicate.MatchPolicy.FULL));
   
  }

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

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

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

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

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.