Class AcceptReject
java.lang.Object
nonapi.io.github.classgraph.scanspec.AcceptReject
- Direct Known Subclasses:
AcceptReject.AcceptRejectPrefix
,AcceptReject.AcceptRejectWholeString
A class storing accept or reject criteria.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Accept/reject for leaf matches.static class
Accept/reject for prefix strings.static class
Accept/reject for whole-strings matches. -
Field Summary
FieldsModifier and TypeFieldDescriptionAccepted items (whole-string match).Accept glob strings.Accept regexp patterns.Accepted items (prefix match), as a sorted list.Accepted items (prefix match), as a set.Rejected items (whole-string match).Reject glob strings.Reject regexp patterns.Rejected items (prefix match).protected char
The separator character. -
Constructor Summary
ConstructorsConstructorDescriptionDeserialization constructor.AcceptReject
(char separatorChar) Constructor for deserialization. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Check if the accept and reject are empty.abstract boolean
acceptHasPrefix
(String str) Check if a string is a prefix of an accepted string.boolean
Check if the accept is empty.abstract void
addToAccept
(String str) Add to the accept.abstract void
addToReject
(String str) Add to the reject.static String
classNameToClassfilePath
(String className) Convert a class name to a classfile path.static Pattern
globToPattern
(String glob, boolean simpleGlob) Convert a spec with a '*' glob character into a regular expression.abstract boolean
isAccepted
(String str) Check if a string is accepted.abstract boolean
Check if a string is accepted and not rejected.abstract boolean
isRejected
(String str) Check if a string is rejected.boolean
Check if a string is specifically accepted.boolean
Check if a string is specifically accepted and not rejected.private static boolean
matchesPatternList
(String str, List<Pattern> patterns) Check if a string matches one of the patterns in the provided list.static String
normalizePackageOrClassName
(String packageOrClassName) Remove initial and final '.' characters, if any.static String
normalizePath
(String path) Remove initial and final '/' characters, if any.static String
packageNameToPath
(String packageName) Convert a package name to a path.static String
pathToPackageName
(String path) Convert a path to a package name.private static void
quoteList
(Collection<String> coll, StringBuilder buf) Quote list.boolean
Check if the reject is empty.(package private) void
Need to sort prefixes to ensure correct accept/reject evaluation (see Issue #167).toString()
-
Field Details
-
accept
Accepted items (whole-string match). -
reject
Rejected items (whole-string match). -
acceptPrefixesSet
Accepted items (prefix match), as a set. -
acceptPrefixes
Accepted items (prefix match), as a sorted list. -
rejectPrefixes
Rejected items (prefix match). -
acceptGlobs
Accept glob strings. (Serialized to JSON, for logging purposes.) -
rejectGlobs
Reject glob strings. (Serialized to JSON, for logging purposes.) -
acceptPatterns
Accept regexp patterns. (Not serialized to JSON.) -
rejectPatterns
Reject regexp patterns. (Not serialized to JSON.) -
separatorChar
protected char separatorCharThe separator character.
-
-
Constructor Details
-
AcceptReject
public AcceptReject()Deserialization constructor. -
AcceptReject
public AcceptReject(char separatorChar) Constructor for deserialization.- Parameters:
separatorChar
- the separator char
-
-
Method Details
-
addToAccept
Add to the accept.- Parameters:
str
- The string to accept.
-
addToReject
Add to the reject.- Parameters:
str
- The string to reject.
-
isAcceptedAndNotRejected
Check if a string is accepted and not rejected.- Parameters:
str
- The string to test.- Returns:
- true if the string is accepted and not rejected.
-
isAccepted
Check if a string is accepted.- Parameters:
str
- The string to test.- Returns:
- true if the string is accepted.
-
acceptHasPrefix
Check if a string is a prefix of an accepted string.- Parameters:
str
- The string to test.- Returns:
- true if the string is a prefix of an accepted string.
-
isRejected
Check if a string is rejected.- Parameters:
str
- The string to test.- Returns:
- true if the string is rejected.
-
normalizePath
Remove initial and final '/' characters, if any.- Parameters:
path
- The path to normalize.- Returns:
- The normalized path.
-
normalizePackageOrClassName
Remove initial and final '.' characters, if any.- Parameters:
packageOrClassName
- The package or class name.- Returns:
- The normalized package or class name.
-
pathToPackageName
Convert a path to a package name.- Parameters:
path
- The path.- Returns:
- The package name.
-
packageNameToPath
Convert a package name to a path.- Parameters:
packageName
- The package name.- Returns:
- The path.
-
classNameToClassfilePath
Convert a class name to a classfile path.- Parameters:
className
- The class name.- Returns:
- The classfile path (including a ".class" suffix).
-
globToPattern
Convert a spec with a '*' glob character into a regular expression.- Parameters:
glob
- The glob string.simpleGlob
- if true, handles simple globs: "*" matches zero or more characters (replaces "." with "\\.", "*" with ".*", then compiles a regular expression). If false, handles filesystem-style globs: "**" matches zero or more characters, "*" matches zero or more characters other than "/", "?" matches one character (replaces "." with "\\.", "**" with ".*", "*" with "[^/]*", and "?" with ".", then compiles a regular expression).- Returns:
- The Pattern created from the glob string.
-
matchesPatternList
Check if a string matches one of the patterns in the provided list.- Parameters:
str
- the string to testpatterns
- the patterns- Returns:
- true, if successful
-
acceptIsEmpty
public boolean acceptIsEmpty()Check if the accept is empty.- Returns:
- true if there were no accept criteria added.
-
rejectIsEmpty
public boolean rejectIsEmpty()Check if the reject is empty.- Returns:
- true if there were no reject criteria added.
-
acceptAndRejectAreEmpty
public boolean acceptAndRejectAreEmpty()Check if the accept and reject are empty.- Returns:
- true if there were no accept or reject criteria added.
-
isSpecificallyAcceptedAndNotRejected
Check if a string is specifically accepted and not rejected.- Parameters:
str
- The string to test.- Returns:
- true if the requested string is specifically accepted and not rejected, i.e. will not return true if the accept is empty, or if the string is rejected.
-
isSpecificallyAccepted
Check if a string is specifically accepted.- Parameters:
str
- The string to test.- Returns:
- true if the requested string is specifically accepted, i.e. will not return true if the accept is empty.
-
sortPrefixes
void sortPrefixes()Need to sort prefixes to ensure correct accept/reject evaluation (see Issue #167). -
quoteList
Quote list.- Parameters:
coll
- the collbuf
- the buf
-
toString
-