public class WildcardClassFilter extends _AbstractBaseFilter implements Serializable, StringFilterType
This filter selects classes one or more wildcards. Testing is case-sensitive by default, but this can be configured.
The wildcard matcher uses the characters '?' and '*' to represent a single or multiple characters. This is the same as often found on Dos/Unix command lines.
For example:
Class<?> clazz = org.xenei.junit.contract.filter.ClassFilter.class;
ClassFilter filter = new WildcardClassFilter("*.filter.*");
if (filter.accept(clazz)) {
System.out.println("it works");
}
ClassPathFilter.UtilNO_ARGSABSTRACT_CLASS, ANNOTATION_CLASS, FALSE, INTERFACE_CLASS, TRUE| Constructor and Description |
|---|
WildcardClassFilter(Case caseSensitivity,
Collection<String> wildcards)
Construct a new wildcard filter for a collection of wildcards specifying
case-sensitivity.
|
WildcardClassFilter(Case caseSensitivity,
String... wildcards)
Construct a new wildcard filter for an array of wildcards specifying
case-sensitivity.
|
WildcardClassFilter(Case caseSensitivity,
String wildcard)
Construct a new wildcard filter for a single wildcard specifying
case-sensitivity.
|
WildcardClassFilter(Collection<String> wildcards)
Construct a new case-sensitive wildcard filter for a collection of
wildcards.
|
WildcardClassFilter(String... wildcards)
Construct a new case-sensitive wildcard filter for an array of wildcards.
|
WildcardClassFilter(String wildcard)
Construct a new case-sensitive wildcard filter for a single wildcard.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
accept(Class<?> clazz)
Accept a Class.
|
boolean |
accept(String className)
Accept a class name.
|
boolean |
accept(URL url)
Accept a URL.
|
void |
addWildcard(String wildcard)
Add a single wildcard string to the filter.
|
void |
addWildCards(Collection<String> wildcards)
Add a collection of wild card strings to the filter
|
void |
addWildCards(String... wildcards)
Add an array of wild card strings to the filter
|
String[] |
args()
Get the arguments for the function.
|
protected org.apache.commons.logging.Log |
getLog() |
static String |
makeRegex(String wildcard)
Convert the wildcard string into a regex string.
|
ClassPathFilter |
optimize() |
String |
toString()
Provide a String representation of this file filter.
|
equals, filterClasses, filterNames, filterURLs, funcName, hashCode, loadClassclone, finalize, getClass, notify, notifyAll, wait, wait, waitfilterClasses, filterNames, filterURLs, funcNamepublic WildcardClassFilter(String wildcard)
wildcard - the wildcard to matchIllegalArgumentException - if the pattern is nullpublic WildcardClassFilter(Case caseSensitivity, String wildcard)
wildcard - the wildcard to match, not nullcaseSensitivity - how to handle case sensitivity, null means case-sensitiveIllegalArgumentException - if the pattern is nullpublic WildcardClassFilter(String... wildcards)
The array is not cloned, so could be changed after constructing the instance. This would be inadvisable however.
wildcards - the array of wildcards to matchIllegalArgumentException - if the pattern array is nullpublic WildcardClassFilter(Case caseSensitivity, String... wildcards)
The array is not cloned, so could be changed after constructing the instance. This would be inadvisable however.
wildcards - the array of wildcards to match, not nullcaseSensitivity - how to handle case sensitivity, null means case-sensitiveIllegalArgumentException - if the pattern array is nullpublic WildcardClassFilter(Collection<String> wildcards)
wildcards - the list of wildcards to match, not nullIllegalArgumentException - if the pattern list is nullClassCastException - if the list does not contain Stringspublic WildcardClassFilter(Case caseSensitivity, Collection<String> wildcards)
wildcards - the list of wildcards to match, not nullcaseSensitivity - how to handle case sensitivity, null means case-sensitiveIllegalArgumentException - if the pattern list is nullClassCastException - if the list does not contain Stringsprotected org.apache.commons.logging.Log getLog()
getLog in class _AbstractBaseFilterpublic void addWildCards(Collection<String> wildcards)
wildcards - The list of wildcard strings.IllegalArgumentException - if the list is null or if any string within the list is null.public void addWildCards(String... wildcards)
wildcards - The array of wildcard strings.IllegalArgumentException - if the array is null or if any string within the list is
null.public void addWildcard(String wildcard)
wildcard - the string to add.IllegalArgumentException - if the wildcard is null.public String toString()
toString in class _AbstractBaseFilterpublic static String makeRegex(String wildcard)
wildcard - The wild card string to convert.public boolean accept(URL url)
accept in interface ClassPathFilterurl - the url to accept.public boolean accept(String className)
accept in interface ClassPathFilterclassName - the class name to accept.public boolean accept(Class<?> clazz)
accept in interface ClassPathFilterclazz - the clazz to accept.public String[] args()
args in interface ClassPathFilterpublic ClassPathFilter optimize()
optimize in interface ClassPathFilterCopyright © 2013-2017 XENEI.com. All Rights Reserved.