Top Description Inners Fields Constructors Methods
nonapi.io.github.classgraph.scanspec

public abstract Class AcceptReject

extends Object
Class Inheritance
Known Direct Subclasses
nonapi.io.github.classgraph.scanspec.AcceptReject.AcceptRejectPrefix, nonapi.io.github.classgraph.scanspec.AcceptReject.AcceptRejectWholeString
Imports
java.util.ArrayList, .Collection, .HashSet, .List, .Set, java.util.regex.Pattern, nonapi.io.github.classgraph.utils.CollectionUtils, .FastPathResolver, .FileUtils, .JarUtils

A class storing accept or reject criteria.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
AcceptReject.AcceptRejectLeafname

Accept/reject for leaf matches.

public static class
AcceptReject.AcceptRejectPrefix

Accept/reject for prefix strings.

public static class
AcceptReject.AcceptRejectWholeString

Accept/reject for whole-strings matches.

Field Summary

Modifier and TypeField and Description
protected Set<String>
accept

Accepted items (whole-string match).

protected Set<String>
acceptGlobs

Accept glob strings.

protected transient List<Pattern>
acceptPatterns

Accept regexp patterns.

protected List<String>
acceptPrefixes

Accepted items (prefix match), as a sorted list.

protected Set<String>
acceptPrefixesSet

Accepted items (prefix match), as a set.

protected Set<String>
reject

Rejected items (whole-string match).

protected Set<String>
rejectGlobs

Reject glob strings.

protected transient List<Pattern>
rejectPatterns

Reject regexp patterns.

protected List<String>
rejectPrefixes

Rejected items (prefix match).

protected char
separatorChar

The separator character.

Constructor Summary

AccessConstructor and Description
public
AcceptReject()

Deserialization constructor.

public
AcceptReject(final char
the separator char
separatorChar
)

Constructor for deserialization.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if there were no accept or reject criteria added.
acceptAndRejectAreEmpty
()

Check if the accept and reject are empty.

public abstract boolean

Returns:

true if the string is a prefix of an accepted string.
acceptHasPrefix
(final String
The string to test.
str
)

Check if a string is a prefix of an accepted string.

public boolean

Returns:

true if there were no accept criteria added.
acceptIsEmpty
()

Check if the accept is empty.

public abstract void
addToAccept(final String
The string to accept.
str
)

Add to the accept.

public abstract void
addToReject(final String
The string to reject.
str
)

Add to the reject.

public static String

Returns:

The classfile path (including a ".class" suffix).
classNameToClassfilePath
(final String
The class name.
className
)

Convert a class name to a classfile path.

public static Pattern

Returns:

The Pattern created from the glob string.
globToPattern
(final String
The glob string.
glob
,
final boolean
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).
simpleGlob
)

Convert a spec with a '*' glob character into a regular expression.

public abstract boolean

Returns:

true if the string is accepted.
isAccepted
(final String
The string to test.
str
)

Check if a string is accepted.

public abstract boolean

Returns:

true if the string is accepted and not rejected.
isAcceptedAndNotRejected
(final String
The string to test.
str
)

Check if a string is accepted and not rejected.

public abstract boolean

Returns:

true if the string is rejected.
isRejected
(final String
The string to test.
str
)

Check if a string is rejected.

public boolean

Returns:

true if the requested string is specifically accepted, i.e. will not return true if the accept is empty.
isSpecificallyAccepted
(final String
The string to test.
str
)

Check if a string is specifically accepted.

public boolean

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.
isSpecificallyAcceptedAndNotRejected
(final String
The string to test.
str
)

Check if a string is specifically accepted and not rejected.

private static boolean

Returns:

true, if successful
matchesPatternList
(final String
the string to test
str
,
final List<Pattern>
the patterns
patterns
)

Check if a string matches one of the patterns in the provided list.

public static String

Returns:

The normalized package or class name.
normalizePackageOrClassName
(final String
The package or class name.
packageOrClassName
)

Remove initial and final '.' characters, if any.

public static String

Returns:

The normalized path.
normalizePath
(final String
The path to normalize.
path
)

Remove initial and final '/' characters, if any.

public static String

Returns:

The path.
packageNameToPath
(final String
The package name.
packageName
)

Convert a package name to a path.

public static String

Returns:

The package name.
pathToPackageName
(final String
The path.
path
)

Convert a path to a package name.

private static void
quoteList(final Collection<String>
the coll
coll
,
final StringBuilder
the buf
buf
)

Quote list.

public boolean

Returns:

true if there were no reject criteria added.
rejectIsEmpty
()

Check if the reject is empty.

pack-priv void
sortPrefixes()

Need to sort prefixes to ensure correct accept/reject evaluation (see Issue #167).

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

acceptback to summary
protected Set<String> accept

Accepted items (whole-string match).

acceptGlobsback to summary
protected Set<String> acceptGlobs

Accept glob strings. (Serialized to JSON, for logging purposes.)

acceptPatternsback to summary
protected transient List<Pattern> acceptPatterns

Accept regexp patterns. (Not serialized to JSON.)

acceptPrefixesback to summary
protected List<String> acceptPrefixes

Accepted items (prefix match), as a sorted list.

acceptPrefixesSetback to summary
protected Set<String> acceptPrefixesSet

Accepted items (prefix match), as a set.

rejectback to summary
protected Set<String> reject

Rejected items (whole-string match).

rejectGlobsback to summary
protected Set<String> rejectGlobs

Reject glob strings. (Serialized to JSON, for logging purposes.)

rejectPatternsback to summary
protected transient List<Pattern> rejectPatterns

Reject regexp patterns. (Not serialized to JSON.)

rejectPrefixesback to summary
protected List<String> rejectPrefixes

Rejected items (prefix match).

separatorCharback to summary
protected char separatorChar

The separator character.

Constructor Detail

AcceptRejectback to summary
public AcceptReject()

Deserialization constructor.

AcceptRejectback to summary
public AcceptReject(final char separatorChar)

Constructor for deserialization.

Parameters
separatorChar:char

the separator char

Method Detail

acceptAndRejectAreEmptyback to summary
public boolean acceptAndRejectAreEmpty()

Check if the accept and reject are empty.

Returns:boolean

true if there were no accept or reject criteria added.

acceptHasPrefixback to summary
public abstract boolean acceptHasPrefix(final String str)

Check if a string is a prefix of an accepted string.

Parameters
str:String

The string to test.

Returns:boolean

true if the string is a prefix of an accepted string.

acceptIsEmptyback to summary
public boolean acceptIsEmpty()

Check if the accept is empty.

Returns:boolean

true if there were no accept criteria added.

addToAcceptback to summary
public abstract void addToAccept(final String str)

Add to the accept.

Parameters
str:String

The string to accept.

addToRejectback to summary
public abstract void addToReject(final String str)

Add to the reject.

Parameters
str:String

The string to reject.

classNameToClassfilePathback to summary
public static String classNameToClassfilePath(final String className)

Convert a class name to a classfile path.

Parameters
className:String

The class name.

Returns:String

The classfile path (including a ".class" suffix).

globToPatternback to summary
public static Pattern globToPattern(final String glob, final boolean simpleGlob)

Convert a spec with a '*' glob character into a regular expression.

Parameters
glob:String

The glob string.

simpleGlob:boolean

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:Pattern

The Pattern created from the glob string.

isAcceptedback to summary
public abstract boolean isAccepted(final String str)

Check if a string is accepted.

Parameters
str:String

The string to test.

Returns:boolean

true if the string is accepted.

isAcceptedAndNotRejectedback to summary
public abstract boolean isAcceptedAndNotRejected(final String str)

Check if a string is accepted and not rejected.

Parameters
str:String

The string to test.

Returns:boolean

true if the string is accepted and not rejected.

isRejectedback to summary
public abstract boolean isRejected(final String str)

Check if a string is rejected.

Parameters
str:String

The string to test.

Returns:boolean

true if the string is rejected.

isSpecificallyAcceptedback to summary
public boolean isSpecificallyAccepted(final String str)

Check if a string is specifically accepted.

Parameters
str:String

The string to test.

Returns:boolean

true if the requested string is specifically accepted, i.e. will not return true if the accept is empty.

isSpecificallyAcceptedAndNotRejectedback to summary
public boolean isSpecificallyAcceptedAndNotRejected(final String str)

Check if a string is specifically accepted and not rejected.

Parameters
str:String

The string to test.

Returns:boolean

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.

matchesPatternListback to summary
private static boolean matchesPatternList(final String str, final List<Pattern> patterns)

Check if a string matches one of the patterns in the provided list.

Parameters
str:String

the string to test

patterns:List<Pattern>

the patterns

Returns:boolean

true, if successful

normalizePackageOrClassNameback to summary
public static String normalizePackageOrClassName(final String packageOrClassName)

Remove initial and final '.' characters, if any.

Parameters
packageOrClassName:String

The package or class name.

Returns:String

The normalized package or class name.

normalizePathback to summary
public static String normalizePath(final String path)

Remove initial and final '/' characters, if any.

Parameters
path:String

The path to normalize.

Returns:String

The normalized path.

packageNameToPathback to summary
public static String packageNameToPath(final String packageName)

Convert a package name to a path.

Parameters
packageName:String

The package name.

Returns:String

The path.

pathToPackageNameback to summary
public static String pathToPackageName(final String path)

Convert a path to a package name.

Parameters
path:String

The path.

Returns:String

The package name.

quoteListback to summary
private static void quoteList(final Collection<String> coll, final StringBuilder buf)

Quote list.

Parameters
coll:Collection<String>

the coll

buf:StringBuilder

the buf

rejectIsEmptyback to summary
public boolean rejectIsEmpty()

Check if the reject is empty.

Returns:boolean

true if there were no reject criteria added.

sortPrefixesback to summary
pack-priv void sortPrefixes()

Need to sort prefixes to ensure correct accept/reject evaluation (see Issue #167).

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
nonapi.io.github.classgraph.scanspec back to summary

public Class AcceptReject.AcceptRejectLeafname

extends AcceptRejectWholeString
Class Inheritance

Accept/reject for leaf matches.

Constructor Summary

AccessConstructor and Description
public
AcceptRejectLeafname()

Deserialization constructor.

public
AcceptRejectLeafname(final char
the separator char
separatorChar
)

Instantiates a new accept/reject for leaf matches.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

(does not return, throws exception)
acceptHasPrefix
(final String
the string to test
str
)

Overrides nonapi.io.github.classgraph.scanspec.AcceptReject.AcceptRejectWholeString.acceptHasPrefix.

Prefix tests are invalid for jar leafnames -- throws IllegalArgumentException.

public void
public void
public boolean

Returns:

true if the string is accepted
isAccepted
(final String
the string to test
str
)

Overrides nonapi.io.github.classgraph.scanspec.AcceptReject.AcceptRejectWholeString.isAccepted.

Check if the requested string is accepted.

public boolean

Returns:

true if the string is accepted and not rejected
isAcceptedAndNotRejected
(final String
the string to test
str
)

Overrides nonapi.io.github.classgraph.scanspec.AcceptReject.AcceptRejectWholeString.isAcceptedAndNotRejected.

Check if the requested string is accepted and not rejected.

public boolean

Returns:

true if the string is rejected
isRejected
(final String
the string to test
str
)

Overrides nonapi.io.github.classgraph.scanspec.AcceptReject.AcceptRejectWholeString.isRejected.

Check if the requested string is rejected.

Constructor Detail

AcceptRejectLeafnameback to summary
public AcceptRejectLeafname()

Deserialization constructor.

AcceptRejectLeafnameback to summary
public AcceptRejectLeafname(final char separatorChar)

Instantiates a new accept/reject for leaf matches.

Parameters
separatorChar:char

the separator char

Method Detail

acceptHasPrefixback to summary
public boolean acceptHasPrefix(final String str)

Overrides nonapi.io.github.classgraph.scanspec.AcceptReject.AcceptRejectWholeString.acceptHasPrefix.

Prefix tests are invalid for jar leafnames -- throws IllegalArgumentException.

Parameters
str:String

the string to test

Returns:boolean

(does not return, throws exception)

Annotations
@Override
Exceptions
IllegalArgumentException:
always
addToAcceptback to summary
public void addToAccept(final String str)

Overrides nonapi.io.github.classgraph.scanspec.AcceptReject.AcceptRejectWholeString.addToAccept.

Add to the accept.

Parameters
str:String

the string to accept

Annotations
@Override
addToRejectback to summary
public void addToReject(final String str)

Overrides nonapi.io.github.classgraph.scanspec.AcceptReject.AcceptRejectWholeString.addToReject.

Add to the reject.

Parameters
str:String

the string to reject

Annotations
@Override
isAcceptedback to summary
public boolean isAccepted(final String str)

Overrides nonapi.io.github.classgraph.scanspec.AcceptReject.AcceptRejectWholeString.isAccepted.

Check if the requested string is accepted.

Parameters
str:String

the string to test

Returns:boolean

true if the string is accepted

Annotations
@Override
isAcceptedAndNotRejectedback to summary
public boolean isAcceptedAndNotRejected(final String str)

Overrides nonapi.io.github.classgraph.scanspec.AcceptReject.AcceptRejectWholeString.isAcceptedAndNotRejected.

Check if the requested string is accepted and not rejected.

Parameters
str:String

the string to test

Returns:boolean

true if the string is accepted and not rejected

Annotations
@Override
isRejectedback to summary
public boolean isRejected(final String str)

Overrides nonapi.io.github.classgraph.scanspec.AcceptReject.AcceptRejectWholeString.isRejected.

Check if the requested string is rejected.

Parameters
str:String

the string to test

Returns:boolean

true if the string is rejected

Annotations
@Override
nonapi.io.github.classgraph.scanspec back to summary

public Class AcceptReject.AcceptRejectPrefix

extends AcceptReject
Class Inheritance

Accept/reject for prefix strings.

Field Summary

Inherited from nonapi.io.github.classgraph.scanspec.AcceptReject:
acceptacceptGlobsacceptPatternsacceptPrefixesacceptPrefixesSetrejectrejectGlobsrejectPatternsrejectPrefixesseparatorChar

Constructor Summary

AccessConstructor and Description
public
AcceptRejectPrefix()

Deserialization constructor.

public
AcceptRejectPrefix(final char
the separator char
separatorChar
)

Instantiate a new accept/reject for prefix strings.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

(does not return, throws exception)
acceptHasPrefix
(final String
the string to test
str
)

Implements abstract nonapi.io.github.classgraph.scanspec.AcceptReject.acceptHasPrefix.

Prefix-of-prefix is invalid -- throws IllegalArgumentException.

public void
addToAccept(final String
the string to accept
str
)

Implements abstract nonapi.io.github.classgraph.scanspec.AcceptReject.addToAccept.

Add to the accept.

public void
addToReject(final String
the string to reject
str
)

Implements abstract nonapi.io.github.classgraph.scanspec.AcceptReject.addToReject.

Add to the reject.

public boolean

Returns:

true if string is accepted
isAccepted
(final String
the string to test
str
)

Implements abstract nonapi.io.github.classgraph.scanspec.AcceptReject.isAccepted.

Check if the requested string has an accepted prefix.

public boolean

Returns:

true if string is accepted and not rejected
isAcceptedAndNotRejected
(final String
the string to test
str
)

Implements abstract nonapi.io.github.classgraph.scanspec.AcceptReject.isAcceptedAndNotRejected.

Check if the requested string has an accepted/non-rejected prefix.

public boolean

Returns:

true if the string has a rejected prefix
isRejected
(final String
the string to test
str
)

Implements abstract nonapi.io.github.classgraph.scanspec.AcceptReject.isRejected.

Check if the requested string has a rejected prefix.

Inherited from nonapi.io.github.classgraph.scanspec.AcceptReject:
acceptAndRejectAreEmptyacceptIsEmptyclassNameToClassfilePathglobToPatternisSpecificallyAcceptedisSpecificallyAcceptedAndNotRejectednormalizePackageOrClassNamenormalizePathpackageNameToPathpathToPackageNamerejectIsEmptysortPrefixestoString

Constructor Detail

AcceptRejectPrefixback to summary
public AcceptRejectPrefix()

Deserialization constructor.

AcceptRejectPrefixback to summary
public AcceptRejectPrefix(final char separatorChar)

Instantiate a new accept/reject for prefix strings.

Parameters
separatorChar:char

the separator char

Method Detail

acceptHasPrefixback to summary
public boolean acceptHasPrefix(final String str)

Implements abstract nonapi.io.github.classgraph.scanspec.AcceptReject.acceptHasPrefix.

Prefix-of-prefix is invalid -- throws IllegalArgumentException.

Parameters
str:String

the string to test

Returns:boolean

(does not return, throws exception)

Annotations
@Override
Exceptions
IllegalArgumentException:
always
addToAcceptback to summary
public void addToAccept(final String str)

Implements abstract nonapi.io.github.classgraph.scanspec.AcceptReject.addToAccept.

Add to the accept.

Parameters
str:String

the string to accept

Annotations
@Override
addToRejectback to summary
public void addToReject(final String str)

Implements abstract nonapi.io.github.classgraph.scanspec.AcceptReject.addToReject.

Add to the reject.

Parameters
str:String

the string to reject

Annotations
@Override
isAcceptedback to summary
public boolean isAccepted(final String str)

Implements abstract nonapi.io.github.classgraph.scanspec.AcceptReject.isAccepted.

Check if the requested string has an accepted prefix.

Parameters
str:String

the string to test

Returns:boolean

true if string is accepted

Annotations
@Override
isAcceptedAndNotRejectedback to summary
public boolean isAcceptedAndNotRejected(final String str)

Implements abstract nonapi.io.github.classgraph.scanspec.AcceptReject.isAcceptedAndNotRejected.

Check if the requested string has an accepted/non-rejected prefix.

Parameters
str:String

the string to test

Returns:boolean

true if string is accepted and not rejected

Annotations
@Override
isRejectedback to summary
public boolean isRejected(final String str)

Implements abstract nonapi.io.github.classgraph.scanspec.AcceptReject.isRejected.

Check if the requested string has a rejected prefix.

Parameters
str:String

the string to test

Returns:boolean

true if the string has a rejected prefix

Annotations
@Override
nonapi.io.github.classgraph.scanspec back to summary

public Class AcceptReject.AcceptRejectWholeString

extends AcceptReject
Class Inheritance
Known Direct Subclasses
nonapi.io.github.classgraph.scanspec.AcceptReject.AcceptRejectLeafname

Accept/reject for whole-strings matches.

Field Summary

Inherited from nonapi.io.github.classgraph.scanspec.AcceptReject:
acceptacceptGlobsacceptPatternsacceptPrefixesacceptPrefixesSetrejectrejectGlobsrejectPatternsrejectPrefixesseparatorChar

Constructor Summary

AccessConstructor and Description
public
AcceptRejectWholeString()

Deserialization constructor.

public
AcceptRejectWholeString(final char
the separator char
separatorChar
)

Instantiate a new accept/reject for whole-string matches.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the string is a prefix of an accepted string
acceptHasPrefix
(final String
the string to test
str
)

Implements abstract nonapi.io.github.classgraph.scanspec.AcceptReject.acceptHasPrefix.

Check if the requested string is a prefix of an accepted string.

public void
addToAccept(final String
the string to accept
str
)

Implements abstract nonapi.io.github.classgraph.scanspec.AcceptReject.addToAccept.

Add to the accept.

public void
addToReject(final String
the string to reject
str
)

Implements abstract nonapi.io.github.classgraph.scanspec.AcceptReject.addToReject.

Add to the reject.

public boolean

Returns:

true if the string is accepted
isAccepted
(final String
the string to test
str
)

Implements abstract nonapi.io.github.classgraph.scanspec.AcceptReject.isAccepted.

Check if the requested string is accepted.

public boolean

Returns:

true if the string is accepted and not rejected
isAcceptedAndNotRejected
(final String
the string to test
str
)

Implements abstract nonapi.io.github.classgraph.scanspec.AcceptReject.isAcceptedAndNotRejected.

Check if the requested string is accepted and not rejected.

public boolean

Returns:

true if the string is rejected
isRejected
(final String
the string to test
str
)

Implements abstract nonapi.io.github.classgraph.scanspec.AcceptReject.isRejected.

Check if the requested string is rejected.

Inherited from nonapi.io.github.classgraph.scanspec.AcceptReject:
acceptAndRejectAreEmptyacceptIsEmptyclassNameToClassfilePathglobToPatternisSpecificallyAcceptedisSpecificallyAcceptedAndNotRejectednormalizePackageOrClassNamenormalizePathpackageNameToPathpathToPackageNamerejectIsEmptysortPrefixestoString

Constructor Detail

AcceptRejectWholeStringback to summary
public AcceptRejectWholeString()

Deserialization constructor.

AcceptRejectWholeStringback to summary
public AcceptRejectWholeString(final char separatorChar)

Instantiate a new accept/reject for whole-string matches.

Parameters
separatorChar:char

the separator char

Method Detail

acceptHasPrefixback to summary
public boolean acceptHasPrefix(final String str)

Implements abstract nonapi.io.github.classgraph.scanspec.AcceptReject.acceptHasPrefix.

Check if the requested string is a prefix of an accepted string.

Parameters
str:String

the string to test

Returns:boolean

true if the string is a prefix of an accepted string

Annotations
@Override
addToAcceptback to summary
public void addToAccept(final String str)

Implements abstract nonapi.io.github.classgraph.scanspec.AcceptReject.addToAccept.

Add to the accept.

Parameters
str:String

the string to accept

Annotations
@Override
addToRejectback to summary
public void addToReject(final String str)

Implements abstract nonapi.io.github.classgraph.scanspec.AcceptReject.addToReject.

Add to the reject.

Parameters
str:String

the string to reject

Annotations
@Override
isAcceptedback to summary
public boolean isAccepted(final String str)

Implements abstract nonapi.io.github.classgraph.scanspec.AcceptReject.isAccepted.

Check if the requested string is accepted.

Parameters
str:String

the string to test

Returns:boolean

true if the string is accepted

Annotations
@Override
isAcceptedAndNotRejectedback to summary
public boolean isAcceptedAndNotRejected(final String str)

Implements abstract nonapi.io.github.classgraph.scanspec.AcceptReject.isAcceptedAndNotRejected.

Check if the requested string is accepted and not rejected.

Parameters
str:String

the string to test

Returns:boolean

true if the string is accepted and not rejected

Annotations
@Override
isRejectedback to summary
public boolean isRejected(final String str)

Implements abstract nonapi.io.github.classgraph.scanspec.AcceptReject.isRejected.

Check if the requested string is rejected.

Parameters
str:String

the string to test

Returns:boolean

true if the string is rejected

Annotations
@Override