Menu

Built-in File Filters

Built-in File Filters

A file filter is responsible to filtering a list of files provided by a file catalogue or a file enumerator. It may either filter passed input files out, but it also may add new files.

The CodeXCavator core engine provides the following built-in file catalogue enumerators:

WildCardFileFilter

The WildCardFileFilter is responsible for either passing thru or filtering out all files, which match a given set of wild card patterns.
The set of wild card patterns can be defined by providing a configuration containing the patterns.

  • Use the <filter></filter> tag with the Type attribute set to "WildCardFileFilter" in order to use it. You have to put the <filter></filter> tag below a , a <catalogue></catalogue>, a <directory></directory> or a <filter></filter> tag if the filter supports nesting.
  • Use the Mode attribute in order to specify, whether the filter should include all files matching one of the patterns ( attribute value "Inclusive" ), or exclude them ( attribute value "Exclusive" ).
  • Provide a <configuration> tag below the <filter> tag, in order to specify the filter configuration. Put a <patterns></patterns> tag below the <configuration></configuration> tag, in order to provide the list of patterns, and put as many <pattern></pattern> tags below the <patterns></patterns> tag as needed. Each wild card pattern must be enclosed by a <pattern></pattern> / tag pair. </filter></configuration>
  • You can use the following wild cards:
    • * : Matches any number of arbitrary characters.
    • ? : Matches a single arbitrary character.
    • # : Matches a single digit.
    • [ charlist ] : Matches a single character contained in charlist.
    • [! charlist ] : Matches a single character not contained in charlist.

Example: Using and configuring the WildCardFileFilter

<Index Path="D:\Temp\TestIndex">
  <FileSources>
    <Catalogue Type="DirectoryFileEnumerator" 
               Path="D:\Programming\Projects\C#\CodeXCavator" 
               Recursive="True">
      <Filter Type="WildCardFileFilter">
        <Configuration>
          <Patterns>
            <Pattern>*.cs</Pattern>
            <Pattern>*.xaml</Pattern>
          </Patterns>
        </Configuration>
      </Filter>
    </Catalogue>
  </FileSource>
</Index>

RegExFileFilter

The RegExFileFilter is responsible for either passing thru or filtering out all files, which match a given set of regular expression patterns.
The set of regular expression patterns can be defined by providing a configuration containing the patterns.

  • Use the <filter></filter> tag with the Type attribute set to "RegExFileFilter" in order to use it. You have to put the <filter></filter> tag below a , a <catalogue></catalogue>, a <directory></directory> or a <filter></filter> tag if the filter supports nesting.
  • Use the Mode attribute in order to specify, whether the filter should include all files matching one of the patterns ( attribute value "Inclusive" ), or exclude them ( attribute value "Exclusive" ).
  • Provide a <configuration> tag below the <filter> tag, in order to specify the filter configuration. Put a <patterns></patterns> tag below the <configuration></configuration> tag, in order to provide the list of patterns, and put as many <pattern></pattern> tags below the <patterns></patterns> tag as needed. Each wild card pattern must be enclosed by a <pattern></pattern> / tag pair. </filter></configuration>
  • The filter uses the .NET regular expression syntax.

Example: Using and configuring the RegExFileFilter

<Index Path="D:\Temp\TestIndex">
  <FileSources>
    <Catalogue Type="DirectoryFileEnumerator" 
               Path="D:\Programming\Projects\C#\CodeXCavator" 
               Recursive="True">
      <Filter Type="RegExFileFilter">
        <Configuration>
          <Patterns>
            <Pattern>[a-z_]+\.cs</Pattern>
          </Patterns>
        </Configuration>
      </Filter>
    </Catalogue>
  </FileSource>
</Index>

AndFilter

The AndFilter is responsible for combining the results of two ore more child filters, which means that it supports child <filter></filter> tags. It performs an intersection of the file sets returned by each child file filter. This corresponds to a boolean AND, i.e. a file must pass through all child filters in order to be accepted.

  • Use the <filter></filter> tag with the Type attribute set to "AndFilter" in order to use it.
  • Put as many <filter></filter> elements below the AndFilter <filter></filter> element as needed.

Example: Using and configuring the AndFilter

<Index Path="D:\Temp\TestIndex">
  <FileSources>
    <Catalogue Type="DirectoryFileEnumerator" 
               Path="D:\Programming\Projects\C#\CodeXCavator" 
               Recursive="True">
      <Filter Type="AndFilter">
          <Filter Type="RegExFileFilter">
            <Configuration>
              <Patterns>
                <Pattern>[a-z_]+\.cs</Pattern>
              </Patterns>
            </Configuration>
          </Filter>
          <Filter Type="RegExFileFilter">
            <Configuration>
              <Patterns>
                <Pattern>[0-9_]+\.cs</Pattern>
              </Patterns>
            </Configuration>
          </Filter>
      </Filter>
    </Catalogue>
  </FileSource>
</Index>

OrFilter

The OrFilter is responsible for combining the results of two ore more child filters, which means that it supports child <filter></filter> tags. It performs a union of the file sets returned by each child file filter. This corresponds to a boolean OR, i.e. a file is accepted when it passes at least one of the child filters.

  • Use the <filter></filter> tag with the Type attribute set to "OrFilter" in order to use it.
  • Put as many <filter></filter> elements below the OrFilter <filter></filter> element as needed.

Example: Using and configuring the OrFilter

<Index Path="D:\Temp\TestIndex">
  <FileSources>
    <Catalogue Type="DirectoryFileEnumerator" 
               Path="D:\Programming\Projects\C#\CodeXCavator" 
               Recursive="True">
      <Filter Type="OrFilter">
          <Filter Type="RegExFileFilter">
            <Configuration>
              <Patterns>
                <Pattern>[a-z_]+\.cs</Pattern>
              </Patterns>
            </Configuration>
          </Filter>
          <Filter Type="RegExFileFilter">
            <Configuration>
              <Patterns>
                <Pattern>[0-9_]+\.cs</Pattern>
              </Patterns>
            </Configuration>
          </Filter>
      </Filter>
    </Catalogue>
  </FileSource>
</Index>

NotFilter

The NotFilter is responsible for inverting the results of a single child filter. It allows only a single child <filter></filter> tag. It performs a subtraction on the original set of files and the set of files returned by the child filter. This corresponds to boolean NOT, i.e. a file is accepted only, when it does not pass the child filter.

  • Use the <filter></filter> tag with the Type attribute set to "NotFilter" in order to use it.
  • Put a single <filter></filter> element below the NotFilter <filter></filter> element.

Example: Using and configuring the NotFilter

<Index Path="D:\Temp\TestIndex">
  <FileSources>
    <Catalogue Type="DirectoryFileEnumerator" 
               Path="D:\Programming\Projects\C#\CodeXCavator" 
               Recursive="True">
      <Filter Type="NotFilter">
          <Filter Type="RegExFileFilter">
            <Configuration>
              <Patterns>
                <Pattern>[0-9_]+\.cs</Pattern>
              </Patterns>
            </Configuration>
          </Filter>
      </Filter>
    </Catalogue>
  </FileSource>
</Index>

[Home][CodeXCavator Indexer][Built-in File Catalogue Enumerators][Built-in File Enumerators]


Related

Wiki: Built-in File Catalogue Enumerators
Wiki: Built-in File Enumerators
Wiki: CodeXCavator Indexer
Wiki: Home