Package net.hydromatic.filtex.ast
Class Asts
java.lang.Object
net.hydromatic.filtex.ast.Asts
Utilities for AST nodes.
-
Method Summary
Modifier and TypeMethodDescriptionstatic AstNodeEnsures that every node has a unique id.static StringConverts filter types to matches (advanced).static StringconvertTypeToOption(boolean is, String type) Converts a type to an option.static StringdateFilterToString(AstNode root, TypeFamily typeFamily) Converts the AST to an array of FilterItems and then converts each item into its expression representation.static @Nullable AstNoderemoveNode(AstNode root, Integer nodeId) Removes node from the AST.static voidWalks over a tree, applying a consumer to each node.treeToList(AstNode root) Converts a FilterAST to a list of FilterASTNodes using in order traversal (left, node, right)static StringGiven an AST and a nodeToString conversion function for that particular type of filter, it converts the AST to a string expression representation.
-
Method Details
-
treeToList
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
Walks over a tree, applying a consumer to each node. -
applyId
Ensures that every node has a unique id. -
removeNode
Removes node from the AST. -
convertTypeToOption
Converts a type to an option. -
convertTypeToMatchesAdvancedOption
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).
-
dateFilterToString
Converts the AST to an array of FilterItems and then converts each item into its expression representation.
-