org.entityfs.util.filter.entity
Class GrepFilter

java.lang.Object
  extended by org.entityfs.support.filter.AbstractConvenientFilter<EntityView>
      extended by org.entityfs.util.filter.entity.GrepFilter
All Implemented Interfaces:
Cloneable, EntityFilter, ConvenientFilter<EntityView>, Filter<EntityView>

public class GrepFilter
extends AbstractConvenientFilter<EntityView>
implements EntityFilter

This filter matches text files that contain text that matches the filter's regular expression pattern. It works somewhat like the Unix command grep, hence its name.

When this filter is run, it will search through the each filtered text file to find the text it looks for. This may take a while if many files are filtered or if the text files are large.

The FGrepFilter does not support regular expressions and should thus be slightly faster.

Since:
1.1.3
Author:
Karl Gustafsson
See Also:
FGrepFilter

Constructor Summary
GrepFilter(Pattern p)
          Create a new grep filter that matches text files containing text that the supplied regular expression pattern matches.
GrepFilter(Pattern p, Charset cs)
          Create a new grep filter that matches text files containing text that the supplied regular expression pattern matches.
GrepFilter(String pattern)
          Create a new grep filter that matches text files containing text that the supplied regular expression pattern matches.
GrepFilter(String pattern, Charset cs)
          Create a new grep filter that matches text files containing text that the supplied regular expression pattern matches.
 
Method Summary
 boolean equals(Object o)
           
 int hashCode()
           
 boolean matches(EntityView object)
          Does the filter match the object?
 
Methods inherited from class org.entityfs.support.filter.AbstractConvenientFilter
and, bitwiseNegate, isCase, not, or, xor
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GrepFilter

public GrepFilter(String pattern)
Create a new grep filter that matches text files containing text that the supplied regular expression pattern matches.

The text files are assumed to be encoded in the platform's default character encoding.

Parameters:
pattern - The regular expression pattern.

GrepFilter

public GrepFilter(Pattern p)
Create a new grep filter that matches text files containing text that the supplied regular expression pattern matches.

The text files are assumed to be encoded in the platform's default character encoding.

Parameters:
p - The regular expression pattern.

GrepFilter

public GrepFilter(String pattern,
                  Charset cs)
Create a new grep filter that matches text files containing text that the supplied regular expression pattern matches.

Parameters:
pattern - The regular expression pattern.
cs - The character encoding of the text files. If this parameter is set to null, the platform's default charset is used.

GrepFilter

public GrepFilter(Pattern p,
                  Charset cs)
Create a new grep filter that matches text files containing text that the supplied regular expression pattern matches.

Parameters:
p - The regular expression pattern.
cs - The character encoding of the text files. If this parameter is set to null, the platform's default charset is used.
Method Detail

matches

public boolean matches(EntityView object)
Description copied from interface: Filter
Does the filter match the object?

Specified by:
matches in interface Filter<EntityView>
Parameters:
object - The object to match.
Returns:
true if the filter matches the object.

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object