Package org.eclipse.jetty.util
Class ClassMatcher
- Direct Known Subclasses:
ClassMatcher
A matcher for classes based on package and/or location and/or module/
Performs pattern matching of a class against a set of pattern entries. A class pattern is a string of one of the forms:
- 'org.package.SomeClass' will match a specific class
- 'org.package.' will match a specific package hierarchy
- 'org.package.SomeClass$NestedClass ' will match a nested class exactly otherwise. Nested classes are matched by their containing class. (eg. org.example.MyClass matches org.example.MyClass$AnyNestedClass)
- 'file:///some/location/' - A file system directory from which the class was loaded
- 'file:///some/location.jar' - The URI of a jar file from which the class was loaded
- 'jrt:/modulename' - A Java9 module name
- Any of the above patterns preceded by '-' will exclude rather than include the match.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
static class
static class
static class
static class
protected static interface
ClassMatcher.Constructor<T extends ClassMatcher>
Deprecated.static class
-
Field Summary
Modifier and TypeFieldDescriptionprotected final Map<String,
ClassMatcher.Entry> protected final IncludeExcludeSet<ClassMatcher.Entry,
URI> protected final IncludeExcludeSet<ClassMatcher.Entry,
String> -
Constructor Summary
ModifierConstructorDescriptionClassMatcher
(String pattern) ClassMatcher
(String... patterns) protected
ClassMatcher
(Map<String, ClassMatcher.Entry> entries, IncludeExcludeSet<ClassMatcher.Entry, String> patterns, IncludeExcludeSet<ClassMatcher.Entry, URI> locations) ClassMatcher
(ClassMatcher patterns) -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
protected boolean
add
(ClassMatcher.Entry entry) void
clear()
boolean
boolean
String[]
String[]
String[]
boolean
boolean
iterator()
boolean
Match the class name against the patternboolean
Match the class name against the patternboolean
protected ClassMatcher.Entry
protected ClassMatcher.Entry
boolean
int
size()
protected static <T extends ClassMatcher>
Twrap
(ClassMatcher matcher, ClassMatcher.Constructor<T> constructor) Deprecated.Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, retainAll, toArray, toArray, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.Set
addAll, contains, containsAll, isEmpty, retainAll, spliterator, toArray, toArray
-
Field Details
-
_entries
-
_patterns
-
_locations
-
-
Constructor Details
-
ClassMatcher
protected ClassMatcher(Map<String, ClassMatcher.Entry> entries, IncludeExcludeSet<ClassMatcher.Entry, String> patterns, IncludeExcludeSet<ClassMatcher.Entry, URI> locations) -
ClassMatcher
public ClassMatcher() -
ClassMatcher
-
ClassMatcher
-
ClassMatcher
-
-
Method Details
-
wrap
@Deprecated protected static <T extends ClassMatcher> T wrap(ClassMatcher matcher, ClassMatcher.Constructor<T> constructor) Deprecated.useClassMatcher
directly.Wrap an instance of aClassMatcher
using a constructor of an extendedClassMatcher
that needs access to the internal fields of the passed matcher.- Type Parameters:
T
- The type of the API specific wrapper- Parameters:
matcher
- The matcher to wrapconstructor
- The constructor to build the API specific wrapper- Returns:
- A wrapper of the
matcher
, sharing internal state.
-
asImmutable
-
include
-
include
-
exclude
-
exclude
-
add
- Specified by:
add
in interfaceCollection<String>
- Specified by:
add
in interfaceSet<String>
- Overrides:
add
in classAbstractCollection<String>
-
add
-
add
-
newEntry
-
newEntry
-
remove
- Specified by:
remove
in interfaceCollection<String>
- Specified by:
remove
in interfaceSet<String>
- Overrides:
remove
in classAbstractCollection<String>
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<String>
- Specified by:
clear
in interfaceSet<String>
- Overrides:
clear
in classAbstractCollection<String>
-
iterator
-
size
public int size()- Specified by:
size
in interfaceCollection<String>
- Specified by:
size
in interfaceSet<String>
- Specified by:
size
in classAbstractCollection<String>
-
getPatterns
- Returns:
- array of classpath patterns
-
getInclusions
- Returns:
- array of inclusive classpath patterns
-
getExclusions
- Returns:
- array of excluded classpath patterns (without '-' prefix)
-
match
Match the class name against the pattern- Parameters:
name
- name of the class to match- Returns:
- true if class matches the pattern
-
match
Match the class name against the pattern- Parameters:
clazz
- A class to try to match- Returns:
- true if class matches the pattern
-
match
-
ClassMatcher
directly.