Package org.hpccsystems.commons.ecl
Class FileFilter
- java.lang.Object
-
- org.hpccsystems.commons.ecl.FileFilter
-
- All Implemented Interfaces:
Serializable
public class FileFilter extends Object implements Serializable
A filter to select records from a file or key. The filter is conjunction of field filters with each field having a list of one or more value ranges. filter : setfilter | wildfilter ; setfilter : field equals set wildfilter : field wildcard set : setfragment (, setfragment)* setfragment : ( upperinclusive | upperexclusive) setvalue ( lowerinclusive | lowerexclusive) //ignore the single paren notation for now setvalue : INTEGER_NUM | QUOTEDUTF8STR QUOTEDUTF8STR : squote utf8string squote; upperinclusive : '[' ; lowerinclusive : ']' ; upperexclusive : '(' ; lowerexclusive : ')' ; wildcard : '*' ; equals : '=' ; range : ':' ; squote : '\'' ; field : ( 'A'..'Z' | 'a'..'z') (( 'A'..'Z' | 'a'..'z') | UNDERSCORE | ETC | INTEGER_NUM )* INTEGER_NUM)?; INTEGER_NUM : ( '1'..'9')( '0'..'9')*;- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static longserialVersionUID
-
Constructor Summary
Constructors Constructor Description FileFilter()A file filter expression to select records, using a string.FileFilter(String sqlfilter)Creates a FileFilter based on an SQL filter for example"(table.field2 <= 'a' AND table.field2 != 4) OR table.field2 != 5 AND field3 In ('Germany', 'France', 'UK')"FileFilter(FieldFilter filter)Creates a FileFilter based on the provided fieldfilter.FileFilter(FileFilter filter)Creates a FileFilter based on the provided filefilter's fieldfilter(s).FileFilter(SQLFilter sqlfilter)Creates a FileFilter based on an SQL filter object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description FileFilterandFilter(FieldFilter fieldfilter)The fieldfilter(s) expression is ANDed to this filefilter expression.FileFilterandFilter(FileFilter filefilter)The filefilter expression is ANDed to this filefilter expression.static FileFilterConvertToHPCCFileFilter(SQLExpression sqlfilter)Convert to HPCC file filter.List<FileFilter>getAndFileFilters()FieldFiltergetFieldFilter(int i)Fetches the ith filter clause in this filefilter.intgetFieldFiltersCount()Reports the number of filter clauses in this filefilter.booleanisEmpty()Is this filter empty?.static voidmain(String[] args)The main method.static FileFilternullFilter()A null filter which selects all records.FileFilterorFilter(FieldFilter fieldfilter)The fieldfilter expression is ORed to this filefilter expression (must target the same field).FileFilterorFilter(FileFilter filefilter)The filefilter expression is ORed to this filefilter expression.StringtoJson()JSon string representation of an array of filefilters.
-
-
-
Field Detail
-
serialVersionUID
public static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FileFilter
public FileFilter()
A file filter expression to select records, using a string. An expression can be comprised of multiple comma delimited clauses An empty filter, selects all records
-
FileFilter
public FileFilter(String sqlfilter) throws Exception
Creates a FileFilter based on an SQL filter for example"(table.field2 <= 'a' AND table.field2 != 4) OR table.field2 != 5 AND field3 In ('Germany', 'France', 'UK')"- Parameters:
sqlfilter- the sqlfilter- Throws:
Exception- the exception
-
FileFilter
public FileFilter(SQLFilter sqlfilter) throws Exception
Creates a FileFilter based on an SQL filter object.- Parameters:
sqlfilter- the sqlfilter- Throws:
Exception- the exception
-
FileFilter
public FileFilter(FieldFilter filter)
Creates a FileFilter based on the provided fieldfilter.- Parameters:
filter- the filter
-
FileFilter
public FileFilter(FileFilter filter)
Creates a FileFilter based on the provided filefilter's fieldfilter(s).- Parameters:
filter- the filter
-
-
Method Detail
-
nullFilter
public static FileFilter nullFilter()
A null filter which selects all records.- Returns:
- an empty filter
-
isEmpty
public boolean isEmpty()
Is this filter empty?.- Returns:
- true when empty
-
andFilter
public FileFilter andFilter(FileFilter filefilter) throws Exception
The filefilter expression is ANDed to this filefilter expression.- Parameters:
filefilter- the filefilter- Returns:
- the file filter
- Throws:
Exception- the exception
-
andFilter
public FileFilter andFilter(FieldFilter fieldfilter) throws Exception
The fieldfilter(s) expression is ANDed to this filefilter expression.- Parameters:
fieldfilter- the fieldfilter- Returns:
- the file filter
- Throws:
Exception- the exception
-
orFilter
public FileFilter orFilter(FileFilter filefilter) throws Exception
The filefilter expression is ORed to this filefilter expression.- Parameters:
filefilter- the filefilter- Returns:
- the file filter
- Throws:
Exception- the exception
-
orFilter
public FileFilter orFilter(FieldFilter fieldfilter) throws Exception
The fieldfilter expression is ORed to this filefilter expression (must target the same field).- Parameters:
fieldfilter- the fieldfilter- Returns:
- the file filter
- Throws:
Exception- the exception
-
getFieldFiltersCount
public int getFieldFiltersCount()
Reports the number of filter clauses in this filefilter.- Returns:
- the field filters count
-
getFieldFilter
public FieldFilter getFieldFilter(int i)
Fetches the ith filter clause in this filefilter.- Parameters:
i- the i- Returns:
- the field filter
-
getAndFileFilters
public List<FileFilter> getAndFileFilters()
-
toJson
public String toJson()
JSon string representation of an array of filefilters.- Returns:
- the string
-
ConvertToHPCCFileFilter
public static FileFilter ConvertToHPCCFileFilter(SQLExpression sqlfilter) throws Exception
Convert to HPCC file filter.- Parameters:
sqlfilter- the sqlfilter- Returns:
- the file filter
- Throws:
Exception- the exception
-
main
public static void main(String[] args)
The main method.- Parameters:
args- the arguments
-
-