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 classAccept/reject for leaf matches.static classAccept/reject for prefix strings.static classAccept/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 charThe separator character. -
Constructor Summary
ConstructorsConstructorDescriptionDeserialization constructor.AcceptReject(char separatorChar) Constructor for deserialization. -
Method Summary
Modifier and TypeMethodDescriptionbooleanCheck if the accept and reject are empty.abstract booleanacceptHasPrefix(String str) Check if a string is a prefix of an accepted string.booleanCheck if the accept is empty.abstract voidaddToAccept(String str) Add to the accept.abstract voidaddToReject(String str) Add to the reject.static StringclassNameToClassfilePath(String className) Convert a class name to a classfile path.static PatternglobToPattern(String glob, boolean simpleGlob) Convert a spec with a '*' glob character into a regular expression.abstract booleanisAccepted(String str) Check if a string is accepted.abstract booleanCheck if a string is accepted and not rejected.abstract booleanisRejected(String str) Check if a string is rejected.booleanCheck if a string is specifically accepted.booleanCheck if a string is specifically accepted and not rejected.private static booleanmatchesPatternList(String str, List<Pattern> patterns) Check if a string matches one of the patterns in the provided list.static StringnormalizePackageOrClassName(String packageOrClassName) Remove initial and final '.' characters, if any.static StringnormalizePath(String path) Remove initial and final '/' characters, if any.static StringpackageNameToPath(String packageName) Convert a package name to a path.static StringpathToPackageName(String path) Convert a path to a package name.private static voidquoteList(Collection<String> coll, StringBuilder buf) Quote list.booleanCheck if the reject is empty.(package private) voidNeed 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
-