Package net.hydromatic.filtex
Class Filtex
java.lang.Object
net.hydromatic.filtex.Filtex
Filter expressions.
Based on the @looker/filter-expressions TypeScript API.
-
Method Summary
Modifier and TypeMethodDescriptionstatic TypeFamilygetExpressionType(boolean numeric, String type) Returns a valid filter expression type when given the type and field properties of a dashboard filter.static voidConverts an AST to a single item for use in a token (i.e.static AstNodeparseFilterExpression(TypeFamily typeFamily, String expression) Returns an Abstract Syntax Tree (AST) that logically represents the filter expression string passed in, as well as the filter expression type (and optional user attributes).static Stringsummary(TypeFamily typeFamily, String s, Locale locale) Returns a localized, human-readable summary of a filter expression, given the expression's type, the expression itself, and the user attributes and field, if applicable.static voidReturns an object with utility functions and values pertaining to a given expression type: toString: a function that converts an AST into an expression of the given type subTypes: an array containing the sub-types of the expression type, for example ">", "<", "=", "between" for a number expression type
-
Method Details
-
getExpressionType
Returns a valid filter expression type when given the type and field properties of a dashboard filter.For example,
getExpressionType(true, "field_filter")returns
TypeFamily.NUMBER. -
parseFilterExpression
Returns an Abstract Syntax Tree (AST) that logically represents the filter expression string passed in, as well as the filter expression type (and optional user attributes).For example,
parseFilterExpression(TypeFamily.NUMBER, "[0,20],>30")returns
{ type: ',', left: { type: 'between', bounds: '[]', low: 0, high: 20, is: true, }, right: { is: true, type: '>', value: [30], }, } -
summary
Returns a localized, human-readable summary of a filter expression, given the expression's type, the expression itself, and the user attributes and field, if applicable.For example,
summary(TypeFamily.NUMBER, "[0,20],>30", Locale.EN_US)returns
"is in range [0, 20] or is > 30". -
typeToGrammar
public static void typeToGrammar()Returns an object with utility functions and values pertaining to a given expression type:- toString: a function that converts an AST into an expression of the given type
- subTypes: an array containing the sub-types of the expression type,
for example "
>", "<", "=", "between" for a number expression type
-
getFilterTokenItem
public static void getFilterTokenItem()Converts an AST to a single item for use in a token (i.e. not advanced) filter.
-