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 classstatic classstatic classstatic classstatic classstatic classprivate static class(package private) static classprivate static classprivate static classprivate 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 TypeMethodDescriptionbooleanbooleanprotected booleanadd(ClasspathPattern.Entry entry) private voidvoidclear()(package private) static booleancombine(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.booleanbooleanString[]booleanbooleaniterator()booleanMatch the class name against the patternbooleanMatch the class name against the patternbooleanprotected ClasspathPattern.Entryprotected ClasspathPattern.Entrybooleanprivate voidInitialize the matcher by parsing each classpath pattern in an arrayintsize()Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAllMethods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, retainAll, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods 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:
addin interfaceCollection<String>- Specified by:
addin interfaceSet<String>- Overrides:
addin classAbstractCollection<String>
-
add
-
newEntry
-
newEntry
-
add
-
remove
- Specified by:
removein interfaceCollection<String>- Specified by:
removein interfaceSet<String>- Overrides:
removein classAbstractCollection<String>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<String>- Specified by:
clearin interfaceSet<String>- Overrides:
clearin classAbstractCollection<String>
-
iterator
-
size
public int size()- Specified by:
sizein interfaceCollection<String>- Specified by:
sizein interfaceSet<String>- Specified by:
sizein 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.
-