Class Asts

java.lang.Object
net.hydromatic.filtex.ast.Asts

public class Asts extends Object
Utilities for AST nodes.
  • Method Details

    • treeToList

      public static List<AstNode> treeToList(AstNode root)
      Converts a FilterAST to a list of FilterASTNodes using in order traversal (left, node, right)
      
          (root(1))      ->  [0,1,2,3,4]
          /      \
       left(0)   right(3)
                 /     \
            left(2)     right(4)
       

      See tree_to_list.ts

    • treeToString

      public static String treeToString(AstNode root, Function<AstNode,String> f, Predicate<AstNode> predicate)
      Given an AST and a nodeToString conversion function for that particular type of filter, it converts the AST to a string expression representation.

      See tree_to_string.ts.

    • traverse

      public static void traverse(AstNode root, Consumer<AstNode> consumer)
      Walks over a tree, applying a consumer to each node.
    • applyId

      public static AstNode applyId(AstNode root)
      Ensures that every node has a unique id.
    • removeNode

      public static @Nullable AstNode removeNode(AstNode root, Integer nodeId)
      Removes node from the AST.
    • convertTypeToOption

      public static String convertTypeToOption(boolean is, String type)
      Converts a type to an option.

      See convert_type_to_option.ts.

    • convertTypeToMatchesAdvancedOption

      public static String convertTypeToMatchesAdvancedOption(String type)
      Converts filter types to matches (advanced).

      dateFilter 'day', type 'thisRange', and type 'pastAgo' need to be in the filter list, but we do not want it showing up in the advanced filter options therefore it should be converted to matches (advanced).

      See convert_type_to_matches_advanced_option.ts.

    • dateFilterToString

      public static String dateFilterToString(AstNode root, TypeFamily typeFamily)
      Converts the AST to an array of FilterItems and then converts each item into its expression representation.