repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
classgraph/classgraph
src/main/java/io/github/classgraph/ClasspathElement.java
ClasspathElement.checkResourcePathWhiteBlackList
protected void checkResourcePathWhiteBlackList(final String relativePath, final LogNode log) { // Whitelist/blacklist classpath elements based on file resource paths if (!scanSpec.classpathElementResourcePathWhiteBlackList.whitelistAndBlacklistAreEmpty()) { if (scanSpec.classpathElementResourcePathWhiteBlackList.isBlacklisted(relativePath)) { if (log != null) { log.log("Reached blacklisted classpath element resource path, stopping scanning: " + relativePath); } skipClasspathElement = true; return; } if (scanSpec.classpathElementResourcePathWhiteBlackList.isSpecificallyWhitelisted(relativePath)) { if (log != null) { log.log("Reached specifically whitelisted classpath element resource path: " + relativePath); } containsSpecificallyWhitelistedClasspathElementResourcePath = true; } } }
java
protected void checkResourcePathWhiteBlackList(final String relativePath, final LogNode log) { // Whitelist/blacklist classpath elements based on file resource paths if (!scanSpec.classpathElementResourcePathWhiteBlackList.whitelistAndBlacklistAreEmpty()) { if (scanSpec.classpathElementResourcePathWhiteBlackList.isBlacklisted(relativePath)) { if (log != null) { log.log("Reached blacklisted classpath element resource path, stopping scanning: " + relativePath); } skipClasspathElement = true; return; } if (scanSpec.classpathElementResourcePathWhiteBlackList.isSpecificallyWhitelisted(relativePath)) { if (log != null) { log.log("Reached specifically whitelisted classpath element resource path: " + relativePath); } containsSpecificallyWhitelistedClasspathElementResourcePath = true; } } }
[ "protected", "void", "checkResourcePathWhiteBlackList", "(", "final", "String", "relativePath", ",", "final", "LogNode", "log", ")", "{", "// Whitelist/blacklist classpath elements based on file resource paths", "if", "(", "!", "scanSpec", ".", "classpathElementResourcePathWhit...
Check relativePath against classpathElementResourcePathWhiteBlackList. @param relativePath the relative path @param log the log
[ "Check", "relativePath", "against", "classpathElementResourcePathWhiteBlackList", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClasspathElement.java#L153-L171
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClasspathElement.java
ClasspathElement.addWhitelistedResource
protected void addWhitelistedResource(final Resource resource, final ScanSpecPathMatch parentMatchStatus, final LogNode log) { final String path = resource.getPath(); final boolean isClassFile = FileUtils.isClassfile(path); boolean isWhitelisted = false; if (isClassFile) { // Check classfile scanning is enabled, and classfile is not specifically blacklisted if (scanSpec.enableClassInfo && !scanSpec.classfilePathWhiteBlackList.isBlacklisted(path)) { // ClassInfo is enabled, and found a whitelisted classfile whitelistedClassfileResources.add(resource); isWhitelisted = true; } } else { // Resources are always whitelisted if found in whitelisted directories isWhitelisted = true; } // Add resource to whitelistedResources, whether for a classfile or non-classfile resource whitelistedResources.add(resource); // Write to log if enabled, and as long as classfile scanning is not disabled, and this is not // a blacklisted classfile if (log != null && isWhitelisted) { final String type = isClassFile ? "classfile" : "resource"; String logStr; switch (parentMatchStatus) { case HAS_WHITELISTED_PATH_PREFIX: logStr = "Found " + type + " within subpackage of whitelisted package: "; break; case AT_WHITELISTED_PATH: logStr = "Found " + type + " within whitelisted package: "; break; case AT_WHITELISTED_CLASS_PACKAGE: logStr = "Found specifically-whitelisted " + type + ": "; break; default: logStr = "Found whitelisted " + type + ": "; break; } // Precede log entry sort key with "0:file:" so that file entries come before dir entries for // ClasspathElementDir classpath elements resource.scanLog = log.log("0:" + path, logStr + path + (path.equals(resource.getPathRelativeToClasspathElement()) ? "" : " ; full path: " + resource.getPathRelativeToClasspathElement())); } }
java
protected void addWhitelistedResource(final Resource resource, final ScanSpecPathMatch parentMatchStatus, final LogNode log) { final String path = resource.getPath(); final boolean isClassFile = FileUtils.isClassfile(path); boolean isWhitelisted = false; if (isClassFile) { // Check classfile scanning is enabled, and classfile is not specifically blacklisted if (scanSpec.enableClassInfo && !scanSpec.classfilePathWhiteBlackList.isBlacklisted(path)) { // ClassInfo is enabled, and found a whitelisted classfile whitelistedClassfileResources.add(resource); isWhitelisted = true; } } else { // Resources are always whitelisted if found in whitelisted directories isWhitelisted = true; } // Add resource to whitelistedResources, whether for a classfile or non-classfile resource whitelistedResources.add(resource); // Write to log if enabled, and as long as classfile scanning is not disabled, and this is not // a blacklisted classfile if (log != null && isWhitelisted) { final String type = isClassFile ? "classfile" : "resource"; String logStr; switch (parentMatchStatus) { case HAS_WHITELISTED_PATH_PREFIX: logStr = "Found " + type + " within subpackage of whitelisted package: "; break; case AT_WHITELISTED_PATH: logStr = "Found " + type + " within whitelisted package: "; break; case AT_WHITELISTED_CLASS_PACKAGE: logStr = "Found specifically-whitelisted " + type + ": "; break; default: logStr = "Found whitelisted " + type + ": "; break; } // Precede log entry sort key with "0:file:" so that file entries come before dir entries for // ClasspathElementDir classpath elements resource.scanLog = log.log("0:" + path, logStr + path + (path.equals(resource.getPathRelativeToClasspathElement()) ? "" : " ; full path: " + resource.getPathRelativeToClasspathElement())); } }
[ "protected", "void", "addWhitelistedResource", "(", "final", "Resource", "resource", ",", "final", "ScanSpecPathMatch", "parentMatchStatus", ",", "final", "LogNode", "log", ")", "{", "final", "String", "path", "=", "resource", ".", "getPath", "(", ")", ";", "fin...
Add a resource discovered during the scan. @param resource the resource @param parentMatchStatus the parent match status @param log the log
[ "Add", "a", "resource", "discovered", "during", "the", "scan", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClasspathElement.java#L239-L284
train
classgraph/classgraph
src/main/java/io/github/classgraph/ModuleInfo.java
ModuleInfo.getLocation
public URI getLocation() { if (locationURI == null) { locationURI = moduleRef != null ? moduleRef.getLocation() : null; if (locationURI == null) { locationURI = classpathElement.getURI(); } } return locationURI; }
java
public URI getLocation() { if (locationURI == null) { locationURI = moduleRef != null ? moduleRef.getLocation() : null; if (locationURI == null) { locationURI = classpathElement.getURI(); } } return locationURI; }
[ "public", "URI", "getLocation", "(", ")", "{", "if", "(", "locationURI", "==", "null", ")", "{", "locationURI", "=", "moduleRef", "!=", "null", "?", "moduleRef", ".", "getLocation", "(", ")", ":", "null", ";", "if", "(", "locationURI", "==", "null", ")...
The module location, or null for modules whose location is unknown. @return the module location, or null for modules whose location is unknown.
[ "The", "module", "location", "or", "null", "for", "modules", "whose", "location", "is", "unknown", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ModuleInfo.java#L96-L104
train
classgraph/classgraph
src/main/java/io/github/classgraph/ModuleInfo.java
ModuleInfo.addAnnotations
void addAnnotations(final AnnotationInfoList moduleAnnotations) { // Currently only class annotations are used in the module-info.class file if (moduleAnnotations != null && !moduleAnnotations.isEmpty()) { if (this.annotationInfo == null) { this.annotationInfo = new AnnotationInfoList(moduleAnnotations); } else { this.annotationInfo.addAll(moduleAnnotations); } } }
java
void addAnnotations(final AnnotationInfoList moduleAnnotations) { // Currently only class annotations are used in the module-info.class file if (moduleAnnotations != null && !moduleAnnotations.isEmpty()) { if (this.annotationInfo == null) { this.annotationInfo = new AnnotationInfoList(moduleAnnotations); } else { this.annotationInfo.addAll(moduleAnnotations); } } }
[ "void", "addAnnotations", "(", "final", "AnnotationInfoList", "moduleAnnotations", ")", "{", "// Currently only class annotations are used in the module-info.class file", "if", "(", "moduleAnnotations", "!=", "null", "&&", "!", "moduleAnnotations", ".", "isEmpty", "(", ")", ...
Add annotations found in a module descriptor classfile. @param moduleAnnotations the module annotations
[ "Add", "annotations", "found", "in", "a", "module", "descriptor", "classfile", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ModuleInfo.java#L217-L226
train
classgraph/classgraph
src/main/java/io/github/classgraph/TypeVariableSignature.java
TypeVariableSignature.parse
static TypeVariableSignature parse(final Parser parser, final String definingClassName) throws ParseException { final char peek = parser.peek(); if (peek == 'T') { parser.next(); if (!TypeUtils.getIdentifierToken(parser)) { throw new ParseException(parser, "Could not parse type variable signature"); } parser.expect(';'); final TypeVariableSignature typeVariableSignature = new TypeVariableSignature(parser.currToken(), definingClassName); // Save type variable signatures in the parser state, so method and class type signatures can link // to type signatures @SuppressWarnings("unchecked") List<TypeVariableSignature> typeVariableSignatures = (List<TypeVariableSignature>) parser.getState(); if (typeVariableSignatures == null) { parser.setState(typeVariableSignatures = new ArrayList<>()); } typeVariableSignatures.add(typeVariableSignature); return typeVariableSignature; } else { return null; } }
java
static TypeVariableSignature parse(final Parser parser, final String definingClassName) throws ParseException { final char peek = parser.peek(); if (peek == 'T') { parser.next(); if (!TypeUtils.getIdentifierToken(parser)) { throw new ParseException(parser, "Could not parse type variable signature"); } parser.expect(';'); final TypeVariableSignature typeVariableSignature = new TypeVariableSignature(parser.currToken(), definingClassName); // Save type variable signatures in the parser state, so method and class type signatures can link // to type signatures @SuppressWarnings("unchecked") List<TypeVariableSignature> typeVariableSignatures = (List<TypeVariableSignature>) parser.getState(); if (typeVariableSignatures == null) { parser.setState(typeVariableSignatures = new ArrayList<>()); } typeVariableSignatures.add(typeVariableSignature); return typeVariableSignature; } else { return null; } }
[ "static", "TypeVariableSignature", "parse", "(", "final", "Parser", "parser", ",", "final", "String", "definingClassName", ")", "throws", "ParseException", "{", "final", "char", "peek", "=", "parser", ".", "peek", "(", ")", ";", "if", "(", "peek", "==", "'",...
Parse a TypeVariableSignature. @param parser the parser @param definingClassName the defining class name @return the type variable signature @throws ParseException if parsing fails
[ "Parse", "a", "TypeVariableSignature", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/TypeVariableSignature.java#L128-L152
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/utils/LogNode.java
LogNode.logJavaInfo
private void logJavaInfo() { log("Operating system: " + VersionFinder.getProperty("os.name") + " " + VersionFinder.getProperty("os.version") + " " + VersionFinder.getProperty("os.arch")); log("Java version: " + VersionFinder.getProperty("java.version") + " / " + VersionFinder.getProperty("java.runtime.version") + " (" + VersionFinder.getProperty("java.vendor") + ")"); log("Java home: " + VersionFinder.getProperty("java.home")); final String jreRtJarPath = SystemJarFinder.getJreRtJarPath(); if (jreRtJarPath != null) { log("JRE rt.jar:").log(jreRtJarPath); } }
java
private void logJavaInfo() { log("Operating system: " + VersionFinder.getProperty("os.name") + " " + VersionFinder.getProperty("os.version") + " " + VersionFinder.getProperty("os.arch")); log("Java version: " + VersionFinder.getProperty("java.version") + " / " + VersionFinder.getProperty("java.runtime.version") + " (" + VersionFinder.getProperty("java.vendor") + ")"); log("Java home: " + VersionFinder.getProperty("java.home")); final String jreRtJarPath = SystemJarFinder.getJreRtJarPath(); if (jreRtJarPath != null) { log("JRE rt.jar:").log(jreRtJarPath); } }
[ "private", "void", "logJavaInfo", "(", ")", "{", "log", "(", "\"Operating system: \"", "+", "VersionFinder", ".", "getProperty", "(", "\"os.name\"", ")", "+", "\" \"", "+", "VersionFinder", ".", "getProperty", "(", "\"os.version\"", ")", "+", "\" \"", "+", "Ve...
Log the Java version and the JRE paths that were found.
[ "Log", "the", "Java", "version", "and", "the", "JRE", "paths", "that", "were", "found", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/utils/LogNode.java#L147-L158
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/utils/LogNode.java
LogNode.appendLine
private void appendLine(final String timeStampStr, final int indentLevel, final String line, final StringBuilder buf) { buf.append(timeStampStr); buf.append('\t'); buf.append(ClassGraph.class.getSimpleName()); buf.append('\t'); final int numDashes = 2 * (indentLevel - 1); for (int i = 0; i < numDashes; i++) { buf.append('-'); } if (numDashes > 0) { buf.append(' '); } buf.append(line); buf.append('\n'); }
java
private void appendLine(final String timeStampStr, final int indentLevel, final String line, final StringBuilder buf) { buf.append(timeStampStr); buf.append('\t'); buf.append(ClassGraph.class.getSimpleName()); buf.append('\t'); final int numDashes = 2 * (indentLevel - 1); for (int i = 0; i < numDashes; i++) { buf.append('-'); } if (numDashes > 0) { buf.append(' '); } buf.append(line); buf.append('\n'); }
[ "private", "void", "appendLine", "(", "final", "String", "timeStampStr", ",", "final", "int", "indentLevel", ",", "final", "String", "line", ",", "final", "StringBuilder", "buf", ")", "{", "buf", ".", "append", "(", "timeStampStr", ")", ";", "buf", ".", "a...
Append a line to the log output, indenting this log entry according to tree structure. @param timeStampStr the timestamp string @param indentLevel the indent level @param line the line to log @param buf the buf
[ "Append", "a", "line", "to", "the", "log", "output", "indenting", "this", "log", "entry", "according", "to", "tree", "structure", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/utils/LogNode.java#L172-L187
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/utils/LogNode.java
LogNode.addChild
private LogNode addChild(final String sortKey, final String msg, final long elapsedTimeNanos, final Throwable exception) { final String newSortKey = sortKeyPrefix + "\t" + (sortKey == null ? "" : sortKey) + "\t" + String.format("%09d", sortKeyUniqueSuffix.getAndIncrement()); final LogNode newChild = new LogNode(newSortKey, msg, elapsedTimeNanos, exception); newChild.parent = this; // Make the sort key unique, so that log entries are not clobbered if keys are reused; increment unique // suffix with each new log entry, so that ties are broken in chronological order. children.put(newSortKey, newChild); return newChild; }
java
private LogNode addChild(final String sortKey, final String msg, final long elapsedTimeNanos, final Throwable exception) { final String newSortKey = sortKeyPrefix + "\t" + (sortKey == null ? "" : sortKey) + "\t" + String.format("%09d", sortKeyUniqueSuffix.getAndIncrement()); final LogNode newChild = new LogNode(newSortKey, msg, elapsedTimeNanos, exception); newChild.parent = this; // Make the sort key unique, so that log entries are not clobbered if keys are reused; increment unique // suffix with each new log entry, so that ties are broken in chronological order. children.put(newSortKey, newChild); return newChild; }
[ "private", "LogNode", "addChild", "(", "final", "String", "sortKey", ",", "final", "String", "msg", ",", "final", "long", "elapsedTimeNanos", ",", "final", "Throwable", "exception", ")", "{", "final", "String", "newSortKey", "=", "sortKeyPrefix", "+", "\"\\t\"",...
Add a child log node. @param sortKey the sort key @param msg the log message @param elapsedTimeNanos the elapsed time in nanos @param exception the exception that was thrown @return the log node
[ "Add", "a", "child", "log", "node", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/utils/LogNode.java#L261-L271
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/utils/LogNode.java
LogNode.addChild
private LogNode addChild(final String sortKey, final String msg, final long elapsedTimeNanos) { return addChild(sortKey, msg, elapsedTimeNanos, null); }
java
private LogNode addChild(final String sortKey, final String msg, final long elapsedTimeNanos) { return addChild(sortKey, msg, elapsedTimeNanos, null); }
[ "private", "LogNode", "addChild", "(", "final", "String", "sortKey", ",", "final", "String", "msg", ",", "final", "long", "elapsedTimeNanos", ")", "{", "return", "addChild", "(", "sortKey", ",", "msg", ",", "elapsedTimeNanos", ",", "null", ")", ";", "}" ]
Add a child log node for a message. @param sortKey the sort key @param msg the log message @param elapsedTimeNanos the elapsed time in nanos @return the log node
[ "Add", "a", "child", "log", "node", "for", "a", "message", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/utils/LogNode.java#L284-L286
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/utils/LogNode.java
LogNode.log
public LogNode log(final String sortKey, final String msg, final long elapsedTimeNanos) { return addChild(sortKey, msg, elapsedTimeNanos); }
java
public LogNode log(final String sortKey, final String msg, final long elapsedTimeNanos) { return addChild(sortKey, msg, elapsedTimeNanos); }
[ "public", "LogNode", "log", "(", "final", "String", "sortKey", ",", "final", "String", "msg", ",", "final", "long", "elapsedTimeNanos", ")", "{", "return", "addChild", "(", "sortKey", ",", "msg", ",", "elapsedTimeNanos", ")", ";", "}" ]
Add a log entry with sort key for deterministic ordering. @param sortKey The sort key for the log entry. @param msg The message. @param elapsedTimeNanos The elapsed time. @return a child log node, which can be used to add sub-entries.
[ "Add", "a", "log", "entry", "with", "sort", "key", "for", "deterministic", "ordering", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/utils/LogNode.java#L327-L329
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/utils/LogNode.java
LogNode.log
public LogNode log(final String msg, final Throwable e) { return addChild("", msg, -1L).addChild(e); }
java
public LogNode log(final String msg, final Throwable e) { return addChild("", msg, -1L).addChild(e); }
[ "public", "LogNode", "log", "(", "final", "String", "msg", ",", "final", "Throwable", "e", ")", "{", "return", "addChild", "(", "\"\"", ",", "msg", ",", "-", "1L", ")", ".", "addChild", "(", "e", ")", ";", "}" ]
Add a log entry. @param msg The message. @param e The {@link Throwable} that was thrown. @return a child log node, which can be used to add sub-entries.
[ "Add", "a", "log", "entry", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/utils/LogNode.java#L396-L398
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/utils/LogNode.java
LogNode.log
public LogNode log(final Collection<String> msgs) { LogNode last = null; for (final String m : msgs) { last = log(m); } return last; }
java
public LogNode log(final Collection<String> msgs) { LogNode last = null; for (final String m : msgs) { last = log(m); } return last; }
[ "public", "LogNode", "log", "(", "final", "Collection", "<", "String", ">", "msgs", ")", "{", "LogNode", "last", "=", "null", ";", "for", "(", "final", "String", "m", ":", "msgs", ")", "{", "last", "=", "log", "(", "m", ")", ";", "}", "return", "...
Add a series of log entries. Returns the last LogNode created. @param msgs The messages. @return the last log node created, which can be used to add sub-entries.
[ "Add", "a", "series", "of", "log", "entries", ".", "Returns", "the", "last", "LogNode", "created", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/utils/LogNode.java#L418-L424
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/utils/LogNode.java
LogNode.flush
public void flush() { if (parent != null) { throw new IllegalArgumentException("Only flush the toplevel LogNode"); } if (!children.isEmpty()) { final String logOutput = this.toString(); this.children.clear(); log.info(logOutput); } }
java
public void flush() { if (parent != null) { throw new IllegalArgumentException("Only flush the toplevel LogNode"); } if (!children.isEmpty()) { final String logOutput = this.toString(); this.children.clear(); log.info(logOutput); } }
[ "public", "void", "flush", "(", ")", "{", "if", "(", "parent", "!=", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Only flush the toplevel LogNode\"", ")", ";", "}", "if", "(", "!", "children", ".", "isEmpty", "(", ")", ")", "{", ...
Flush out the log to stderr, and clear the log contents. Only call this on the toplevel log node, when threads do not have access to references of internal log nodes so that they cannot add more log entries inside the tree, otherwise log entries may be lost.
[ "Flush", "out", "the", "log", "to", "stderr", "and", "clear", "the", "log", "contents", ".", "Only", "call", "this", "on", "the", "toplevel", "log", "node", "when", "threads", "do", "not", "have", "access", "to", "references", "of", "internal", "log", "n...
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/utils/LogNode.java#L442-L451
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/concurrency/InterruptionChecker.java
InterruptionChecker.checkAndReturn
public boolean checkAndReturn() { // Check if any thread has been interrupted if (interrupted.get()) { // If so, interrupt this thread interrupt(); return true; } // Check if this thread has been interrupted if (Thread.currentThread().isInterrupted()) { // If so, interrupt other threads interrupted.set(true); return true; } return false; }
java
public boolean checkAndReturn() { // Check if any thread has been interrupted if (interrupted.get()) { // If so, interrupt this thread interrupt(); return true; } // Check if this thread has been interrupted if (Thread.currentThread().isInterrupted()) { // If so, interrupt other threads interrupted.set(true); return true; } return false; }
[ "public", "boolean", "checkAndReturn", "(", ")", "{", "// Check if any thread has been interrupted", "if", "(", "interrupted", ".", "get", "(", ")", ")", "{", "// If so, interrupt this thread", "interrupt", "(", ")", ";", "return", "true", ";", "}", "// Check if thi...
Check for interruption and return interruption status. @return true if this thread or any other thread that shares this InterruptionChecker instance has been interrupted or has thrown an exception.
[ "Check", "for", "interruption", "and", "return", "interruption", "status", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/concurrency/InterruptionChecker.java#L97-L111
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/concurrency/InterruptionChecker.java
InterruptionChecker.check
public void check() throws InterruptedException, ExecutionException { // If a thread threw an uncaught exception, re-throw it. final ExecutionException executionException = getExecutionException(); if (executionException != null) { throw executionException; } // If this thread or another thread has been interrupted, throw InterruptedException if (checkAndReturn()) { throw new InterruptedException(); } }
java
public void check() throws InterruptedException, ExecutionException { // If a thread threw an uncaught exception, re-throw it. final ExecutionException executionException = getExecutionException(); if (executionException != null) { throw executionException; } // If this thread or another thread has been interrupted, throw InterruptedException if (checkAndReturn()) { throw new InterruptedException(); } }
[ "public", "void", "check", "(", ")", "throws", "InterruptedException", ",", "ExecutionException", "{", "// If a thread threw an uncaught exception, re-throw it.", "final", "ExecutionException", "executionException", "=", "getExecutionException", "(", ")", ";", "if", "(", "e...
Check if this thread or any other thread that shares this InterruptionChecker instance has been interrupted or has thrown an exception, and if so, throw InterruptedException. @throws InterruptedException If a thread has been interrupted. @throws ExecutionException if a thread has thrown an uncaught exception.
[ "Check", "if", "this", "thread", "or", "any", "other", "thread", "that", "shares", "this", "InterruptionChecker", "instance", "has", "been", "interrupted", "or", "has", "thrown", "an", "exception", "and", "if", "so", "throw", "InterruptedException", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/concurrency/InterruptionChecker.java#L122-L132
train
classgraph/classgraph
src/main/java/io/github/classgraph/ModuleRef.java
ModuleRef.isSystemModule
public boolean isSystemModule() { if (name == null || name.isEmpty()) { return false; } return name.startsWith("java.") || name.startsWith("jdk.") || name.startsWith("javafx.") || name.startsWith("oracle."); }
java
public boolean isSystemModule() { if (name == null || name.isEmpty()) { return false; } return name.startsWith("java.") || name.startsWith("jdk.") || name.startsWith("javafx.") || name.startsWith("oracle."); }
[ "public", "boolean", "isSystemModule", "(", ")", "{", "if", "(", "name", "==", "null", "||", "name", ".", "isEmpty", "(", ")", ")", "{", "return", "false", ";", "}", "return", "name", ".", "startsWith", "(", "\"java.\"", ")", "||", "name", ".", "star...
Checks if this module is a system module. @return true if this module is a system module.
[ "Checks", "if", "this", "module", "is", "a", "system", "module", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ModuleRef.java#L245-L251
train
classgraph/classgraph
src/main/java/io/github/classgraph/MethodTypeSignature.java
MethodTypeSignature.parse
static MethodTypeSignature parse(final String typeDescriptor, final String definingClassName) throws ParseException { if (typeDescriptor.equals("<init>")) { // Special case for instance initialization method signatures in a CONSTANT_NameAndType_info structure: // https://docs.oracle.com/javase/specs/jvms/se11/html/jvms-4.html#jvms-4.4.2 return new MethodTypeSignature(Collections.<TypeParameter> emptyList(), Collections.<TypeSignature> emptyList(), new BaseTypeSignature("void"), Collections.<ClassRefOrTypeVariableSignature> emptyList()); } final Parser parser = new Parser(typeDescriptor); final List<TypeParameter> typeParameters = TypeParameter.parseList(parser, definingClassName); parser.expect('('); final List<TypeSignature> paramTypes = new ArrayList<>(); while (parser.peek() != ')') { if (!parser.hasMore()) { throw new ParseException(parser, "Ran out of input while parsing method signature"); } final TypeSignature paramType = TypeSignature.parse(parser, definingClassName); if (paramType == null) { throw new ParseException(parser, "Missing method parameter type signature"); } paramTypes.add(paramType); } parser.expect(')'); final TypeSignature resultType = TypeSignature.parse(parser, definingClassName); if (resultType == null) { throw new ParseException(parser, "Missing method result type signature"); } List<ClassRefOrTypeVariableSignature> throwsSignatures; if (parser.peek() == '^') { throwsSignatures = new ArrayList<>(); while (parser.peek() == '^') { parser.expect('^'); final ClassRefTypeSignature classTypeSignature = ClassRefTypeSignature.parse(parser, definingClassName); if (classTypeSignature != null) { throwsSignatures.add(classTypeSignature); } else { final TypeVariableSignature typeVariableSignature = TypeVariableSignature.parse(parser, definingClassName); if (typeVariableSignature != null) { throwsSignatures.add(typeVariableSignature); } else { throw new ParseException(parser, "Missing type variable signature"); } } } } else { throwsSignatures = Collections.emptyList(); } if (parser.hasMore()) { throw new ParseException(parser, "Extra characters at end of type descriptor"); } final MethodTypeSignature methodSignature = new MethodTypeSignature(typeParameters, paramTypes, resultType, throwsSignatures); // Add back-links from type variable signature to the method signature it is part of, // and to the enclosing class' type signature @SuppressWarnings("unchecked") final List<TypeVariableSignature> typeVariableSignatures = (List<TypeVariableSignature>) parser.getState(); if (typeVariableSignatures != null) { for (final TypeVariableSignature typeVariableSignature : typeVariableSignatures) { typeVariableSignature.containingMethodSignature = methodSignature; } } return methodSignature; }
java
static MethodTypeSignature parse(final String typeDescriptor, final String definingClassName) throws ParseException { if (typeDescriptor.equals("<init>")) { // Special case for instance initialization method signatures in a CONSTANT_NameAndType_info structure: // https://docs.oracle.com/javase/specs/jvms/se11/html/jvms-4.html#jvms-4.4.2 return new MethodTypeSignature(Collections.<TypeParameter> emptyList(), Collections.<TypeSignature> emptyList(), new BaseTypeSignature("void"), Collections.<ClassRefOrTypeVariableSignature> emptyList()); } final Parser parser = new Parser(typeDescriptor); final List<TypeParameter> typeParameters = TypeParameter.parseList(parser, definingClassName); parser.expect('('); final List<TypeSignature> paramTypes = new ArrayList<>(); while (parser.peek() != ')') { if (!parser.hasMore()) { throw new ParseException(parser, "Ran out of input while parsing method signature"); } final TypeSignature paramType = TypeSignature.parse(parser, definingClassName); if (paramType == null) { throw new ParseException(parser, "Missing method parameter type signature"); } paramTypes.add(paramType); } parser.expect(')'); final TypeSignature resultType = TypeSignature.parse(parser, definingClassName); if (resultType == null) { throw new ParseException(parser, "Missing method result type signature"); } List<ClassRefOrTypeVariableSignature> throwsSignatures; if (parser.peek() == '^') { throwsSignatures = new ArrayList<>(); while (parser.peek() == '^') { parser.expect('^'); final ClassRefTypeSignature classTypeSignature = ClassRefTypeSignature.parse(parser, definingClassName); if (classTypeSignature != null) { throwsSignatures.add(classTypeSignature); } else { final TypeVariableSignature typeVariableSignature = TypeVariableSignature.parse(parser, definingClassName); if (typeVariableSignature != null) { throwsSignatures.add(typeVariableSignature); } else { throw new ParseException(parser, "Missing type variable signature"); } } } } else { throwsSignatures = Collections.emptyList(); } if (parser.hasMore()) { throw new ParseException(parser, "Extra characters at end of type descriptor"); } final MethodTypeSignature methodSignature = new MethodTypeSignature(typeParameters, paramTypes, resultType, throwsSignatures); // Add back-links from type variable signature to the method signature it is part of, // and to the enclosing class' type signature @SuppressWarnings("unchecked") final List<TypeVariableSignature> typeVariableSignatures = (List<TypeVariableSignature>) parser.getState(); if (typeVariableSignatures != null) { for (final TypeVariableSignature typeVariableSignature : typeVariableSignatures) { typeVariableSignature.containingMethodSignature = methodSignature; } } return methodSignature; }
[ "static", "MethodTypeSignature", "parse", "(", "final", "String", "typeDescriptor", ",", "final", "String", "definingClassName", ")", "throws", "ParseException", "{", "if", "(", "typeDescriptor", ".", "equals", "(", "\"<init>\"", ")", ")", "{", "// Special case for ...
Parse a method signature. @param typeDescriptor The type descriptor of the method. @param definingClassName The name of the defining class (for resolving type variables). @return The parsed method type signature. @throws ParseException If method type signature could not be parsed.
[ "Parse", "a", "method", "signature", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/MethodTypeSignature.java#L131-L196
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/json/JSONArray.java
JSONArray.toJSONString
void toJSONString(final Map<ReferenceEqualityKey<JSONReference>, CharSequence> jsonReferenceToId, final boolean includeNullValuedFields, final int depth, final int indentWidth, final StringBuilder buf) { final boolean prettyPrint = indentWidth > 0; final int n = items.size(); if (n == 0) { buf.append("[]"); } else { buf.append('['); if (prettyPrint) { buf.append('\n'); } for (int i = 0; i < n; i++) { final Object item = items.get(i); if (prettyPrint) { JSONUtils.indent(depth + 1, indentWidth, buf); } JSONSerializer.jsonValToJSONString(item, jsonReferenceToId, includeNullValuedFields, depth + 1, indentWidth, buf); if (i < n - 1) { buf.append(','); } if (prettyPrint) { buf.append('\n'); } } if (prettyPrint) { JSONUtils.indent(depth, indentWidth, buf); } buf.append(']'); } }
java
void toJSONString(final Map<ReferenceEqualityKey<JSONReference>, CharSequence> jsonReferenceToId, final boolean includeNullValuedFields, final int depth, final int indentWidth, final StringBuilder buf) { final boolean prettyPrint = indentWidth > 0; final int n = items.size(); if (n == 0) { buf.append("[]"); } else { buf.append('['); if (prettyPrint) { buf.append('\n'); } for (int i = 0; i < n; i++) { final Object item = items.get(i); if (prettyPrint) { JSONUtils.indent(depth + 1, indentWidth, buf); } JSONSerializer.jsonValToJSONString(item, jsonReferenceToId, includeNullValuedFields, depth + 1, indentWidth, buf); if (i < n - 1) { buf.append(','); } if (prettyPrint) { buf.append('\n'); } } if (prettyPrint) { JSONUtils.indent(depth, indentWidth, buf); } buf.append(']'); } }
[ "void", "toJSONString", "(", "final", "Map", "<", "ReferenceEqualityKey", "<", "JSONReference", ">", ",", "CharSequence", ">", "jsonReferenceToId", ",", "final", "boolean", "includeNullValuedFields", ",", "final", "int", "depth", ",", "final", "int", "indentWidth", ...
Serialize this JSONArray to a string. @param jsonReferenceToId the map from json reference to id @param includeNullValuedFields whether to include null-valued fields @param depth the nesting depth @param indentWidth the indent width @param buf the buf
[ "Serialize", "this", "JSONArray", "to", "a", "string", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/json/JSONArray.java#L71-L102
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassInfo.java
ClassInfo.addRelatedClass
boolean addRelatedClass(final RelType relType, final ClassInfo classInfo) { Set<ClassInfo> classInfoSet = relatedClasses.get(relType); if (classInfoSet == null) { relatedClasses.put(relType, classInfoSet = new LinkedHashSet<>(4)); } return classInfoSet.add(classInfo); }
java
boolean addRelatedClass(final RelType relType, final ClassInfo classInfo) { Set<ClassInfo> classInfoSet = relatedClasses.get(relType); if (classInfoSet == null) { relatedClasses.put(relType, classInfoSet = new LinkedHashSet<>(4)); } return classInfoSet.add(classInfo); }
[ "boolean", "addRelatedClass", "(", "final", "RelType", "relType", ",", "final", "ClassInfo", "classInfo", ")", "{", "Set", "<", "ClassInfo", ">", "classInfoSet", "=", "relatedClasses", ".", "get", "(", "relType", ")", ";", "if", "(", "classInfoSet", "==", "n...
Add a class with a given relationship type. Return whether the collection changed as a result of the call. @param relType the {@link RelType} @param classInfo the {@link ClassInfo} @return true, if successful
[ "Add", "a", "class", "with", "a", "given", "relationship", "type", ".", "Return", "whether", "the", "collection", "changed", "as", "a", "result", "of", "the", "call", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassInfo.java#L287-L293
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassInfo.java
ClassInfo.getOrCreateClassInfo
static ClassInfo getOrCreateClassInfo(final String className, final int classModifiers, final Map<String, ClassInfo> classNameToClassInfo) { ClassInfo classInfo = classNameToClassInfo.get(className); if (classInfo == null) { classNameToClassInfo.put(className, classInfo = new ClassInfo(className, classModifiers, /* classfileResource = */ null)); } classInfo.setModifiers(classModifiers); return classInfo; }
java
static ClassInfo getOrCreateClassInfo(final String className, final int classModifiers, final Map<String, ClassInfo> classNameToClassInfo) { ClassInfo classInfo = classNameToClassInfo.get(className); if (classInfo == null) { classNameToClassInfo.put(className, classInfo = new ClassInfo(className, classModifiers, /* classfileResource = */ null)); } classInfo.setModifiers(classModifiers); return classInfo; }
[ "static", "ClassInfo", "getOrCreateClassInfo", "(", "final", "String", "className", ",", "final", "int", "classModifiers", ",", "final", "Map", "<", "String", ",", "ClassInfo", ">", "classNameToClassInfo", ")", "{", "ClassInfo", "classInfo", "=", "classNameToClassIn...
Get a ClassInfo object, or create it if it doesn't exist. N.B. not threadsafe, so ClassInfo objects should only ever be constructed by a single thread. @param className the class name @param classModifiers the class modifiers @param classNameToClassInfo the map from class name to class info @return the or create class info
[ "Get", "a", "ClassInfo", "object", "or", "create", "it", "if", "it", "doesn", "t", "exist", ".", "N", ".", "B", ".", "not", "threadsafe", "so", "ClassInfo", "objects", "should", "only", "ever", "be", "constructed", "by", "a", "single", "thread", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassInfo.java#L309-L318
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassInfo.java
ClassInfo.setModifiers
void setModifiers(final int modifiers) { this.modifiers |= modifiers; if ((modifiers & ANNOTATION_CLASS_MODIFIER) != 0) { this.isAnnotation = true; } if ((modifiers & Modifier.INTERFACE) != 0) { this.isInterface = true; } }
java
void setModifiers(final int modifiers) { this.modifiers |= modifiers; if ((modifiers & ANNOTATION_CLASS_MODIFIER) != 0) { this.isAnnotation = true; } if ((modifiers & Modifier.INTERFACE) != 0) { this.isInterface = true; } }
[ "void", "setModifiers", "(", "final", "int", "modifiers", ")", "{", "this", ".", "modifiers", "|=", "modifiers", ";", "if", "(", "(", "modifiers", "&", "ANNOTATION_CLASS_MODIFIER", ")", "!=", "0", ")", "{", "this", ".", "isAnnotation", "=", "true", ";", ...
Set class modifiers. @param modifiers the class modifiers
[ "Set", "class", "modifiers", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassInfo.java#L326-L334
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassInfo.java
ClassInfo.addSuperclass
void addSuperclass(final String superclassName, final Map<String, ClassInfo> classNameToClassInfo) { if (superclassName != null && !superclassName.equals("java.lang.Object")) { final ClassInfo superclassClassInfo = getOrCreateClassInfo(superclassName, /* classModifiers = */ 0, classNameToClassInfo); this.addRelatedClass(RelType.SUPERCLASSES, superclassClassInfo); superclassClassInfo.addRelatedClass(RelType.SUBCLASSES, this); } }
java
void addSuperclass(final String superclassName, final Map<String, ClassInfo> classNameToClassInfo) { if (superclassName != null && !superclassName.equals("java.lang.Object")) { final ClassInfo superclassClassInfo = getOrCreateClassInfo(superclassName, /* classModifiers = */ 0, classNameToClassInfo); this.addRelatedClass(RelType.SUPERCLASSES, superclassClassInfo); superclassClassInfo.addRelatedClass(RelType.SUBCLASSES, this); } }
[ "void", "addSuperclass", "(", "final", "String", "superclassName", ",", "final", "Map", "<", "String", ",", "ClassInfo", ">", "classNameToClassInfo", ")", "{", "if", "(", "superclassName", "!=", "null", "&&", "!", "superclassName", ".", "equals", "(", "\"java....
Add a superclass to this class. @param superclassName the superclass name @param classNameToClassInfo the map from class name to class info
[ "Add", "a", "superclass", "to", "this", "class", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassInfo.java#L366-L373
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassInfo.java
ClassInfo.addImplementedInterface
void addImplementedInterface(final String interfaceName, final Map<String, ClassInfo> classNameToClassInfo) { final ClassInfo interfaceClassInfo = getOrCreateClassInfo(interfaceName, /* classModifiers = */ Modifier.INTERFACE, classNameToClassInfo); interfaceClassInfo.isInterface = true; interfaceClassInfo.modifiers |= Modifier.INTERFACE; this.addRelatedClass(RelType.IMPLEMENTED_INTERFACES, interfaceClassInfo); interfaceClassInfo.addRelatedClass(RelType.CLASSES_IMPLEMENTING, this); }
java
void addImplementedInterface(final String interfaceName, final Map<String, ClassInfo> classNameToClassInfo) { final ClassInfo interfaceClassInfo = getOrCreateClassInfo(interfaceName, /* classModifiers = */ Modifier.INTERFACE, classNameToClassInfo); interfaceClassInfo.isInterface = true; interfaceClassInfo.modifiers |= Modifier.INTERFACE; this.addRelatedClass(RelType.IMPLEMENTED_INTERFACES, interfaceClassInfo); interfaceClassInfo.addRelatedClass(RelType.CLASSES_IMPLEMENTING, this); }
[ "void", "addImplementedInterface", "(", "final", "String", "interfaceName", ",", "final", "Map", "<", "String", ",", "ClassInfo", ">", "classNameToClassInfo", ")", "{", "final", "ClassInfo", "interfaceClassInfo", "=", "getOrCreateClassInfo", "(", "interfaceName", ",",...
Add an implemented interface to this class. @param interfaceName the interface name @param classNameToClassInfo the map from class name to class info
[ "Add", "an", "implemented", "interface", "to", "this", "class", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassInfo.java#L383-L390
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassInfo.java
ClassInfo.addClassContainment
static void addClassContainment(final List<SimpleEntry<String, String>> classContainmentEntries, final Map<String, ClassInfo> classNameToClassInfo) { for (final SimpleEntry<String, String> ent : classContainmentEntries) { final String innerClassName = ent.getKey(); final ClassInfo innerClassInfo = ClassInfo.getOrCreateClassInfo(innerClassName, /* classModifiers = */ 0, classNameToClassInfo); final String outerClassName = ent.getValue(); final ClassInfo outerClassInfo = ClassInfo.getOrCreateClassInfo(outerClassName, /* classModifiers = */ 0, classNameToClassInfo); innerClassInfo.addRelatedClass(RelType.CONTAINED_WITHIN_OUTER_CLASS, outerClassInfo); outerClassInfo.addRelatedClass(RelType.CONTAINS_INNER_CLASS, innerClassInfo); } }
java
static void addClassContainment(final List<SimpleEntry<String, String>> classContainmentEntries, final Map<String, ClassInfo> classNameToClassInfo) { for (final SimpleEntry<String, String> ent : classContainmentEntries) { final String innerClassName = ent.getKey(); final ClassInfo innerClassInfo = ClassInfo.getOrCreateClassInfo(innerClassName, /* classModifiers = */ 0, classNameToClassInfo); final String outerClassName = ent.getValue(); final ClassInfo outerClassInfo = ClassInfo.getOrCreateClassInfo(outerClassName, /* classModifiers = */ 0, classNameToClassInfo); innerClassInfo.addRelatedClass(RelType.CONTAINED_WITHIN_OUTER_CLASS, outerClassInfo); outerClassInfo.addRelatedClass(RelType.CONTAINS_INNER_CLASS, innerClassInfo); } }
[ "static", "void", "addClassContainment", "(", "final", "List", "<", "SimpleEntry", "<", "String", ",", "String", ">", ">", "classContainmentEntries", ",", "final", "Map", "<", "String", ",", "ClassInfo", ">", "classNameToClassInfo", ")", "{", "for", "(", "fina...
Add class containment info. @param classContainmentEntries the class containment entries @param classNameToClassInfo the map from class name to class info
[ "Add", "class", "containment", "info", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassInfo.java#L400-L412
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassInfo.java
ClassInfo.addClassAnnotation
void addClassAnnotation(final AnnotationInfo classAnnotationInfo, final Map<String, ClassInfo> classNameToClassInfo) { final ClassInfo annotationClassInfo = getOrCreateClassInfo(classAnnotationInfo.getName(), ANNOTATION_CLASS_MODIFIER, classNameToClassInfo); if (this.annotationInfo == null) { this.annotationInfo = new AnnotationInfoList(2); } this.annotationInfo.add(classAnnotationInfo); this.addRelatedClass(RelType.CLASS_ANNOTATIONS, annotationClassInfo); annotationClassInfo.addRelatedClass(RelType.CLASSES_WITH_ANNOTATION, this); // Record use of @Inherited meta-annotation if (classAnnotationInfo.getName().equals(Inherited.class.getName())) { isInherited = true; } }
java
void addClassAnnotation(final AnnotationInfo classAnnotationInfo, final Map<String, ClassInfo> classNameToClassInfo) { final ClassInfo annotationClassInfo = getOrCreateClassInfo(classAnnotationInfo.getName(), ANNOTATION_CLASS_MODIFIER, classNameToClassInfo); if (this.annotationInfo == null) { this.annotationInfo = new AnnotationInfoList(2); } this.annotationInfo.add(classAnnotationInfo); this.addRelatedClass(RelType.CLASS_ANNOTATIONS, annotationClassInfo); annotationClassInfo.addRelatedClass(RelType.CLASSES_WITH_ANNOTATION, this); // Record use of @Inherited meta-annotation if (classAnnotationInfo.getName().equals(Inherited.class.getName())) { isInherited = true; } }
[ "void", "addClassAnnotation", "(", "final", "AnnotationInfo", "classAnnotationInfo", ",", "final", "Map", "<", "String", ",", "ClassInfo", ">", "classNameToClassInfo", ")", "{", "final", "ClassInfo", "annotationClassInfo", "=", "getOrCreateClassInfo", "(", "classAnnotat...
Add an annotation to this class. @param classAnnotationInfo the class annotation info @param classNameToClassInfo the map from class name to class info
[ "Add", "an", "annotation", "to", "this", "class", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassInfo.java#L432-L448
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassInfo.java
ClassInfo.addFieldOrMethodAnnotationInfo
private void addFieldOrMethodAnnotationInfo(final AnnotationInfoList annotationInfoList, final boolean isField, final Map<String, ClassInfo> classNameToClassInfo) { if (annotationInfoList != null) { for (final AnnotationInfo fieldAnnotationInfo : annotationInfoList) { final ClassInfo annotationClassInfo = getOrCreateClassInfo(fieldAnnotationInfo.getName(), ANNOTATION_CLASS_MODIFIER, classNameToClassInfo); // Mark this class as having a field or method with this annotation this.addRelatedClass(isField ? RelType.FIELD_ANNOTATIONS : RelType.METHOD_ANNOTATIONS, annotationClassInfo); annotationClassInfo.addRelatedClass( isField ? RelType.CLASSES_WITH_FIELD_ANNOTATION : RelType.CLASSES_WITH_METHOD_ANNOTATION, this); } } }
java
private void addFieldOrMethodAnnotationInfo(final AnnotationInfoList annotationInfoList, final boolean isField, final Map<String, ClassInfo> classNameToClassInfo) { if (annotationInfoList != null) { for (final AnnotationInfo fieldAnnotationInfo : annotationInfoList) { final ClassInfo annotationClassInfo = getOrCreateClassInfo(fieldAnnotationInfo.getName(), ANNOTATION_CLASS_MODIFIER, classNameToClassInfo); // Mark this class as having a field or method with this annotation this.addRelatedClass(isField ? RelType.FIELD_ANNOTATIONS : RelType.METHOD_ANNOTATIONS, annotationClassInfo); annotationClassInfo.addRelatedClass( isField ? RelType.CLASSES_WITH_FIELD_ANNOTATION : RelType.CLASSES_WITH_METHOD_ANNOTATION, this); } } }
[ "private", "void", "addFieldOrMethodAnnotationInfo", "(", "final", "AnnotationInfoList", "annotationInfoList", ",", "final", "boolean", "isField", ",", "final", "Map", "<", "String", ",", "ClassInfo", ">", "classNameToClassInfo", ")", "{", "if", "(", "annotationInfoLi...
Add field or method annotation cross-links. @param annotationInfoList the annotation info list @param isField the is field @param classNameToClassInfo the map from class name to class info
[ "Add", "field", "or", "method", "annotation", "cross", "-", "links", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassInfo.java#L460-L474
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassInfo.java
ClassInfo.addFieldInfo
void addFieldInfo(final FieldInfoList fieldInfoList, final Map<String, ClassInfo> classNameToClassInfo) { for (final FieldInfo fi : fieldInfoList) { // Index field annotations addFieldOrMethodAnnotationInfo(fi.annotationInfo, /* isField = */ true, classNameToClassInfo); } if (this.fieldInfo == null) { this.fieldInfo = fieldInfoList; } else { this.fieldInfo.addAll(fieldInfoList); } }
java
void addFieldInfo(final FieldInfoList fieldInfoList, final Map<String, ClassInfo> classNameToClassInfo) { for (final FieldInfo fi : fieldInfoList) { // Index field annotations addFieldOrMethodAnnotationInfo(fi.annotationInfo, /* isField = */ true, classNameToClassInfo); } if (this.fieldInfo == null) { this.fieldInfo = fieldInfoList; } else { this.fieldInfo.addAll(fieldInfoList); } }
[ "void", "addFieldInfo", "(", "final", "FieldInfoList", "fieldInfoList", ",", "final", "Map", "<", "String", ",", "ClassInfo", ">", "classNameToClassInfo", ")", "{", "for", "(", "final", "FieldInfo", "fi", ":", "fieldInfoList", ")", "{", "// Index field annotations...
Add field info. @param fieldInfoList the field info list @param classNameToClassInfo the map from class name to class info
[ "Add", "field", "info", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassInfo.java#L484-L494
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassInfo.java
ClassInfo.addMethodInfo
void addMethodInfo(final MethodInfoList methodInfoList, final Map<String, ClassInfo> classNameToClassInfo) { for (final MethodInfo mi : methodInfoList) { // Index method annotations addFieldOrMethodAnnotationInfo(mi.annotationInfo, /* isField = */ false, classNameToClassInfo); // Index method parameter annotations if (mi.parameterAnnotationInfo != null) { for (int i = 0; i < mi.parameterAnnotationInfo.length; i++) { final AnnotationInfo[] paramAnnotationInfoArr = mi.parameterAnnotationInfo[i]; if (paramAnnotationInfoArr != null) { for (int j = 0; j < paramAnnotationInfoArr.length; j++) { final AnnotationInfo methodParamAnnotationInfo = paramAnnotationInfoArr[j]; final ClassInfo annotationClassInfo = getOrCreateClassInfo( methodParamAnnotationInfo.getName(), ANNOTATION_CLASS_MODIFIER, classNameToClassInfo); annotationClassInfo.addRelatedClass(RelType.CLASSES_WITH_METHOD_PARAMETER_ANNOTATION, this); this.addRelatedClass(RelType.METHOD_PARAMETER_ANNOTATIONS, annotationClassInfo); } } } } } if (this.methodInfo == null) { this.methodInfo = methodInfoList; } else { this.methodInfo.addAll(methodInfoList); } }
java
void addMethodInfo(final MethodInfoList methodInfoList, final Map<String, ClassInfo> classNameToClassInfo) { for (final MethodInfo mi : methodInfoList) { // Index method annotations addFieldOrMethodAnnotationInfo(mi.annotationInfo, /* isField = */ false, classNameToClassInfo); // Index method parameter annotations if (mi.parameterAnnotationInfo != null) { for (int i = 0; i < mi.parameterAnnotationInfo.length; i++) { final AnnotationInfo[] paramAnnotationInfoArr = mi.parameterAnnotationInfo[i]; if (paramAnnotationInfoArr != null) { for (int j = 0; j < paramAnnotationInfoArr.length; j++) { final AnnotationInfo methodParamAnnotationInfo = paramAnnotationInfoArr[j]; final ClassInfo annotationClassInfo = getOrCreateClassInfo( methodParamAnnotationInfo.getName(), ANNOTATION_CLASS_MODIFIER, classNameToClassInfo); annotationClassInfo.addRelatedClass(RelType.CLASSES_WITH_METHOD_PARAMETER_ANNOTATION, this); this.addRelatedClass(RelType.METHOD_PARAMETER_ANNOTATIONS, annotationClassInfo); } } } } } if (this.methodInfo == null) { this.methodInfo = methodInfoList; } else { this.methodInfo.addAll(methodInfoList); } }
[ "void", "addMethodInfo", "(", "final", "MethodInfoList", "methodInfoList", ",", "final", "Map", "<", "String", ",", "ClassInfo", ">", "classNameToClassInfo", ")", "{", "for", "(", "final", "MethodInfo", "mi", ":", "methodInfoList", ")", "{", "// Index method annot...
Add method info. @param methodInfoList the method info list @param classNameToClassInfo the map from class name to class info
[ "Add", "method", "info", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassInfo.java#L504-L532
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassInfo.java
ClassInfo.filterClassInfo
private static Set<ClassInfo> filterClassInfo(final Collection<ClassInfo> classes, final ScanSpec scanSpec, final boolean strictWhitelist, final ClassType... classTypes) { if (classes == null) { return Collections.<ClassInfo> emptySet(); } boolean includeAllTypes = classTypes.length == 0; boolean includeStandardClasses = false; boolean includeImplementedInterfaces = false; boolean includeAnnotations = false; for (final ClassType classType : classTypes) { switch (classType) { case ALL: includeAllTypes = true; break; case STANDARD_CLASS: includeStandardClasses = true; break; case IMPLEMENTED_INTERFACE: includeImplementedInterfaces = true; break; case ANNOTATION: includeAnnotations = true; break; case INTERFACE_OR_ANNOTATION: includeImplementedInterfaces = includeAnnotations = true; break; default: throw new IllegalArgumentException("Unknown ClassType: " + classType); } } if (includeStandardClasses && includeImplementedInterfaces && includeAnnotations) { includeAllTypes = true; } final Set<ClassInfo> classInfoSetFiltered = new LinkedHashSet<>(classes.size()); for (final ClassInfo classInfo : classes) { // Check class type against requested type(s) if ((includeAllTypes // || includeStandardClasses && classInfo.isStandardClass() || includeImplementedInterfaces && classInfo.isImplementedInterface() || includeAnnotations && classInfo.isAnnotation()) // // Always check blacklist && !scanSpec.classOrPackageIsBlacklisted(classInfo.name) // // Always return whitelisted classes, or external classes if enableExternalClasses is true && (!classInfo.isExternalClass || scanSpec.enableExternalClasses // Return external (non-whitelisted) classes if viewing class hierarchy "upwards" || !strictWhitelist)) { // Class passed strict whitelist criteria classInfoSetFiltered.add(classInfo); } } return classInfoSetFiltered; }
java
private static Set<ClassInfo> filterClassInfo(final Collection<ClassInfo> classes, final ScanSpec scanSpec, final boolean strictWhitelist, final ClassType... classTypes) { if (classes == null) { return Collections.<ClassInfo> emptySet(); } boolean includeAllTypes = classTypes.length == 0; boolean includeStandardClasses = false; boolean includeImplementedInterfaces = false; boolean includeAnnotations = false; for (final ClassType classType : classTypes) { switch (classType) { case ALL: includeAllTypes = true; break; case STANDARD_CLASS: includeStandardClasses = true; break; case IMPLEMENTED_INTERFACE: includeImplementedInterfaces = true; break; case ANNOTATION: includeAnnotations = true; break; case INTERFACE_OR_ANNOTATION: includeImplementedInterfaces = includeAnnotations = true; break; default: throw new IllegalArgumentException("Unknown ClassType: " + classType); } } if (includeStandardClasses && includeImplementedInterfaces && includeAnnotations) { includeAllTypes = true; } final Set<ClassInfo> classInfoSetFiltered = new LinkedHashSet<>(classes.size()); for (final ClassInfo classInfo : classes) { // Check class type against requested type(s) if ((includeAllTypes // || includeStandardClasses && classInfo.isStandardClass() || includeImplementedInterfaces && classInfo.isImplementedInterface() || includeAnnotations && classInfo.isAnnotation()) // // Always check blacklist && !scanSpec.classOrPackageIsBlacklisted(classInfo.name) // // Always return whitelisted classes, or external classes if enableExternalClasses is true && (!classInfo.isExternalClass || scanSpec.enableExternalClasses // Return external (non-whitelisted) classes if viewing class hierarchy "upwards" || !strictWhitelist)) { // Class passed strict whitelist criteria classInfoSetFiltered.add(classInfo); } } return classInfoSetFiltered; }
[ "private", "static", "Set", "<", "ClassInfo", ">", "filterClassInfo", "(", "final", "Collection", "<", "ClassInfo", ">", "classes", ",", "final", "ScanSpec", "scanSpec", ",", "final", "boolean", "strictWhitelist", ",", "final", "ClassType", "...", "classTypes", ...
Filter classes according to scan spec and class type. @param classes the classes @param scanSpec the scan spec @param strictWhitelist If true, exclude class if it is is external, blacklisted, or a system class. @param classTypes the class types @return the filtered classes.
[ "Filter", "classes", "according", "to", "scan", "spec", "and", "class", "type", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassInfo.java#L646-L697
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassInfo.java
ClassInfo.getAllClasses
static ClassInfoList getAllClasses(final Collection<ClassInfo> classes, final ScanSpec scanSpec) { return new ClassInfoList( ClassInfo.filterClassInfo(classes, scanSpec, /* strictWhitelist = */ true, ClassType.ALL), /* sortByName = */ true); }
java
static ClassInfoList getAllClasses(final Collection<ClassInfo> classes, final ScanSpec scanSpec) { return new ClassInfoList( ClassInfo.filterClassInfo(classes, scanSpec, /* strictWhitelist = */ true, ClassType.ALL), /* sortByName = */ true); }
[ "static", "ClassInfoList", "getAllClasses", "(", "final", "Collection", "<", "ClassInfo", ">", "classes", ",", "final", "ScanSpec", "scanSpec", ")", "{", "return", "new", "ClassInfoList", "(", "ClassInfo", ".", "filterClassInfo", "(", "classes", ",", "scanSpec", ...
Get all classes found during the scan. @param classes the classes @param scanSpec the scan spec @return A list of all classes found during the scan, or the empty list if none.
[ "Get", "all", "classes", "found", "during", "the", "scan", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassInfo.java#L825-L829
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassInfo.java
ClassInfo.getAllStandardClasses
static ClassInfoList getAllStandardClasses(final Collection<ClassInfo> classes, final ScanSpec scanSpec) { return new ClassInfoList(ClassInfo.filterClassInfo(classes, scanSpec, /* strictWhitelist = */ true, ClassType.STANDARD_CLASS), /* sortByName = */ true); }
java
static ClassInfoList getAllStandardClasses(final Collection<ClassInfo> classes, final ScanSpec scanSpec) { return new ClassInfoList(ClassInfo.filterClassInfo(classes, scanSpec, /* strictWhitelist = */ true, ClassType.STANDARD_CLASS), /* sortByName = */ true); }
[ "static", "ClassInfoList", "getAllStandardClasses", "(", "final", "Collection", "<", "ClassInfo", ">", "classes", ",", "final", "ScanSpec", "scanSpec", ")", "{", "return", "new", "ClassInfoList", "(", "ClassInfo", ".", "filterClassInfo", "(", "classes", ",", "scan...
Get all standard classes found during the scan. @param classes the classes @param scanSpec the scan spec @return A list of all standard classes found during the scan, or the empty list if none.
[ "Get", "all", "standard", "classes", "found", "during", "the", "scan", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassInfo.java#L840-L843
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassInfo.java
ClassInfo.getModifiersStr
public String getModifiersStr() { final StringBuilder buf = new StringBuilder(); TypeUtils.modifiersToString(modifiers, ModifierType.CLASS, /* ignored */ false, buf); return buf.toString(); }
java
public String getModifiersStr() { final StringBuilder buf = new StringBuilder(); TypeUtils.modifiersToString(modifiers, ModifierType.CLASS, /* ignored */ false, buf); return buf.toString(); }
[ "public", "String", "getModifiersStr", "(", ")", "{", "final", "StringBuilder", "buf", "=", "new", "StringBuilder", "(", ")", ";", "TypeUtils", ".", "modifiersToString", "(", "modifiers", ",", "ModifierType", ".", "CLASS", ",", "/* ignored */", "false", ",", "...
Get the class modifiers as a String. @return The field modifiers as a string, e.g. "public static final". For the modifier bits, call {@link #getModifiers()}.
[ "Get", "the", "class", "modifiers", "as", "a", "String", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassInfo.java#L981-L985
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassInfo.java
ClassInfo.hasField
public boolean hasField(final String fieldName) { for (final ClassInfo ci : getOverrideOrder()) { if (ci.hasDeclaredField(fieldName)) { return true; } } return false; }
java
public boolean hasField(final String fieldName) { for (final ClassInfo ci : getOverrideOrder()) { if (ci.hasDeclaredField(fieldName)) { return true; } } return false; }
[ "public", "boolean", "hasField", "(", "final", "String", "fieldName", ")", "{", "for", "(", "final", "ClassInfo", "ci", ":", "getOverrideOrder", "(", ")", ")", "{", "if", "(", "ci", ".", "hasDeclaredField", "(", "fieldName", ")", ")", "{", "return", "tru...
Checks whether this class or one of its superclasses has the named field. @param fieldName The name of a field. @return true if this class or one of its superclasses declares a field of the given name.
[ "Checks", "whether", "this", "class", "or", "one", "of", "its", "superclasses", "has", "the", "named", "field", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassInfo.java#L1175-L1182
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassInfo.java
ClassInfo.hasDeclaredFieldAnnotation
public boolean hasDeclaredFieldAnnotation(final String fieldAnnotationName) { for (final FieldInfo fi : getDeclaredFieldInfo()) { if (fi.hasAnnotation(fieldAnnotationName)) { return true; } } return false; }
java
public boolean hasDeclaredFieldAnnotation(final String fieldAnnotationName) { for (final FieldInfo fi : getDeclaredFieldInfo()) { if (fi.hasAnnotation(fieldAnnotationName)) { return true; } } return false; }
[ "public", "boolean", "hasDeclaredFieldAnnotation", "(", "final", "String", "fieldAnnotationName", ")", "{", "for", "(", "final", "FieldInfo", "fi", ":", "getDeclaredFieldInfo", "(", ")", ")", "{", "if", "(", "fi", ".", "hasAnnotation", "(", "fieldAnnotationName", ...
Checks whether this class declares a field with the named annotation. @param fieldAnnotationName The name of a field annotation. @return true if this class declares a field with the named annotation.
[ "Checks", "whether", "this", "class", "declares", "a", "field", "with", "the", "named", "annotation", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassInfo.java#L1191-L1198
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassInfo.java
ClassInfo.hasFieldAnnotation
public boolean hasFieldAnnotation(final String fieldAnnotationName) { for (final ClassInfo ci : getOverrideOrder()) { if (ci.hasDeclaredFieldAnnotation(fieldAnnotationName)) { return true; } } return false; }
java
public boolean hasFieldAnnotation(final String fieldAnnotationName) { for (final ClassInfo ci : getOverrideOrder()) { if (ci.hasDeclaredFieldAnnotation(fieldAnnotationName)) { return true; } } return false; }
[ "public", "boolean", "hasFieldAnnotation", "(", "final", "String", "fieldAnnotationName", ")", "{", "for", "(", "final", "ClassInfo", "ci", ":", "getOverrideOrder", "(", ")", ")", "{", "if", "(", "ci", ".", "hasDeclaredFieldAnnotation", "(", "fieldAnnotationName",...
Checks whether this class or one of its superclasses declares a field with the named annotation. @param fieldAnnotationName The name of a field annotation. @return true if this class or one of its superclasses declares a field with the named annotation.
[ "Checks", "whether", "this", "class", "or", "one", "of", "its", "superclasses", "declares", "a", "field", "with", "the", "named", "annotation", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassInfo.java#L1207-L1214
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassInfo.java
ClassInfo.hasMethod
public boolean hasMethod(final String methodName) { for (final ClassInfo ci : getOverrideOrder()) { if (ci.hasDeclaredMethod(methodName)) { return true; } } return false; }
java
public boolean hasMethod(final String methodName) { for (final ClassInfo ci : getOverrideOrder()) { if (ci.hasDeclaredMethod(methodName)) { return true; } } return false; }
[ "public", "boolean", "hasMethod", "(", "final", "String", "methodName", ")", "{", "for", "(", "final", "ClassInfo", "ci", ":", "getOverrideOrder", "(", ")", ")", "{", "if", "(", "ci", ".", "hasDeclaredMethod", "(", "methodName", ")", ")", "{", "return", ...
Checks whether this class or one of its superclasses or interfaces declares a method of the given name. @param methodName The name of a method. @return true if this class or one of its superclasses or interfaces declares a method of the given name.
[ "Checks", "whether", "this", "class", "or", "one", "of", "its", "superclasses", "or", "interfaces", "declares", "a", "method", "of", "the", "given", "name", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassInfo.java#L1234-L1241
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassInfo.java
ClassInfo.hasMethodAnnotation
public boolean hasMethodAnnotation(final String methodAnnotationName) { for (final ClassInfo ci : getOverrideOrder()) { if (ci.hasDeclaredMethodAnnotation(methodAnnotationName)) { return true; } } return false; }
java
public boolean hasMethodAnnotation(final String methodAnnotationName) { for (final ClassInfo ci : getOverrideOrder()) { if (ci.hasDeclaredMethodAnnotation(methodAnnotationName)) { return true; } } return false; }
[ "public", "boolean", "hasMethodAnnotation", "(", "final", "String", "methodAnnotationName", ")", "{", "for", "(", "final", "ClassInfo", "ci", ":", "getOverrideOrder", "(", ")", ")", "{", "if", "(", "ci", ".", "hasDeclaredMethodAnnotation", "(", "methodAnnotationNa...
Checks whether this class or one of its superclasses or interfaces declares a method with the named annotation. @param methodAnnotationName The name of a method annotation. @return true if this class or one of its superclasses or interfaces declares a method with the named annotation.
[ "Checks", "whether", "this", "class", "or", "one", "of", "its", "superclasses", "or", "interfaces", "declares", "a", "method", "with", "the", "named", "annotation", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassInfo.java#L1268-L1275
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassInfo.java
ClassInfo.hasMethodParameterAnnotation
public boolean hasMethodParameterAnnotation(final String methodParameterAnnotationName) { for (final ClassInfo ci : getOverrideOrder()) { if (ci.hasDeclaredMethodParameterAnnotation(methodParameterAnnotationName)) { return true; } } return false; }
java
public boolean hasMethodParameterAnnotation(final String methodParameterAnnotationName) { for (final ClassInfo ci : getOverrideOrder()) { if (ci.hasDeclaredMethodParameterAnnotation(methodParameterAnnotationName)) { return true; } } return false; }
[ "public", "boolean", "hasMethodParameterAnnotation", "(", "final", "String", "methodParameterAnnotationName", ")", "{", "for", "(", "final", "ClassInfo", "ci", ":", "getOverrideOrder", "(", ")", ")", "{", "if", "(", "ci", ".", "hasDeclaredMethodParameterAnnotation", ...
Checks whether this class or one of its superclasses or interfaces has a method with the named annotation. @param methodParameterAnnotationName The name of a method annotation. @return true if this class or one of its superclasses or interfaces has a method with the named annotation.
[ "Checks", "whether", "this", "class", "or", "one", "of", "its", "superclasses", "or", "interfaces", "has", "a", "method", "with", "the", "named", "annotation", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassInfo.java#L1300-L1307
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassInfo.java
ClassInfo.getOverrideOrder
private List<ClassInfo> getOverrideOrder(final Set<ClassInfo> visited, final List<ClassInfo> overrideOrderOut) { if (visited.add(this)) { overrideOrderOut.add(this); for (final ClassInfo iface : getInterfaces()) { iface.getOverrideOrder(visited, overrideOrderOut); } final ClassInfo superclass = getSuperclass(); if (superclass != null) { superclass.getOverrideOrder(visited, overrideOrderOut); } } return overrideOrderOut; }
java
private List<ClassInfo> getOverrideOrder(final Set<ClassInfo> visited, final List<ClassInfo> overrideOrderOut) { if (visited.add(this)) { overrideOrderOut.add(this); for (final ClassInfo iface : getInterfaces()) { iface.getOverrideOrder(visited, overrideOrderOut); } final ClassInfo superclass = getSuperclass(); if (superclass != null) { superclass.getOverrideOrder(visited, overrideOrderOut); } } return overrideOrderOut; }
[ "private", "List", "<", "ClassInfo", ">", "getOverrideOrder", "(", "final", "Set", "<", "ClassInfo", ">", "visited", ",", "final", "List", "<", "ClassInfo", ">", "overrideOrderOut", ")", "{", "if", "(", "visited", ".", "add", "(", "this", ")", ")", "{", ...
Recurse to interfaces and superclasses to get the order that fields and methods are overridden in. @param visited visited @param overrideOrderOut the override order @return the override order
[ "Recurse", "to", "interfaces", "and", "superclasses", "to", "get", "the", "order", "that", "fields", "and", "methods", "are", "overridden", "in", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassInfo.java#L1320-L1332
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassInfo.java
ClassInfo.getInterfaces
public ClassInfoList getInterfaces() { // Classes also implement the interfaces of their superclasses final ReachableAndDirectlyRelatedClasses implementedInterfaces = this .filterClassInfo(RelType.IMPLEMENTED_INTERFACES, /* strictWhitelist = */ false); final Set<ClassInfo> allInterfaces = new LinkedHashSet<>(implementedInterfaces.reachableClasses); for (final ClassInfo superclass : this.filterClassInfo(RelType.SUPERCLASSES, /* strictWhitelist = */ false).reachableClasses) { final Set<ClassInfo> superclassImplementedInterfaces = superclass.filterClassInfo( RelType.IMPLEMENTED_INTERFACES, /* strictWhitelist = */ false).reachableClasses; allInterfaces.addAll(superclassImplementedInterfaces); } return new ClassInfoList(allInterfaces, implementedInterfaces.directlyRelatedClasses, /* sortByName = */ true); }
java
public ClassInfoList getInterfaces() { // Classes also implement the interfaces of their superclasses final ReachableAndDirectlyRelatedClasses implementedInterfaces = this .filterClassInfo(RelType.IMPLEMENTED_INTERFACES, /* strictWhitelist = */ false); final Set<ClassInfo> allInterfaces = new LinkedHashSet<>(implementedInterfaces.reachableClasses); for (final ClassInfo superclass : this.filterClassInfo(RelType.SUPERCLASSES, /* strictWhitelist = */ false).reachableClasses) { final Set<ClassInfo> superclassImplementedInterfaces = superclass.filterClassInfo( RelType.IMPLEMENTED_INTERFACES, /* strictWhitelist = */ false).reachableClasses; allInterfaces.addAll(superclassImplementedInterfaces); } return new ClassInfoList(allInterfaces, implementedInterfaces.directlyRelatedClasses, /* sortByName = */ true); }
[ "public", "ClassInfoList", "getInterfaces", "(", ")", "{", "// Classes also implement the interfaces of their superclasses", "final", "ReachableAndDirectlyRelatedClasses", "implementedInterfaces", "=", "this", ".", "filterClassInfo", "(", "RelType", ".", "IMPLEMENTED_INTERFACES", ...
Get the interfaces implemented by this class or by one of its superclasses, if this is a standard class, or the superinterfaces extended by this interface, if this is an interface. @return The list of interfaces implemented by this class or by one of its superclasses, if this is a standard class, or the superinterfaces extended by this interface, if this is an interface. Returns the empty list if none.
[ "Get", "the", "interfaces", "implemented", "by", "this", "class", "or", "by", "one", "of", "its", "superclasses", "if", "this", "is", "a", "standard", "class", "or", "the", "superinterfaces", "extended", "by", "this", "interface", "if", "this", "is", "an", ...
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassInfo.java#L1445-L1458
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassInfo.java
ClassInfo.getClassesWithFieldOrMethodAnnotation
private ClassInfoList getClassesWithFieldOrMethodAnnotation(final RelType relType) { final boolean isField = relType == RelType.CLASSES_WITH_FIELD_ANNOTATION; if (!(isField ? scanResult.scanSpec.enableFieldInfo : scanResult.scanSpec.enableMethodInfo) || !scanResult.scanSpec.enableAnnotationInfo) { throw new IllegalArgumentException("Please call ClassGraph#enable" + (isField ? "Field" : "Method") + "Info() and " + "#enableAnnotationInfo() before #scan()"); } final ReachableAndDirectlyRelatedClasses classesWithDirectlyAnnotatedFieldsOrMethods = this .filterClassInfo(relType, /* strictWhitelist = */ !isExternalClass); final ReachableAndDirectlyRelatedClasses annotationsWithThisMetaAnnotation = this.filterClassInfo( RelType.CLASSES_WITH_ANNOTATION, /* strictWhitelist = */ !isExternalClass, ClassType.ANNOTATION); if (annotationsWithThisMetaAnnotation.reachableClasses.isEmpty()) { // This annotation does not meta-annotate another annotation that annotates a method return new ClassInfoList(classesWithDirectlyAnnotatedFieldsOrMethods, /* sortByName = */ true); } else { // Take the union of all classes with fields or methods directly annotated by this annotation, // and classes with fields or methods meta-annotated by this annotation final Set<ClassInfo> allClassesWithAnnotatedOrMetaAnnotatedFieldsOrMethods = new LinkedHashSet<>( classesWithDirectlyAnnotatedFieldsOrMethods.reachableClasses); for (final ClassInfo metaAnnotatedAnnotation : annotationsWithThisMetaAnnotation.reachableClasses) { allClassesWithAnnotatedOrMetaAnnotatedFieldsOrMethods .addAll(metaAnnotatedAnnotation.filterClassInfo(relType, /* strictWhitelist = */ !metaAnnotatedAnnotation.isExternalClass).reachableClasses); } return new ClassInfoList(allClassesWithAnnotatedOrMetaAnnotatedFieldsOrMethods, classesWithDirectlyAnnotatedFieldsOrMethods.directlyRelatedClasses, /* sortByName = */ true); } }
java
private ClassInfoList getClassesWithFieldOrMethodAnnotation(final RelType relType) { final boolean isField = relType == RelType.CLASSES_WITH_FIELD_ANNOTATION; if (!(isField ? scanResult.scanSpec.enableFieldInfo : scanResult.scanSpec.enableMethodInfo) || !scanResult.scanSpec.enableAnnotationInfo) { throw new IllegalArgumentException("Please call ClassGraph#enable" + (isField ? "Field" : "Method") + "Info() and " + "#enableAnnotationInfo() before #scan()"); } final ReachableAndDirectlyRelatedClasses classesWithDirectlyAnnotatedFieldsOrMethods = this .filterClassInfo(relType, /* strictWhitelist = */ !isExternalClass); final ReachableAndDirectlyRelatedClasses annotationsWithThisMetaAnnotation = this.filterClassInfo( RelType.CLASSES_WITH_ANNOTATION, /* strictWhitelist = */ !isExternalClass, ClassType.ANNOTATION); if (annotationsWithThisMetaAnnotation.reachableClasses.isEmpty()) { // This annotation does not meta-annotate another annotation that annotates a method return new ClassInfoList(classesWithDirectlyAnnotatedFieldsOrMethods, /* sortByName = */ true); } else { // Take the union of all classes with fields or methods directly annotated by this annotation, // and classes with fields or methods meta-annotated by this annotation final Set<ClassInfo> allClassesWithAnnotatedOrMetaAnnotatedFieldsOrMethods = new LinkedHashSet<>( classesWithDirectlyAnnotatedFieldsOrMethods.reachableClasses); for (final ClassInfo metaAnnotatedAnnotation : annotationsWithThisMetaAnnotation.reachableClasses) { allClassesWithAnnotatedOrMetaAnnotatedFieldsOrMethods .addAll(metaAnnotatedAnnotation.filterClassInfo(relType, /* strictWhitelist = */ !metaAnnotatedAnnotation.isExternalClass).reachableClasses); } return new ClassInfoList(allClassesWithAnnotatedOrMetaAnnotatedFieldsOrMethods, classesWithDirectlyAnnotatedFieldsOrMethods.directlyRelatedClasses, /* sortByName = */ true); } }
[ "private", "ClassInfoList", "getClassesWithFieldOrMethodAnnotation", "(", "final", "RelType", "relType", ")", "{", "final", "boolean", "isField", "=", "relType", "==", "RelType", ".", "CLASSES_WITH_FIELD_ANNOTATION", ";", "if", "(", "!", "(", "isField", "?", "scanRe...
Get the classes that have this class as a field, method or method parameter annotation. @param relType One of {@link RelType#CLASSES_WITH_FIELD_ANNOTATION}, {@link RelType#CLASSES_WITH_METHOD_ANNOTATION} or {@link RelType#CLASSES_WITH_METHOD_PARAMETER_ANNOTATION}. @return A list of classes that have a declared method with this annotation or meta-annotation, or the empty list if none.
[ "Get", "the", "classes", "that", "have", "this", "class", "as", "a", "field", "method", "or", "method", "parameter", "annotation", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassInfo.java#L1571-L1598
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassInfo.java
ClassInfo.getAnnotationDefaultParameterValues
public AnnotationParameterValueList getAnnotationDefaultParameterValues() { if (!scanResult.scanSpec.enableAnnotationInfo) { throw new IllegalArgumentException("Please call ClassGraph#enableAnnotationInfo() before #scan()"); } if (!isAnnotation) { throw new IllegalArgumentException("Class is not an annotation: " + getName()); } if (annotationDefaultParamValues == null) { return AnnotationParameterValueList.EMPTY_LIST; } if (!annotationDefaultParamValuesHasBeenConvertedToPrimitive) { annotationDefaultParamValues.convertWrapperArraysToPrimitiveArrays(this); annotationDefaultParamValuesHasBeenConvertedToPrimitive = true; } return annotationDefaultParamValues; }
java
public AnnotationParameterValueList getAnnotationDefaultParameterValues() { if (!scanResult.scanSpec.enableAnnotationInfo) { throw new IllegalArgumentException("Please call ClassGraph#enableAnnotationInfo() before #scan()"); } if (!isAnnotation) { throw new IllegalArgumentException("Class is not an annotation: " + getName()); } if (annotationDefaultParamValues == null) { return AnnotationParameterValueList.EMPTY_LIST; } if (!annotationDefaultParamValuesHasBeenConvertedToPrimitive) { annotationDefaultParamValues.convertWrapperArraysToPrimitiveArrays(this); annotationDefaultParamValuesHasBeenConvertedToPrimitive = true; } return annotationDefaultParamValues; }
[ "public", "AnnotationParameterValueList", "getAnnotationDefaultParameterValues", "(", ")", "{", "if", "(", "!", "scanResult", ".", "scanSpec", ".", "enableAnnotationInfo", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Please call ClassGraph#enableAnnotationInf...
Get the default parameter values for this annotation, if this is an annotation class. @return A list of {@link AnnotationParameterValue} objects for each of the default parameter values for this annotation, if this is an annotation class with default parameter values, otherwise the empty list.
[ "Get", "the", "default", "parameter", "values", "for", "this", "annotation", "if", "this", "is", "an", "annotation", "class", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassInfo.java#L1667-L1682
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassInfo.java
ClassInfo.getClassesWithAnnotation
public ClassInfoList getClassesWithAnnotation() { if (!scanResult.scanSpec.enableAnnotationInfo) { throw new IllegalArgumentException("Please call ClassGraph#enableAnnotationInfo() before #scan()"); } if (!isAnnotation) { throw new IllegalArgumentException("Class is not an annotation: " + getName()); } // Get classes that have this annotation final ReachableAndDirectlyRelatedClasses classesWithAnnotation = this .filterClassInfo(RelType.CLASSES_WITH_ANNOTATION, /* strictWhitelist = */ !isExternalClass); if (isInherited) { // If this is an inherited annotation, add into the result all subclasses of the annotated classes. final Set<ClassInfo> classesWithAnnotationAndTheirSubclasses = new LinkedHashSet<>( classesWithAnnotation.reachableClasses); for (final ClassInfo classWithAnnotation : classesWithAnnotation.reachableClasses) { classesWithAnnotationAndTheirSubclasses.addAll(classWithAnnotation.getSubclasses()); } return new ClassInfoList(classesWithAnnotationAndTheirSubclasses, classesWithAnnotation.directlyRelatedClasses, /* sortByName = */ true); } else { // If not inherited, only return the annotated classes return new ClassInfoList(classesWithAnnotation, /* sortByName = */ true); } }
java
public ClassInfoList getClassesWithAnnotation() { if (!scanResult.scanSpec.enableAnnotationInfo) { throw new IllegalArgumentException("Please call ClassGraph#enableAnnotationInfo() before #scan()"); } if (!isAnnotation) { throw new IllegalArgumentException("Class is not an annotation: " + getName()); } // Get classes that have this annotation final ReachableAndDirectlyRelatedClasses classesWithAnnotation = this .filterClassInfo(RelType.CLASSES_WITH_ANNOTATION, /* strictWhitelist = */ !isExternalClass); if (isInherited) { // If this is an inherited annotation, add into the result all subclasses of the annotated classes. final Set<ClassInfo> classesWithAnnotationAndTheirSubclasses = new LinkedHashSet<>( classesWithAnnotation.reachableClasses); for (final ClassInfo classWithAnnotation : classesWithAnnotation.reachableClasses) { classesWithAnnotationAndTheirSubclasses.addAll(classWithAnnotation.getSubclasses()); } return new ClassInfoList(classesWithAnnotationAndTheirSubclasses, classesWithAnnotation.directlyRelatedClasses, /* sortByName = */ true); } else { // If not inherited, only return the annotated classes return new ClassInfoList(classesWithAnnotation, /* sortByName = */ true); } }
[ "public", "ClassInfoList", "getClassesWithAnnotation", "(", ")", "{", "if", "(", "!", "scanResult", ".", "scanSpec", ".", "enableAnnotationInfo", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Please call ClassGraph#enableAnnotationInfo() before #scan()\"", "...
Get the classes that have this class as an annotation. @return A list of standard classes and non-annotation interfaces that are annotated by this class, if this is an annotation class, or the empty list if none. Also handles the {@link Inherited} meta-annotation, which causes an annotation on a class to be inherited by all of its subclasses.
[ "Get", "the", "classes", "that", "have", "this", "class", "as", "an", "annotation", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassInfo.java#L1691-L1716
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassInfo.java
ClassInfo.getTypeSignature
public ClassTypeSignature getTypeSignature() { if (typeSignatureStr == null) { return null; } if (typeSignature == null) { try { typeSignature = ClassTypeSignature.parse(typeSignatureStr, this); typeSignature.setScanResult(scanResult); } catch (final ParseException e) { throw new IllegalArgumentException(e); } } return typeSignature; }
java
public ClassTypeSignature getTypeSignature() { if (typeSignatureStr == null) { return null; } if (typeSignature == null) { try { typeSignature = ClassTypeSignature.parse(typeSignatureStr, this); typeSignature.setScanResult(scanResult); } catch (final ParseException e) { throw new IllegalArgumentException(e); } } return typeSignature; }
[ "public", "ClassTypeSignature", "getTypeSignature", "(", ")", "{", "if", "(", "typeSignatureStr", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "typeSignature", "==", "null", ")", "{", "try", "{", "typeSignature", "=", "ClassTypeSignature", ...
Get the type signature of the class. @return The class type signature, if available, otherwise returns null.
[ "Get", "the", "type", "signature", "of", "the", "class", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassInfo.java#L2359-L2372
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassInfo.java
ClassInfo.addReferencedClassNames
void addReferencedClassNames(final Set<String> refdClassNames) { if (this.referencedClassNames == null) { this.referencedClassNames = refdClassNames; } else { this.referencedClassNames.addAll(refdClassNames); } }
java
void addReferencedClassNames(final Set<String> refdClassNames) { if (this.referencedClassNames == null) { this.referencedClassNames = refdClassNames; } else { this.referencedClassNames.addAll(refdClassNames); } }
[ "void", "addReferencedClassNames", "(", "final", "Set", "<", "String", ">", "refdClassNames", ")", "{", "if", "(", "this", ".", "referencedClassNames", "==", "null", ")", "{", "this", ".", "referencedClassNames", "=", "refdClassNames", ";", "}", "else", "{", ...
Add names of classes referenced by this class. @param refdClassNames the referenced class names
[ "Add", "names", "of", "classes", "referenced", "by", "this", "class", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassInfo.java#L2590-L2596
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassInfo.java
ClassInfo.findReferencedClassNames
@Override protected void findReferencedClassNames(final Set<String> referencedClassNames) { if (this.referencedClassNames != null) { referencedClassNames.addAll(this.referencedClassNames); } getMethodInfo().findReferencedClassNames(referencedClassNames); getFieldInfo().findReferencedClassNames(referencedClassNames); getAnnotationInfo().findReferencedClassNames(referencedClassNames); if (annotationDefaultParamValues != null) { annotationDefaultParamValues.findReferencedClassNames(referencedClassNames); } final ClassTypeSignature classSig = getTypeSignature(); if (classSig != null) { classSig.findReferencedClassNames(referencedClassNames); } // Remove any self-references referencedClassNames.remove(name); }
java
@Override protected void findReferencedClassNames(final Set<String> referencedClassNames) { if (this.referencedClassNames != null) { referencedClassNames.addAll(this.referencedClassNames); } getMethodInfo().findReferencedClassNames(referencedClassNames); getFieldInfo().findReferencedClassNames(referencedClassNames); getAnnotationInfo().findReferencedClassNames(referencedClassNames); if (annotationDefaultParamValues != null) { annotationDefaultParamValues.findReferencedClassNames(referencedClassNames); } final ClassTypeSignature classSig = getTypeSignature(); if (classSig != null) { classSig.findReferencedClassNames(referencedClassNames); } // Remove any self-references referencedClassNames.remove(name); }
[ "@", "Override", "protected", "void", "findReferencedClassNames", "(", "final", "Set", "<", "String", ">", "referencedClassNames", ")", "{", "if", "(", "this", ".", "referencedClassNames", "!=", "null", ")", "{", "referencedClassNames", ".", "addAll", "(", "this...
Get the names of any classes referenced in this class' type descriptor, or the type descriptors of fields, methods or annotations. @param referencedClassNames the referenced class names
[ "Get", "the", "names", "of", "any", "classes", "referenced", "in", "this", "class", "type", "descriptor", "or", "the", "type", "descriptors", "of", "fields", "methods", "or", "annotations", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassInfo.java#L2605-L2622
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassInfo.java
ClassInfo.getClassDependencies
public ClassInfoList getClassDependencies() { if (!scanResult.scanSpec.enableInterClassDependencies) { throw new IllegalArgumentException( "Please call ClassGraph#enableInterClassDependencies() before #scan()"); } return referencedClasses == null ? ClassInfoList.EMPTY_LIST : referencedClasses; }
java
public ClassInfoList getClassDependencies() { if (!scanResult.scanSpec.enableInterClassDependencies) { throw new IllegalArgumentException( "Please call ClassGraph#enableInterClassDependencies() before #scan()"); } return referencedClasses == null ? ClassInfoList.EMPTY_LIST : referencedClasses; }
[ "public", "ClassInfoList", "getClassDependencies", "(", ")", "{", "if", "(", "!", "scanResult", ".", "scanSpec", ".", "enableInterClassDependencies", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Please call ClassGraph#enableInterClassDependencies() before #sc...
Get the class dependencies. @return A {@link ClassInfoList} of {@link ClassInfo} objects for all classes referenced by this class. Note that you need to call {@link ClassGraph#enableInterClassDependencies()} before {@link ClassGraph#scan()} for this method to work. You should also call {@link ClassGraph#enableExternalClasses()} before {@link ClassGraph#scan()} if you want non-whitelisted classes to appear in the result.
[ "Get", "the", "class", "dependencies", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassInfo.java#L2645-L2651
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/utils/FastPathResolver.java
FastPathResolver.translateSeparator
private static void translateSeparator(final String path, final int startIdx, final int endIdx, final boolean stripFinalSeparator, final StringBuilder buf) { for (int i = startIdx; i < endIdx; i++) { final char c = path.charAt(i); if (c == '\\' || c == '/') { // Strip trailing separator, if necessary if (i < endIdx - 1 || !stripFinalSeparator) { // Remove duplicate separators final char prevChar = buf.length() == 0 ? '\0' : buf.charAt(buf.length() - 1); if (prevChar != '/') { buf.append('/'); } } } else { buf.append(c); } } }
java
private static void translateSeparator(final String path, final int startIdx, final int endIdx, final boolean stripFinalSeparator, final StringBuilder buf) { for (int i = startIdx; i < endIdx; i++) { final char c = path.charAt(i); if (c == '\\' || c == '/') { // Strip trailing separator, if necessary if (i < endIdx - 1 || !stripFinalSeparator) { // Remove duplicate separators final char prevChar = buf.length() == 0 ? '\0' : buf.charAt(buf.length() - 1); if (prevChar != '/') { buf.append('/'); } } } else { buf.append(c); } } }
[ "private", "static", "void", "translateSeparator", "(", "final", "String", "path", ",", "final", "int", "startIdx", ",", "final", "int", "endIdx", ",", "final", "boolean", "stripFinalSeparator", ",", "final", "StringBuilder", "buf", ")", "{", "for", "(", "int"...
Translate backslashes to forward slashes, optionally removing trailing separator. @param path the path @param startIdx the start index @param endIdx the end index @param stripFinalSeparator if true, strip the final separator @param buf the buf
[ "Translate", "backslashes", "to", "forward", "slashes", "optionally", "removing", "trailing", "separator", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/utils/FastPathResolver.java#L69-L86
train
classgraph/classgraph
src/main/java/io/github/classgraph/AnnotationClassRef.java
AnnotationClassRef.getTypeSignature
private TypeSignature getTypeSignature() { if (typeSignature == null) { try { // There can't be any type variables to resolve in either ClassRefTypeSignature or // BaseTypeSignature, so just set definingClassName to null typeSignature = TypeSignature.parse(typeDescriptorStr, /* definingClassName = */ null); typeSignature.setScanResult(scanResult); } catch (final ParseException e) { throw new IllegalArgumentException(e); } } return typeSignature; }
java
private TypeSignature getTypeSignature() { if (typeSignature == null) { try { // There can't be any type variables to resolve in either ClassRefTypeSignature or // BaseTypeSignature, so just set definingClassName to null typeSignature = TypeSignature.parse(typeDescriptorStr, /* definingClassName = */ null); typeSignature.setScanResult(scanResult); } catch (final ParseException e) { throw new IllegalArgumentException(e); } } return typeSignature; }
[ "private", "TypeSignature", "getTypeSignature", "(", ")", "{", "if", "(", "typeSignature", "==", "null", ")", "{", "try", "{", "// There can't be any type variables to resolve in either ClassRefTypeSignature or", "// BaseTypeSignature, so just set definingClassName to null", "typeS...
Get the type signature. @return The type signature of the {@code Class<?>} reference. This will be a {@link ClassRefTypeSignature} or a {@link BaseTypeSignature}.
[ "Get", "the", "type", "signature", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/AnnotationClassRef.java#L83-L95
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/fastzipfilereader/NestedJarHandler.java
NestedJarHandler.sanitizeFilename
private String sanitizeFilename(final String filename) { return filename.replace('/', '_').replace('\\', '_').replace(':', '_').replace('?', '_').replace('&', '_') .replace('=', '_').replace(' ', '_'); }
java
private String sanitizeFilename(final String filename) { return filename.replace('/', '_').replace('\\', '_').replace(':', '_').replace('?', '_').replace('&', '_') .replace('=', '_').replace(' ', '_'); }
[ "private", "String", "sanitizeFilename", "(", "final", "String", "filename", ")", "{", "return", "filename", ".", "replace", "(", "'", "'", ",", "'", "'", ")", ".", "replace", "(", "'", "'", ",", "'", "'", ")", ".", "replace", "(", "'", "'", ",", ...
Sanitize filename. @param filename the filename @return the sanitized filename
[ "Sanitize", "filename", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/fastzipfilereader/NestedJarHandler.java#L489-L492
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/fastzipfilereader/NestedJarHandler.java
NestedJarHandler.makeTempFile
private File makeTempFile(final String filePath, final boolean onlyUseLeafname) throws IOException { final File tempFile = File.createTempFile("ClassGraph--", TEMP_FILENAME_LEAF_SEPARATOR + sanitizeFilename(onlyUseLeafname ? leafname(filePath) : filePath)); tempFile.deleteOnExit(); tempFiles.add(tempFile); return tempFile; }
java
private File makeTempFile(final String filePath, final boolean onlyUseLeafname) throws IOException { final File tempFile = File.createTempFile("ClassGraph--", TEMP_FILENAME_LEAF_SEPARATOR + sanitizeFilename(onlyUseLeafname ? leafname(filePath) : filePath)); tempFile.deleteOnExit(); tempFiles.add(tempFile); return tempFile; }
[ "private", "File", "makeTempFile", "(", "final", "String", "filePath", ",", "final", "boolean", "onlyUseLeafname", ")", "throws", "IOException", "{", "final", "File", "tempFile", "=", "File", ".", "createTempFile", "(", "\"ClassGraph--\"", ",", "TEMP_FILENAME_LEAF_S...
Create a temporary file, and mark it for deletion on exit. @param filePath The path to derive the temporary filename from. @param onlyUseLeafname If true, only use the leafname of filePath to derive the temporary filename. @return The temporary {@link File}. @throws IOException If the temporary file could not be created.
[ "Create", "a", "temporary", "file", "and", "mark", "it", "for", "deletion", "on", "exit", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/fastzipfilereader/NestedJarHandler.java#L505-L511
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/fastzipfilereader/NestedJarHandler.java
NestedJarHandler.downloadTempFile
private File downloadTempFile(final String jarURL, final LogNode log) { final LogNode subLog = log == null ? null : log.log(jarURL, "Downloading URL " + jarURL); File tempFile; try { tempFile = makeTempFile(jarURL, /* onlyUseLeafname = */ true); final URL url = new URL(jarURL); try (InputStream inputStream = url.openStream()) { Files.copy(inputStream, tempFile.toPath(), StandardCopyOption.REPLACE_EXISTING); } if (subLog != null) { subLog.addElapsedTime(); } } catch (final IOException | SecurityException e) { if (subLog != null) { subLog.log("Could not download " + jarURL, e); } return null; } if (subLog != null) { subLog.log("Downloaded to temporary file " + tempFile); subLog.log("***** Note that it is time-consuming to scan jars at http(s) addresses, " + "they must be downloaded for every scan, and the same jars must also be " + "separately downloaded by the ClassLoader *****"); } return tempFile; }
java
private File downloadTempFile(final String jarURL, final LogNode log) { final LogNode subLog = log == null ? null : log.log(jarURL, "Downloading URL " + jarURL); File tempFile; try { tempFile = makeTempFile(jarURL, /* onlyUseLeafname = */ true); final URL url = new URL(jarURL); try (InputStream inputStream = url.openStream()) { Files.copy(inputStream, tempFile.toPath(), StandardCopyOption.REPLACE_EXISTING); } if (subLog != null) { subLog.addElapsedTime(); } } catch (final IOException | SecurityException e) { if (subLog != null) { subLog.log("Could not download " + jarURL, e); } return null; } if (subLog != null) { subLog.log("Downloaded to temporary file " + tempFile); subLog.log("***** Note that it is time-consuming to scan jars at http(s) addresses, " + "they must be downloaded for every scan, and the same jars must also be " + "separately downloaded by the ClassLoader *****"); } return tempFile; }
[ "private", "File", "downloadTempFile", "(", "final", "String", "jarURL", ",", "final", "LogNode", "log", ")", "{", "final", "LogNode", "subLog", "=", "log", "==", "null", "?", "null", ":", "log", ".", "log", "(", "jarURL", ",", "\"Downloading URL \"", "+",...
Download a jar from a URL to a temporary file. @param jarURL the jar URL @param log the log @return the temporary file the jar was downloaded to
[ "Download", "a", "jar", "from", "a", "URL", "to", "a", "temporary", "file", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/fastzipfilereader/NestedJarHandler.java#L522-L547
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassInfoList.java
ClassInfoList.generateGraphVizDotFile
public String generateGraphVizDotFile(final float sizeX, final float sizeY) { return generateGraphVizDotFile(sizeX, sizeY, /* showFields = */ true, /* showFieldTypeDependencyEdges = */ true, /* showMethods = */ true, /* showMethodTypeDependencyEdges = */ true, /* showAnnotations = */ true); }
java
public String generateGraphVizDotFile(final float sizeX, final float sizeY) { return generateGraphVizDotFile(sizeX, sizeY, /* showFields = */ true, /* showFieldTypeDependencyEdges = */ true, /* showMethods = */ true, /* showMethodTypeDependencyEdges = */ true, /* showAnnotations = */ true); }
[ "public", "String", "generateGraphVizDotFile", "(", "final", "float", "sizeX", ",", "final", "float", "sizeY", ")", "{", "return", "generateGraphVizDotFile", "(", "sizeX", ",", "sizeY", ",", "/* showFields = */", "true", ",", "/* showFieldTypeDependencyEdges = */", "t...
Generate a .dot file which can be fed into GraphViz for layout and visualization of the class graph. <p> Methods, fields and annotations are shown if enabled, via {@link ClassGraph#enableMethodInfo()}, {@link ClassGraph#enableFieldInfo()} and {@link ClassGraph#enableAnnotationInfo()}. <p> Only public classes, methods, and fields are shown, unless {@link ClassGraph#ignoreClassVisibility()}, {@link ClassGraph#ignoreMethodVisibility()}, and/or {@link ClassGraph#ignoreFieldVisibility()} has/have been called. @param sizeX The GraphViz layout width in inches. @param sizeY The GraphViz layout width in inches. @return the GraphViz file contents. @throws IllegalArgumentException if this {@link ClassInfoList} is empty or {@link ClassGraph#enableClassInfo()} was not called before scanning (since there would be nothing to graph).
[ "Generate", "a", ".", "dot", "file", "which", "can", "be", "fed", "into", "GraphViz", "for", "layout", "and", "visualization", "of", "the", "class", "graph", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassInfoList.java#L732-L736
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassInfoList.java
ClassInfoList.generateGraphVizDotFile
public void generateGraphVizDotFile(final File file) throws IOException { try (PrintWriter writer = new PrintWriter(file)) { writer.print(generateGraphVizDotFile()); } }
java
public void generateGraphVizDotFile(final File file) throws IOException { try (PrintWriter writer = new PrintWriter(file)) { writer.print(generateGraphVizDotFile()); } }
[ "public", "void", "generateGraphVizDotFile", "(", "final", "File", "file", ")", "throws", "IOException", "{", "try", "(", "PrintWriter", "writer", "=", "new", "PrintWriter", "(", "file", ")", ")", "{", "writer", ".", "print", "(", "generateGraphVizDotFile", "(...
Generate a and save a .dot file, which can be fed into GraphViz for layout and visualization of the class graph. <p> Methods, fields and annotations are shown if enabled, via {@link ClassGraph#enableMethodInfo()}, {@link ClassGraph#enableFieldInfo()} and {@link ClassGraph#enableAnnotationInfo()}. <p> Only public classes, methods, and fields are shown, unless {@link ClassGraph#ignoreClassVisibility()}, {@link ClassGraph#ignoreMethodVisibility()}, and/or {@link ClassGraph#ignoreFieldVisibility()} has/have been called. @param file the file to save the GraphViz .dot file to. @throws IOException if the file could not be saved. @throws IllegalArgumentException if this {@link ClassInfoList} is empty or {@link ClassGraph#enableClassInfo()} was not called before scanning (since there would be nothing to graph).
[ "Generate", "a", "and", "save", "a", ".", "dot", "file", "which", "can", "be", "fed", "into", "GraphViz", "for", "layout", "and", "visualization", "of", "the", "class", "graph", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassInfoList.java#L782-L786
train
classgraph/classgraph
src/main/java/io/github/classgraph/MappableInfoList.java
MappableInfoList.containsName
public boolean containsName(final String name) { for (final T i : this) { if (i.getName().equals(name)) { return true; } } return false; }
java
public boolean containsName(final String name) { for (final T i : this) { if (i.getName().equals(name)) { return true; } } return false; }
[ "public", "boolean", "containsName", "(", "final", "String", "name", ")", "{", "for", "(", "final", "T", "i", ":", "this", ")", "{", "if", "(", "i", ".", "getName", "(", ")", ".", "equals", "(", "name", ")", ")", "{", "return", "true", ";", "}", ...
Check if this list contains an item with the given name. @param name The name to search for. @return true if this list contains an item with the given name.
[ "Check", "if", "this", "list", "contains", "an", "item", "with", "the", "given", "name", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/MappableInfoList.java#L91-L98
train
classgraph/classgraph
src/main/java/io/github/classgraph/MappableInfoList.java
MappableInfoList.get
public T get(final String name) { for (final T i : this) { if (i.getName().equals(name)) { return i; } } return null; }
java
public T get(final String name) { for (final T i : this) { if (i.getName().equals(name)) { return i; } } return null; }
[ "public", "T", "get", "(", "final", "String", "name", ")", "{", "for", "(", "final", "T", "i", ":", "this", ")", "{", "if", "(", "i", ".", "getName", "(", ")", ".", "equals", "(", "name", ")", ")", "{", "return", "i", ";", "}", "}", "return",...
Get the list item with the given name, or null if not found. @param name The name to search for. @return The list item with the given name, or null if not found.
[ "Get", "the", "list", "item", "with", "the", "given", "name", "or", "null", "if", "not", "found", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/MappableInfoList.java#L107-L114
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/concurrency/WorkQueue.java
WorkQueue.runWorkQueue
public static <U> void runWorkQueue(final Collection<U> elements, final ExecutorService executorService, final InterruptionChecker interruptionChecker, final int numParallelTasks, final LogNode log, final WorkUnitProcessor<U> workUnitProcessor) throws InterruptedException, ExecutionException { if (elements.isEmpty()) { // Nothing to do return; } // WorkQueue#close() is called when this try-with-resources block terminates, initiating a barrier wait // while all worker threads complete. try (WorkQueue<U> workQueue = new WorkQueue<>(elements, workUnitProcessor, numParallelTasks, interruptionChecker, log)) { // Start (numParallelTasks - 1) worker threads (may start zero threads if numParallelTasks == 1) workQueue.startWorkers(executorService, numParallelTasks - 1); // Use the current thread to do work too, in case there is only one thread available in the // ExecutorService, or in case numParallelTasks is greater than the number of available threads in the // ExecutorService. workQueue.runWorkLoop(); } }
java
public static <U> void runWorkQueue(final Collection<U> elements, final ExecutorService executorService, final InterruptionChecker interruptionChecker, final int numParallelTasks, final LogNode log, final WorkUnitProcessor<U> workUnitProcessor) throws InterruptedException, ExecutionException { if (elements.isEmpty()) { // Nothing to do return; } // WorkQueue#close() is called when this try-with-resources block terminates, initiating a barrier wait // while all worker threads complete. try (WorkQueue<U> workQueue = new WorkQueue<>(elements, workUnitProcessor, numParallelTasks, interruptionChecker, log)) { // Start (numParallelTasks - 1) worker threads (may start zero threads if numParallelTasks == 1) workQueue.startWorkers(executorService, numParallelTasks - 1); // Use the current thread to do work too, in case there is only one thread available in the // ExecutorService, or in case numParallelTasks is greater than the number of available threads in the // ExecutorService. workQueue.runWorkLoop(); } }
[ "public", "static", "<", "U", ">", "void", "runWorkQueue", "(", "final", "Collection", "<", "U", ">", "elements", ",", "final", "ExecutorService", "executorService", ",", "final", "InterruptionChecker", "interruptionChecker", ",", "final", "int", "numParallelTasks",...
Start a work queue on the elements in the provided collection, blocking until all work units have been completed. @param <U> The type of the work queue units. @param elements The work queue units to process. @param executorService The {@link ExecutorService}. @param interruptionChecker the interruption checker @param numParallelTasks The number of parallel tasks. @param log The log. @param workUnitProcessor The {@link WorkUnitProcessor}. @throws InterruptedException If the work was interrupted. @throws ExecutionException If a worker throws an uncaught exception.
[ "Start", "a", "work", "queue", "on", "the", "elements", "in", "the", "provided", "collection", "blocking", "until", "all", "work", "units", "have", "been", "completed", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/concurrency/WorkQueue.java#L145-L163
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/concurrency/WorkQueue.java
WorkQueue.startWorkers
private void startWorkers(final ExecutorService executorService, final int numTasks) { for (int i = 0; i < numTasks; i++) { workerFutures.add(executorService.submit(new Callable<Void>() { @Override public Void call() throws Exception { runWorkLoop(); return null; } })); } }
java
private void startWorkers(final ExecutorService executorService, final int numTasks) { for (int i = 0; i < numTasks; i++) { workerFutures.add(executorService.submit(new Callable<Void>() { @Override public Void call() throws Exception { runWorkLoop(); return null; } })); } }
[ "private", "void", "startWorkers", "(", "final", "ExecutorService", "executorService", ",", "final", "int", "numTasks", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "numTasks", ";", "i", "++", ")", "{", "workerFutures", ".", "add", "(", "...
Start worker threads with a shared log. @param executorService the executor service @param numTasks the number of worker tasks to start
[ "Start", "worker", "threads", "with", "a", "shared", "log", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/concurrency/WorkQueue.java#L196-L206
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/concurrency/WorkQueue.java
WorkQueue.sendPoisonPills
private void sendPoisonPills() { for (int i = 0; i < numWorkers; i++) { workUnits.add(new WorkUnitWrapper<T>(null)); } }
java
private void sendPoisonPills() { for (int i = 0; i < numWorkers; i++) { workUnits.add(new WorkUnitWrapper<T>(null)); } }
[ "private", "void", "sendPoisonPills", "(", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "numWorkers", ";", "i", "++", ")", "{", "workUnits", ".", "add", "(", "new", "WorkUnitWrapper", "<", "T", ">", "(", "null", ")", ")", ";", "}", ...
Send poison pills to workers.
[ "Send", "poison", "pills", "to", "workers", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/concurrency/WorkQueue.java#L211-L215
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/concurrency/WorkQueue.java
WorkQueue.addWorkUnit
public void addWorkUnit(final T workUnit) { if (workUnit == null) { throw new NullPointerException("workUnit cannot be null"); } numIncompleteWorkUnits.incrementAndGet(); workUnits.add(new WorkUnitWrapper<>(workUnit)); }
java
public void addWorkUnit(final T workUnit) { if (workUnit == null) { throw new NullPointerException("workUnit cannot be null"); } numIncompleteWorkUnits.incrementAndGet(); workUnits.add(new WorkUnitWrapper<>(workUnit)); }
[ "public", "void", "addWorkUnit", "(", "final", "T", "workUnit", ")", "{", "if", "(", "workUnit", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", "\"workUnit cannot be null\"", ")", ";", "}", "numIncompleteWorkUnits", ".", "incrementAndGet", ...
Add a unit of work. May be called by workers to add more work units to the tail of the queue. @param workUnit the work unit @throws NullPointerException if the work unit is null.
[ "Add", "a", "unit", "of", "work", ".", "May", "be", "called", "by", "workers", "to", "add", "more", "work", "units", "to", "the", "tail", "of", "the", "queue", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/concurrency/WorkQueue.java#L276-L282
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/json/ClassFieldCache.java
ClassFieldCache.get
ClassFields get(final Class<?> cls) { ClassFields classFields = classToClassFields.get(cls); if (classFields == null) { classToClassFields.put(cls, classFields = new ClassFields(cls, resolveTypes, onlySerializePublicFields, this)); } return classFields; }
java
ClassFields get(final Class<?> cls) { ClassFields classFields = classToClassFields.get(cls); if (classFields == null) { classToClassFields.put(cls, classFields = new ClassFields(cls, resolveTypes, onlySerializePublicFields, this)); } return classFields; }
[ "ClassFields", "get", "(", "final", "Class", "<", "?", ">", "cls", ")", "{", "ClassFields", "classFields", "=", "classToClassFields", ".", "get", "(", "cls", ")", ";", "if", "(", "classFields", "==", "null", ")", "{", "classToClassFields", ".", "put", "(...
For a given resolved type, find the visible and accessible fields, resolve the types of any generically typed fields, and return the resolved fields. @param cls the cls @return the class fields
[ "For", "a", "given", "resolved", "type", "find", "the", "visible", "and", "accessible", "fields", "resolve", "the", "types", "of", "any", "generically", "typed", "fields", "and", "return", "the", "resolved", "fields", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/json/ClassFieldCache.java#L131-L138
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/json/ClassFieldCache.java
ClassFieldCache.getConcreteType
private static Class<?> getConcreteType(final Class<?> rawType, final boolean returnNullIfNotMapOrCollection) { // This list is not complete (e.g. EnumMap cannot be instantiated directly, you need to pass the // enum key type into a factory method), but this should cover a lot of the common types if (rawType == Map.class || rawType == AbstractMap.class || rawType == HashMap.class) { return HashMap.class; } else if (rawType == ConcurrentMap.class || rawType == ConcurrentHashMap.class) { return ConcurrentHashMap.class; } else if (rawType == SortedMap.class || rawType == NavigableMap.class || rawType == TreeMap.class) { return TreeMap.class; } else if (rawType == ConcurrentNavigableMap.class || rawType == ConcurrentSkipListMap.class) { return ConcurrentSkipListMap.class; } else if (rawType == List.class || rawType == AbstractList.class || rawType == ArrayList.class || rawType == Collection.class) { return ArrayList.class; } else if (rawType == AbstractSequentialList.class || rawType == LinkedList.class) { return LinkedList.class; } else if (rawType == Set.class || rawType == AbstractSet.class || rawType == HashSet.class) { return HashSet.class; } else if (rawType == SortedSet.class || rawType == TreeSet.class) { return TreeSet.class; } else if (rawType == Queue.class || rawType == AbstractQueue.class || rawType == Deque.class || rawType == ArrayDeque.class) { return ArrayDeque.class; } else if (rawType == BlockingQueue.class || rawType == LinkedBlockingQueue.class) { return LinkedBlockingQueue.class; } else if (rawType == BlockingDeque.class || rawType == LinkedBlockingDeque.class) { return LinkedBlockingDeque.class; } else if (rawType == TransferQueue.class || rawType == LinkedTransferQueue.class) { return LinkedTransferQueue.class; } else { return returnNullIfNotMapOrCollection ? null : rawType; } }
java
private static Class<?> getConcreteType(final Class<?> rawType, final boolean returnNullIfNotMapOrCollection) { // This list is not complete (e.g. EnumMap cannot be instantiated directly, you need to pass the // enum key type into a factory method), but this should cover a lot of the common types if (rawType == Map.class || rawType == AbstractMap.class || rawType == HashMap.class) { return HashMap.class; } else if (rawType == ConcurrentMap.class || rawType == ConcurrentHashMap.class) { return ConcurrentHashMap.class; } else if (rawType == SortedMap.class || rawType == NavigableMap.class || rawType == TreeMap.class) { return TreeMap.class; } else if (rawType == ConcurrentNavigableMap.class || rawType == ConcurrentSkipListMap.class) { return ConcurrentSkipListMap.class; } else if (rawType == List.class || rawType == AbstractList.class || rawType == ArrayList.class || rawType == Collection.class) { return ArrayList.class; } else if (rawType == AbstractSequentialList.class || rawType == LinkedList.class) { return LinkedList.class; } else if (rawType == Set.class || rawType == AbstractSet.class || rawType == HashSet.class) { return HashSet.class; } else if (rawType == SortedSet.class || rawType == TreeSet.class) { return TreeSet.class; } else if (rawType == Queue.class || rawType == AbstractQueue.class || rawType == Deque.class || rawType == ArrayDeque.class) { return ArrayDeque.class; } else if (rawType == BlockingQueue.class || rawType == LinkedBlockingQueue.class) { return LinkedBlockingQueue.class; } else if (rawType == BlockingDeque.class || rawType == LinkedBlockingDeque.class) { return LinkedBlockingDeque.class; } else if (rawType == TransferQueue.class || rawType == LinkedTransferQueue.class) { return LinkedTransferQueue.class; } else { return returnNullIfNotMapOrCollection ? null : rawType; } }
[ "private", "static", "Class", "<", "?", ">", "getConcreteType", "(", "final", "Class", "<", "?", ">", "rawType", ",", "final", "boolean", "returnNullIfNotMapOrCollection", ")", "{", "// This list is not complete (e.g. EnumMap cannot be instantiated directly, you need to pass ...
Get the concrete type for a map or collection whose raw type is an interface or abstract class. @param rawType the raw type @param returnNullIfNotMapOrCollection return null if not map or collection @return the concrete type
[ "Get", "the", "concrete", "type", "for", "a", "map", "or", "collection", "whose", "raw", "type", "is", "an", "interface", "or", "abstract", "class", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/json/ClassFieldCache.java#L149-L181
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/json/ClassFieldCache.java
ClassFieldCache.getDefaultConstructorForConcreteTypeOf
Constructor<?> getDefaultConstructorForConcreteTypeOf(final Class<?> cls) { if (cls == null) { throw new IllegalArgumentException("Class reference cannot be null"); } // Check cache final Constructor<?> constructor = defaultConstructorForConcreteType.get(cls); if (constructor != null) { return constructor; } final Class<?> concreteType = getConcreteType(cls, /* returnNullIfNotMapOrCollection = */ false); for (Class<?> c = concreteType; c != null && (c != Object.class || cls == Object.class); c = c.getSuperclass()) { try { final Constructor<?> defaultConstructor = c.getDeclaredConstructor(); JSONUtils.isAccessibleOrMakeAccessible(defaultConstructor); // Store found constructor in cache defaultConstructorForConcreteType.put(cls, defaultConstructor); return defaultConstructor; } catch (final ReflectiveOperationException | SecurityException e) { // Ignore } } throw new IllegalArgumentException("Class " + cls.getName() // + " does not have an accessible default (no-arg) constructor"); }
java
Constructor<?> getDefaultConstructorForConcreteTypeOf(final Class<?> cls) { if (cls == null) { throw new IllegalArgumentException("Class reference cannot be null"); } // Check cache final Constructor<?> constructor = defaultConstructorForConcreteType.get(cls); if (constructor != null) { return constructor; } final Class<?> concreteType = getConcreteType(cls, /* returnNullIfNotMapOrCollection = */ false); for (Class<?> c = concreteType; c != null && (c != Object.class || cls == Object.class); c = c.getSuperclass()) { try { final Constructor<?> defaultConstructor = c.getDeclaredConstructor(); JSONUtils.isAccessibleOrMakeAccessible(defaultConstructor); // Store found constructor in cache defaultConstructorForConcreteType.put(cls, defaultConstructor); return defaultConstructor; } catch (final ReflectiveOperationException | SecurityException e) { // Ignore } } throw new IllegalArgumentException("Class " + cls.getName() // + " does not have an accessible default (no-arg) constructor"); }
[ "Constructor", "<", "?", ">", "getDefaultConstructorForConcreteTypeOf", "(", "final", "Class", "<", "?", ">", "cls", ")", "{", "if", "(", "cls", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Class reference cannot be null\"", ")", "...
Get the concrete type of the given class, then return the default constructor for that type. @param cls the class @return the default constructor for concrete type of class @throws IllegalArgumentException if no default constructor is both found and accessible.
[ "Get", "the", "concrete", "type", "of", "the", "given", "class", "then", "return", "the", "default", "constructor", "for", "that", "type", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/json/ClassFieldCache.java#L192-L216
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/json/JSONUtils.java
JSONUtils.getFieldValue
static Object getFieldValue(final Object containingObj, final Field field) throws IllegalArgumentException, IllegalAccessException { final Class<?> fieldType = field.getType(); if (fieldType == Integer.TYPE) { return field.getInt(containingObj); } else if (fieldType == Long.TYPE) { return field.getLong(containingObj); } else if (fieldType == Short.TYPE) { return field.getShort(containingObj); } else if (fieldType == Double.TYPE) { return field.getDouble(containingObj); } else if (fieldType == Float.TYPE) { return field.getFloat(containingObj); } else if (fieldType == Boolean.TYPE) { return field.getBoolean(containingObj); } else if (fieldType == Byte.TYPE) { return field.getByte(containingObj); } else if (fieldType == Character.TYPE) { return field.getChar(containingObj); } else { return field.get(containingObj); } }
java
static Object getFieldValue(final Object containingObj, final Field field) throws IllegalArgumentException, IllegalAccessException { final Class<?> fieldType = field.getType(); if (fieldType == Integer.TYPE) { return field.getInt(containingObj); } else if (fieldType == Long.TYPE) { return field.getLong(containingObj); } else if (fieldType == Short.TYPE) { return field.getShort(containingObj); } else if (fieldType == Double.TYPE) { return field.getDouble(containingObj); } else if (fieldType == Float.TYPE) { return field.getFloat(containingObj); } else if (fieldType == Boolean.TYPE) { return field.getBoolean(containingObj); } else if (fieldType == Byte.TYPE) { return field.getByte(containingObj); } else if (fieldType == Character.TYPE) { return field.getChar(containingObj); } else { return field.get(containingObj); } }
[ "static", "Object", "getFieldValue", "(", "final", "Object", "containingObj", ",", "final", "Field", "field", ")", "throws", "IllegalArgumentException", ",", "IllegalAccessException", "{", "final", "Class", "<", "?", ">", "fieldType", "=", "field", ".", "getType",...
Get a field value, appropriately handling primitive-typed fields. @param containingObj the containing object @param field the field @return the field value @throws IllegalArgumentException if the specified object is not an instance of the class or interface declaring the underlying field @throws IllegalAccessException if the field cannot be read
[ "Get", "a", "field", "value", "appropriately", "handling", "primitive", "-", "typed", "fields", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/json/JSONUtils.java#L195-L217
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/json/JSONUtils.java
JSONUtils.isBasicValueType
static boolean isBasicValueType(final Type type) { if (type instanceof Class<?>) { return isBasicValueType((Class<?>) type); } else if (type instanceof ParameterizedType) { return isBasicValueType(((ParameterizedType) type).getRawType()); } else { return false; } }
java
static boolean isBasicValueType(final Type type) { if (type instanceof Class<?>) { return isBasicValueType((Class<?>) type); } else if (type instanceof ParameterizedType) { return isBasicValueType(((ParameterizedType) type).getRawType()); } else { return false; } }
[ "static", "boolean", "isBasicValueType", "(", "final", "Type", "type", ")", "{", "if", "(", "type", "instanceof", "Class", "<", "?", ">", ")", "{", "return", "isBasicValueType", "(", "(", "Class", "<", "?", ">", ")", "type", ")", ";", "}", "else", "i...
Return true for types that can be converted directly to and from string representation. @param type the type @return true, if the type is a basic value type
[ "Return", "true", "for", "types", "that", "can", "be", "converted", "directly", "to", "and", "from", "string", "representation", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/json/JSONUtils.java#L249-L257
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/json/JSONUtils.java
JSONUtils.isBasicValueType
static boolean isBasicValueType(final Object obj) { return obj == null || obj instanceof String || obj instanceof Integer || obj instanceof Boolean || obj instanceof Long || obj instanceof Float || obj instanceof Double || obj instanceof Short || obj instanceof Byte || obj instanceof Character || obj.getClass().isEnum(); }
java
static boolean isBasicValueType(final Object obj) { return obj == null || obj instanceof String || obj instanceof Integer || obj instanceof Boolean || obj instanceof Long || obj instanceof Float || obj instanceof Double || obj instanceof Short || obj instanceof Byte || obj instanceof Character || obj.getClass().isEnum(); }
[ "static", "boolean", "isBasicValueType", "(", "final", "Object", "obj", ")", "{", "return", "obj", "==", "null", "||", "obj", "instanceof", "String", "||", "obj", "instanceof", "Integer", "||", "obj", "instanceof", "Boolean", "||", "obj", "instanceof", "Long",...
Return true for objects that can be converted directly to and from string representation. @param obj the object @return true, if the object is null or of basic value type
[ "Return", "true", "for", "objects", "that", "can", "be", "converted", "directly", "to", "and", "from", "string", "representation", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/json/JSONUtils.java#L266-L270
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/json/JSONUtils.java
JSONUtils.fieldIsSerializable
static boolean fieldIsSerializable(final Field field, final boolean onlySerializePublicFields) { final int modifiers = field.getModifiers(); if ((!onlySerializePublicFields || Modifier.isPublic(modifiers)) && !Modifier.isTransient(modifiers) && !Modifier.isFinal(modifiers) && ((modifiers & 0x1000 /* synthetic */) == 0)) { return JSONUtils.isAccessibleOrMakeAccessible(field); } return false; }
java
static boolean fieldIsSerializable(final Field field, final boolean onlySerializePublicFields) { final int modifiers = field.getModifiers(); if ((!onlySerializePublicFields || Modifier.isPublic(modifiers)) && !Modifier.isTransient(modifiers) && !Modifier.isFinal(modifiers) && ((modifiers & 0x1000 /* synthetic */) == 0)) { return JSONUtils.isAccessibleOrMakeAccessible(field); } return false; }
[ "static", "boolean", "fieldIsSerializable", "(", "final", "Field", "field", ",", "final", "boolean", "onlySerializePublicFields", ")", "{", "final", "int", "modifiers", "=", "field", ".", "getModifiers", "(", ")", ";", "if", "(", "(", "!", "onlySerializePublicFi...
Check if a field is serializable. Don't serialize transient, final, synthetic, or inaccessible fields. <p> N.B. Tries to set field to accessible, which will require an "opens" declarations from modules that want to allow this introspection. @param field the field @param onlySerializePublicFields if true, only serialize public fields @return true if the field is serializable
[ "Check", "if", "a", "field", "is", "serializable", ".", "Don", "t", "serialize", "transient", "final", "synthetic", "or", "inaccessible", "fields", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/json/JSONUtils.java#L353-L360
train
classgraph/classgraph
src/main/java/io/github/classgraph/AnnotationInfo.java
AnnotationInfo.getParameterValues
public AnnotationParameterValueList getParameterValues() { if (annotationParamValuesWithDefaults == null) { final ClassInfo classInfo = getClassInfo(); if (classInfo == null) { // ClassInfo has not yet been set, just return values without defaults // (happens when trying to log AnnotationInfo during scanning, before ScanResult is available) return annotationParamValues == null ? AnnotationParameterValueList.EMPTY_LIST : annotationParamValues; } // Lazily convert any Object[] arrays of boxed types to primitive arrays if (annotationParamValues != null && !annotationParamValuesHasBeenConvertedToPrimitive) { annotationParamValues.convertWrapperArraysToPrimitiveArrays(classInfo); annotationParamValuesHasBeenConvertedToPrimitive = true; } if (classInfo.annotationDefaultParamValues != null && !classInfo.annotationDefaultParamValuesHasBeenConvertedToPrimitive) { classInfo.annotationDefaultParamValues.convertWrapperArraysToPrimitiveArrays(classInfo); classInfo.annotationDefaultParamValuesHasBeenConvertedToPrimitive = true; } // Check if one or both of the defaults and the values in this annotation instance are null (empty) final AnnotationParameterValueList defaultParamValues = classInfo.annotationDefaultParamValues; if (defaultParamValues == null && annotationParamValues == null) { return AnnotationParameterValueList.EMPTY_LIST; } else if (defaultParamValues == null) { return annotationParamValues; } else if (annotationParamValues == null) { return defaultParamValues; } // Overwrite defaults with non-defaults final Map<String, Object> allParamValues = new HashMap<>(); for (final AnnotationParameterValue defaultParamValue : defaultParamValues) { allParamValues.put(defaultParamValue.getName(), defaultParamValue.getValue()); } for (final AnnotationParameterValue annotationParamValue : this.annotationParamValues) { allParamValues.put(annotationParamValue.getName(), annotationParamValue.getValue()); } // Put annotation values in the same order as the annotation methods (there is one method for each // annotation constant) if (classInfo.methodInfo == null) { // Should not happen (when classfile is read, methods are always read, whether or not // scanSpec.enableMethodInfo is true) throw new IllegalArgumentException("Could not find methods for annotation " + classInfo.getName()); } annotationParamValuesWithDefaults = new AnnotationParameterValueList(); for (final MethodInfo mi : classInfo.methodInfo) { final String paramName = mi.getName(); switch (paramName) { // None of these method names should be present in the @interface class itself, it should only // contain methods for the annotation constants (but skip them anyway to be safe). These methods // should only exist in concrete instances of the annotation. case "<init>": case "<clinit>": case "hashCode": case "equals": case "toString": case "annotationType": // Skip break; default: // Annotation constant final Object paramValue = allParamValues.get(paramName); // Annotation values cannot be null (or absent, from either defaults or annotation instance) if (paramValue != null) { annotationParamValuesWithDefaults.add(new AnnotationParameterValue(paramName, paramValue)); } break; } } } return annotationParamValuesWithDefaults; }
java
public AnnotationParameterValueList getParameterValues() { if (annotationParamValuesWithDefaults == null) { final ClassInfo classInfo = getClassInfo(); if (classInfo == null) { // ClassInfo has not yet been set, just return values without defaults // (happens when trying to log AnnotationInfo during scanning, before ScanResult is available) return annotationParamValues == null ? AnnotationParameterValueList.EMPTY_LIST : annotationParamValues; } // Lazily convert any Object[] arrays of boxed types to primitive arrays if (annotationParamValues != null && !annotationParamValuesHasBeenConvertedToPrimitive) { annotationParamValues.convertWrapperArraysToPrimitiveArrays(classInfo); annotationParamValuesHasBeenConvertedToPrimitive = true; } if (classInfo.annotationDefaultParamValues != null && !classInfo.annotationDefaultParamValuesHasBeenConvertedToPrimitive) { classInfo.annotationDefaultParamValues.convertWrapperArraysToPrimitiveArrays(classInfo); classInfo.annotationDefaultParamValuesHasBeenConvertedToPrimitive = true; } // Check if one or both of the defaults and the values in this annotation instance are null (empty) final AnnotationParameterValueList defaultParamValues = classInfo.annotationDefaultParamValues; if (defaultParamValues == null && annotationParamValues == null) { return AnnotationParameterValueList.EMPTY_LIST; } else if (defaultParamValues == null) { return annotationParamValues; } else if (annotationParamValues == null) { return defaultParamValues; } // Overwrite defaults with non-defaults final Map<String, Object> allParamValues = new HashMap<>(); for (final AnnotationParameterValue defaultParamValue : defaultParamValues) { allParamValues.put(defaultParamValue.getName(), defaultParamValue.getValue()); } for (final AnnotationParameterValue annotationParamValue : this.annotationParamValues) { allParamValues.put(annotationParamValue.getName(), annotationParamValue.getValue()); } // Put annotation values in the same order as the annotation methods (there is one method for each // annotation constant) if (classInfo.methodInfo == null) { // Should not happen (when classfile is read, methods are always read, whether or not // scanSpec.enableMethodInfo is true) throw new IllegalArgumentException("Could not find methods for annotation " + classInfo.getName()); } annotationParamValuesWithDefaults = new AnnotationParameterValueList(); for (final MethodInfo mi : classInfo.methodInfo) { final String paramName = mi.getName(); switch (paramName) { // None of these method names should be present in the @interface class itself, it should only // contain methods for the annotation constants (but skip them anyway to be safe). These methods // should only exist in concrete instances of the annotation. case "<init>": case "<clinit>": case "hashCode": case "equals": case "toString": case "annotationType": // Skip break; default: // Annotation constant final Object paramValue = allParamValues.get(paramName); // Annotation values cannot be null (or absent, from either defaults or annotation instance) if (paramValue != null) { annotationParamValuesWithDefaults.add(new AnnotationParameterValue(paramName, paramValue)); } break; } } } return annotationParamValuesWithDefaults; }
[ "public", "AnnotationParameterValueList", "getParameterValues", "(", ")", "{", "if", "(", "annotationParamValuesWithDefaults", "==", "null", ")", "{", "final", "ClassInfo", "classInfo", "=", "getClassInfo", "(", ")", ";", "if", "(", "classInfo", "==", "null", ")",...
Get the parameter values. @return The parameter values of this annotation, including any default parameter values inherited from the annotation class definition, or the empty list if none.
[ "Get", "the", "parameter", "values", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/AnnotationInfo.java#L119-L193
train
classgraph/classgraph
src/main/java/io/github/classgraph/MethodInfo.java
MethodInfo.getAnnotationInfo
public AnnotationInfoList getAnnotationInfo() { if (!scanResult.scanSpec.enableAnnotationInfo) { throw new IllegalArgumentException("Please call ClassGraph#enableAnnotationInfo() before #scan()"); } return annotationInfo == null ? AnnotationInfoList.EMPTY_LIST : AnnotationInfoList.getIndirectAnnotations(annotationInfo, /* annotatedClass = */ null); }
java
public AnnotationInfoList getAnnotationInfo() { if (!scanResult.scanSpec.enableAnnotationInfo) { throw new IllegalArgumentException("Please call ClassGraph#enableAnnotationInfo() before #scan()"); } return annotationInfo == null ? AnnotationInfoList.EMPTY_LIST : AnnotationInfoList.getIndirectAnnotations(annotationInfo, /* annotatedClass = */ null); }
[ "public", "AnnotationInfoList", "getAnnotationInfo", "(", ")", "{", "if", "(", "!", "scanResult", ".", "scanSpec", ".", "enableAnnotationInfo", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Please call ClassGraph#enableAnnotationInfo() before #scan()\"", ")"...
Get a list of annotations on this method, along with any annotation parameter values. @return a list of annotations on this method, along with any annotation parameter values, wrapped in {@link AnnotationInfo} objects, or the empty list if none.
[ "Get", "a", "list", "of", "annotations", "on", "this", "method", "along", "with", "any", "annotation", "parameter", "values", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/MethodInfo.java#L473-L479
train
classgraph/classgraph
src/main/java/io/github/classgraph/MethodInfo.java
MethodInfo.hasParameterAnnotation
public boolean hasParameterAnnotation(final String annotationName) { for (final MethodParameterInfo methodParameterInfo : getParameterInfo()) { if (methodParameterInfo.hasAnnotation(annotationName)) { return true; } } return false; }
java
public boolean hasParameterAnnotation(final String annotationName) { for (final MethodParameterInfo methodParameterInfo : getParameterInfo()) { if (methodParameterInfo.hasAnnotation(annotationName)) { return true; } } return false; }
[ "public", "boolean", "hasParameterAnnotation", "(", "final", "String", "annotationName", ")", "{", "for", "(", "final", "MethodParameterInfo", "methodParameterInfo", ":", "getParameterInfo", "(", ")", ")", "{", "if", "(", "methodParameterInfo", ".", "hasAnnotation", ...
Check if this method has a parameter with the named annotation. @param annotationName The name of a method parameter annotation. @return true if this method has a parameter with the named annotation.
[ "Check", "if", "this", "method", "has", "a", "parameter", "with", "the", "named", "annotation", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/MethodInfo.java#L525-L532
train
classgraph/classgraph
src/main/java/io/github/classgraph/MethodInfo.java
MethodInfo.compareTo
@Override public int compareTo(final MethodInfo other) { final int diff0 = declaringClassName.compareTo(other.declaringClassName); if (diff0 != 0) { return diff0; } final int diff1 = name.compareTo(other.name); if (diff1 != 0) { return diff1; } return typeDescriptorStr.compareTo(other.typeDescriptorStr); }
java
@Override public int compareTo(final MethodInfo other) { final int diff0 = declaringClassName.compareTo(other.declaringClassName); if (diff0 != 0) { return diff0; } final int diff1 = name.compareTo(other.name); if (diff1 != 0) { return diff1; } return typeDescriptorStr.compareTo(other.typeDescriptorStr); }
[ "@", "Override", "public", "int", "compareTo", "(", "final", "MethodInfo", "other", ")", "{", "final", "int", "diff0", "=", "declaringClassName", ".", "compareTo", "(", "other", ".", "declaringClassName", ")", ";", "if", "(", "diff0", "!=", "0", ")", "{", ...
Sort in order of class name, method name, then type descriptor. @param other the other {@link MethodInfo} to compare. @return the result of the comparison.
[ "Sort", "in", "order", "of", "class", "name", "method", "name", "then", "type", "descriptor", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/MethodInfo.java#L717-L728
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/utils/VersionFinder.java
VersionFinder.getVersion
public static synchronized String getVersion() { // Try to get version number from pom.xml (available when running in Eclipse) final Class<?> cls = ClassGraph.class; try { final String className = cls.getName(); final URL classpathResource = cls.getResource("/" + JarUtils.classNameToClassfilePath(className)); if (classpathResource != null) { final Path absolutePackagePath = Paths.get(classpathResource.toURI()).getParent(); final int packagePathSegments = className.length() - className.replace(".", "").length(); // Remove package segments from path Path path = absolutePackagePath; for (int i = 0; i < packagePathSegments && path != null; i++) { path = path.getParent(); } // Remove up to two more levels for "bin" or "target/classes" for (int i = 0; i < 3 && path != null; i++, path = path.getParent()) { final Path pom = path.resolve("pom.xml"); try (InputStream is = Files.newInputStream(pom)) { final Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(is); doc.getDocumentElement().normalize(); String version = (String) XPathFactory.newInstance().newXPath().compile("/project/version") .evaluate(doc, XPathConstants.STRING); if (version != null) { version = version.trim(); if (!version.isEmpty()) { return version; } } } catch (final IOException e) { // Not found } } } } catch (final Exception e) { // Ignore } // Try to get version number from maven properties in jar's META-INF directory try (InputStream is = cls.getResourceAsStream( "/META-INF/maven/" + MAVEN_PACKAGE + "/" + MAVEN_ARTIFACT + "/pom.properties")) { if (is != null) { final Properties p = new Properties(); p.load(is); final String version = p.getProperty("version", "").trim(); if (!version.isEmpty()) { return version; } } } catch (final IOException e) { // Ignore } // Fallback to using Java API (version number is obtained from MANIFEST.MF) final Package pkg = cls.getPackage(); if (pkg != null) { String version = pkg.getImplementationVersion(); if (version == null) { version = ""; } version = version.trim(); if (version.isEmpty()) { version = pkg.getSpecificationVersion(); if (version == null) { version = ""; } version = version.trim(); } if (!version.isEmpty()) { return version; } } return "unknown"; }
java
public static synchronized String getVersion() { // Try to get version number from pom.xml (available when running in Eclipse) final Class<?> cls = ClassGraph.class; try { final String className = cls.getName(); final URL classpathResource = cls.getResource("/" + JarUtils.classNameToClassfilePath(className)); if (classpathResource != null) { final Path absolutePackagePath = Paths.get(classpathResource.toURI()).getParent(); final int packagePathSegments = className.length() - className.replace(".", "").length(); // Remove package segments from path Path path = absolutePackagePath; for (int i = 0; i < packagePathSegments && path != null; i++) { path = path.getParent(); } // Remove up to two more levels for "bin" or "target/classes" for (int i = 0; i < 3 && path != null; i++, path = path.getParent()) { final Path pom = path.resolve("pom.xml"); try (InputStream is = Files.newInputStream(pom)) { final Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(is); doc.getDocumentElement().normalize(); String version = (String) XPathFactory.newInstance().newXPath().compile("/project/version") .evaluate(doc, XPathConstants.STRING); if (version != null) { version = version.trim(); if (!version.isEmpty()) { return version; } } } catch (final IOException e) { // Not found } } } } catch (final Exception e) { // Ignore } // Try to get version number from maven properties in jar's META-INF directory try (InputStream is = cls.getResourceAsStream( "/META-INF/maven/" + MAVEN_PACKAGE + "/" + MAVEN_ARTIFACT + "/pom.properties")) { if (is != null) { final Properties p = new Properties(); p.load(is); final String version = p.getProperty("version", "").trim(); if (!version.isEmpty()) { return version; } } } catch (final IOException e) { // Ignore } // Fallback to using Java API (version number is obtained from MANIFEST.MF) final Package pkg = cls.getPackage(); if (pkg != null) { String version = pkg.getImplementationVersion(); if (version == null) { version = ""; } version = version.trim(); if (version.isEmpty()) { version = pkg.getSpecificationVersion(); if (version == null) { version = ""; } version = version.trim(); } if (!version.isEmpty()) { return version; } } return "unknown"; }
[ "public", "static", "synchronized", "String", "getVersion", "(", ")", "{", "// Try to get version number from pom.xml (available when running in Eclipse)", "final", "Class", "<", "?", ">", "cls", "=", "ClassGraph", ".", "class", ";", "try", "{", "final", "String", "cl...
Get the version number of ClassGraph. @return the version number of ClassGraph.
[ "Get", "the", "version", "number", "of", "ClassGraph", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/utils/VersionFinder.java#L206-L278
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/fastzipfilereader/ZipFileSliceReader.java
ZipFileSliceReader.getChunk
private ByteBuffer getChunk(final int chunkIdx) throws IOException, InterruptedException { ByteBuffer chunk = chunkCache[chunkIdx]; if (chunk == null) { final ByteBuffer byteBufferDup = zipFileSlice.physicalZipFile.getByteBuffer(chunkIdx).duplicate(); chunk = chunkCache[chunkIdx] = byteBufferDup; } return chunk; }
java
private ByteBuffer getChunk(final int chunkIdx) throws IOException, InterruptedException { ByteBuffer chunk = chunkCache[chunkIdx]; if (chunk == null) { final ByteBuffer byteBufferDup = zipFileSlice.physicalZipFile.getByteBuffer(chunkIdx).duplicate(); chunk = chunkCache[chunkIdx] = byteBufferDup; } return chunk; }
[ "private", "ByteBuffer", "getChunk", "(", "final", "int", "chunkIdx", ")", "throws", "IOException", ",", "InterruptedException", "{", "ByteBuffer", "chunk", "=", "chunkCache", "[", "chunkIdx", "]", ";", "if", "(", "chunk", "==", "null", ")", "{", "final", "B...
Get the 2GB chunk of the zipfile with the given chunk index. @param chunkIdx the chunk index @return the chunk @throws IOException if an I/O exception occurs. @throws InterruptedException if the thread was interrupted.
[ "Get", "the", "2GB", "chunk", "of", "the", "zipfile", "with", "the", "given", "chunk", "index", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/fastzipfilereader/ZipFileSliceReader.java#L76-L83
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/fastzipfilereader/ZipFileSliceReader.java
ZipFileSliceReader.getShort
static int getShort(final byte[] arr, final long off) throws IndexOutOfBoundsException { final int ioff = (int) off; if (ioff < 0 || ioff > arr.length - 2) { throw new IndexOutOfBoundsException(); } return ((arr[ioff + 1] & 0xff) << 8) | (arr[ioff] & 0xff); }
java
static int getShort(final byte[] arr, final long off) throws IndexOutOfBoundsException { final int ioff = (int) off; if (ioff < 0 || ioff > arr.length - 2) { throw new IndexOutOfBoundsException(); } return ((arr[ioff + 1] & 0xff) << 8) | (arr[ioff] & 0xff); }
[ "static", "int", "getShort", "(", "final", "byte", "[", "]", "arr", ",", "final", "long", "off", ")", "throws", "IndexOutOfBoundsException", "{", "final", "int", "ioff", "=", "(", "int", ")", "off", ";", "if", "(", "ioff", "<", "0", "||", "ioff", ">"...
Get a short from a byte array. @param arr the byte array @param off the offset to start reading from @return the short @throws IndexOutOfBoundsException the index out of bounds exception
[ "Get", "a", "short", "from", "a", "byte", "array", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/fastzipfilereader/ZipFileSliceReader.java#L154-L160
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/fastzipfilereader/ZipFileSliceReader.java
ZipFileSliceReader.getShort
int getShort(final long off) throws IOException, InterruptedException { if (off < 0 || off > zipFileSlice.len - 2) { throw new IndexOutOfBoundsException(); } if (read(off, scratch, 0, 2) < 2) { throw new EOFException("Unexpected EOF"); } return ((scratch[1] & 0xff) << 8) | (scratch[0] & 0xff); }
java
int getShort(final long off) throws IOException, InterruptedException { if (off < 0 || off > zipFileSlice.len - 2) { throw new IndexOutOfBoundsException(); } if (read(off, scratch, 0, 2) < 2) { throw new EOFException("Unexpected EOF"); } return ((scratch[1] & 0xff) << 8) | (scratch[0] & 0xff); }
[ "int", "getShort", "(", "final", "long", "off", ")", "throws", "IOException", ",", "InterruptedException", "{", "if", "(", "off", "<", "0", "||", "off", ">", "zipFileSlice", ".", "len", "-", "2", ")", "{", "throw", "new", "IndexOutOfBoundsException", "(", ...
Get a short from the zipfile slice. @param off the offset to start reading from @return the short @throws IOException if an I/O exception occurs. @throws InterruptedException if the thread was interrupted.
[ "Get", "a", "short", "from", "the", "zipfile", "slice", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/fastzipfilereader/ZipFileSliceReader.java#L173-L181
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/fastzipfilereader/ZipFileSliceReader.java
ZipFileSliceReader.getInt
static int getInt(final byte[] arr, final long off) throws IOException { final int ioff = (int) off; if (ioff < 0 || ioff > arr.length - 4) { throw new IndexOutOfBoundsException(); } return ((arr[ioff + 3] & 0xff) << 24) // | ((arr[ioff + 2] & 0xff) << 16) // | ((arr[ioff + 1] & 0xff) << 8) // | (arr[ioff] & 0xff); }
java
static int getInt(final byte[] arr, final long off) throws IOException { final int ioff = (int) off; if (ioff < 0 || ioff > arr.length - 4) { throw new IndexOutOfBoundsException(); } return ((arr[ioff + 3] & 0xff) << 24) // | ((arr[ioff + 2] & 0xff) << 16) // | ((arr[ioff + 1] & 0xff) << 8) // | (arr[ioff] & 0xff); }
[ "static", "int", "getInt", "(", "final", "byte", "[", "]", "arr", ",", "final", "long", "off", ")", "throws", "IOException", "{", "final", "int", "ioff", "=", "(", "int", ")", "off", ";", "if", "(", "ioff", "<", "0", "||", "ioff", ">", "arr", "."...
Get an int from a byte array. @param arr the byte array @param off the offset to start reading from @return the int @throws IOException if an I/O exception occurs.
[ "Get", "an", "int", "from", "a", "byte", "array", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/fastzipfilereader/ZipFileSliceReader.java#L194-L203
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/fastzipfilereader/ZipFileSliceReader.java
ZipFileSliceReader.getLong
static long getLong(final byte[] arr, final long off) throws IOException { final int ioff = (int) off; if (ioff < 0 || ioff > arr.length - 8) { throw new IndexOutOfBoundsException(); } return ((arr[ioff + 7] & 0xffL) << 56) // | ((arr[ioff + 6] & 0xffL) << 48) // | ((arr[ioff + 5] & 0xffL) << 40) // | ((arr[ioff + 4] & 0xffL) << 32) // | ((arr[ioff + 3] & 0xffL) << 24) // | ((arr[ioff + 2] & 0xffL) << 16) // | ((arr[ioff + 1] & 0xffL) << 8) // | (arr[ioff] & 0xffL); }
java
static long getLong(final byte[] arr, final long off) throws IOException { final int ioff = (int) off; if (ioff < 0 || ioff > arr.length - 8) { throw new IndexOutOfBoundsException(); } return ((arr[ioff + 7] & 0xffL) << 56) // | ((arr[ioff + 6] & 0xffL) << 48) // | ((arr[ioff + 5] & 0xffL) << 40) // | ((arr[ioff + 4] & 0xffL) << 32) // | ((arr[ioff + 3] & 0xffL) << 24) // | ((arr[ioff + 2] & 0xffL) << 16) // | ((arr[ioff + 1] & 0xffL) << 8) // | (arr[ioff] & 0xffL); }
[ "static", "long", "getLong", "(", "final", "byte", "[", "]", "arr", ",", "final", "long", "off", ")", "throws", "IOException", "{", "final", "int", "ioff", "=", "(", "int", ")", "off", ";", "if", "(", "ioff", "<", "0", "||", "ioff", ">", "arr", "...
Get a long from a byte array. @param arr the byte array @param off the offset to start reading from @return the long @throws IOException if an I/O exception occurs.
[ "Get", "a", "long", "from", "a", "byte", "array", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/fastzipfilereader/ZipFileSliceReader.java#L240-L253
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/fastzipfilereader/ZipFileSliceReader.java
ZipFileSliceReader.getLong
long getLong(final long off) throws IOException, InterruptedException { if (off < 0 || off > zipFileSlice.len - 8) { throw new IndexOutOfBoundsException(); } if (read(off, scratch, 0, 8) < 8) { throw new EOFException("Unexpected EOF"); } return ((scratch[7] & 0xffL) << 56) // | ((scratch[6] & 0xffL) << 48) // | ((scratch[5] & 0xffL) << 40) // | ((scratch[4] & 0xffL) << 32) // | ((scratch[3] & 0xffL) << 24) // | ((scratch[2] & 0xffL) << 16) // | ((scratch[1] & 0xffL) << 8) // | (scratch[0] & 0xffL); }
java
long getLong(final long off) throws IOException, InterruptedException { if (off < 0 || off > zipFileSlice.len - 8) { throw new IndexOutOfBoundsException(); } if (read(off, scratch, 0, 8) < 8) { throw new EOFException("Unexpected EOF"); } return ((scratch[7] & 0xffL) << 56) // | ((scratch[6] & 0xffL) << 48) // | ((scratch[5] & 0xffL) << 40) // | ((scratch[4] & 0xffL) << 32) // | ((scratch[3] & 0xffL) << 24) // | ((scratch[2] & 0xffL) << 16) // | ((scratch[1] & 0xffL) << 8) // | (scratch[0] & 0xffL); }
[ "long", "getLong", "(", "final", "long", "off", ")", "throws", "IOException", ",", "InterruptedException", "{", "if", "(", "off", "<", "0", "||", "off", ">", "zipFileSlice", ".", "len", "-", "8", ")", "{", "throw", "new", "IndexOutOfBoundsException", "(", ...
Get a long from the zipfile slice. @param off the offset to start reading from @return the long @throws IOException if an I/O exception occurs. @throws InterruptedException if the thread was interrupted.
[ "Get", "a", "long", "from", "the", "zipfile", "slice", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/fastzipfilereader/ZipFileSliceReader.java#L266-L281
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/fastzipfilereader/ZipFileSliceReader.java
ZipFileSliceReader.getString
static String getString(final byte[] arr, final long off, final int lenBytes) throws IOException { final int ioff = (int) off; if (ioff < 0 || ioff > arr.length - lenBytes) { throw new IndexOutOfBoundsException(); } return new String(arr, ioff, lenBytes, StandardCharsets.UTF_8); }
java
static String getString(final byte[] arr, final long off, final int lenBytes) throws IOException { final int ioff = (int) off; if (ioff < 0 || ioff > arr.length - lenBytes) { throw new IndexOutOfBoundsException(); } return new String(arr, ioff, lenBytes, StandardCharsets.UTF_8); }
[ "static", "String", "getString", "(", "final", "byte", "[", "]", "arr", ",", "final", "long", "off", ",", "final", "int", "lenBytes", ")", "throws", "IOException", "{", "final", "int", "ioff", "=", "(", "int", ")", "off", ";", "if", "(", "ioff", "<",...
Get a string from a byte array. @param arr the byte array @param off the offset to start reading from @param lenBytes the length of the string in bytes @return the string @throws IOException if an I/O exception occurs.
[ "Get", "a", "string", "from", "a", "byte", "array", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/fastzipfilereader/ZipFileSliceReader.java#L296-L302
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/fastzipfilereader/ZipFileSliceReader.java
ZipFileSliceReader.getString
String getString(final long off, final int lenBytes) throws IOException, InterruptedException { if (off < 0 || off > zipFileSlice.len - lenBytes) { throw new IndexOutOfBoundsException(); } final byte[] scratchToUse = lenBytes <= scratch.length ? scratch : new byte[lenBytes]; if (read(off, scratchToUse, 0, lenBytes) < lenBytes) { throw new EOFException("Unexpected EOF"); } // Assume the entry names are encoded in UTF-8 (should be the case for all jars; the only other // valid zipfile charset is CP437, which is the same as ASCII for printable high-bit-clear chars) return new String(scratchToUse, 0, lenBytes, StandardCharsets.UTF_8); }
java
String getString(final long off, final int lenBytes) throws IOException, InterruptedException { if (off < 0 || off > zipFileSlice.len - lenBytes) { throw new IndexOutOfBoundsException(); } final byte[] scratchToUse = lenBytes <= scratch.length ? scratch : new byte[lenBytes]; if (read(off, scratchToUse, 0, lenBytes) < lenBytes) { throw new EOFException("Unexpected EOF"); } // Assume the entry names are encoded in UTF-8 (should be the case for all jars; the only other // valid zipfile charset is CP437, which is the same as ASCII for printable high-bit-clear chars) return new String(scratchToUse, 0, lenBytes, StandardCharsets.UTF_8); }
[ "String", "getString", "(", "final", "long", "off", ",", "final", "int", "lenBytes", ")", "throws", "IOException", ",", "InterruptedException", "{", "if", "(", "off", "<", "0", "||", "off", ">", "zipFileSlice", ".", "len", "-", "lenBytes", ")", "{", "thr...
Get a string from the zipfile slice. @param off the offset to start reading from @param lenBytes the length of the string in bytes @return the string @throws IOException if an I/O exception occurs. @throws InterruptedException if the thread was interrupted.
[ "Get", "a", "string", "from", "the", "zipfile", "slice", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/fastzipfilereader/ZipFileSliceReader.java#L317-L328
train
classgraph/classgraph
src/main/java/io/github/classgraph/ReferenceTypeSignature.java
ReferenceTypeSignature.parseReferenceTypeSignature
static ReferenceTypeSignature parseReferenceTypeSignature(final Parser parser, final String definingClassName) throws ParseException { final ClassRefTypeSignature classTypeSignature = ClassRefTypeSignature.parse(parser, definingClassName); if (classTypeSignature != null) { return classTypeSignature; } final TypeVariableSignature typeVariableSignature = TypeVariableSignature.parse(parser, definingClassName); if (typeVariableSignature != null) { return typeVariableSignature; } final ArrayTypeSignature arrayTypeSignature = ArrayTypeSignature.parse(parser, definingClassName); if (arrayTypeSignature != null) { return arrayTypeSignature; } return null; }
java
static ReferenceTypeSignature parseReferenceTypeSignature(final Parser parser, final String definingClassName) throws ParseException { final ClassRefTypeSignature classTypeSignature = ClassRefTypeSignature.parse(parser, definingClassName); if (classTypeSignature != null) { return classTypeSignature; } final TypeVariableSignature typeVariableSignature = TypeVariableSignature.parse(parser, definingClassName); if (typeVariableSignature != null) { return typeVariableSignature; } final ArrayTypeSignature arrayTypeSignature = ArrayTypeSignature.parse(parser, definingClassName); if (arrayTypeSignature != null) { return arrayTypeSignature; } return null; }
[ "static", "ReferenceTypeSignature", "parseReferenceTypeSignature", "(", "final", "Parser", "parser", ",", "final", "String", "definingClassName", ")", "throws", "ParseException", "{", "final", "ClassRefTypeSignature", "classTypeSignature", "=", "ClassRefTypeSignature", ".", ...
Parse a reference type signature. @param parser The parser @param definingClassName The class containing the type descriptor. @return The parsed type reference type signature. @throws ParseException If the type signature could not be parsed.
[ "Parse", "a", "reference", "type", "signature", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ReferenceTypeSignature.java#L55-L70
train
classgraph/classgraph
src/main/java/io/github/classgraph/ReferenceTypeSignature.java
ReferenceTypeSignature.parseClassBound
static ReferenceTypeSignature parseClassBound(final Parser parser, final String definingClassName) throws ParseException { parser.expect(':'); // May return null if there is no signature after ':' (class bound signature may be empty) return parseReferenceTypeSignature(parser, definingClassName); }
java
static ReferenceTypeSignature parseClassBound(final Parser parser, final String definingClassName) throws ParseException { parser.expect(':'); // May return null if there is no signature after ':' (class bound signature may be empty) return parseReferenceTypeSignature(parser, definingClassName); }
[ "static", "ReferenceTypeSignature", "parseClassBound", "(", "final", "Parser", "parser", ",", "final", "String", "definingClassName", ")", "throws", "ParseException", "{", "parser", ".", "expect", "(", "'", "'", ")", ";", "// May return null if there is no signature aft...
Parse a class bound. @param parser The parser. @param definingClassName The class containing the type descriptor. @return The parsed class bound. @throws ParseException If the type signature could not be parsed.
[ "Parse", "a", "class", "bound", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ReferenceTypeSignature.java#L83-L88
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/utils/FileUtils.java
FileUtils.isClassfile
public static boolean isClassfile(final String path) { final int len = path.length(); return len > 6 && path.regionMatches(true, len - 6, ".class", 0, 6); }
java
public static boolean isClassfile(final String path) { final int len = path.length(); return len > 6 && path.regionMatches(true, len - 6, ".class", 0, 6); }
[ "public", "static", "boolean", "isClassfile", "(", "final", "String", "path", ")", "{", "final", "int", "len", "=", "path", ".", "length", "(", ")", ";", "return", "len", ">", "6", "&&", "path", ".", "regionMatches", "(", "true", ",", "len", "-", "6"...
Check if the path ends with a ".class" extension, ignoring case. @param path A file path. @return true if path has a ".class" extension, ignoring case.
[ "Check", "if", "the", "path", "ends", "with", "a", ".", "class", "extension", "ignoring", "case", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/utils/FileUtils.java#L398-L401
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/utils/FileUtils.java
FileUtils.getParentDirPath
public static String getParentDirPath(final String path, final char separator) { final int lastSlashIdx = path.lastIndexOf(separator); if (lastSlashIdx <= 0) { return ""; } return path.substring(0, lastSlashIdx); }
java
public static String getParentDirPath(final String path, final char separator) { final int lastSlashIdx = path.lastIndexOf(separator); if (lastSlashIdx <= 0) { return ""; } return path.substring(0, lastSlashIdx); }
[ "public", "static", "String", "getParentDirPath", "(", "final", "String", "path", ",", "final", "char", "separator", ")", "{", "final", "int", "lastSlashIdx", "=", "path", ".", "lastIndexOf", "(", "separator", ")", ";", "if", "(", "lastSlashIdx", "<=", "0", ...
Get the parent dir path. @param path the path @param separator the separator @return the parent dir path
[ "Get", "the", "parent", "dir", "path", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/utils/FileUtils.java#L431-L437
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/utils/ReflectionUtils.java
ReflectionUtils.getStaticFieldVal
public static Object getStaticFieldVal(final Class<?> cls, final String fieldName, final boolean throwException) throws IllegalArgumentException { if (cls == null || fieldName == null) { if (throwException) { throw new NullPointerException(); } else { return null; } } return getFieldVal(cls, null, fieldName, throwException); }
java
public static Object getStaticFieldVal(final Class<?> cls, final String fieldName, final boolean throwException) throws IllegalArgumentException { if (cls == null || fieldName == null) { if (throwException) { throw new NullPointerException(); } else { return null; } } return getFieldVal(cls, null, fieldName, throwException); }
[ "public", "static", "Object", "getStaticFieldVal", "(", "final", "Class", "<", "?", ">", "cls", ",", "final", "String", "fieldName", ",", "final", "boolean", "throwException", ")", "throws", "IllegalArgumentException", "{", "if", "(", "cls", "==", "null", "||"...
Get the value of the named static field in the given class or any of its superclasses. If an exception is thrown while trying to read the field value, and throwException is true, then IllegalArgumentException is thrown wrapping the cause, otherwise this will return null. If passed a null class reference, returns null unless throwException is true, then throws IllegalArgumentException. @param cls The class. @param fieldName The field name. @param throwException If true, throw an exception if the field value could not be read. @return The field value. @throws IllegalArgumentException If the field value could not be read.
[ "Get", "the", "value", "of", "the", "named", "static", "field", "in", "the", "given", "class", "or", "any", "of", "its", "superclasses", ".", "If", "an", "exception", "is", "thrown", "while", "trying", "to", "read", "the", "field", "value", "and", "throw...
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/utils/ReflectionUtils.java#L151-L161
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/classloaderhandler/FelixClassLoaderHandler.java
FelixClassLoaderHandler.getContentLocation
private static String getContentLocation(final Object content) { final File file = (File) ReflectionUtils.invokeMethod(content, "getFile", false); return file != null ? file.toURI().toString() : null; }
java
private static String getContentLocation(final Object content) { final File file = (File) ReflectionUtils.invokeMethod(content, "getFile", false); return file != null ? file.toURI().toString() : null; }
[ "private", "static", "String", "getContentLocation", "(", "final", "Object", "content", ")", "{", "final", "File", "file", "=", "(", "File", ")", "ReflectionUtils", ".", "invokeMethod", "(", "content", ",", "\"getFile\"", ",", "false", ")", ";", "return", "f...
Get the content location. @param content the content object @return the content location
[ "Get", "the", "content", "location", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/classloaderhandler/FelixClassLoaderHandler.java#L90-L93
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/classloaderhandler/FelixClassLoaderHandler.java
FelixClassLoaderHandler.addBundle
private static void addBundle(final Object bundleWiring, final ClassLoader classLoader, final ClasspathOrder classpathOrderOut, final Set<Object> bundles, final ScanSpec scanSpec, final LogNode log) { // Track the bundles we've processed to prevent loops bundles.add(bundleWiring); // Get the revision for this wiring final Object revision = ReflectionUtils.invokeMethod(bundleWiring, "getRevision", false); // Get the contents final Object content = ReflectionUtils.invokeMethod(revision, "getContent", false); final String location = content != null ? getContentLocation(content) : null; if (location != null) { // Add the bundle object classpathOrderOut.addClasspathEntry(location, classLoader, scanSpec, log); // And any embedded content final List<?> embeddedContent = (List<?>) ReflectionUtils.invokeMethod(revision, "getContentPath", false); if (embeddedContent != null) { for (final Object embedded : embeddedContent) { if (embedded != content) { final String embeddedLocation = embedded != null ? getContentLocation(embedded) : null; if (embeddedLocation != null) { classpathOrderOut.addClasspathEntry(embeddedLocation, classLoader, scanSpec, log); } } } } } }
java
private static void addBundle(final Object bundleWiring, final ClassLoader classLoader, final ClasspathOrder classpathOrderOut, final Set<Object> bundles, final ScanSpec scanSpec, final LogNode log) { // Track the bundles we've processed to prevent loops bundles.add(bundleWiring); // Get the revision for this wiring final Object revision = ReflectionUtils.invokeMethod(bundleWiring, "getRevision", false); // Get the contents final Object content = ReflectionUtils.invokeMethod(revision, "getContent", false); final String location = content != null ? getContentLocation(content) : null; if (location != null) { // Add the bundle object classpathOrderOut.addClasspathEntry(location, classLoader, scanSpec, log); // And any embedded content final List<?> embeddedContent = (List<?>) ReflectionUtils.invokeMethod(revision, "getContentPath", false); if (embeddedContent != null) { for (final Object embedded : embeddedContent) { if (embedded != content) { final String embeddedLocation = embedded != null ? getContentLocation(embedded) : null; if (embeddedLocation != null) { classpathOrderOut.addClasspathEntry(embeddedLocation, classLoader, scanSpec, log); } } } } } }
[ "private", "static", "void", "addBundle", "(", "final", "Object", "bundleWiring", ",", "final", "ClassLoader", "classLoader", ",", "final", "ClasspathOrder", "classpathOrderOut", ",", "final", "Set", "<", "Object", ">", "bundles", ",", "final", "ScanSpec", "scanSp...
Adds the bundle. @param bundleWiring the bundle wiring @param classLoader the classloader @param classpathOrderOut the classpath order out @param bundles the bundles @param scanSpec the scan spec @param log the log
[ "Adds", "the", "bundle", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/classloaderhandler/FelixClassLoaderHandler.java#L111-L140
train
classgraph/classgraph
src/main/java/io/github/classgraph/AnnotationParameterValue.java
AnnotationParameterValue.toStringParamValueOnly
void toStringParamValueOnly(final StringBuilder buf) { if (value == null) { buf.append("null"); } else { final Object paramVal = value.get(); final Class<?> valClass = paramVal.getClass(); if (valClass.isArray()) { buf.append('['); for (int j = 0, n = Array.getLength(paramVal); j < n; j++) { if (j > 0) { buf.append(", "); } final Object elt = Array.get(paramVal, j); buf.append(elt == null ? "null" : elt.toString()); } buf.append(']'); } else if (paramVal instanceof String) { buf.append('"'); buf.append(paramVal.toString().replace("\"", "\\\"").replace("\n", "\\n").replace("\r", "\\r")); buf.append('"'); } else if (paramVal instanceof Character) { buf.append('\''); buf.append(paramVal.toString().replace("'", "\\'").replace("\n", "\\n").replace("\r", "\\r")); buf.append('\''); } else { buf.append(paramVal.toString()); } } }
java
void toStringParamValueOnly(final StringBuilder buf) { if (value == null) { buf.append("null"); } else { final Object paramVal = value.get(); final Class<?> valClass = paramVal.getClass(); if (valClass.isArray()) { buf.append('['); for (int j = 0, n = Array.getLength(paramVal); j < n; j++) { if (j > 0) { buf.append(", "); } final Object elt = Array.get(paramVal, j); buf.append(elt == null ? "null" : elt.toString()); } buf.append(']'); } else if (paramVal instanceof String) { buf.append('"'); buf.append(paramVal.toString().replace("\"", "\\\"").replace("\n", "\\n").replace("\r", "\\r")); buf.append('"'); } else if (paramVal instanceof Character) { buf.append('\''); buf.append(paramVal.toString().replace("'", "\\'").replace("\n", "\\n").replace("\r", "\\r")); buf.append('\''); } else { buf.append(paramVal.toString()); } } }
[ "void", "toStringParamValueOnly", "(", "final", "StringBuilder", "buf", ")", "{", "if", "(", "value", "==", "null", ")", "{", "buf", ".", "append", "(", "\"null\"", ")", ";", "}", "else", "{", "final", "Object", "paramVal", "=", "value", ".", "get", "(...
To string, param value only. @param buf the buf
[ "To", "string", "param", "value", "only", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/AnnotationParameterValue.java#L206-L234
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/classpath/SystemJarFinder.java
SystemJarFinder.addJREPath
private static boolean addJREPath(final File dir) { if (dir != null && !dir.getPath().isEmpty() && FileUtils.canRead(dir) && dir.isDirectory()) { final File[] dirFiles = dir.listFiles(); if (dirFiles != null) { for (final File file : dirFiles) { final String filePath = file.getPath(); if (filePath.endsWith(".jar")) { final String jarPathResolved = FastPathResolver.resolve(FileUtils.CURR_DIR_PATH, filePath); if (jarPathResolved.endsWith("/rt.jar")) { RT_JARS.add(jarPathResolved); } else { JRE_LIB_OR_EXT_JARS.add(jarPathResolved); } try { final File canonicalFile = file.getCanonicalFile(); final String canonicalFilePath = canonicalFile.getPath(); if (!canonicalFilePath.equals(filePath)) { final String canonicalJarPathResolved = FastPathResolver .resolve(FileUtils.CURR_DIR_PATH, filePath); JRE_LIB_OR_EXT_JARS.add(canonicalJarPathResolved); } } catch (IOException | SecurityException e) { // Ignored } } } return true; } } return false; }
java
private static boolean addJREPath(final File dir) { if (dir != null && !dir.getPath().isEmpty() && FileUtils.canRead(dir) && dir.isDirectory()) { final File[] dirFiles = dir.listFiles(); if (dirFiles != null) { for (final File file : dirFiles) { final String filePath = file.getPath(); if (filePath.endsWith(".jar")) { final String jarPathResolved = FastPathResolver.resolve(FileUtils.CURR_DIR_PATH, filePath); if (jarPathResolved.endsWith("/rt.jar")) { RT_JARS.add(jarPathResolved); } else { JRE_LIB_OR_EXT_JARS.add(jarPathResolved); } try { final File canonicalFile = file.getCanonicalFile(); final String canonicalFilePath = canonicalFile.getPath(); if (!canonicalFilePath.equals(filePath)) { final String canonicalJarPathResolved = FastPathResolver .resolve(FileUtils.CURR_DIR_PATH, filePath); JRE_LIB_OR_EXT_JARS.add(canonicalJarPathResolved); } } catch (IOException | SecurityException e) { // Ignored } } } return true; } } return false; }
[ "private", "static", "boolean", "addJREPath", "(", "final", "File", "dir", ")", "{", "if", "(", "dir", "!=", "null", "&&", "!", "dir", ".", "getPath", "(", ")", ".", "isEmpty", "(", ")", "&&", "FileUtils", ".", "canRead", "(", "dir", ")", "&&", "di...
Add and search a JRE path. @param dir the JRE directory @return true if the directory was readable.
[ "Add", "and", "search", "a", "JRE", "path", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/classpath/SystemJarFinder.java#L66-L96
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/fastzipfilereader/LogicalZipFile.java
LogicalZipFile.getManifestValue
private static Entry<String, Integer> getManifestValue(final byte[] manifest, final int startIdx) { // See if manifest entry is split across multiple lines int curr = startIdx; final int len = manifest.length; while (curr < len && manifest[curr] == (byte) ' ') { // Skip initial spaces curr++; } final int firstNonSpaceIdx = curr; boolean isMultiLine = false; for (; curr < len && !isMultiLine; curr++) { final byte b = manifest[curr]; if (b == (byte) '\r' && curr < len - 1 && manifest[curr + 1] == (byte) '\n') { if (curr < len - 2 && manifest[curr + 2] == (byte) ' ') { isMultiLine = true; } break; } else if (b == (byte) '\r' || b == (byte) '\n') { if (curr < len - 1 && manifest[curr + 1] == (byte) ' ') { isMultiLine = true; } break; } } String val; if (!isMultiLine) { // Fast path for single-line value val = new String(manifest, firstNonSpaceIdx, curr - firstNonSpaceIdx, StandardCharsets.UTF_8); } else { // Skip (newline + space) sequences in multi-line values final ByteArrayOutputStream buf = new ByteArrayOutputStream(); curr = firstNonSpaceIdx; for (; curr < len; curr++) { final byte b = manifest[curr]; boolean isLineEnd; if (b == (byte) '\r' && curr < len - 1 && manifest[curr + 1] == (byte) '\n') { // CRLF curr += 2; isLineEnd = true; } else if (b == '\r' || b == '\n') { // CR or LF curr += 1; isLineEnd = true; } else { buf.write(b); isLineEnd = false; } if (isLineEnd && curr < len && manifest[curr] != (byte) ' ') { // Value ends if line break is not followed by a space break; } // If line break was followed by a space, then the curr++ in the for loop header will skip it } try { val = buf.toString("UTF-8"); } catch (final UnsupportedEncodingException e) { // Should not happen throw ClassGraphException.newClassGraphException("UTF-8 encoding unsupported", e); } } return new SimpleEntry<>(val.endsWith(" ") ? val.trim() : val, curr); }
java
private static Entry<String, Integer> getManifestValue(final byte[] manifest, final int startIdx) { // See if manifest entry is split across multiple lines int curr = startIdx; final int len = manifest.length; while (curr < len && manifest[curr] == (byte) ' ') { // Skip initial spaces curr++; } final int firstNonSpaceIdx = curr; boolean isMultiLine = false; for (; curr < len && !isMultiLine; curr++) { final byte b = manifest[curr]; if (b == (byte) '\r' && curr < len - 1 && manifest[curr + 1] == (byte) '\n') { if (curr < len - 2 && manifest[curr + 2] == (byte) ' ') { isMultiLine = true; } break; } else if (b == (byte) '\r' || b == (byte) '\n') { if (curr < len - 1 && manifest[curr + 1] == (byte) ' ') { isMultiLine = true; } break; } } String val; if (!isMultiLine) { // Fast path for single-line value val = new String(manifest, firstNonSpaceIdx, curr - firstNonSpaceIdx, StandardCharsets.UTF_8); } else { // Skip (newline + space) sequences in multi-line values final ByteArrayOutputStream buf = new ByteArrayOutputStream(); curr = firstNonSpaceIdx; for (; curr < len; curr++) { final byte b = manifest[curr]; boolean isLineEnd; if (b == (byte) '\r' && curr < len - 1 && manifest[curr + 1] == (byte) '\n') { // CRLF curr += 2; isLineEnd = true; } else if (b == '\r' || b == '\n') { // CR or LF curr += 1; isLineEnd = true; } else { buf.write(b); isLineEnd = false; } if (isLineEnd && curr < len && manifest[curr] != (byte) ' ') { // Value ends if line break is not followed by a space break; } // If line break was followed by a space, then the curr++ in the for loop header will skip it } try { val = buf.toString("UTF-8"); } catch (final UnsupportedEncodingException e) { // Should not happen throw ClassGraphException.newClassGraphException("UTF-8 encoding unsupported", e); } } return new SimpleEntry<>(val.endsWith(" ") ? val.trim() : val, curr); }
[ "private", "static", "Entry", "<", "String", ",", "Integer", ">", "getManifestValue", "(", "final", "byte", "[", "]", "manifest", ",", "final", "int", "startIdx", ")", "{", "// See if manifest entry is split across multiple lines", "int", "curr", "=", "startIdx", ...
Extract a value from the manifest, and return the value as a string, along with the index after the terminating newline. Manifest files support three different line terminator types, and entries can be split across lines with a line terminator followed by a space. @param manifest the manifest bytes @param startIdx the start index of the manifest value @return the manifest value
[ "Extract", "a", "value", "from", "the", "manifest", "and", "return", "the", "value", "as", "a", "string", "along", "with", "the", "index", "after", "the", "terminating", "newline", ".", "Manifest", "files", "support", "three", "different", "line", "terminator"...
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/fastzipfilereader/LogicalZipFile.java#L170-L231
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/fastzipfilereader/LogicalZipFile.java
LogicalZipFile.manifestKeyToBytes
private static byte[] manifestKeyToBytes(final String key) { final byte[] bytes = new byte[key.length()]; for (int i = 0; i < key.length(); i++) { bytes[i] = (byte) Character.toLowerCase(key.charAt(i)); } return bytes; }
java
private static byte[] manifestKeyToBytes(final String key) { final byte[] bytes = new byte[key.length()]; for (int i = 0; i < key.length(); i++) { bytes[i] = (byte) Character.toLowerCase(key.charAt(i)); } return bytes; }
[ "private", "static", "byte", "[", "]", "manifestKeyToBytes", "(", "final", "String", "key", ")", "{", "final", "byte", "[", "]", "bytes", "=", "new", "byte", "[", "key", ".", "length", "(", ")", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i...
Manifest key to bytes. @param key the manifest key @return the manifest key bytes, lowercased.
[ "Manifest", "key", "to", "bytes", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/fastzipfilereader/LogicalZipFile.java#L240-L246
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/fastzipfilereader/LogicalZipFile.java
LogicalZipFile.keyMatchesAtPosition
private static boolean keyMatchesAtPosition(final byte[] manifest, final byte[] key, final int pos) { if (pos + key.length + 1 > manifest.length || manifest[pos + key.length] != ':') { return false; } for (int i = 0; i < key.length; i++) { // Manifest keys are case insensitive if (toLowerCase[manifest[i + pos]] != key[i]) { return false; } } return true; }
java
private static boolean keyMatchesAtPosition(final byte[] manifest, final byte[] key, final int pos) { if (pos + key.length + 1 > manifest.length || manifest[pos + key.length] != ':') { return false; } for (int i = 0; i < key.length; i++) { // Manifest keys are case insensitive if (toLowerCase[manifest[i + pos]] != key[i]) { return false; } } return true; }
[ "private", "static", "boolean", "keyMatchesAtPosition", "(", "final", "byte", "[", "]", "manifest", ",", "final", "byte", "[", "]", "key", ",", "final", "int", "pos", ")", "{", "if", "(", "pos", "+", "key", ".", "length", "+", "1", ">", "manifest", "...
Key matches at position. @param manifest the manifest @param key the key @param pos the position to try matching @return true if the key matches at this position
[ "Key", "matches", "at", "position", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/fastzipfilereader/LogicalZipFile.java#L259-L270
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClasspathElementModule.java
ClasspathElementModule.getModuleName
@Override public String getModuleName() { String moduleName = moduleRef.getName(); if (moduleName == null || moduleName.isEmpty()) { moduleName = moduleNameFromModuleDescriptor; } return moduleName == null || moduleName.isEmpty() ? null : moduleName; }
java
@Override public String getModuleName() { String moduleName = moduleRef.getName(); if (moduleName == null || moduleName.isEmpty()) { moduleName = moduleNameFromModuleDescriptor; } return moduleName == null || moduleName.isEmpty() ? null : moduleName; }
[ "@", "Override", "public", "String", "getModuleName", "(", ")", "{", "String", "moduleName", "=", "moduleRef", ".", "getName", "(", ")", ";", "if", "(", "moduleName", "==", "null", "||", "moduleName", ".", "isEmpty", "(", ")", ")", "{", "moduleName", "="...
Get the module name from the module reference or the module descriptor. @return the module name, or null if the module does not have a name.
[ "Get", "the", "module", "name", "from", "the", "module", "reference", "or", "the", "module", "descriptor", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClasspathElementModule.java#L348-L355
train
classgraph/classgraph
src/main/java/io/github/classgraph/PackageInfo.java
PackageInfo.addAnnotations
void addAnnotations(final AnnotationInfoList packageAnnotations) { // Currently only class annotations are used in the package-info.class file if (packageAnnotations != null && !packageAnnotations.isEmpty()) { if (this.annotationInfo == null) { this.annotationInfo = new AnnotationInfoList(packageAnnotations); } else { this.annotationInfo.addAll(packageAnnotations); } } }
java
void addAnnotations(final AnnotationInfoList packageAnnotations) { // Currently only class annotations are used in the package-info.class file if (packageAnnotations != null && !packageAnnotations.isEmpty()) { if (this.annotationInfo == null) { this.annotationInfo = new AnnotationInfoList(packageAnnotations); } else { this.annotationInfo.addAll(packageAnnotations); } } }
[ "void", "addAnnotations", "(", "final", "AnnotationInfoList", "packageAnnotations", ")", "{", "// Currently only class annotations are used in the package-info.class file", "if", "(", "packageAnnotations", "!=", "null", "&&", "!", "packageAnnotations", ".", "isEmpty", "(", ")...
Add annotations found in a package descriptor classfile. @param packageAnnotations the package annotations
[ "Add", "annotations", "found", "in", "a", "package", "descriptor", "classfile", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/PackageInfo.java#L91-L100
train
classgraph/classgraph
src/main/java/io/github/classgraph/PackageInfo.java
PackageInfo.getChildren
public PackageInfoList getChildren() { if (children == null) { return PackageInfoList.EMPTY_LIST; } final PackageInfoList childrenSorted = new PackageInfoList(children); // Ensure children are sorted CollectionUtils.sortIfNotEmpty(childrenSorted, new Comparator<PackageInfo>() { @Override public int compare(final PackageInfo o1, final PackageInfo o2) { return o1.name.compareTo(o2.name); } }); return childrenSorted; }
java
public PackageInfoList getChildren() { if (children == null) { return PackageInfoList.EMPTY_LIST; } final PackageInfoList childrenSorted = new PackageInfoList(children); // Ensure children are sorted CollectionUtils.sortIfNotEmpty(childrenSorted, new Comparator<PackageInfo>() { @Override public int compare(final PackageInfo o1, final PackageInfo o2) { return o1.name.compareTo(o2.name); } }); return childrenSorted; }
[ "public", "PackageInfoList", "getChildren", "(", ")", "{", "if", "(", "children", "==", "null", ")", "{", "return", "PackageInfoList", ".", "EMPTY_LIST", ";", "}", "final", "PackageInfoList", "childrenSorted", "=", "new", "PackageInfoList", "(", "children", ")",...
The child packages of this package, or the empty list if none. @return the child packages, or the empty list if none.
[ "The", "child", "packages", "of", "this", "package", "or", "the", "empty", "list", "if", "none", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/PackageInfo.java#L166-L179
train
classgraph/classgraph
src/main/java/io/github/classgraph/PackageInfo.java
PackageInfo.getParentPackageName
static String getParentPackageName(final String packageOrClassName) { if (packageOrClassName.isEmpty()) { return null; } final int lastDotIdx = packageOrClassName.lastIndexOf('.'); return lastDotIdx < 0 ? "" : packageOrClassName.substring(0, lastDotIdx); }
java
static String getParentPackageName(final String packageOrClassName) { if (packageOrClassName.isEmpty()) { return null; } final int lastDotIdx = packageOrClassName.lastIndexOf('.'); return lastDotIdx < 0 ? "" : packageOrClassName.substring(0, lastDotIdx); }
[ "static", "String", "getParentPackageName", "(", "final", "String", "packageOrClassName", ")", "{", "if", "(", "packageOrClassName", ".", "isEmpty", "(", ")", ")", "{", "return", "null", ";", "}", "final", "int", "lastDotIdx", "=", "packageOrClassName", ".", "...
Get the name of the parent package of a parent, or the package of the named class. @param packageOrClassName The package or class name. @return the parent package, or the package of the named class, or null if packageOrClassName is the root package ("").
[ "Get", "the", "name", "of", "the", "parent", "package", "of", "a", "parent", "or", "the", "package", "of", "the", "named", "class", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/PackageInfo.java#L239-L245
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/types/Parser.java
Parser.getPositionInfo
public String getPositionInfo() { final int showStart = Math.max(0, position - SHOW_BEFORE); final int showEnd = Math.min(string.length(), position + SHOW_AFTER); return "before: \"" + JSONUtils.escapeJSONString(string.substring(showStart, position)) + "\"; after: \"" + JSONUtils.escapeJSONString(string.substring(position, showEnd)) + "\"; position: " + position + "; token: \"" + token + "\""; }
java
public String getPositionInfo() { final int showStart = Math.max(0, position - SHOW_BEFORE); final int showEnd = Math.min(string.length(), position + SHOW_AFTER); return "before: \"" + JSONUtils.escapeJSONString(string.substring(showStart, position)) + "\"; after: \"" + JSONUtils.escapeJSONString(string.substring(position, showEnd)) + "\"; position: " + position + "; token: \"" + token + "\""; }
[ "public", "String", "getPositionInfo", "(", ")", "{", "final", "int", "showStart", "=", "Math", ".", "max", "(", "0", ",", "position", "-", "SHOW_BEFORE", ")", ";", "final", "int", "showEnd", "=", "Math", ".", "min", "(", "string", ".", "length", "(", ...
Get the parsing context as a string, for debugging. @return A string showing parsing context, for debugging.
[ "Get", "the", "parsing", "context", "as", "a", "string", "for", "debugging", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/types/Parser.java#L75-L81
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/types/Parser.java
Parser.expect
public void expect(final char expectedChar) throws ParseException { final int next = getc(); if (next != expectedChar) { throw new ParseException(this, "Expected '" + expectedChar + "'; got '" + (char) next + "'"); } }
java
public void expect(final char expectedChar) throws ParseException { final int next = getc(); if (next != expectedChar) { throw new ParseException(this, "Expected '" + expectedChar + "'; got '" + (char) next + "'"); } }
[ "public", "void", "expect", "(", "final", "char", "expectedChar", ")", "throws", "ParseException", "{", "final", "int", "next", "=", "getc", "(", ")", ";", "if", "(", "next", "!=", "expectedChar", ")", "{", "throw", "new", "ParseException", "(", "this", ...
Expect the next character. @param expectedChar The expected character. @throws ParseException If the next character was not the expected character.
[ "Expect", "the", "next", "character", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/types/Parser.java#L127-L132
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/types/Parser.java
Parser.skipWhitespace
public void skipWhitespace() { while (position < string.length()) { final char c = string.charAt(position); if (c == ' ' || c == '\n' || c == '\r' || c == '\t') { position++; } else { break; } } }
java
public void skipWhitespace() { while (position < string.length()) { final char c = string.charAt(position); if (c == ' ' || c == '\n' || c == '\r' || c == '\t') { position++; } else { break; } } }
[ "public", "void", "skipWhitespace", "(", ")", "{", "while", "(", "position", "<", "string", ".", "length", "(", ")", ")", "{", "final", "char", "c", "=", "string", ".", "charAt", "(", "position", ")", ";", "if", "(", "c", "==", "'", "'", "||", "c...
Skip whitespace starting at the current position.
[ "Skip", "whitespace", "starting", "at", "the", "current", "position", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/types/Parser.java#L277-L286
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/json/JSONObject.java
JSONObject.toJSONString
void toJSONString(final Map<ReferenceEqualityKey<JSONReference>, CharSequence> jsonReferenceToId, final boolean includeNullValuedFields, final int depth, final int indentWidth, final StringBuilder buf) { final boolean prettyPrint = indentWidth > 0; final int n = items.size(); int numDisplayedFields; if (includeNullValuedFields) { numDisplayedFields = n; } else { numDisplayedFields = 0; for (final Entry<String, Object> item : items) { if (item.getValue() != null) { numDisplayedFields++; } } } if (objectId == null && numDisplayedFields == 0) { buf.append("{}"); } else { buf.append(prettyPrint ? "{\n" : "{"); if (objectId != null) { // id will be non-null if this object does not have an @Id field, but was referenced by // another object (need to include ID_TAG) if (prettyPrint) { JSONUtils.indent(depth + 1, indentWidth, buf); } buf.append('"'); buf.append(JSONUtils.ID_KEY); buf.append(prettyPrint ? "\": " : "\":"); JSONSerializer.jsonValToJSONString(objectId, jsonReferenceToId, includeNullValuedFields, depth + 1, indentWidth, buf); if (numDisplayedFields > 0) { buf.append(','); } if (prettyPrint) { buf.append('\n'); } } for (int i = 0, j = 0; i < n; i++) { final Entry<String, Object> item = items.get(i); final Object val = item.getValue(); if (val != null || includeNullValuedFields) { final String key = item.getKey(); if (key == null) { // Keys must be quoted, so the unquoted null value cannot be a key // (Should not happen -- JSONParser.parseJSONObject checks for null keys) throw new IllegalArgumentException("Cannot serialize JSON object with null key"); } if (prettyPrint) { JSONUtils.indent(depth + 1, indentWidth, buf); } buf.append('"'); JSONUtils.escapeJSONString(key, buf); buf.append(prettyPrint ? "\": " : "\":"); JSONSerializer.jsonValToJSONString(val, jsonReferenceToId, includeNullValuedFields, depth + 1, indentWidth, buf); if (++j < numDisplayedFields) { buf.append(','); } if (prettyPrint) { buf.append('\n'); } } } if (prettyPrint) { JSONUtils.indent(depth, indentWidth, buf); } buf.append('}'); } }
java
void toJSONString(final Map<ReferenceEqualityKey<JSONReference>, CharSequence> jsonReferenceToId, final boolean includeNullValuedFields, final int depth, final int indentWidth, final StringBuilder buf) { final boolean prettyPrint = indentWidth > 0; final int n = items.size(); int numDisplayedFields; if (includeNullValuedFields) { numDisplayedFields = n; } else { numDisplayedFields = 0; for (final Entry<String, Object> item : items) { if (item.getValue() != null) { numDisplayedFields++; } } } if (objectId == null && numDisplayedFields == 0) { buf.append("{}"); } else { buf.append(prettyPrint ? "{\n" : "{"); if (objectId != null) { // id will be non-null if this object does not have an @Id field, but was referenced by // another object (need to include ID_TAG) if (prettyPrint) { JSONUtils.indent(depth + 1, indentWidth, buf); } buf.append('"'); buf.append(JSONUtils.ID_KEY); buf.append(prettyPrint ? "\": " : "\":"); JSONSerializer.jsonValToJSONString(objectId, jsonReferenceToId, includeNullValuedFields, depth + 1, indentWidth, buf); if (numDisplayedFields > 0) { buf.append(','); } if (prettyPrint) { buf.append('\n'); } } for (int i = 0, j = 0; i < n; i++) { final Entry<String, Object> item = items.get(i); final Object val = item.getValue(); if (val != null || includeNullValuedFields) { final String key = item.getKey(); if (key == null) { // Keys must be quoted, so the unquoted null value cannot be a key // (Should not happen -- JSONParser.parseJSONObject checks for null keys) throw new IllegalArgumentException("Cannot serialize JSON object with null key"); } if (prettyPrint) { JSONUtils.indent(depth + 1, indentWidth, buf); } buf.append('"'); JSONUtils.escapeJSONString(key, buf); buf.append(prettyPrint ? "\": " : "\":"); JSONSerializer.jsonValToJSONString(val, jsonReferenceToId, includeNullValuedFields, depth + 1, indentWidth, buf); if (++j < numDisplayedFields) { buf.append(','); } if (prettyPrint) { buf.append('\n'); } } } if (prettyPrint) { JSONUtils.indent(depth, indentWidth, buf); } buf.append('}'); } }
[ "void", "toJSONString", "(", "final", "Map", "<", "ReferenceEqualityKey", "<", "JSONReference", ">", ",", "CharSequence", ">", "jsonReferenceToId", ",", "final", "boolean", "includeNullValuedFields", ",", "final", "int", "depth", ",", "final", "int", "indentWidth", ...
Serialize this JSONObject to a string. @param jsonReferenceToId a map from json reference to id @param includeNullValuedFields if true, include null valued fields @param depth the nesting depth @param indentWidth the indent width @param buf the buf
[ "Serialize", "this", "JSONObject", "to", "a", "string", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/json/JSONObject.java#L78-L147
train