Package org.eclipse.jetty.webapp
Class ClasspathPattern
Classpath classes list performs pattern matching of a class name
against an internal array of classpath 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
Nested ClassesModifier and TypeClassDescriptionstatic class
static class
static class
static class
static class
static class
private static class
(package private) static class
private static class
private static class
private static class
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) Map<String,
ClasspathPattern.Entry> (package private) IncludeExcludeSet<ClasspathPattern.Entry,
URI> (package private) IncludeExcludeSet<ClasspathPattern.Entry,
String> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
protected boolean
add
(ClasspathPattern.Entry entry) private void
void
clear()
(package private) static boolean
combine
(IncludeExcludeSet<ClasspathPattern.Entry, String> names, String name, IncludeExcludeSet<ClasspathPattern.Entry, URI> locations, Supplier<URI> location) Match a class against inclusions and exclusions by name and location.boolean
boolean
String[]
boolean
boolean
iterator()
boolean
Match the class name against the patternboolean
Match the class name against the patternboolean
protected ClasspathPattern.Entry
protected ClasspathPattern.Entry
boolean
private void
Initialize the matcher by parsing each classpath pattern in an arrayint
size()
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
Map<String,ClasspathPattern.Entry> _entries -
_packageOrNamePatterns
IncludeExcludeSet<ClasspathPattern.Entry,String> _packageOrNamePatterns -
_locations
IncludeExcludeSet<ClasspathPattern.Entry,URI> _locations
-
-
Constructor Details
-
ClasspathPattern
public ClasspathPattern() -
ClasspathPattern
-
ClasspathPattern
-
-
Method Details
-
include
-
include
-
exclude
-
exclude
-
add
- Specified by:
add
in interfaceCollection<String>
- Specified by:
add
in interfaceSet<String>
- Overrides:
add
in classAbstractCollection<String>
-
add
-
newEntry
-
newEntry
-
add
-
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>
-
setAll
Initialize the matcher by parsing each classpath pattern in an array- Parameters:
classes
- array of classpath patterns
-
addAll
- Parameters:
classes
- array of classpath patterns
-
getPatterns
- Returns:
- array of classpath patterns
-
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
-
combine
static boolean combine(IncludeExcludeSet<ClasspathPattern.Entry, String> names, String name, IncludeExcludeSet<ClasspathPattern.Entry, URI> locations, Supplier<URI> location) Match a class against inclusions and exclusions by name and location. Name based checks are performed before location checks. For a class to match, it must not be excluded by either name or location, and must either be explicitly included, or for there to be no inclusions. In the case where the location of the class is null, it will match if it is included by name, or if there are no location exclusions.- Parameters:
names
- configured inclusions and exclusions by namename
- the name to checklocations
- configured inclusions and exclusions by locationlocation
- the location of the class (can be null)- Returns:
- true if the class is not excluded but is included, or there are no inclusions. False otherwise.
-