use of org.apache.nifi.record.path.filter.MatchesRegex in project nifi by apache.
the class RecordPathCompiler method createFunctionFilter.
private static RecordPathFilter createFunctionFilter(final Tree functionTree, final boolean absolute) {
final String functionName = functionTree.getChild(0).getText();
final Tree argumentListTree = functionTree.getChild(1);
switch(functionName) {
case "contains":
{
final RecordPathSegment[] args = getArgPaths(argumentListTree, 2, functionName, absolute);
return new Contains(args[0], args[1]);
}
case "matchesRegex":
{
final RecordPathSegment[] args = getArgPaths(argumentListTree, 2, functionName, absolute);
return new MatchesRegex(args[0], args[1]);
}
case "containsRegex":
{
final RecordPathSegment[] args = getArgPaths(argumentListTree, 2, functionName, absolute);
return new ContainsRegex(args[0], args[1]);
}
case "startsWith":
{
final RecordPathSegment[] args = getArgPaths(argumentListTree, 2, functionName, absolute);
return new StartsWith(args[0], args[1]);
}
case "endsWith":
{
final RecordPathSegment[] args = getArgPaths(argumentListTree, 2, functionName, absolute);
return new EndsWith(args[0], args[1]);
}
case "isEmpty":
{
final RecordPathSegment[] args = getArgPaths(argumentListTree, 1, functionName, absolute);
return new IsEmpty(args[0]);
}
case "isBlank":
{
final RecordPathSegment[] args = getArgPaths(argumentListTree, 1, functionName, absolute);
return new IsBlank(args[0]);
}
case "not":
{
final int numArgs = argumentListTree.getChildCount();
if (numArgs != 1) {
throw new RecordPathException("Invalid number of arguments: " + functionName + " function takes 1 argument but got " + numArgs);
}
final Tree childTree = argumentListTree.getChild(0);
final RecordPathFilter childFilter = createFilter(childTree, null, absolute);
return new NotFilter(childFilter);
}
}
throw new RecordPathException("Invalid function name: " + functionName);
}
Aggregations