Class 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
    • 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
      • 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