net.sourceforge.pmd.util.filter
Class RegexStringFilter

java.lang.Object
  extended by net.sourceforge.pmd.util.filter.RegexStringFilter
All Implemented Interfaces:
Filter<java.lang.String>

public class RegexStringFilter
extends java.lang.Object
implements Filter<java.lang.String>

A filter which uses a regular expression to match Strings. Invalid regular expressions will match nothing.

Because regular expression matching is slow, and a common usage is to match some sort of relative file path, the regular expression is checked to see if it can be evaluated using much faster calls to String.endsWith(String).


Field Summary
protected  java.lang.String endsWith
           
protected  java.util.regex.Pattern pattern
           
protected  java.lang.String regex
           
 
Constructor Summary
RegexStringFilter(java.lang.String regex)
           
 
Method Summary
 boolean filter(java.lang.String obj)
           
 java.lang.String getEndsWith()
           
 java.lang.String getRegex()
           
protected  void optimize()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

regex

protected java.lang.String regex

pattern

protected java.util.regex.Pattern pattern

endsWith

protected java.lang.String endsWith
Constructor Detail

RegexStringFilter

public RegexStringFilter(java.lang.String regex)
Method Detail

getRegex

public java.lang.String getRegex()

getEndsWith

public java.lang.String getEndsWith()

optimize

protected void optimize()

filter

public boolean filter(java.lang.String obj)
Specified by:
filter in interface Filter<java.lang.String>

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2002-2011 InfoEther. All Rights Reserved.