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
minio/minio-java
api/src/main/java/io/minio/MinioClient.java
MinioClient.completeMultipart
private void completeMultipart(String bucketName, String objectName, String uploadId, Part[] parts) throws InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, NoResponseException, XmlPullParserException, ErrorResponseException, InternalException { Map<String,String> queryParamMap = new HashMap<>(); queryParamMap.put(UPLOAD_ID, uploadId); CompleteMultipartUpload completeManifest = new CompleteMultipartUpload(parts); HttpResponse response = executePost(bucketName, objectName, null, queryParamMap, completeManifest); // Fixing issue https://github.com/minio/minio-java/issues/391 String bodyContent = ""; Scanner scanner = new Scanner(response.body().charStream()); try { // read entire body stream to string. scanner.useDelimiter("\\A"); if (scanner.hasNext()) { bodyContent = scanner.next(); } } finally { response.body().close(); scanner.close(); } bodyContent = bodyContent.trim(); if (!bodyContent.isEmpty()) { ErrorResponse errorResponse = new ErrorResponse(new StringReader(bodyContent)); if (errorResponse.code() != null) { throw new ErrorResponseException(errorResponse, response.response()); } } }
java
private void completeMultipart(String bucketName, String objectName, String uploadId, Part[] parts) throws InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, NoResponseException, XmlPullParserException, ErrorResponseException, InternalException { Map<String,String> queryParamMap = new HashMap<>(); queryParamMap.put(UPLOAD_ID, uploadId); CompleteMultipartUpload completeManifest = new CompleteMultipartUpload(parts); HttpResponse response = executePost(bucketName, objectName, null, queryParamMap, completeManifest); // Fixing issue https://github.com/minio/minio-java/issues/391 String bodyContent = ""; Scanner scanner = new Scanner(response.body().charStream()); try { // read entire body stream to string. scanner.useDelimiter("\\A"); if (scanner.hasNext()) { bodyContent = scanner.next(); } } finally { response.body().close(); scanner.close(); } bodyContent = bodyContent.trim(); if (!bodyContent.isEmpty()) { ErrorResponse errorResponse = new ErrorResponse(new StringReader(bodyContent)); if (errorResponse.code() != null) { throw new ErrorResponseException(errorResponse, response.response()); } } }
[ "private", "void", "completeMultipart", "(", "String", "bucketName", ",", "String", "objectName", ",", "String", "uploadId", ",", "Part", "[", "]", "parts", ")", "throws", "InvalidBucketNameException", ",", "NoSuchAlgorithmException", ",", "InsufficientDataException", ...
Executes complete multipart upload of given bucket name, object name, upload ID and parts.
[ "Executes", "complete", "multipart", "upload", "of", "given", "bucket", "name", "object", "name", "upload", "ID", "and", "parts", "." ]
b2028f56403c89ce2d5900ae813bc1314c87bc7f
https://github.com/minio/minio-java/blob/b2028f56403c89ce2d5900ae813bc1314c87bc7f/api/src/main/java/io/minio/MinioClient.java#L4746-L4778
train
minio/minio-java
api/src/main/java/io/minio/MinioClient.java
MinioClient.abortMultipartUpload
private void abortMultipartUpload(String bucketName, String objectName, String uploadId) throws InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, NoResponseException, XmlPullParserException, ErrorResponseException, InternalException { Map<String,String> queryParamMap = new HashMap<>(); queryParamMap.put(UPLOAD_ID, uploadId); executeDelete(bucketName, objectName, queryParamMap); }
java
private void abortMultipartUpload(String bucketName, String objectName, String uploadId) throws InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, NoResponseException, XmlPullParserException, ErrorResponseException, InternalException { Map<String,String> queryParamMap = new HashMap<>(); queryParamMap.put(UPLOAD_ID, uploadId); executeDelete(bucketName, objectName, queryParamMap); }
[ "private", "void", "abortMultipartUpload", "(", "String", "bucketName", ",", "String", "objectName", ",", "String", "uploadId", ")", "throws", "InvalidBucketNameException", ",", "NoSuchAlgorithmException", ",", "InsufficientDataException", ",", "IOException", ",", "Invali...
Aborts multipart upload of given bucket name, object name and upload ID.
[ "Aborts", "multipart", "upload", "of", "given", "bucket", "name", "object", "name", "and", "upload", "ID", "." ]
b2028f56403c89ce2d5900ae813bc1314c87bc7f
https://github.com/minio/minio-java/blob/b2028f56403c89ce2d5900ae813bc1314c87bc7f/api/src/main/java/io/minio/MinioClient.java#L4907-L4914
train
minio/minio-java
api/src/main/java/io/minio/MinioClient.java
MinioClient.removeIncompleteUpload
public void removeIncompleteUpload(String bucketName, String objectName) throws InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, NoResponseException, XmlPullParserException, ErrorResponseException, InternalException { for (Result<Upload> r : listIncompleteUploads(bucketName, objectName, true, false)) { Upload upload = r.get(); if (objectName.equals(upload.objectName())) { abortMultipartUpload(bucketName, objectName, upload.uploadId()); return; } } }
java
public void removeIncompleteUpload(String bucketName, String objectName) throws InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, NoResponseException, XmlPullParserException, ErrorResponseException, InternalException { for (Result<Upload> r : listIncompleteUploads(bucketName, objectName, true, false)) { Upload upload = r.get(); if (objectName.equals(upload.objectName())) { abortMultipartUpload(bucketName, objectName, upload.uploadId()); return; } } }
[ "public", "void", "removeIncompleteUpload", "(", "String", "bucketName", ",", "String", "objectName", ")", "throws", "InvalidBucketNameException", ",", "NoSuchAlgorithmException", ",", "InsufficientDataException", ",", "IOException", ",", "InvalidKeyException", ",", "NoResp...
Removes incomplete multipart upload of given object. </p><b>Example:</b><br> <pre>{@code minioClient.removeIncompleteUpload("my-bucketname", "my-objectname"); System.out.println("successfully removed all incomplete upload session of my-bucketname/my-objectname"); }</pre> @param bucketName Bucket name. @param objectName Object name in the bucket. @throws InvalidBucketNameException upon invalid bucket name is given @throws NoSuchAlgorithmException upon requested algorithm was not found during signature calculation @throws InsufficientDataException upon getting EOFException while reading given InputStream even before reading given length @throws IOException upon connection error @throws InvalidKeyException upon an invalid access key or secret key @throws NoResponseException upon no response from server @throws XmlPullParserException upon parsing response xml @throws ErrorResponseException upon unsuccessful execution @throws InternalException upon internal library error
[ "Removes", "incomplete", "multipart", "upload", "of", "given", "object", "." ]
b2028f56403c89ce2d5900ae813bc1314c87bc7f
https://github.com/minio/minio-java/blob/b2028f56403c89ce2d5900ae813bc1314c87bc7f/api/src/main/java/io/minio/MinioClient.java#L4940-L4951
train
minio/minio-java
api/src/main/java/io/minio/MinioClient.java
MinioClient.listenBucketNotification
public void listenBucketNotification(String bucketName, String prefix, String suffix, String[] events, BucketEventListener eventCallback) throws InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, NoResponseException, XmlPullParserException, ErrorResponseException, InternalException { Multimap<String,String> queryParamMap = HashMultimap.create(); queryParamMap.put("prefix", prefix); queryParamMap.put("suffix", suffix); for (String event: events) { queryParamMap.put("events", event); } String bodyContent = ""; Scanner scanner = null; HttpResponse response = null; ObjectMapper mapper = new ObjectMapper(); try { response = executeReq(Method.GET, getRegion(bucketName), bucketName, "", null, queryParamMap, null, 0); scanner = new Scanner(response.body().charStream()); scanner.useDelimiter("\n"); while (scanner.hasNext()) { bodyContent = scanner.next().trim(); if (bodyContent.equals("")) { continue; } NotificationInfo ni = mapper.readValue(bodyContent, NotificationInfo.class); eventCallback.updateEvent(ni); } } catch (RuntimeException e) { throw e; } catch (Exception e) { throw e; } finally { if (response != null) { response.body().close(); } if (scanner != null) { scanner.close(); } } }
java
public void listenBucketNotification(String bucketName, String prefix, String suffix, String[] events, BucketEventListener eventCallback) throws InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException, IOException, InvalidKeyException, NoResponseException, XmlPullParserException, ErrorResponseException, InternalException { Multimap<String,String> queryParamMap = HashMultimap.create(); queryParamMap.put("prefix", prefix); queryParamMap.put("suffix", suffix); for (String event: events) { queryParamMap.put("events", event); } String bodyContent = ""; Scanner scanner = null; HttpResponse response = null; ObjectMapper mapper = new ObjectMapper(); try { response = executeReq(Method.GET, getRegion(bucketName), bucketName, "", null, queryParamMap, null, 0); scanner = new Scanner(response.body().charStream()); scanner.useDelimiter("\n"); while (scanner.hasNext()) { bodyContent = scanner.next().trim(); if (bodyContent.equals("")) { continue; } NotificationInfo ni = mapper.readValue(bodyContent, NotificationInfo.class); eventCallback.updateEvent(ni); } } catch (RuntimeException e) { throw e; } catch (Exception e) { throw e; } finally { if (response != null) { response.body().close(); } if (scanner != null) { scanner.close(); } } }
[ "public", "void", "listenBucketNotification", "(", "String", "bucketName", ",", "String", "prefix", ",", "String", "suffix", ",", "String", "[", "]", "events", ",", "BucketEventListener", "eventCallback", ")", "throws", "InvalidBucketNameException", ",", "NoSuchAlgori...
Listen to bucket notifications. @param bucketName Bucket name. @param prefix Prefix of concerned objects events. @param suffix Suffix of concerned objects events. @param events List of events to watch. @param eventCallback Event handler. @throws InvalidBucketNameException upon invalid bucket name is given @throws NoSuchAlgorithmException upon requested algorithm was not found during signature calculation @throws InsufficientDataException upon getting EOFException while reading given InputStream even before reading given length @throws IOException upon connection error @throws InvalidKeyException upon an invalid access key or secret key @throws NoResponseException upon no response from server @throws XmlPullParserException upon parsing response xml @throws ErrorResponseException upon unsuccessful execution @throws InternalException upon internal library error
[ "Listen", "to", "bucket", "notifications", "." ]
b2028f56403c89ce2d5900ae813bc1314c87bc7f
https://github.com/minio/minio-java/blob/b2028f56403c89ce2d5900ae813bc1314c87bc7f/api/src/main/java/io/minio/MinioClient.java#L4977-L5020
train
minio/minio-java
api/src/main/java/io/minio/MinioClient.java
MinioClient.calculateMultipartSize
private static int[] calculateMultipartSize(long size) throws InvalidArgumentException { if (size > MAX_OBJECT_SIZE) { throw new InvalidArgumentException("size " + size + " is greater than allowed size 5TiB"); } double partSize = Math.ceil((double) size / MAX_MULTIPART_COUNT); partSize = Math.ceil(partSize / MIN_MULTIPART_SIZE) * MIN_MULTIPART_SIZE; double partCount = Math.ceil(size / partSize); double lastPartSize = partSize - (partSize * partCount - size); if (lastPartSize == 0.0) { lastPartSize = partSize; } return new int[] { (int) partSize, (int) partCount, (int) lastPartSize }; }
java
private static int[] calculateMultipartSize(long size) throws InvalidArgumentException { if (size > MAX_OBJECT_SIZE) { throw new InvalidArgumentException("size " + size + " is greater than allowed size 5TiB"); } double partSize = Math.ceil((double) size / MAX_MULTIPART_COUNT); partSize = Math.ceil(partSize / MIN_MULTIPART_SIZE) * MIN_MULTIPART_SIZE; double partCount = Math.ceil(size / partSize); double lastPartSize = partSize - (partSize * partCount - size); if (lastPartSize == 0.0) { lastPartSize = partSize; } return new int[] { (int) partSize, (int) partCount, (int) lastPartSize }; }
[ "private", "static", "int", "[", "]", "calculateMultipartSize", "(", "long", "size", ")", "throws", "InvalidArgumentException", "{", "if", "(", "size", ">", "MAX_OBJECT_SIZE", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"size \"", "+", "size", "...
Calculates multipart size of given size and returns three element array contains part size, part count and last part size.
[ "Calculates", "multipart", "size", "of", "given", "size", "and", "returns", "three", "element", "array", "contains", "part", "size", "part", "count", "and", "last", "part", "size", "." ]
b2028f56403c89ce2d5900ae813bc1314c87bc7f
https://github.com/minio/minio-java/blob/b2028f56403c89ce2d5900ae813bc1314c87bc7f/api/src/main/java/io/minio/MinioClient.java#L5027-L5044
train
minio/minio-java
api/src/main/java/io/minio/MinioClient.java
MinioClient.getAvailableSize
private int getAvailableSize(Object inputStream, int expectedReadSize) throws IOException, InternalException { RandomAccessFile file = null; BufferedInputStream stream = null; if (inputStream instanceof RandomAccessFile) { file = (RandomAccessFile) inputStream; } else if (inputStream instanceof BufferedInputStream) { stream = (BufferedInputStream) inputStream; } else { throw new InternalException("Unknown input stream. This should not happen. " + "Please report to https://github.com/minio/minio-java/issues/"); } // hold current position of file/stream to reset back to this position. long pos = 0; if (file != null) { pos = file.getFilePointer(); } else { stream.mark(expectedReadSize); } // 16KiB buffer for optimization byte[] buf = new byte[16384]; int bytesToRead = buf.length; int bytesRead = 0; int totalBytesRead = 0; while (totalBytesRead < expectedReadSize) { if ((expectedReadSize - totalBytesRead) < bytesToRead) { bytesToRead = expectedReadSize - totalBytesRead; } if (file != null) { bytesRead = file.read(buf, 0, bytesToRead); } else { bytesRead = stream.read(buf, 0, bytesToRead); } if (bytesRead < 0) { // reached EOF break; } totalBytesRead += bytesRead; } // reset back to saved position. if (file != null) { file.seek(pos); } else { stream.reset(); } return totalBytesRead; }
java
private int getAvailableSize(Object inputStream, int expectedReadSize) throws IOException, InternalException { RandomAccessFile file = null; BufferedInputStream stream = null; if (inputStream instanceof RandomAccessFile) { file = (RandomAccessFile) inputStream; } else if (inputStream instanceof BufferedInputStream) { stream = (BufferedInputStream) inputStream; } else { throw new InternalException("Unknown input stream. This should not happen. " + "Please report to https://github.com/minio/minio-java/issues/"); } // hold current position of file/stream to reset back to this position. long pos = 0; if (file != null) { pos = file.getFilePointer(); } else { stream.mark(expectedReadSize); } // 16KiB buffer for optimization byte[] buf = new byte[16384]; int bytesToRead = buf.length; int bytesRead = 0; int totalBytesRead = 0; while (totalBytesRead < expectedReadSize) { if ((expectedReadSize - totalBytesRead) < bytesToRead) { bytesToRead = expectedReadSize - totalBytesRead; } if (file != null) { bytesRead = file.read(buf, 0, bytesToRead); } else { bytesRead = stream.read(buf, 0, bytesToRead); } if (bytesRead < 0) { // reached EOF break; } totalBytesRead += bytesRead; } // reset back to saved position. if (file != null) { file.seek(pos); } else { stream.reset(); } return totalBytesRead; }
[ "private", "int", "getAvailableSize", "(", "Object", "inputStream", ",", "int", "expectedReadSize", ")", "throws", "IOException", ",", "InternalException", "{", "RandomAccessFile", "file", "=", "null", ";", "BufferedInputStream", "stream", "=", "null", ";", "if", ...
Return available size of given input stream up to given expected read size. If less data is available than expected read size, it returns how much data available to read.
[ "Return", "available", "size", "of", "given", "input", "stream", "up", "to", "given", "expected", "read", "size", ".", "If", "less", "data", "is", "available", "than", "expected", "read", "size", "it", "returns", "how", "much", "data", "available", "to", "...
b2028f56403c89ce2d5900ae813bc1314c87bc7f
https://github.com/minio/minio-java/blob/b2028f56403c89ce2d5900ae813bc1314c87bc7f/api/src/main/java/io/minio/MinioClient.java#L5050-L5102
train
minio/minio-java
api/src/main/java/io/minio/MinioClient.java
MinioClient.traceOn
public void traceOn(OutputStream traceStream) { if (traceStream == null) { throw new NullPointerException(); } else { this.traceStream = new PrintWriter(new OutputStreamWriter(traceStream, StandardCharsets.UTF_8), true); } }
java
public void traceOn(OutputStream traceStream) { if (traceStream == null) { throw new NullPointerException(); } else { this.traceStream = new PrintWriter(new OutputStreamWriter(traceStream, StandardCharsets.UTF_8), true); } }
[ "public", "void", "traceOn", "(", "OutputStream", "traceStream", ")", "{", "if", "(", "traceStream", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", ")", ";", "}", "else", "{", "this", ".", "traceStream", "=", "new", "PrintWriter", "("...
Enables HTTP call tracing and written to traceStream. @param traceStream {@link OutputStream} for writing HTTP call tracing. @see #traceOff
[ "Enables", "HTTP", "call", "tracing", "and", "written", "to", "traceStream", "." ]
b2028f56403c89ce2d5900ae813bc1314c87bc7f
https://github.com/minio/minio-java/blob/b2028f56403c89ce2d5900ae813bc1314c87bc7f/api/src/main/java/io/minio/MinioClient.java#L5112-L5118
train
minio/minio-java
api/src/main/java/io/minio/http/HeaderParser.java
HeaderParser.set
public static void set(Headers headers, Object destination) { Field[] publicFields; Field[] privateFields; Field[] fields; Class<?> cls = destination.getClass(); publicFields = cls.getFields(); privateFields = cls.getDeclaredFields(); fields = new Field[publicFields.length + privateFields.length]; System.arraycopy(publicFields, 0, fields, 0, publicFields.length); System.arraycopy(privateFields, 0, fields, publicFields.length, privateFields.length); for (Field field : fields) { Annotation annotation = field.getAnnotation(Header.class); if (annotation == null) { continue; } Header httpHeader = (Header) annotation; String value = httpHeader.value(); String setter = httpHeader.setter(); if (setter.isEmpty()) { // assume setter name as 'setFieldName' String name = field.getName(); setter = "set" + name.substring(0, 1).toUpperCase(Locale.US) + name.substring(1); } try { Method setterMethod = cls.getMethod(setter, new Class[]{String.class}); String valueString = headers.get(value); if (valueString != null) { setterMethod.invoke(destination, valueString); } } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | IllegalArgumentException e) { LOGGER.log(Level.SEVERE, "exception occured: ", e); LOGGER.log(Level.INFO, "setter: " + setter); LOGGER.log(Level.INFO, "annotation: " + value); LOGGER.log(Level.INFO, "value: " + headers.get(value)); } } }
java
public static void set(Headers headers, Object destination) { Field[] publicFields; Field[] privateFields; Field[] fields; Class<?> cls = destination.getClass(); publicFields = cls.getFields(); privateFields = cls.getDeclaredFields(); fields = new Field[publicFields.length + privateFields.length]; System.arraycopy(publicFields, 0, fields, 0, publicFields.length); System.arraycopy(privateFields, 0, fields, publicFields.length, privateFields.length); for (Field field : fields) { Annotation annotation = field.getAnnotation(Header.class); if (annotation == null) { continue; } Header httpHeader = (Header) annotation; String value = httpHeader.value(); String setter = httpHeader.setter(); if (setter.isEmpty()) { // assume setter name as 'setFieldName' String name = field.getName(); setter = "set" + name.substring(0, 1).toUpperCase(Locale.US) + name.substring(1); } try { Method setterMethod = cls.getMethod(setter, new Class[]{String.class}); String valueString = headers.get(value); if (valueString != null) { setterMethod.invoke(destination, valueString); } } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | IllegalArgumentException e) { LOGGER.log(Level.SEVERE, "exception occured: ", e); LOGGER.log(Level.INFO, "setter: " + setter); LOGGER.log(Level.INFO, "annotation: " + value); LOGGER.log(Level.INFO, "value: " + headers.get(value)); } } }
[ "public", "static", "void", "set", "(", "Headers", "headers", ",", "Object", "destination", ")", "{", "Field", "[", "]", "publicFields", ";", "Field", "[", "]", "privateFields", ";", "Field", "[", "]", "fields", ";", "Class", "<", "?", ">", "cls", "=",...
Sets destination object from Headers object.
[ "Sets", "destination", "object", "from", "Headers", "object", "." ]
b2028f56403c89ce2d5900ae813bc1314c87bc7f
https://github.com/minio/minio-java/blob/b2028f56403c89ce2d5900ae813bc1314c87bc7f/api/src/main/java/io/minio/http/HeaderParser.java#L42-L84
train
minio/minio-java
api/src/main/java/io/minio/S3Escaper.java
S3Escaper.encode
public static String encode(String str) { if (str == null) { return ""; } return ESCAPER.escape(str) .replaceAll("\\!", "%21") .replaceAll("\\$", "%24") .replaceAll("\\&", "%26") .replaceAll("\\'", "%27") .replaceAll("\\(", "%28") .replaceAll("\\)", "%29") .replaceAll("\\*", "%2A") .replaceAll("\\+", "%2B") .replaceAll("\\,", "%2C") .replaceAll("\\/", "%2F") .replaceAll("\\:", "%3A") .replaceAll("\\;", "%3B") .replaceAll("\\=", "%3D") .replaceAll("\\@", "%40") .replaceAll("\\[", "%5B") .replaceAll("\\]", "%5D"); }
java
public static String encode(String str) { if (str == null) { return ""; } return ESCAPER.escape(str) .replaceAll("\\!", "%21") .replaceAll("\\$", "%24") .replaceAll("\\&", "%26") .replaceAll("\\'", "%27") .replaceAll("\\(", "%28") .replaceAll("\\)", "%29") .replaceAll("\\*", "%2A") .replaceAll("\\+", "%2B") .replaceAll("\\,", "%2C") .replaceAll("\\/", "%2F") .replaceAll("\\:", "%3A") .replaceAll("\\;", "%3B") .replaceAll("\\=", "%3D") .replaceAll("\\@", "%40") .replaceAll("\\[", "%5B") .replaceAll("\\]", "%5D"); }
[ "public", "static", "String", "encode", "(", "String", "str", ")", "{", "if", "(", "str", "==", "null", ")", "{", "return", "\"\"", ";", "}", "return", "ESCAPER", ".", "escape", "(", "str", ")", ".", "replaceAll", "(", "\"\\\\!\"", ",", "\"%21\"", ")...
Returns S3 encoded string.
[ "Returns", "S3", "encoded", "string", "." ]
b2028f56403c89ce2d5900ae813bc1314c87bc7f
https://github.com/minio/minio-java/blob/b2028f56403c89ce2d5900ae813bc1314c87bc7f/api/src/main/java/io/minio/S3Escaper.java#L29-L51
train
minio/minio-java
api/src/main/java/io/minio/Signer.java
Signer.getChunkSignature
public static String getChunkSignature(String chunkSha256, DateTime date, String region, String secretKey, String prevSignature) throws NoSuchAlgorithmException, InvalidKeyException { Signer signer = new Signer(null, chunkSha256, date, region, null, secretKey, prevSignature); signer.setScope(); signer.setChunkStringToSign(); signer.setSigningKey(); signer.setSignature(); return signer.signature; }
java
public static String getChunkSignature(String chunkSha256, DateTime date, String region, String secretKey, String prevSignature) throws NoSuchAlgorithmException, InvalidKeyException { Signer signer = new Signer(null, chunkSha256, date, region, null, secretKey, prevSignature); signer.setScope(); signer.setChunkStringToSign(); signer.setSigningKey(); signer.setSignature(); return signer.signature; }
[ "public", "static", "String", "getChunkSignature", "(", "String", "chunkSha256", ",", "DateTime", "date", ",", "String", "region", ",", "String", "secretKey", ",", "String", "prevSignature", ")", "throws", "NoSuchAlgorithmException", ",", "InvalidKeyException", "{", ...
Returns chunk signature calculated using given arguments.
[ "Returns", "chunk", "signature", "calculated", "using", "given", "arguments", "." ]
b2028f56403c89ce2d5900ae813bc1314c87bc7f
https://github.com/minio/minio-java/blob/b2028f56403c89ce2d5900ae813bc1314c87bc7f/api/src/main/java/io/minio/Signer.java#L241-L251
train
minio/minio-java
api/src/main/java/io/minio/Signer.java
Signer.getChunkSeedSignature
public static String getChunkSeedSignature(Request request, String region, String secretKey) throws NoSuchAlgorithmException, InvalidKeyException { String contentSha256 = request.header("x-amz-content-sha256"); DateTime date = DateFormat.AMZ_DATE_FORMAT.parseDateTime(request.header("x-amz-date")); Signer signer = new Signer(request, contentSha256, date, region, null, secretKey, null); signer.setScope(); signer.setCanonicalRequest(); signer.setStringToSign(); signer.setSigningKey(); signer.setSignature(); return signer.signature; }
java
public static String getChunkSeedSignature(Request request, String region, String secretKey) throws NoSuchAlgorithmException, InvalidKeyException { String contentSha256 = request.header("x-amz-content-sha256"); DateTime date = DateFormat.AMZ_DATE_FORMAT.parseDateTime(request.header("x-amz-date")); Signer signer = new Signer(request, contentSha256, date, region, null, secretKey, null); signer.setScope(); signer.setCanonicalRequest(); signer.setStringToSign(); signer.setSigningKey(); signer.setSignature(); return signer.signature; }
[ "public", "static", "String", "getChunkSeedSignature", "(", "Request", "request", ",", "String", "region", ",", "String", "secretKey", ")", "throws", "NoSuchAlgorithmException", ",", "InvalidKeyException", "{", "String", "contentSha256", "=", "request", ".", "header",...
Returns seed signature for given request.
[ "Returns", "seed", "signature", "for", "given", "request", "." ]
b2028f56403c89ce2d5900ae813bc1314c87bc7f
https://github.com/minio/minio-java/blob/b2028f56403c89ce2d5900ae813bc1314c87bc7f/api/src/main/java/io/minio/Signer.java#L257-L270
train
minio/minio-java
api/src/main/java/io/minio/Signer.java
Signer.signV4
public static Request signV4(Request request, String region, String accessKey, String secretKey) throws NoSuchAlgorithmException, InvalidKeyException { String contentSha256 = request.header("x-amz-content-sha256"); DateTime date = DateFormat.AMZ_DATE_FORMAT.parseDateTime(request.header("x-amz-date")); Signer signer = new Signer(request, contentSha256, date, region, accessKey, secretKey, null); signer.setScope(); signer.setCanonicalRequest(); signer.setStringToSign(); signer.setSigningKey(); signer.setSignature(); signer.setAuthorization(); return request.newBuilder().header("Authorization", signer.authorization).build(); }
java
public static Request signV4(Request request, String region, String accessKey, String secretKey) throws NoSuchAlgorithmException, InvalidKeyException { String contentSha256 = request.header("x-amz-content-sha256"); DateTime date = DateFormat.AMZ_DATE_FORMAT.parseDateTime(request.header("x-amz-date")); Signer signer = new Signer(request, contentSha256, date, region, accessKey, secretKey, null); signer.setScope(); signer.setCanonicalRequest(); signer.setStringToSign(); signer.setSigningKey(); signer.setSignature(); signer.setAuthorization(); return request.newBuilder().header("Authorization", signer.authorization).build(); }
[ "public", "static", "Request", "signV4", "(", "Request", "request", ",", "String", "region", ",", "String", "accessKey", ",", "String", "secretKey", ")", "throws", "NoSuchAlgorithmException", ",", "InvalidKeyException", "{", "String", "contentSha256", "=", "request"...
Returns signed request object for given request, region, access key and secret key.
[ "Returns", "signed", "request", "object", "for", "given", "request", "region", "access", "key", "and", "secret", "key", "." ]
b2028f56403c89ce2d5900ae813bc1314c87bc7f
https://github.com/minio/minio-java/blob/b2028f56403c89ce2d5900ae813bc1314c87bc7f/api/src/main/java/io/minio/Signer.java#L276-L290
train
minio/minio-java
api/src/main/java/io/minio/Signer.java
Signer.presignV4
public static HttpUrl presignV4(Request request, String region, String accessKey, String secretKey, int expires) throws NoSuchAlgorithmException, InvalidKeyException { String contentSha256 = "UNSIGNED-PAYLOAD"; DateTime date = DateFormat.AMZ_DATE_FORMAT.parseDateTime(request.header("x-amz-date")); Signer signer = new Signer(request, contentSha256, date, region, accessKey, secretKey, null); signer.setScope(); signer.setPresignCanonicalRequest(expires); signer.setStringToSign(); signer.setSigningKey(); signer.setSignature(); return signer.url.newBuilder() .addEncodedQueryParameter(S3Escaper.encode("X-Amz-Signature"), S3Escaper.encode(signer.signature)) .build(); }
java
public static HttpUrl presignV4(Request request, String region, String accessKey, String secretKey, int expires) throws NoSuchAlgorithmException, InvalidKeyException { String contentSha256 = "UNSIGNED-PAYLOAD"; DateTime date = DateFormat.AMZ_DATE_FORMAT.parseDateTime(request.header("x-amz-date")); Signer signer = new Signer(request, contentSha256, date, region, accessKey, secretKey, null); signer.setScope(); signer.setPresignCanonicalRequest(expires); signer.setStringToSign(); signer.setSigningKey(); signer.setSignature(); return signer.url.newBuilder() .addEncodedQueryParameter(S3Escaper.encode("X-Amz-Signature"), S3Escaper.encode(signer.signature)) .build(); }
[ "public", "static", "HttpUrl", "presignV4", "(", "Request", "request", ",", "String", "region", ",", "String", "accessKey", ",", "String", "secretKey", ",", "int", "expires", ")", "throws", "NoSuchAlgorithmException", ",", "InvalidKeyException", "{", "String", "co...
Returns pre-signed HttpUrl object for given request, region, access key, secret key and expires time.
[ "Returns", "pre", "-", "signed", "HttpUrl", "object", "for", "given", "request", "region", "access", "key", "secret", "key", "and", "expires", "time", "." ]
b2028f56403c89ce2d5900ae813bc1314c87bc7f
https://github.com/minio/minio-java/blob/b2028f56403c89ce2d5900ae813bc1314c87bc7f/api/src/main/java/io/minio/Signer.java#L328-L343
train
minio/minio-java
api/src/main/java/io/minio/Signer.java
Signer.credential
public static String credential(String accessKey, DateTime date, String region) { return accessKey + "/" + date.toString(DateFormat.SIGNER_DATE_FORMAT) + "/" + region + "/s3/aws4_request"; }
java
public static String credential(String accessKey, DateTime date, String region) { return accessKey + "/" + date.toString(DateFormat.SIGNER_DATE_FORMAT) + "/" + region + "/s3/aws4_request"; }
[ "public", "static", "String", "credential", "(", "String", "accessKey", ",", "DateTime", "date", ",", "String", "region", ")", "{", "return", "accessKey", "+", "\"/\"", "+", "date", ".", "toString", "(", "DateFormat", ".", "SIGNER_DATE_FORMAT", ")", "+", "\"...
Returns credential string of given access key, date and region.
[ "Returns", "credential", "string", "of", "given", "access", "key", "date", "and", "region", "." ]
b2028f56403c89ce2d5900ae813bc1314c87bc7f
https://github.com/minio/minio-java/blob/b2028f56403c89ce2d5900ae813bc1314c87bc7f/api/src/main/java/io/minio/Signer.java#L349-L351
train
minio/minio-java
api/src/main/java/io/minio/Signer.java
Signer.postPresignV4
public static String postPresignV4(String stringToSign, String secretKey, DateTime date, String region) throws NoSuchAlgorithmException, InvalidKeyException { Signer signer = new Signer(null, null, date, region, null, secretKey, null); signer.stringToSign = stringToSign; signer.setSigningKey(); signer.setSignature(); return signer.signature; }
java
public static String postPresignV4(String stringToSign, String secretKey, DateTime date, String region) throws NoSuchAlgorithmException, InvalidKeyException { Signer signer = new Signer(null, null, date, region, null, secretKey, null); signer.stringToSign = stringToSign; signer.setSigningKey(); signer.setSignature(); return signer.signature; }
[ "public", "static", "String", "postPresignV4", "(", "String", "stringToSign", ",", "String", "secretKey", ",", "DateTime", "date", ",", "String", "region", ")", "throws", "NoSuchAlgorithmException", ",", "InvalidKeyException", "{", "Signer", "signer", "=", "new", ...
Returns pre-signed post policy string for given stringToSign, secret key, date and region.
[ "Returns", "pre", "-", "signed", "post", "policy", "string", "for", "given", "stringToSign", "secret", "key", "date", "and", "region", "." ]
b2028f56403c89ce2d5900ae813bc1314c87bc7f
https://github.com/minio/minio-java/blob/b2028f56403c89ce2d5900ae813bc1314c87bc7f/api/src/main/java/io/minio/Signer.java#L357-L365
train
minio/minio-java
api/src/main/java/io/minio/Signer.java
Signer.sumHmac
public static byte[] sumHmac(byte[] key, byte[] data) throws NoSuchAlgorithmException, InvalidKeyException { Mac mac = Mac.getInstance("HmacSHA256"); mac.init(new SecretKeySpec(key, "HmacSHA256")); mac.update(data); return mac.doFinal(); }
java
public static byte[] sumHmac(byte[] key, byte[] data) throws NoSuchAlgorithmException, InvalidKeyException { Mac mac = Mac.getInstance("HmacSHA256"); mac.init(new SecretKeySpec(key, "HmacSHA256")); mac.update(data); return mac.doFinal(); }
[ "public", "static", "byte", "[", "]", "sumHmac", "(", "byte", "[", "]", "key", ",", "byte", "[", "]", "data", ")", "throws", "NoSuchAlgorithmException", ",", "InvalidKeyException", "{", "Mac", "mac", "=", "Mac", ".", "getInstance", "(", "\"HmacSHA256\"", "...
Returns HMacSHA256 digest of given key and data.
[ "Returns", "HMacSHA256", "digest", "of", "given", "key", "and", "data", "." ]
b2028f56403c89ce2d5900ae813bc1314c87bc7f
https://github.com/minio/minio-java/blob/b2028f56403c89ce2d5900ae813bc1314c87bc7f/api/src/main/java/io/minio/Signer.java#L371-L379
train
minio/minio-java
api/src/main/java/io/minio/PostPolicy.java
PostPolicy.setContentType
public void setContentType(String contentType) throws InvalidArgumentException { if (Strings.isNullOrEmpty(contentType)) { throw new InvalidArgumentException("empty content type"); } this.contentType = contentType; }
java
public void setContentType(String contentType) throws InvalidArgumentException { if (Strings.isNullOrEmpty(contentType)) { throw new InvalidArgumentException("empty content type"); } this.contentType = contentType; }
[ "public", "void", "setContentType", "(", "String", "contentType", ")", "throws", "InvalidArgumentException", "{", "if", "(", "Strings", ".", "isNullOrEmpty", "(", "contentType", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"empty content type\"", ...
Sets content type.
[ "Sets", "content", "type", "." ]
b2028f56403c89ce2d5900ae813bc1314c87bc7f
https://github.com/minio/minio-java/blob/b2028f56403c89ce2d5900ae813bc1314c87bc7f/api/src/main/java/io/minio/PostPolicy.java#L86-L92
train
minio/minio-java
api/src/main/java/io/minio/PostPolicy.java
PostPolicy.setContentEncoding
public void setContentEncoding(String contentEncoding) throws InvalidArgumentException { if (Strings.isNullOrEmpty(contentEncoding)) { throw new InvalidArgumentException("empty content encoding"); } this.contentEncoding = contentEncoding; }
java
public void setContentEncoding(String contentEncoding) throws InvalidArgumentException { if (Strings.isNullOrEmpty(contentEncoding)) { throw new InvalidArgumentException("empty content encoding"); } this.contentEncoding = contentEncoding; }
[ "public", "void", "setContentEncoding", "(", "String", "contentEncoding", ")", "throws", "InvalidArgumentException", "{", "if", "(", "Strings", ".", "isNullOrEmpty", "(", "contentEncoding", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"empty conte...
Sets content encoding.
[ "Sets", "content", "encoding", "." ]
b2028f56403c89ce2d5900ae813bc1314c87bc7f
https://github.com/minio/minio-java/blob/b2028f56403c89ce2d5900ae813bc1314c87bc7f/api/src/main/java/io/minio/PostPolicy.java#L98-L104
train
minio/minio-java
api/src/main/java/io/minio/PostPolicy.java
PostPolicy.setContentRange
public void setContentRange(long startRange, long endRange) throws InvalidArgumentException { if (startRange <= 0 || endRange <= 0) { throw new InvalidArgumentException("negative start/end range"); } if (startRange > endRange) { throw new InvalidArgumentException("start range is higher than end range"); } this.contentRangeStart = startRange; this.contentRangeEnd = endRange; }
java
public void setContentRange(long startRange, long endRange) throws InvalidArgumentException { if (startRange <= 0 || endRange <= 0) { throw new InvalidArgumentException("negative start/end range"); } if (startRange > endRange) { throw new InvalidArgumentException("start range is higher than end range"); } this.contentRangeStart = startRange; this.contentRangeEnd = endRange; }
[ "public", "void", "setContentRange", "(", "long", "startRange", ",", "long", "endRange", ")", "throws", "InvalidArgumentException", "{", "if", "(", "startRange", "<=", "0", "||", "endRange", "<=", "0", ")", "{", "throw", "new", "InvalidArgumentException", "(", ...
Sets content range.
[ "Sets", "content", "range", "." ]
b2028f56403c89ce2d5900ae813bc1314c87bc7f
https://github.com/minio/minio-java/blob/b2028f56403c89ce2d5900ae813bc1314c87bc7f/api/src/main/java/io/minio/PostPolicy.java#L122-L133
train
minio/minio-java
api/src/main/java/io/minio/PostPolicy.java
PostPolicy.formData
public Map<String,String> formData(String accessKey, String secretKey, String region) throws NoSuchAlgorithmException, InvalidKeyException, InvalidArgumentException { if (Strings.isNullOrEmpty(region)) { throw new InvalidArgumentException("empty region"); } return makeFormData(accessKey, secretKey, region); }
java
public Map<String,String> formData(String accessKey, String secretKey, String region) throws NoSuchAlgorithmException, InvalidKeyException, InvalidArgumentException { if (Strings.isNullOrEmpty(region)) { throw new InvalidArgumentException("empty region"); } return makeFormData(accessKey, secretKey, region); }
[ "public", "Map", "<", "String", ",", "String", ">", "formData", "(", "String", "accessKey", ",", "String", "secretKey", ",", "String", "region", ")", "throws", "NoSuchAlgorithmException", ",", "InvalidKeyException", ",", "InvalidArgumentException", "{", "if", "(",...
Returns form data of this post policy setting the provided region.
[ "Returns", "form", "data", "of", "this", "post", "policy", "setting", "the", "provided", "region", "." ]
b2028f56403c89ce2d5900ae813bc1314c87bc7f
https://github.com/minio/minio-java/blob/b2028f56403c89ce2d5900ae813bc1314c87bc7f/api/src/main/java/io/minio/PostPolicy.java#L177-L185
train
minio/minio-java
api/src/main/java/io/minio/CopyConditions.java
CopyConditions.setModified
public void setModified(DateTime date) throws InvalidArgumentException { if (date == null) { throw new InvalidArgumentException("Date cannot be empty"); } copyConditions.put("x-amz-copy-source-if-modified-since", date.toString(DateFormat.HTTP_HEADER_DATE_FORMAT)); }
java
public void setModified(DateTime date) throws InvalidArgumentException { if (date == null) { throw new InvalidArgumentException("Date cannot be empty"); } copyConditions.put("x-amz-copy-source-if-modified-since", date.toString(DateFormat.HTTP_HEADER_DATE_FORMAT)); }
[ "public", "void", "setModified", "(", "DateTime", "date", ")", "throws", "InvalidArgumentException", "{", "if", "(", "date", "==", "null", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Date cannot be empty\"", ")", ";", "}", "copyConditions", ".", ...
Set modified condition, copy object modified since given time. @throws InvalidArgumentException When date is null
[ "Set", "modified", "condition", "copy", "object", "modified", "since", "given", "time", "." ]
b2028f56403c89ce2d5900ae813bc1314c87bc7f
https://github.com/minio/minio-java/blob/b2028f56403c89ce2d5900ae813bc1314c87bc7f/api/src/main/java/io/minio/CopyConditions.java#L45-L50
train
minio/minio-java
api/src/main/java/io/minio/CopyConditions.java
CopyConditions.setMatchETag
public void setMatchETag(String etag) throws InvalidArgumentException { if (etag == null) { throw new InvalidArgumentException("ETag cannot be empty"); } copyConditions.put("x-amz-copy-source-if-match", etag); }
java
public void setMatchETag(String etag) throws InvalidArgumentException { if (etag == null) { throw new InvalidArgumentException("ETag cannot be empty"); } copyConditions.put("x-amz-copy-source-if-match", etag); }
[ "public", "void", "setMatchETag", "(", "String", "etag", ")", "throws", "InvalidArgumentException", "{", "if", "(", "etag", "==", "null", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"ETag cannot be empty\"", ")", ";", "}", "copyConditions", ".", ...
Set matching ETag condition, copy object which matches the following ETag. @throws InvalidArgumentException When etag is null
[ "Set", "matching", "ETag", "condition", "copy", "object", "which", "matches", "the", "following", "ETag", "." ]
b2028f56403c89ce2d5900ae813bc1314c87bc7f
https://github.com/minio/minio-java/blob/b2028f56403c89ce2d5900ae813bc1314c87bc7f/api/src/main/java/io/minio/CopyConditions.java#L73-L78
train
minio/minio-java
api/src/main/java/io/minio/CopyConditions.java
CopyConditions.setMatchETagNone
public void setMatchETagNone(String etag) throws InvalidArgumentException { if (etag == null) { throw new InvalidArgumentException("ETag cannot be empty"); } copyConditions.put("x-amz-copy-source-if-none-match", etag); }
java
public void setMatchETagNone(String etag) throws InvalidArgumentException { if (etag == null) { throw new InvalidArgumentException("ETag cannot be empty"); } copyConditions.put("x-amz-copy-source-if-none-match", etag); }
[ "public", "void", "setMatchETagNone", "(", "String", "etag", ")", "throws", "InvalidArgumentException", "{", "if", "(", "etag", "==", "null", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"ETag cannot be empty\"", ")", ";", "}", "copyConditions", "....
Set matching ETag none condition, copy object which does not match the following ETag. @throws InvalidArgumentException When etag is null
[ "Set", "matching", "ETag", "none", "condition", "copy", "object", "which", "does", "not", "match", "the", "following", "ETag", "." ]
b2028f56403c89ce2d5900ae813bc1314c87bc7f
https://github.com/minio/minio-java/blob/b2028f56403c89ce2d5900ae813bc1314c87bc7f/api/src/main/java/io/minio/CopyConditions.java#L87-L92
train
minio/minio-java
api/src/main/java/io/minio/messages/XmlEntity.java
XmlEntity.parseXml
public void parseXml(Reader reader) throws IOException, XmlPullParserException { this.xmlPullParser.setInput(reader); Xml.parseElement(this.xmlPullParser, this, this.defaultNamespaceDictionary, null); }
java
public void parseXml(Reader reader) throws IOException, XmlPullParserException { this.xmlPullParser.setInput(reader); Xml.parseElement(this.xmlPullParser, this, this.defaultNamespaceDictionary, null); }
[ "public", "void", "parseXml", "(", "Reader", "reader", ")", "throws", "IOException", ",", "XmlPullParserException", "{", "this", ".", "xmlPullParser", ".", "setInput", "(", "reader", ")", ";", "Xml", ".", "parseElement", "(", "this", ".", "xmlPullParser", ",",...
Parses content from given reader input stream.
[ "Parses", "content", "from", "given", "reader", "input", "stream", "." ]
b2028f56403c89ce2d5900ae813bc1314c87bc7f
https://github.com/minio/minio-java/blob/b2028f56403c89ce2d5900ae813bc1314c87bc7f/api/src/main/java/io/minio/messages/XmlEntity.java#L63-L66
train
minio/minio-java
api/src/main/java/io/minio/messages/XmlEntity.java
XmlEntity.parseXml
protected void parseXml(Reader reader, XmlNamespaceDictionary namespaceDictionary) throws IOException, XmlPullParserException { this.xmlPullParser.setInput(reader); Xml.parseElement(this.xmlPullParser, this, namespaceDictionary, null); }
java
protected void parseXml(Reader reader, XmlNamespaceDictionary namespaceDictionary) throws IOException, XmlPullParserException { this.xmlPullParser.setInput(reader); Xml.parseElement(this.xmlPullParser, this, namespaceDictionary, null); }
[ "protected", "void", "parseXml", "(", "Reader", "reader", ",", "XmlNamespaceDictionary", "namespaceDictionary", ")", "throws", "IOException", ",", "XmlPullParserException", "{", "this", ".", "xmlPullParser", ".", "setInput", "(", "reader", ")", ";", "Xml", ".", "p...
Parses content from given reader input stream and namespace dictionary.
[ "Parses", "content", "from", "given", "reader", "input", "stream", "and", "namespace", "dictionary", "." ]
b2028f56403c89ce2d5900ae813bc1314c87bc7f
https://github.com/minio/minio-java/blob/b2028f56403c89ce2d5900ae813bc1314c87bc7f/api/src/main/java/io/minio/messages/XmlEntity.java#L72-L76
train
minio/minio-java
api/src/main/java/io/minio/ChunkedInputStream.java
ChunkedInputStream.read
public int read() throws IOException { if (this.bytesRead == this.length) { // All chunks and final additional chunk are read. // This means we have reached EOF. return -1; } try { // Read a chunk from given input stream when // it is first chunk or all bytes in chunk body is read if (this.streamBytesRead == 0 || this.chunkPos == this.chunkBody.length) { // Check if there are data available to read from given input stream. if (this.streamBytesRead != this.streamSize) { // Send all data chunks. int chunkSize = CHUNK_SIZE; if (this.streamBytesRead + chunkSize > this.streamSize) { chunkSize = this.streamSize - this.streamBytesRead; } if (readChunk(chunkSize) < 0) { return -1; } this.streamBytesRead += chunkSize; } else { // Send final additional chunk to complete chunk upload. byte[] chunk = new byte[0]; createChunkBody(chunk); } } this.bytesRead++; // Value must be between 0 to 255. int value = this.chunkBody[this.chunkPos] & 0xFF; this.chunkPos++; return value; } catch (NoSuchAlgorithmException | InvalidKeyException | InsufficientDataException | InternalException e) { throw new IOException(e.getCause()); } }
java
public int read() throws IOException { if (this.bytesRead == this.length) { // All chunks and final additional chunk are read. // This means we have reached EOF. return -1; } try { // Read a chunk from given input stream when // it is first chunk or all bytes in chunk body is read if (this.streamBytesRead == 0 || this.chunkPos == this.chunkBody.length) { // Check if there are data available to read from given input stream. if (this.streamBytesRead != this.streamSize) { // Send all data chunks. int chunkSize = CHUNK_SIZE; if (this.streamBytesRead + chunkSize > this.streamSize) { chunkSize = this.streamSize - this.streamBytesRead; } if (readChunk(chunkSize) < 0) { return -1; } this.streamBytesRead += chunkSize; } else { // Send final additional chunk to complete chunk upload. byte[] chunk = new byte[0]; createChunkBody(chunk); } } this.bytesRead++; // Value must be between 0 to 255. int value = this.chunkBody[this.chunkPos] & 0xFF; this.chunkPos++; return value; } catch (NoSuchAlgorithmException | InvalidKeyException | InsufficientDataException | InternalException e) { throw new IOException(e.getCause()); } }
[ "public", "int", "read", "(", ")", "throws", "IOException", "{", "if", "(", "this", ".", "bytesRead", "==", "this", ".", "length", ")", "{", "// All chunks and final additional chunk are read.", "// This means we have reached EOF.", "return", "-", "1", ";", "}", "...
read single byte from chunk body.
[ "read", "single", "byte", "from", "chunk", "body", "." ]
b2028f56403c89ce2d5900ae813bc1314c87bc7f
https://github.com/minio/minio-java/blob/b2028f56403c89ce2d5900ae813bc1314c87bc7f/api/src/main/java/io/minio/ChunkedInputStream.java#L164-L203
train
pwittchen/ReactiveNetwork
library/src/main/java/com/github/pwittchen/reactivenetwork/library/rx2/internet/observing/strategy/SocketInternetObservingStrategy.java
SocketInternetObservingStrategy.adjustHost
protected String adjustHost(final String host) { if (host.startsWith(HTTP_PROTOCOL)) { return host.replace(HTTP_PROTOCOL, EMPTY_STRING); } else if (host.startsWith(HTTPS_PROTOCOL)) { return host.replace(HTTPS_PROTOCOL, EMPTY_STRING); } return host; }
java
protected String adjustHost(final String host) { if (host.startsWith(HTTP_PROTOCOL)) { return host.replace(HTTP_PROTOCOL, EMPTY_STRING); } else if (host.startsWith(HTTPS_PROTOCOL)) { return host.replace(HTTPS_PROTOCOL, EMPTY_STRING); } return host; }
[ "protected", "String", "adjustHost", "(", "final", "String", "host", ")", "{", "if", "(", "host", ".", "startsWith", "(", "HTTP_PROTOCOL", ")", ")", "{", "return", "host", ".", "replace", "(", "HTTP_PROTOCOL", ",", "EMPTY_STRING", ")", ";", "}", "else", ...
adjusts host to needs of SocketInternetObservingStrategy @return transformed host
[ "adjusts", "host", "to", "needs", "of", "SocketInternetObservingStrategy" ]
cfeb3b79a1e44d106581af5e6709ff206e60c369
https://github.com/pwittchen/ReactiveNetwork/blob/cfeb3b79a1e44d106581af5e6709ff206e60c369/library/src/main/java/com/github/pwittchen/reactivenetwork/library/rx2/internet/observing/strategy/SocketInternetObservingStrategy.java#L81-L88
train
pwittchen/ReactiveNetwork
library/src/main/java/com/github/pwittchen/reactivenetwork/library/rx2/Preconditions.java
Preconditions.checkNotNullOrEmpty
public static void checkNotNullOrEmpty(String string, String message) { if (string == null || string.isEmpty()) { throw new IllegalArgumentException(message); } }
java
public static void checkNotNullOrEmpty(String string, String message) { if (string == null || string.isEmpty()) { throw new IllegalArgumentException(message); } }
[ "public", "static", "void", "checkNotNullOrEmpty", "(", "String", "string", ",", "String", "message", ")", "{", "if", "(", "string", "==", "null", "||", "string", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "message",...
Validation method, which checks if a string is null or empty @param string to verify @param message to be thrown in exception
[ "Validation", "method", "which", "checks", "if", "a", "string", "is", "null", "or", "empty" ]
cfeb3b79a1e44d106581af5e6709ff206e60c369
https://github.com/pwittchen/ReactiveNetwork/blob/cfeb3b79a1e44d106581af5e6709ff206e60c369/library/src/main/java/com/github/pwittchen/reactivenetwork/library/rx2/Preconditions.java#L39-L43
train
pwittchen/ReactiveNetwork
library/src/main/java/com/github/pwittchen/reactivenetwork/library/rx2/ReactiveNetwork.java
ReactiveNetwork.observeNetworkConnectivity
@RequiresPermission(Manifest.permission.ACCESS_NETWORK_STATE) public static Observable<Connectivity> observeNetworkConnectivity(final Context context) { final NetworkObservingStrategy strategy; if (Preconditions.isAtLeastAndroidMarshmallow()) { strategy = new MarshmallowNetworkObservingStrategy(); } else if (Preconditions.isAtLeastAndroidLollipop()) { strategy = new LollipopNetworkObservingStrategy(); } else { strategy = new PreLollipopNetworkObservingStrategy(); } return observeNetworkConnectivity(context, strategy); }
java
@RequiresPermission(Manifest.permission.ACCESS_NETWORK_STATE) public static Observable<Connectivity> observeNetworkConnectivity(final Context context) { final NetworkObservingStrategy strategy; if (Preconditions.isAtLeastAndroidMarshmallow()) { strategy = new MarshmallowNetworkObservingStrategy(); } else if (Preconditions.isAtLeastAndroidLollipop()) { strategy = new LollipopNetworkObservingStrategy(); } else { strategy = new PreLollipopNetworkObservingStrategy(); } return observeNetworkConnectivity(context, strategy); }
[ "@", "RequiresPermission", "(", "Manifest", ".", "permission", ".", "ACCESS_NETWORK_STATE", ")", "public", "static", "Observable", "<", "Connectivity", ">", "observeNetworkConnectivity", "(", "final", "Context", "context", ")", "{", "final", "NetworkObservingStrategy", ...
Observes network connectivity. Information about network state, type and typeName are contained in observed Connectivity object. @param context Context of the activity or an application @return RxJava Observable with Connectivity class containing information about network state, type and typeName
[ "Observes", "network", "connectivity", ".", "Information", "about", "network", "state", "type", "and", "typeName", "are", "contained", "in", "observed", "Connectivity", "object", "." ]
cfeb3b79a1e44d106581af5e6709ff206e60c369
https://github.com/pwittchen/ReactiveNetwork/blob/cfeb3b79a1e44d106581af5e6709ff206e60c369/library/src/main/java/com/github/pwittchen/reactivenetwork/library/rx2/ReactiveNetwork.java#L60-L73
train
pwittchen/ReactiveNetwork
library/src/main/java/com/github/pwittchen/reactivenetwork/library/rx2/ReactiveNetwork.java
ReactiveNetwork.observeNetworkConnectivity
@RequiresPermission(Manifest.permission.ACCESS_NETWORK_STATE) public static Observable<Connectivity> observeNetworkConnectivity(final Context context, final NetworkObservingStrategy strategy) { Preconditions.checkNotNull(context, "context == null"); Preconditions.checkNotNull(strategy, "strategy == null"); return strategy.observeNetworkConnectivity(context); }
java
@RequiresPermission(Manifest.permission.ACCESS_NETWORK_STATE) public static Observable<Connectivity> observeNetworkConnectivity(final Context context, final NetworkObservingStrategy strategy) { Preconditions.checkNotNull(context, "context == null"); Preconditions.checkNotNull(strategy, "strategy == null"); return strategy.observeNetworkConnectivity(context); }
[ "@", "RequiresPermission", "(", "Manifest", ".", "permission", ".", "ACCESS_NETWORK_STATE", ")", "public", "static", "Observable", "<", "Connectivity", ">", "observeNetworkConnectivity", "(", "final", "Context", "context", ",", "final", "NetworkObservingStrategy", "stra...
Observes network connectivity. Information about network state, type and typeName are contained in observed Connectivity object. Moreover, allows you to define NetworkObservingStrategy. @param context Context of the activity or an application @param strategy NetworkObserving strategy to be applied - you can use one of the existing strategies {@link PreLollipopNetworkObservingStrategy}, {@link LollipopNetworkObservingStrategy} or create your own custom strategy @return RxJava Observable with Connectivity class containing information about network state, type and typeName
[ "Observes", "network", "connectivity", ".", "Information", "about", "network", "state", "type", "and", "typeName", "are", "contained", "in", "observed", "Connectivity", "object", ".", "Moreover", "allows", "you", "to", "define", "NetworkObservingStrategy", "." ]
cfeb3b79a1e44d106581af5e6709ff206e60c369
https://github.com/pwittchen/ReactiveNetwork/blob/cfeb3b79a1e44d106581af5e6709ff206e60c369/library/src/main/java/com/github/pwittchen/reactivenetwork/library/rx2/ReactiveNetwork.java#L86-L92
train
pwittchen/ReactiveNetwork
library/src/main/java/com/github/pwittchen/reactivenetwork/library/rx2/ReactiveNetwork.java
ReactiveNetwork.observeInternetConnectivity
@RequiresPermission(Manifest.permission.INTERNET) protected static Observable<Boolean> observeInternetConnectivity( final InternetObservingStrategy strategy, final int initialIntervalInMs, final int intervalInMs, final String host, final int port, final int timeoutInMs, final int httpResponse, final ErrorHandler errorHandler) { checkStrategyIsNotNull(strategy); return strategy.observeInternetConnectivity(initialIntervalInMs, intervalInMs, host, port, timeoutInMs, httpResponse, errorHandler); }
java
@RequiresPermission(Manifest.permission.INTERNET) protected static Observable<Boolean> observeInternetConnectivity( final InternetObservingStrategy strategy, final int initialIntervalInMs, final int intervalInMs, final String host, final int port, final int timeoutInMs, final int httpResponse, final ErrorHandler errorHandler) { checkStrategyIsNotNull(strategy); return strategy.observeInternetConnectivity(initialIntervalInMs, intervalInMs, host, port, timeoutInMs, httpResponse, errorHandler); }
[ "@", "RequiresPermission", "(", "Manifest", ".", "permission", ".", "INTERNET", ")", "protected", "static", "Observable", "<", "Boolean", ">", "observeInternetConnectivity", "(", "final", "InternetObservingStrategy", "strategy", ",", "final", "int", "initialIntervalInMs...
Observes connectivity with the Internet in a given time interval. @param strategy for observing Internet connectivity @param initialIntervalInMs in milliseconds determining the delay of the first connectivity check @param intervalInMs in milliseconds determining how often we want to check connectivity @param host for checking Internet connectivity @param port for checking Internet connectivity @param timeoutInMs for pinging remote host in milliseconds @param httpResponse expected HTTP response code indicating that connection is established @param errorHandler for handling errors during connectivity check @return RxJava Observable with Boolean - true, when we have connection with host and false if not
[ "Observes", "connectivity", "with", "the", "Internet", "in", "a", "given", "time", "interval", "." ]
cfeb3b79a1e44d106581af5e6709ff206e60c369
https://github.com/pwittchen/ReactiveNetwork/blob/cfeb3b79a1e44d106581af5e6709ff206e60c369/library/src/main/java/com/github/pwittchen/reactivenetwork/library/rx2/ReactiveNetwork.java#L142-L150
train
pwittchen/ReactiveNetwork
library/src/main/java/com/github/pwittchen/reactivenetwork/library/rx2/ConnectivityPredicate.java
ConnectivityPredicate.appendUnknownNetworkTypeToTypes
protected static int[] appendUnknownNetworkTypeToTypes(int[] types) { int i = 0; final int[] extendedTypes = new int[types.length + 1]; for (int type : types) { extendedTypes[i] = type; i++; } extendedTypes[i] = Connectivity.UNKNOWN_TYPE; return extendedTypes; }
java
protected static int[] appendUnknownNetworkTypeToTypes(int[] types) { int i = 0; final int[] extendedTypes = new int[types.length + 1]; for (int type : types) { extendedTypes[i] = type; i++; } extendedTypes[i] = Connectivity.UNKNOWN_TYPE; return extendedTypes; }
[ "protected", "static", "int", "[", "]", "appendUnknownNetworkTypeToTypes", "(", "int", "[", "]", "types", ")", "{", "int", "i", "=", "0", ";", "final", "int", "[", "]", "extendedTypes", "=", "new", "int", "[", "types", ".", "length", "+", "1", "]", "...
Returns network types from the input with additional unknown type, what helps during connections filtering when device is being disconnected from a specific network @param types of the network as an array of ints @return types of the network with unknown type as an array of ints
[ "Returns", "network", "types", "from", "the", "input", "with", "additional", "unknown", "type", "what", "helps", "during", "connections", "filtering", "when", "device", "is", "being", "disconnected", "from", "a", "specific", "network" ]
cfeb3b79a1e44d106581af5e6709ff206e60c369
https://github.com/pwittchen/ReactiveNetwork/blob/cfeb3b79a1e44d106581af5e6709ff206e60c369/library/src/main/java/com/github/pwittchen/reactivenetwork/library/rx2/ConnectivityPredicate.java#L79-L88
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/json/JSONParser.java
JSONParser.getAndParseHexChar
private int getAndParseHexChar() throws ParseException { final char hexChar = getc(); if (hexChar >= '0' && hexChar <= '9') { return hexChar - '0'; } else if (hexChar >= 'a' && hexChar <= 'f') { return hexChar - 'a' + 10; } else if (hexChar >= 'A' && hexChar <= 'F') { return hexChar - 'A' + 10; } else { throw new ParseException(this, "Invalid character in Unicode escape sequence: " + hexChar); } }
java
private int getAndParseHexChar() throws ParseException { final char hexChar = getc(); if (hexChar >= '0' && hexChar <= '9') { return hexChar - '0'; } else if (hexChar >= 'a' && hexChar <= 'f') { return hexChar - 'a' + 10; } else if (hexChar >= 'A' && hexChar <= 'F') { return hexChar - 'A' + 10; } else { throw new ParseException(this, "Invalid character in Unicode escape sequence: " + hexChar); } }
[ "private", "int", "getAndParseHexChar", "(", ")", "throws", "ParseException", "{", "final", "char", "hexChar", "=", "getc", "(", ")", ";", "if", "(", "hexChar", ">=", "'", "'", "&&", "hexChar", "<=", "'", "'", ")", "{", "return", "hexChar", "-", "'", ...
Get and parse a hexadecimal digit character. @return the hex char @throws ParseException if the character was not hexadecimal
[ "Get", "and", "parse", "a", "hexadecimal", "digit", "character", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/json/JSONParser.java#L68-L79
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/json/JSONParser.java
JSONParser.parseNumber
private Number parseNumber() throws ParseException { final int startIdx = getPosition(); if (peekMatches("Infinity")) { advance(8); return Double.POSITIVE_INFINITY; } else if (peekMatches("-Infinity")) { advance(9); return Double.NEGATIVE_INFINITY; } else if (peekMatches("NaN")) { advance(3); return Double.NaN; } if (peek() == '-') { next(); } final int integralStartIdx = getPosition(); for (; hasMore(); next()) { final char c = peek(); if (c < '0' || c > '9') { break; } } final int integralEndIdx = getPosition(); final int numIntegralDigits = integralEndIdx - integralStartIdx; if (numIntegralDigits == 0) { throw new ParseException(this, "Expected a number"); } final boolean hasFractionalPart = peek() == '.'; if (hasFractionalPart) { next(); for (; hasMore(); next()) { final char c = peek(); if (c < '0' || c > '9') { break; } } if (getPosition() - (integralEndIdx + 1) == 0) { throw new ParseException(this, "Expected digits after decimal point"); } } final boolean hasExponentPart = peek() == '.'; if (hasExponentPart) { next(); final char sign = peek(); if (sign == '-' || sign == '+') { next(); } final int exponentStart = getPosition(); for (; hasMore(); next()) { final char c = peek(); if (c < '0' || c > '9') { break; } } if (getPosition() - exponentStart == 0) { throw new ParseException(this, "Expected an exponent"); } } final int endIdx = getPosition(); final String numberStr = getSubstring(startIdx, endIdx); if (hasFractionalPart || hasExponentPart) { return Double.valueOf(numberStr); } else if (numIntegralDigits < 9) { return Integer.valueOf(numberStr); } else if (numIntegralDigits == 9) { // For 9-digit numbers, could be int or long final long longVal = Long.parseLong(numberStr); if (longVal >= Integer.MIN_VALUE && longVal <= Integer.MAX_VALUE) { return (int) longVal; } else { return longVal; } } else { return Long.valueOf(numberStr); } }
java
private Number parseNumber() throws ParseException { final int startIdx = getPosition(); if (peekMatches("Infinity")) { advance(8); return Double.POSITIVE_INFINITY; } else if (peekMatches("-Infinity")) { advance(9); return Double.NEGATIVE_INFINITY; } else if (peekMatches("NaN")) { advance(3); return Double.NaN; } if (peek() == '-') { next(); } final int integralStartIdx = getPosition(); for (; hasMore(); next()) { final char c = peek(); if (c < '0' || c > '9') { break; } } final int integralEndIdx = getPosition(); final int numIntegralDigits = integralEndIdx - integralStartIdx; if (numIntegralDigits == 0) { throw new ParseException(this, "Expected a number"); } final boolean hasFractionalPart = peek() == '.'; if (hasFractionalPart) { next(); for (; hasMore(); next()) { final char c = peek(); if (c < '0' || c > '9') { break; } } if (getPosition() - (integralEndIdx + 1) == 0) { throw new ParseException(this, "Expected digits after decimal point"); } } final boolean hasExponentPart = peek() == '.'; if (hasExponentPart) { next(); final char sign = peek(); if (sign == '-' || sign == '+') { next(); } final int exponentStart = getPosition(); for (; hasMore(); next()) { final char c = peek(); if (c < '0' || c > '9') { break; } } if (getPosition() - exponentStart == 0) { throw new ParseException(this, "Expected an exponent"); } } final int endIdx = getPosition(); final String numberStr = getSubstring(startIdx, endIdx); if (hasFractionalPart || hasExponentPart) { return Double.valueOf(numberStr); } else if (numIntegralDigits < 9) { return Integer.valueOf(numberStr); } else if (numIntegralDigits == 9) { // For 9-digit numbers, could be int or long final long longVal = Long.parseLong(numberStr); if (longVal >= Integer.MIN_VALUE && longVal <= Integer.MAX_VALUE) { return (int) longVal; } else { return longVal; } } else { return Long.valueOf(numberStr); } }
[ "private", "Number", "parseNumber", "(", ")", "throws", "ParseException", "{", "final", "int", "startIdx", "=", "getPosition", "(", ")", ";", "if", "(", "peekMatches", "(", "\"Infinity\"", ")", ")", "{", "advance", "(", "8", ")", ";", "return", "Double", ...
Parses and returns Integer, Long or Double type. <pre> Number ← Minus? IntegralPart FractionalPart? ExponentPart? Minus ← "-" IntegralPart ← "0" / [1-9] [0-9]* FractionalPart ← "." [0-9]+ ExponentPart ← ( "e" / "E" ) ( "+" / "-" )? [0-9]+ </pre> @return the number @throws ParseException if parsing fails
[ "Parses", "and", "returns", "Integer", "Long", "or", "Double", "type", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/json/JSONParser.java#L211-L286
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/json/JSONParser.java
JSONParser.parseJSONObject
private JSONObject parseJSONObject() throws ParseException { expect('{'); skipWhitespace(); if (peek() == '}') { // Empty object next(); return new JSONObject(Collections.<Entry<String, Object>> emptyList()); } final List<Entry<String, Object>> kvPairs = new ArrayList<>(); final JSONObject jsonObject = new JSONObject(kvPairs); boolean first = true; while (peek() != '}') { if (first) { first = false; } else { expect(','); } final CharSequence key = parseString(); if (key == null) { throw new ParseException(this, "Object keys must be strings"); } if (peek() != ':') { return null; } expect(':'); final Object value = parseJSON(); // Check for special object id key if (key.equals(JSONUtils.ID_KEY)) { if (value == null) { throw new ParseException(this, "Got null value for \"" + JSONUtils.ID_KEY + "\" key"); } jsonObject.objectId = (CharSequence) value; } else { kvPairs.add(new SimpleEntry<>(key.toString(), value)); } } expect('}'); return jsonObject; }
java
private JSONObject parseJSONObject() throws ParseException { expect('{'); skipWhitespace(); if (peek() == '}') { // Empty object next(); return new JSONObject(Collections.<Entry<String, Object>> emptyList()); } final List<Entry<String, Object>> kvPairs = new ArrayList<>(); final JSONObject jsonObject = new JSONObject(kvPairs); boolean first = true; while (peek() != '}') { if (first) { first = false; } else { expect(','); } final CharSequence key = parseString(); if (key == null) { throw new ParseException(this, "Object keys must be strings"); } if (peek() != ':') { return null; } expect(':'); final Object value = parseJSON(); // Check for special object id key if (key.equals(JSONUtils.ID_KEY)) { if (value == null) { throw new ParseException(this, "Got null value for \"" + JSONUtils.ID_KEY + "\" key"); } jsonObject.objectId = (CharSequence) value; } else { kvPairs.add(new SimpleEntry<>(key.toString(), value)); } } expect('}'); return jsonObject; }
[ "private", "JSONObject", "parseJSONObject", "(", ")", "throws", "ParseException", "{", "expect", "(", "'", "'", ")", ";", "skipWhitespace", "(", ")", ";", "if", "(", "peek", "(", ")", "==", "'", "'", ")", "{", "// Empty object", "next", "(", ")", ";", ...
Parse a JSON Object. <pre> Object ← "{" ( String ":" JSON ( "," String ":" JSON )* / S? ) "}" </pre> @return the JSON object @throws ParseException if parsing fails
[ "Parse", "a", "JSON", "Object", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/json/JSONParser.java#L342-L382
train
classgraph/classgraph
src/main/java/io/github/classgraph/ObjectTypedValueWrapper.java
ObjectTypedValueWrapper.instantiateOrGet
Object instantiateOrGet(final ClassInfo annotationClassInfo, final String paramName) { final boolean instantiate = annotationClassInfo != null; if (enumValue != null) { return instantiate ? enumValue.loadClassAndReturnEnumValue() : enumValue; } else if (classRef != null) { return instantiate ? classRef.loadClass() : classRef; } else if (annotationInfo != null) { return instantiate ? annotationInfo.loadClassAndInstantiate() : annotationInfo; } else if (stringValue != null) { return stringValue; } else if (integerValue != null) { return integerValue; } else if (longValue != null) { return longValue; } else if (shortValue != null) { return shortValue; } else if (booleanValue != null) { return booleanValue; } else if (characterValue != null) { return characterValue; } else if (floatValue != null) { return floatValue; } else if (doubleValue != null) { return doubleValue; } else if (byteValue != null) { return byteValue; } else if (stringArrayValue != null) { return stringArrayValue; } else if (intArrayValue != null) { return intArrayValue; } else if (longArrayValue != null) { return longArrayValue; } else if (shortArrayValue != null) { return shortArrayValue; } else if (booleanArrayValue != null) { return booleanArrayValue; } else if (charArrayValue != null) { return charArrayValue; } else if (floatArrayValue != null) { return floatArrayValue; } else if (doubleArrayValue != null) { return doubleArrayValue; } else if (byteArrayValue != null) { return byteArrayValue; } else if (objectArrayValue != null) { // Get the element type of the array final Class<?> eltClass = instantiate ? (Class<?>) getArrayValueClassOrName(annotationClassInfo, paramName, /* getClass = */ true) : null; // Allocate array as either a generic Object[] array, if the element type could not be determined, // or as an array of specific element type, if the element type was determined. final Object annotationValueObjectArray = eltClass == null ? new Object[objectArrayValue.length] : Array.newInstance(eltClass, objectArrayValue.length); // Fill the array instance. for (int i = 0; i < objectArrayValue.length; i++) { if (objectArrayValue[i] != null) { // Get the element value (may also cause the element to be instantiated) final Object eltValue = objectArrayValue[i].instantiateOrGet(annotationClassInfo, paramName); // Store the possibly-instantiated value in the array Array.set(annotationValueObjectArray, i, eltValue); } } return annotationValueObjectArray; } else { return null; } }
java
Object instantiateOrGet(final ClassInfo annotationClassInfo, final String paramName) { final boolean instantiate = annotationClassInfo != null; if (enumValue != null) { return instantiate ? enumValue.loadClassAndReturnEnumValue() : enumValue; } else if (classRef != null) { return instantiate ? classRef.loadClass() : classRef; } else if (annotationInfo != null) { return instantiate ? annotationInfo.loadClassAndInstantiate() : annotationInfo; } else if (stringValue != null) { return stringValue; } else if (integerValue != null) { return integerValue; } else if (longValue != null) { return longValue; } else if (shortValue != null) { return shortValue; } else if (booleanValue != null) { return booleanValue; } else if (characterValue != null) { return characterValue; } else if (floatValue != null) { return floatValue; } else if (doubleValue != null) { return doubleValue; } else if (byteValue != null) { return byteValue; } else if (stringArrayValue != null) { return stringArrayValue; } else if (intArrayValue != null) { return intArrayValue; } else if (longArrayValue != null) { return longArrayValue; } else if (shortArrayValue != null) { return shortArrayValue; } else if (booleanArrayValue != null) { return booleanArrayValue; } else if (charArrayValue != null) { return charArrayValue; } else if (floatArrayValue != null) { return floatArrayValue; } else if (doubleArrayValue != null) { return doubleArrayValue; } else if (byteArrayValue != null) { return byteArrayValue; } else if (objectArrayValue != null) { // Get the element type of the array final Class<?> eltClass = instantiate ? (Class<?>) getArrayValueClassOrName(annotationClassInfo, paramName, /* getClass = */ true) : null; // Allocate array as either a generic Object[] array, if the element type could not be determined, // or as an array of specific element type, if the element type was determined. final Object annotationValueObjectArray = eltClass == null ? new Object[objectArrayValue.length] : Array.newInstance(eltClass, objectArrayValue.length); // Fill the array instance. for (int i = 0; i < objectArrayValue.length; i++) { if (objectArrayValue[i] != null) { // Get the element value (may also cause the element to be instantiated) final Object eltValue = objectArrayValue[i].instantiateOrGet(annotationClassInfo, paramName); // Store the possibly-instantiated value in the array Array.set(annotationValueObjectArray, i, eltValue); } } return annotationValueObjectArray; } else { return null; } }
[ "Object", "instantiateOrGet", "(", "final", "ClassInfo", "annotationClassInfo", ",", "final", "String", "paramName", ")", "{", "final", "boolean", "instantiate", "=", "annotationClassInfo", "!=", "null", ";", "if", "(", "enumValue", "!=", "null", ")", "{", "retu...
Instantiate or get the wrapped value. @param annotationClassInfo if non-null, instantiate this object as a parameter value of this annotation class. @param paramName if non-null, instantiate this object as a value of this named parameter. @return The value wrapped by this wrapper class.
[ "Instantiate", "or", "get", "the", "wrapped", "value", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ObjectTypedValueWrapper.java#L196-L262
train
classgraph/classgraph
src/main/java/io/github/classgraph/ObjectTypedValueWrapper.java
ObjectTypedValueWrapper.getArrayValueClassOrName
private Object getArrayValueClassOrName(final ClassInfo annotationClassInfo, final String paramName, final boolean getClass) { // Find the method in the annotation class with the same name as the annotation parameter. final MethodInfoList annotationMethodList = annotationClassInfo.methodInfo == null ? null : annotationClassInfo.methodInfo.get(paramName); if (annotationMethodList != null && annotationMethodList.size() > 1) { // There should only be one method with a given name in an annotation throw new IllegalArgumentException("Duplicated annotation parameter method " + paramName + "() in annotation class " + annotationClassInfo.getName()); } else if (annotationMethodList != null && annotationMethodList.size() == 1) { // Get the result type of the method with the same name as the annotation parameter final TypeSignature annotationMethodResultTypeSig = annotationMethodList.get(0) .getTypeSignatureOrTypeDescriptor().getResultType(); // The result type has to be an array type if (!(annotationMethodResultTypeSig instanceof ArrayTypeSignature)) { throw new IllegalArgumentException("Annotation parameter " + paramName + " in annotation class " + annotationClassInfo.getName() + " holds an array, but does not have an array type signature"); } final ArrayTypeSignature arrayTypeSig = (ArrayTypeSignature) annotationMethodResultTypeSig; if (arrayTypeSig.getNumDimensions() != 1) { throw new IllegalArgumentException("Annotations only support 1-dimensional arrays"); } final TypeSignature elementTypeSig = arrayTypeSig.getElementTypeSignature(); if (elementTypeSig instanceof ClassRefTypeSignature) { // Look up the name of the element type, for non-primitive arrays final ClassRefTypeSignature classRefTypeSignature = (ClassRefTypeSignature) elementTypeSig; return getClass ? classRefTypeSignature.loadClass() : classRefTypeSignature.getFullyQualifiedClassName(); } else if (elementTypeSig instanceof BaseTypeSignature) { // Look up the name of the primitive class, for primitive arrays final BaseTypeSignature baseTypeSignature = (BaseTypeSignature) elementTypeSig; return getClass ? baseTypeSignature.getType() : baseTypeSignature.getTypeStr(); } } else { // Could not find a method with this name -- this is an external class. // Find first non-null object in array, and use its type as the type of the array. for (final ObjectTypedValueWrapper elt : objectArrayValue) { if (elt != null) { return elt.integerValue != null ? (getClass ? Integer.class : "int") : elt.longValue != null ? (getClass ? Long.class : "long") : elt.shortValue != null ? (getClass ? Short.class : "short") : elt.characterValue != null ? (getClass ? Character.class : "char") : elt.byteValue != null ? (getClass ? Byte.class : "byte") : elt.booleanValue != null ? (getClass ? Boolean.class : "boolean") : elt.doubleValue != null ? (getClass ? Double.class : "double") : elt.floatValue != null ? (getClass ? Float.class : "float") : (getClass ? null : ""); } } } return getClass ? null : ""; }
java
private Object getArrayValueClassOrName(final ClassInfo annotationClassInfo, final String paramName, final boolean getClass) { // Find the method in the annotation class with the same name as the annotation parameter. final MethodInfoList annotationMethodList = annotationClassInfo.methodInfo == null ? null : annotationClassInfo.methodInfo.get(paramName); if (annotationMethodList != null && annotationMethodList.size() > 1) { // There should only be one method with a given name in an annotation throw new IllegalArgumentException("Duplicated annotation parameter method " + paramName + "() in annotation class " + annotationClassInfo.getName()); } else if (annotationMethodList != null && annotationMethodList.size() == 1) { // Get the result type of the method with the same name as the annotation parameter final TypeSignature annotationMethodResultTypeSig = annotationMethodList.get(0) .getTypeSignatureOrTypeDescriptor().getResultType(); // The result type has to be an array type if (!(annotationMethodResultTypeSig instanceof ArrayTypeSignature)) { throw new IllegalArgumentException("Annotation parameter " + paramName + " in annotation class " + annotationClassInfo.getName() + " holds an array, but does not have an array type signature"); } final ArrayTypeSignature arrayTypeSig = (ArrayTypeSignature) annotationMethodResultTypeSig; if (arrayTypeSig.getNumDimensions() != 1) { throw new IllegalArgumentException("Annotations only support 1-dimensional arrays"); } final TypeSignature elementTypeSig = arrayTypeSig.getElementTypeSignature(); if (elementTypeSig instanceof ClassRefTypeSignature) { // Look up the name of the element type, for non-primitive arrays final ClassRefTypeSignature classRefTypeSignature = (ClassRefTypeSignature) elementTypeSig; return getClass ? classRefTypeSignature.loadClass() : classRefTypeSignature.getFullyQualifiedClassName(); } else if (elementTypeSig instanceof BaseTypeSignature) { // Look up the name of the primitive class, for primitive arrays final BaseTypeSignature baseTypeSignature = (BaseTypeSignature) elementTypeSig; return getClass ? baseTypeSignature.getType() : baseTypeSignature.getTypeStr(); } } else { // Could not find a method with this name -- this is an external class. // Find first non-null object in array, and use its type as the type of the array. for (final ObjectTypedValueWrapper elt : objectArrayValue) { if (elt != null) { return elt.integerValue != null ? (getClass ? Integer.class : "int") : elt.longValue != null ? (getClass ? Long.class : "long") : elt.shortValue != null ? (getClass ? Short.class : "short") : elt.characterValue != null ? (getClass ? Character.class : "char") : elt.byteValue != null ? (getClass ? Byte.class : "byte") : elt.booleanValue != null ? (getClass ? Boolean.class : "boolean") : elt.doubleValue != null ? (getClass ? Double.class : "double") : elt.floatValue != null ? (getClass ? Float.class : "float") : (getClass ? null : ""); } } } return getClass ? null : ""; }
[ "private", "Object", "getArrayValueClassOrName", "(", "final", "ClassInfo", "annotationClassInfo", ",", "final", "String", "paramName", ",", "final", "boolean", "getClass", ")", "{", "// Find the method in the annotation class with the same name as the annotation parameter.", "fi...
Get the element type of an array element. @param annotationClassInfo annotation class @param paramName the parameter name @param getClass If true, return a {@code Class<?>} reference, otherwise return the class name. @return the array value type as a {@code Class<?>} reference if getClass is true, otherwise the class name as a String.
[ "Get", "the", "element", "type", "of", "an", "array", "element", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ObjectTypedValueWrapper.java#L287-L343
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassGraph.java
ClassGraph.enableAllInfo
public ClassGraph enableAllInfo() { enableClassInfo(); enableFieldInfo(); enableMethodInfo(); enableAnnotationInfo(); enableStaticFinalFieldConstantInitializerValues(); ignoreClassVisibility(); ignoreFieldVisibility(); ignoreMethodVisibility(); return this; }
java
public ClassGraph enableAllInfo() { enableClassInfo(); enableFieldInfo(); enableMethodInfo(); enableAnnotationInfo(); enableStaticFinalFieldConstantInitializerValues(); ignoreClassVisibility(); ignoreFieldVisibility(); ignoreMethodVisibility(); return this; }
[ "public", "ClassGraph", "enableAllInfo", "(", ")", "{", "enableClassInfo", "(", ")", ";", "enableFieldInfo", "(", ")", ";", "enableMethodInfo", "(", ")", ";", "enableAnnotationInfo", "(", ")", ";", "enableStaticFinalFieldConstantInitializerValues", "(", ")", ";", ...
Enables the scanning of all classes, fields, methods, annotations, and static final field constant initializer values, and ignores all visibility modifiers, so that both public and non-public classes, fields and methods are all scanned. <p> Calls {@link #enableClassInfo()}, {@link #enableFieldInfo()}, {@link #enableMethodInfo()}, {@link #enableAnnotationInfo()}, {@link #enableStaticFinalFieldConstantInitializerValues()}, {@link #ignoreClassVisibility()}, {@link #ignoreFieldVisibility()}, and {@link #ignoreMethodVisibility()}. @return this (for method chaining).
[ "Enables", "the", "scanning", "of", "all", "classes", "fields", "methods", "annotations", "and", "static", "final", "field", "constant", "initializer", "values", "and", "ignores", "all", "visibility", "modifiers", "so", "that", "both", "public", "and", "non", "-...
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassGraph.java#L126-L136
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassGraph.java
ClassGraph.overrideClasspath
public ClassGraph overrideClasspath(final Iterable<?> overrideClasspathElements) { final String overrideClasspath = JarUtils.pathElementsToPathStr(overrideClasspathElements); if (overrideClasspath.isEmpty()) { throw new IllegalArgumentException("Can't override classpath with an empty path"); } overrideClasspath(overrideClasspath); return this; }
java
public ClassGraph overrideClasspath(final Iterable<?> overrideClasspathElements) { final String overrideClasspath = JarUtils.pathElementsToPathStr(overrideClasspathElements); if (overrideClasspath.isEmpty()) { throw new IllegalArgumentException("Can't override classpath with an empty path"); } overrideClasspath(overrideClasspath); return this; }
[ "public", "ClassGraph", "overrideClasspath", "(", "final", "Iterable", "<", "?", ">", "overrideClasspathElements", ")", "{", "final", "String", "overrideClasspath", "=", "JarUtils", ".", "pathElementsToPathStr", "(", "overrideClasspathElements", ")", ";", "if", "(", ...
Override the automatically-detected classpath with a custom path. Causes system ClassLoaders and the java.class.path system property to be ignored. Also causes modules not to be scanned. <p> Works for Iterables of any type whose toString() method resolves to a classpath element string, e.g. String, File or Path. @param overrideClasspathElements The custom classpath to use for scanning, with path elements separated by File.pathSeparatorChar. @return this (for method chaining).
[ "Override", "the", "automatically", "-", "detected", "classpath", "with", "a", "custom", "path", ".", "Causes", "system", "ClassLoaders", "and", "the", "java", ".", "class", ".", "path", "system", "property", "to", "be", "ignored", ".", "Also", "causes", "mo...
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassGraph.java#L388-L395
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassGraph.java
ClassGraph.whitelistPackages
public ClassGraph whitelistPackages(final String... packageNames) { enableClassInfo(); for (final String packageName : packageNames) { final String packageNameNormalized = WhiteBlackList.normalizePackageOrClassName(packageName); if (packageNameNormalized.startsWith("!") || packageNameNormalized.startsWith("-")) { throw new IllegalArgumentException( "This style of whitelisting/blacklisting is no longer supported: " + packageNameNormalized); } // Whitelist package scanSpec.packageWhiteBlackList.addToWhitelist(packageNameNormalized); final String path = WhiteBlackList.packageNameToPath(packageNameNormalized); scanSpec.pathWhiteBlackList.addToWhitelist(path + "/"); if (packageNameNormalized.isEmpty()) { scanSpec.pathWhiteBlackList.addToWhitelist(""); } if (!packageNameNormalized.contains("*")) { // Whitelist sub-packages if (packageNameNormalized.isEmpty()) { scanSpec.packagePrefixWhiteBlackList.addToWhitelist(""); scanSpec.pathPrefixWhiteBlackList.addToWhitelist(""); } else { scanSpec.packagePrefixWhiteBlackList.addToWhitelist(packageNameNormalized + "."); scanSpec.pathPrefixWhiteBlackList.addToWhitelist(path + "/"); } } } return this; }
java
public ClassGraph whitelistPackages(final String... packageNames) { enableClassInfo(); for (final String packageName : packageNames) { final String packageNameNormalized = WhiteBlackList.normalizePackageOrClassName(packageName); if (packageNameNormalized.startsWith("!") || packageNameNormalized.startsWith("-")) { throw new IllegalArgumentException( "This style of whitelisting/blacklisting is no longer supported: " + packageNameNormalized); } // Whitelist package scanSpec.packageWhiteBlackList.addToWhitelist(packageNameNormalized); final String path = WhiteBlackList.packageNameToPath(packageNameNormalized); scanSpec.pathWhiteBlackList.addToWhitelist(path + "/"); if (packageNameNormalized.isEmpty()) { scanSpec.pathWhiteBlackList.addToWhitelist(""); } if (!packageNameNormalized.contains("*")) { // Whitelist sub-packages if (packageNameNormalized.isEmpty()) { scanSpec.packagePrefixWhiteBlackList.addToWhitelist(""); scanSpec.pathPrefixWhiteBlackList.addToWhitelist(""); } else { scanSpec.packagePrefixWhiteBlackList.addToWhitelist(packageNameNormalized + "."); scanSpec.pathPrefixWhiteBlackList.addToWhitelist(path + "/"); } } } return this; }
[ "public", "ClassGraph", "whitelistPackages", "(", "final", "String", "...", "packageNames", ")", "{", "enableClassInfo", "(", ")", ";", "for", "(", "final", "String", "packageName", ":", "packageNames", ")", "{", "final", "String", "packageNameNormalized", "=", ...
Scan one or more specific packages and their sub-packages. <p> N.B. Automatically calls {@link #enableClassInfo()} -- call {@link #whitelistPaths(String...)} instead if you only need to scan resources. @param packageNames The fully-qualified names of packages to scan (using '.' as a separator). May include a glob wildcard ({@code '*'}). @return this (for method chaining).
[ "Scan", "one", "or", "more", "specific", "packages", "and", "their", "sub", "-", "packages", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassGraph.java#L558-L585
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassGraph.java
ClassGraph.whitelistPaths
public ClassGraph whitelistPaths(final String... paths) { for (final String path : paths) { final String pathNormalized = WhiteBlackList.normalizePath(path); // Whitelist path final String packageName = WhiteBlackList.pathToPackageName(pathNormalized); scanSpec.packageWhiteBlackList.addToWhitelist(packageName); scanSpec.pathWhiteBlackList.addToWhitelist(pathNormalized + "/"); if (pathNormalized.isEmpty()) { scanSpec.pathWhiteBlackList.addToWhitelist(""); } if (!pathNormalized.contains("*")) { // Whitelist sub-directories / nested paths if (pathNormalized.isEmpty()) { scanSpec.packagePrefixWhiteBlackList.addToWhitelist(""); scanSpec.pathPrefixWhiteBlackList.addToWhitelist(""); } else { scanSpec.packagePrefixWhiteBlackList.addToWhitelist(packageName + "."); scanSpec.pathPrefixWhiteBlackList.addToWhitelist(pathNormalized + "/"); } } } return this; }
java
public ClassGraph whitelistPaths(final String... paths) { for (final String path : paths) { final String pathNormalized = WhiteBlackList.normalizePath(path); // Whitelist path final String packageName = WhiteBlackList.pathToPackageName(pathNormalized); scanSpec.packageWhiteBlackList.addToWhitelist(packageName); scanSpec.pathWhiteBlackList.addToWhitelist(pathNormalized + "/"); if (pathNormalized.isEmpty()) { scanSpec.pathWhiteBlackList.addToWhitelist(""); } if (!pathNormalized.contains("*")) { // Whitelist sub-directories / nested paths if (pathNormalized.isEmpty()) { scanSpec.packagePrefixWhiteBlackList.addToWhitelist(""); scanSpec.pathPrefixWhiteBlackList.addToWhitelist(""); } else { scanSpec.packagePrefixWhiteBlackList.addToWhitelist(packageName + "."); scanSpec.pathPrefixWhiteBlackList.addToWhitelist(pathNormalized + "/"); } } } return this; }
[ "public", "ClassGraph", "whitelistPaths", "(", "final", "String", "...", "paths", ")", "{", "for", "(", "final", "String", "path", ":", "paths", ")", "{", "final", "String", "pathNormalized", "=", "WhiteBlackList", ".", "normalizePath", "(", "path", ")", ";"...
Scan one or more specific paths, and their sub-directories or nested paths. @param paths The paths to scan, relative to the package root of the classpath element (with '/' as a separator). May include a glob wildcard ({@code '*'}). @return this (for method chaining).
[ "Scan", "one", "or", "more", "specific", "paths", "and", "their", "sub", "-", "directories", "or", "nested", "paths", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassGraph.java#L595-L617
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassGraph.java
ClassGraph.whitelistPackagesNonRecursive
public ClassGraph whitelistPackagesNonRecursive(final String... packageNames) { enableClassInfo(); for (final String packageName : packageNames) { final String packageNameNormalized = WhiteBlackList.normalizePackageOrClassName(packageName); if (packageNameNormalized.contains("*")) { throw new IllegalArgumentException("Cannot use a glob wildcard here: " + packageNameNormalized); } // Whitelist package, but not sub-packages scanSpec.packageWhiteBlackList.addToWhitelist(packageNameNormalized); scanSpec.pathWhiteBlackList .addToWhitelist(WhiteBlackList.packageNameToPath(packageNameNormalized) + "/"); if (packageNameNormalized.isEmpty()) { scanSpec.pathWhiteBlackList.addToWhitelist(""); } } return this; }
java
public ClassGraph whitelistPackagesNonRecursive(final String... packageNames) { enableClassInfo(); for (final String packageName : packageNames) { final String packageNameNormalized = WhiteBlackList.normalizePackageOrClassName(packageName); if (packageNameNormalized.contains("*")) { throw new IllegalArgumentException("Cannot use a glob wildcard here: " + packageNameNormalized); } // Whitelist package, but not sub-packages scanSpec.packageWhiteBlackList.addToWhitelist(packageNameNormalized); scanSpec.pathWhiteBlackList .addToWhitelist(WhiteBlackList.packageNameToPath(packageNameNormalized) + "/"); if (packageNameNormalized.isEmpty()) { scanSpec.pathWhiteBlackList.addToWhitelist(""); } } return this; }
[ "public", "ClassGraph", "whitelistPackagesNonRecursive", "(", "final", "String", "...", "packageNames", ")", "{", "enableClassInfo", "(", ")", ";", "for", "(", "final", "String", "packageName", ":", "packageNames", ")", "{", "final", "String", "packageNameNormalized...
Scan one or more specific packages, without recursively scanning sub-packages unless they are themselves whitelisted. <p> N.B. Automatically calls {@link #enableClassInfo()} -- call {@link #whitelistPathsNonRecursive(String...)} instead if you only need to scan resources. <p> This may be particularly useful for scanning the package root ("") without recursively scanning everything in the jar, dir or module. @param packageNames The fully-qualified names of packages to scan (with '.' as a separator). May not include a glob wildcard ({@code '*'}). @return this (for method chaining).
[ "Scan", "one", "or", "more", "specific", "packages", "without", "recursively", "scanning", "sub", "-", "packages", "unless", "they", "are", "themselves", "whitelisted", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassGraph.java#L637-L653
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassGraph.java
ClassGraph.whitelistPathsNonRecursive
public ClassGraph whitelistPathsNonRecursive(final String... paths) { for (final String path : paths) { if (path.contains("*")) { throw new IllegalArgumentException("Cannot use a glob wildcard here: " + path); } final String pathNormalized = WhiteBlackList.normalizePath(path); // Whitelist path, but not sub-directories / nested paths scanSpec.packageWhiteBlackList.addToWhitelist(WhiteBlackList.pathToPackageName(pathNormalized)); scanSpec.pathWhiteBlackList.addToWhitelist(pathNormalized + "/"); if (pathNormalized.isEmpty()) { scanSpec.pathWhiteBlackList.addToWhitelist(""); } } return this; }
java
public ClassGraph whitelistPathsNonRecursive(final String... paths) { for (final String path : paths) { if (path.contains("*")) { throw new IllegalArgumentException("Cannot use a glob wildcard here: " + path); } final String pathNormalized = WhiteBlackList.normalizePath(path); // Whitelist path, but not sub-directories / nested paths scanSpec.packageWhiteBlackList.addToWhitelist(WhiteBlackList.pathToPackageName(pathNormalized)); scanSpec.pathWhiteBlackList.addToWhitelist(pathNormalized + "/"); if (pathNormalized.isEmpty()) { scanSpec.pathWhiteBlackList.addToWhitelist(""); } } return this; }
[ "public", "ClassGraph", "whitelistPathsNonRecursive", "(", "final", "String", "...", "paths", ")", "{", "for", "(", "final", "String", "path", ":", "paths", ")", "{", "if", "(", "path", ".", "contains", "(", "\"*\"", ")", ")", "{", "throw", "new", "Illeg...
Scan one or more specific paths, without recursively scanning sub-directories or nested paths unless they are themselves whitelisted. <p> This may be particularly useful for scanning the package root ("") without recursively scanning everything in the jar, dir or module. @param paths The paths to scan, relative to the package root of the classpath element (with '/' as a separator). May not include a glob wildcard ({@code '*'}). @return this (for method chaining).
[ "Scan", "one", "or", "more", "specific", "paths", "without", "recursively", "scanning", "sub", "-", "directories", "or", "nested", "paths", "unless", "they", "are", "themselves", "whitelisted", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassGraph.java#L668-L682
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassGraph.java
ClassGraph.blacklistPackages
public ClassGraph blacklistPackages(final String... packageNames) { enableClassInfo(); for (final String packageName : packageNames) { final String packageNameNormalized = WhiteBlackList.normalizePackageOrClassName(packageName); if (packageNameNormalized.isEmpty()) { throw new IllegalArgumentException( "Blacklisting the root package (\"\") will cause nothing to be scanned"); } // Blacklisting always prevents further recursion, no need to blacklist sub-packages scanSpec.packageWhiteBlackList.addToBlacklist(packageNameNormalized); final String path = WhiteBlackList.packageNameToPath(packageNameNormalized); scanSpec.pathWhiteBlackList.addToBlacklist(path + "/"); if (!packageNameNormalized.contains("*")) { // Blacklist sub-packages (zipfile entries can occur in any order) scanSpec.packagePrefixWhiteBlackList.addToBlacklist(packageNameNormalized + "."); scanSpec.pathPrefixWhiteBlackList.addToBlacklist(path + "/"); } } return this; }
java
public ClassGraph blacklistPackages(final String... packageNames) { enableClassInfo(); for (final String packageName : packageNames) { final String packageNameNormalized = WhiteBlackList.normalizePackageOrClassName(packageName); if (packageNameNormalized.isEmpty()) { throw new IllegalArgumentException( "Blacklisting the root package (\"\") will cause nothing to be scanned"); } // Blacklisting always prevents further recursion, no need to blacklist sub-packages scanSpec.packageWhiteBlackList.addToBlacklist(packageNameNormalized); final String path = WhiteBlackList.packageNameToPath(packageNameNormalized); scanSpec.pathWhiteBlackList.addToBlacklist(path + "/"); if (!packageNameNormalized.contains("*")) { // Blacklist sub-packages (zipfile entries can occur in any order) scanSpec.packagePrefixWhiteBlackList.addToBlacklist(packageNameNormalized + "."); scanSpec.pathPrefixWhiteBlackList.addToBlacklist(path + "/"); } } return this; }
[ "public", "ClassGraph", "blacklistPackages", "(", "final", "String", "...", "packageNames", ")", "{", "enableClassInfo", "(", ")", ";", "for", "(", "final", "String", "packageName", ":", "packageNames", ")", "{", "final", "String", "packageNameNormalized", "=", ...
Prevent the scanning of one or more specific packages and their sub-packages. <p> N.B. Automatically calls {@link #enableClassInfo()} -- call {@link #blacklistPaths(String...)} instead if you only need to scan resources. @param packageNames The fully-qualified names of packages to blacklist (with '.' as a separator). May include a glob wildcard ({@code '*'}). @return this (for method chaining).
[ "Prevent", "the", "scanning", "of", "one", "or", "more", "specific", "packages", "and", "their", "sub", "-", "packages", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassGraph.java#L696-L715
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassGraph.java
ClassGraph.whitelistClasses
public ClassGraph whitelistClasses(final String... classNames) { enableClassInfo(); for (final String className : classNames) { if (className.contains("*")) { throw new IllegalArgumentException("Cannot use a glob wildcard here: " + className); } final String classNameNormalized = WhiteBlackList.normalizePackageOrClassName(className); // Whitelist the class itself scanSpec.classWhiteBlackList.addToWhitelist(classNameNormalized); scanSpec.classfilePathWhiteBlackList .addToWhitelist(WhiteBlackList.classNameToClassfilePath(classNameNormalized)); final String packageName = PackageInfo.getParentPackageName(classNameNormalized); // Record the package containing the class, so we can recurse to this point even if the package // is not itself whitelisted scanSpec.classPackageWhiteBlackList.addToWhitelist(packageName); scanSpec.classPackagePathWhiteBlackList .addToWhitelist(WhiteBlackList.packageNameToPath(packageName) + "/"); } return this; }
java
public ClassGraph whitelistClasses(final String... classNames) { enableClassInfo(); for (final String className : classNames) { if (className.contains("*")) { throw new IllegalArgumentException("Cannot use a glob wildcard here: " + className); } final String classNameNormalized = WhiteBlackList.normalizePackageOrClassName(className); // Whitelist the class itself scanSpec.classWhiteBlackList.addToWhitelist(classNameNormalized); scanSpec.classfilePathWhiteBlackList .addToWhitelist(WhiteBlackList.classNameToClassfilePath(classNameNormalized)); final String packageName = PackageInfo.getParentPackageName(classNameNormalized); // Record the package containing the class, so we can recurse to this point even if the package // is not itself whitelisted scanSpec.classPackageWhiteBlackList.addToWhitelist(packageName); scanSpec.classPackagePathWhiteBlackList .addToWhitelist(WhiteBlackList.packageNameToPath(packageName) + "/"); } return this; }
[ "public", "ClassGraph", "whitelistClasses", "(", "final", "String", "...", "classNames", ")", "{", "enableClassInfo", "(", ")", ";", "for", "(", "final", "String", "className", ":", "classNames", ")", "{", "if", "(", "className", ".", "contains", "(", "\"*\"...
Scan one or more specific classes, without scanning other classes in the same package unless the package is itself whitelisted. <p> N.B. Automatically calls {@link #enableClassInfo()}. @param classNames The fully-qualified names of classes to scan (using '.' as a separator). May not include a glob wildcard ({@code '*'}). @return this (for method chaining).
[ "Scan", "one", "or", "more", "specific", "classes", "without", "scanning", "other", "classes", "in", "the", "same", "package", "unless", "the", "package", "is", "itself", "whitelisted", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassGraph.java#L757-L776
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassGraph.java
ClassGraph.blacklistClasses
public ClassGraph blacklistClasses(final String... classNames) { enableClassInfo(); for (final String className : classNames) { if (className.contains("*")) { throw new IllegalArgumentException("Cannot use a glob wildcard here: " + className); } final String classNameNormalized = WhiteBlackList.normalizePackageOrClassName(className); scanSpec.classWhiteBlackList.addToBlacklist(classNameNormalized); scanSpec.classfilePathWhiteBlackList .addToBlacklist(WhiteBlackList.classNameToClassfilePath(classNameNormalized)); } return this; }
java
public ClassGraph blacklistClasses(final String... classNames) { enableClassInfo(); for (final String className : classNames) { if (className.contains("*")) { throw new IllegalArgumentException("Cannot use a glob wildcard here: " + className); } final String classNameNormalized = WhiteBlackList.normalizePackageOrClassName(className); scanSpec.classWhiteBlackList.addToBlacklist(classNameNormalized); scanSpec.classfilePathWhiteBlackList .addToBlacklist(WhiteBlackList.classNameToClassfilePath(classNameNormalized)); } return this; }
[ "public", "ClassGraph", "blacklistClasses", "(", "final", "String", "...", "classNames", ")", "{", "enableClassInfo", "(", ")", ";", "for", "(", "final", "String", "className", ":", "classNames", ")", "{", "if", "(", "className", ".", "contains", "(", "\"*\"...
Specifically blacklist one or more specific classes, preventing them from being scanned even if they are in a whitelisted package. <p> N.B. Automatically calls {@link #enableClassInfo()}. @param classNames The fully-qualified names of classes to blacklist (using '.' as a separator). May not include a glob wildcard ({@code '*'}). @return this (for method chaining).
[ "Specifically", "blacklist", "one", "or", "more", "specific", "classes", "preventing", "them", "from", "being", "scanned", "even", "if", "they", "are", "in", "a", "whitelisted", "package", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassGraph.java#L790-L802
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassGraph.java
ClassGraph.whitelistJars
public ClassGraph whitelistJars(final String... jarLeafNames) { for (final String jarLeafName : jarLeafNames) { final String leafName = JarUtils.leafName(jarLeafName); if (!leafName.equals(jarLeafName)) { throw new IllegalArgumentException("Can only whitelist jars by leafname: " + jarLeafName); } scanSpec.jarWhiteBlackList.addToWhitelist(leafName); } return this; }
java
public ClassGraph whitelistJars(final String... jarLeafNames) { for (final String jarLeafName : jarLeafNames) { final String leafName = JarUtils.leafName(jarLeafName); if (!leafName.equals(jarLeafName)) { throw new IllegalArgumentException("Can only whitelist jars by leafname: " + jarLeafName); } scanSpec.jarWhiteBlackList.addToWhitelist(leafName); } return this; }
[ "public", "ClassGraph", "whitelistJars", "(", "final", "String", "...", "jarLeafNames", ")", "{", "for", "(", "final", "String", "jarLeafName", ":", "jarLeafNames", ")", "{", "final", "String", "leafName", "=", "JarUtils", ".", "leafName", "(", "jarLeafName", ...
Whitelist one or more jars. This will cause only the whitelisted jars to be scanned. @param jarLeafNames The leafnames of the jars that should be scanned (e.g. {@code "mylib.jar"}). May contain a wildcard glob ({@code "mylib-*.jar"}). @return this (for method chaining).
[ "Whitelist", "one", "or", "more", "jars", ".", "This", "will", "cause", "only", "the", "whitelisted", "jars", "to", "be", "scanned", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassGraph.java#L812-L821
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassGraph.java
ClassGraph.blacklistJars
public ClassGraph blacklistJars(final String... jarLeafNames) { for (final String jarLeafName : jarLeafNames) { final String leafName = JarUtils.leafName(jarLeafName); if (!leafName.equals(jarLeafName)) { throw new IllegalArgumentException("Can only blacklist jars by leafname: " + jarLeafName); } scanSpec.jarWhiteBlackList.addToBlacklist(leafName); } return this; }
java
public ClassGraph blacklistJars(final String... jarLeafNames) { for (final String jarLeafName : jarLeafNames) { final String leafName = JarUtils.leafName(jarLeafName); if (!leafName.equals(jarLeafName)) { throw new IllegalArgumentException("Can only blacklist jars by leafname: " + jarLeafName); } scanSpec.jarWhiteBlackList.addToBlacklist(leafName); } return this; }
[ "public", "ClassGraph", "blacklistJars", "(", "final", "String", "...", "jarLeafNames", ")", "{", "for", "(", "final", "String", "jarLeafName", ":", "jarLeafNames", ")", "{", "final", "String", "leafName", "=", "JarUtils", ".", "leafName", "(", "jarLeafName", ...
Blacklist one or more jars, preventing them from being scanned. @param jarLeafNames The leafnames of the jars that should be scanned (e.g. {@code "badlib.jar"}). May contain a wildcard glob ({@code "badlib-*.jar"}). @return this (for method chaining).
[ "Blacklist", "one", "or", "more", "jars", "preventing", "them", "from", "being", "scanned", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassGraph.java#L831-L840
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassGraph.java
ClassGraph.whitelistOrBlacklistLibOrExtJars
private void whitelistOrBlacklistLibOrExtJars(final boolean whitelist, final String... jarLeafNames) { if (jarLeafNames.length == 0) { // If no jar leafnames are given, whitelist or blacklist all lib or ext jars for (final String libOrExtJar : SystemJarFinder.getJreLibOrExtJars()) { whitelistOrBlacklistLibOrExtJars(whitelist, JarUtils.leafName(libOrExtJar)); } } else { for (final String jarLeafName : jarLeafNames) { final String leafName = JarUtils.leafName(jarLeafName); if (!leafName.equals(jarLeafName)) { throw new IllegalArgumentException("Can only " + (whitelist ? "whitelist" : "blacklist") + " jars by leafname: " + jarLeafName); } if (jarLeafName.contains("*")) { // Compare wildcarded pattern against all jars in lib and ext dirs final Pattern pattern = WhiteBlackList.globToPattern(jarLeafName); boolean found = false; for (final String libOrExtJarPath : SystemJarFinder.getJreLibOrExtJars()) { final String libOrExtJarLeafName = JarUtils.leafName(libOrExtJarPath); if (pattern.matcher(libOrExtJarLeafName).matches()) { // Check for "*" in filename to prevent infinite recursion (shouldn't happen) if (!libOrExtJarLeafName.contains("*")) { whitelistOrBlacklistLibOrExtJars(whitelist, libOrExtJarLeafName); } found = true; } } if (!found && topLevelLog != null) { topLevelLog.log("Could not find lib or ext jar matching wildcard: " + jarLeafName); } } else { // No wildcards, just whitelist or blacklist the named jar, if present boolean found = false; for (final String libOrExtJarPath : SystemJarFinder.getJreLibOrExtJars()) { final String libOrExtJarLeafName = JarUtils.leafName(libOrExtJarPath); if (jarLeafName.equals(libOrExtJarLeafName)) { if (whitelist) { scanSpec.libOrExtJarWhiteBlackList.addToWhitelist(jarLeafName); } else { scanSpec.libOrExtJarWhiteBlackList.addToBlacklist(jarLeafName); } if (topLevelLog != null) { topLevelLog.log((whitelist ? "Whitelisting" : "Blacklisting") + " lib or ext jar: " + libOrExtJarPath); } found = true; break; } } if (!found && topLevelLog != null) { topLevelLog.log("Could not find lib or ext jar: " + jarLeafName); } } } } }
java
private void whitelistOrBlacklistLibOrExtJars(final boolean whitelist, final String... jarLeafNames) { if (jarLeafNames.length == 0) { // If no jar leafnames are given, whitelist or blacklist all lib or ext jars for (final String libOrExtJar : SystemJarFinder.getJreLibOrExtJars()) { whitelistOrBlacklistLibOrExtJars(whitelist, JarUtils.leafName(libOrExtJar)); } } else { for (final String jarLeafName : jarLeafNames) { final String leafName = JarUtils.leafName(jarLeafName); if (!leafName.equals(jarLeafName)) { throw new IllegalArgumentException("Can only " + (whitelist ? "whitelist" : "blacklist") + " jars by leafname: " + jarLeafName); } if (jarLeafName.contains("*")) { // Compare wildcarded pattern against all jars in lib and ext dirs final Pattern pattern = WhiteBlackList.globToPattern(jarLeafName); boolean found = false; for (final String libOrExtJarPath : SystemJarFinder.getJreLibOrExtJars()) { final String libOrExtJarLeafName = JarUtils.leafName(libOrExtJarPath); if (pattern.matcher(libOrExtJarLeafName).matches()) { // Check for "*" in filename to prevent infinite recursion (shouldn't happen) if (!libOrExtJarLeafName.contains("*")) { whitelistOrBlacklistLibOrExtJars(whitelist, libOrExtJarLeafName); } found = true; } } if (!found && topLevelLog != null) { topLevelLog.log("Could not find lib or ext jar matching wildcard: " + jarLeafName); } } else { // No wildcards, just whitelist or blacklist the named jar, if present boolean found = false; for (final String libOrExtJarPath : SystemJarFinder.getJreLibOrExtJars()) { final String libOrExtJarLeafName = JarUtils.leafName(libOrExtJarPath); if (jarLeafName.equals(libOrExtJarLeafName)) { if (whitelist) { scanSpec.libOrExtJarWhiteBlackList.addToWhitelist(jarLeafName); } else { scanSpec.libOrExtJarWhiteBlackList.addToBlacklist(jarLeafName); } if (topLevelLog != null) { topLevelLog.log((whitelist ? "Whitelisting" : "Blacklisting") + " lib or ext jar: " + libOrExtJarPath); } found = true; break; } } if (!found && topLevelLog != null) { topLevelLog.log("Could not find lib or ext jar: " + jarLeafName); } } } } }
[ "private", "void", "whitelistOrBlacklistLibOrExtJars", "(", "final", "boolean", "whitelist", ",", "final", "String", "...", "jarLeafNames", ")", "{", "if", "(", "jarLeafNames", ".", "length", "==", "0", ")", "{", "// If no jar leafnames are given, whitelist or blacklist...
Add lib or ext jars to whitelist or blacklist. @param whitelist if true, add to whitelist, otherwise add to blacklist. @param jarLeafNames the jar leaf names to whitelist
[ "Add", "lib", "or", "ext", "jars", "to", "whitelist", "or", "blacklist", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassGraph.java#L850-L905
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassGraph.java
ClassGraph.whitelistModules
public ClassGraph whitelistModules(final String... moduleNames) { for (final String moduleName : moduleNames) { scanSpec.moduleWhiteBlackList.addToWhitelist(WhiteBlackList.normalizePackageOrClassName(moduleName)); } return this; }
java
public ClassGraph whitelistModules(final String... moduleNames) { for (final String moduleName : moduleNames) { scanSpec.moduleWhiteBlackList.addToWhitelist(WhiteBlackList.normalizePackageOrClassName(moduleName)); } return this; }
[ "public", "ClassGraph", "whitelistModules", "(", "final", "String", "...", "moduleNames", ")", "{", "for", "(", "final", "String", "moduleName", ":", "moduleNames", ")", "{", "scanSpec", ".", "moduleWhiteBlackList", ".", "addToWhitelist", "(", "WhiteBlackList", "....
Whitelist one or more modules to scan. @param moduleNames The names of the modules that should be scanned. May contain a wildcard glob ({@code '*'}). @return this (for method chaining).
[ "Whitelist", "one", "or", "more", "modules", "to", "scan", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassGraph.java#L943-L948
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassGraph.java
ClassGraph.blacklistModules
public ClassGraph blacklistModules(final String... moduleNames) { for (final String moduleName : moduleNames) { scanSpec.moduleWhiteBlackList.addToBlacklist(WhiteBlackList.normalizePackageOrClassName(moduleName)); } return this; }
java
public ClassGraph blacklistModules(final String... moduleNames) { for (final String moduleName : moduleNames) { scanSpec.moduleWhiteBlackList.addToBlacklist(WhiteBlackList.normalizePackageOrClassName(moduleName)); } return this; }
[ "public", "ClassGraph", "blacklistModules", "(", "final", "String", "...", "moduleNames", ")", "{", "for", "(", "final", "String", "moduleName", ":", "moduleNames", ")", "{", "scanSpec", ".", "moduleWhiteBlackList", ".", "addToBlacklist", "(", "WhiteBlackList", "....
Blacklist one or more modules, preventing them from being scanned. @param moduleNames The names of the modules that should not be scanned. May contain a wildcard glob ({@code '*'}). @return this (for method chaining).
[ "Blacklist", "one", "or", "more", "modules", "preventing", "them", "from", "being", "scanned", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassGraph.java#L957-L962
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassGraph.java
ClassGraph.whitelistClasspathElementsContainingResourcePath
public ClassGraph whitelistClasspathElementsContainingResourcePath(final String... resourcePaths) { for (final String resourcePath : resourcePaths) { final String resourcePathNormalized = WhiteBlackList.normalizePath(resourcePath); scanSpec.classpathElementResourcePathWhiteBlackList.addToWhitelist(resourcePathNormalized); } return this; }
java
public ClassGraph whitelistClasspathElementsContainingResourcePath(final String... resourcePaths) { for (final String resourcePath : resourcePaths) { final String resourcePathNormalized = WhiteBlackList.normalizePath(resourcePath); scanSpec.classpathElementResourcePathWhiteBlackList.addToWhitelist(resourcePathNormalized); } return this; }
[ "public", "ClassGraph", "whitelistClasspathElementsContainingResourcePath", "(", "final", "String", "...", "resourcePaths", ")", "{", "for", "(", "final", "String", "resourcePath", ":", "resourcePaths", ")", "{", "final", "String", "resourcePathNormalized", "=", "WhiteB...
Whitelist classpath elements based on resource paths. Only classpath elements that contain resources with paths matching the whitelist will be scanned. @param resourcePaths The resource paths, any of which must be present in a classpath element for the classpath element to be scanned. May contain a wildcard glob ({@code '*'}). @return this (for method chaining).
[ "Whitelist", "classpath", "elements", "based", "on", "resource", "paths", ".", "Only", "classpath", "elements", "that", "contain", "resources", "with", "paths", "matching", "the", "whitelist", "will", "be", "scanned", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassGraph.java#L973-L979
train
classgraph/classgraph
src/main/java/io/github/classgraph/ClassGraph.java
ClassGraph.blacklistClasspathElementsContainingResourcePath
public ClassGraph blacklistClasspathElementsContainingResourcePath(final String... resourcePaths) { for (final String resourcePath : resourcePaths) { final String resourcePathNormalized = WhiteBlackList.normalizePath(resourcePath); scanSpec.classpathElementResourcePathWhiteBlackList.addToBlacklist(resourcePathNormalized); } return this; }
java
public ClassGraph blacklistClasspathElementsContainingResourcePath(final String... resourcePaths) { for (final String resourcePath : resourcePaths) { final String resourcePathNormalized = WhiteBlackList.normalizePath(resourcePath); scanSpec.classpathElementResourcePathWhiteBlackList.addToBlacklist(resourcePathNormalized); } return this; }
[ "public", "ClassGraph", "blacklistClasspathElementsContainingResourcePath", "(", "final", "String", "...", "resourcePaths", ")", "{", "for", "(", "final", "String", "resourcePath", ":", "resourcePaths", ")", "{", "final", "String", "resourcePathNormalized", "=", "WhiteB...
Blacklist classpath elements based on resource paths. Classpath elements that contain resources with paths matching the blacklist will not be scanned. @param resourcePaths The resource paths which cause a classpath not to be scanned if any are present in a classpath element for the classpath element. May contain a wildcard glob ({@code '*'}). @return this (for method chaining).
[ "Blacklist", "classpath", "elements", "based", "on", "resource", "paths", ".", "Classpath", "elements", "that", "contain", "resources", "with", "paths", "matching", "the", "blacklist", "will", "not", "be", "scanned", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassGraph.java#L990-L996
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/recycler/Recycler.java
Recycler.acquire
public T acquire() throws E { final T instance; final T recycledInstance = unusedInstances.poll(); if (recycledInstance == null) { // Allocate a new instance -- may throw an exception of type E final T newInstance = newInstance(); if (newInstance == null) { throw new NullPointerException("Failed to allocate a new recyclable instance"); } instance = newInstance; } else { // Reuse an unused instance instance = recycledInstance; } usedInstances.add(instance); return instance; }
java
public T acquire() throws E { final T instance; final T recycledInstance = unusedInstances.poll(); if (recycledInstance == null) { // Allocate a new instance -- may throw an exception of type E final T newInstance = newInstance(); if (newInstance == null) { throw new NullPointerException("Failed to allocate a new recyclable instance"); } instance = newInstance; } else { // Reuse an unused instance instance = recycledInstance; } usedInstances.add(instance); return instance; }
[ "public", "T", "acquire", "(", ")", "throws", "E", "{", "final", "T", "instance", ";", "final", "T", "recycledInstance", "=", "unusedInstances", ".", "poll", "(", ")", ";", "if", "(", "recycledInstance", "==", "null", ")", "{", "// Allocate a new instance --...
Acquire on object instance of type T, either by reusing a previously recycled instance if possible, or if there are no currently-unused instances, by allocating a new instance. @return Either a new or a recycled object instance. @throws E if {@link #newInstance()} threw an exception of type E. @throws NullPointerException if {@link #newInstance()} returned null.
[ "Acquire", "on", "object", "instance", "of", "type", "T", "either", "by", "reusing", "a", "previously", "recycled", "instance", "if", "possible", "or", "if", "there", "are", "no", "currently", "-", "unused", "instances", "by", "allocating", "a", "new", "inst...
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/recycler/Recycler.java#L74-L90
train
classgraph/classgraph
src/main/java/io/github/classgraph/ScanResult.java
ScanResult.getClasspathURIs
public List<URI> getClasspathURIs() { if (closed.get()) { throw new IllegalArgumentException("Cannot use a ScanResult after it has been closed"); } final List<URI> classpathElementOrderURIs = new ArrayList<>(); for (final ClasspathElement classpathElement : classpathOrder) { try { final URI uri = classpathElement.getURI(); if (uri != null) { classpathElementOrderURIs.add(uri); } } catch (final IllegalArgumentException e) { // Skip null location URIs } } return classpathElementOrderURIs; }
java
public List<URI> getClasspathURIs() { if (closed.get()) { throw new IllegalArgumentException("Cannot use a ScanResult after it has been closed"); } final List<URI> classpathElementOrderURIs = new ArrayList<>(); for (final ClasspathElement classpathElement : classpathOrder) { try { final URI uri = classpathElement.getURI(); if (uri != null) { classpathElementOrderURIs.add(uri); } } catch (final IllegalArgumentException e) { // Skip null location URIs } } return classpathElementOrderURIs; }
[ "public", "List", "<", "URI", ">", "getClasspathURIs", "(", ")", "{", "if", "(", "closed", ".", "get", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Cannot use a ScanResult after it has been closed\"", ")", ";", "}", "final", "List", ...
Returns an ordered list of unique classpath element and module URIs. @return The unique classpath element and module URIs.
[ "Returns", "an", "ordered", "list", "of", "unique", "classpath", "element", "and", "module", "URIs", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ScanResult.java#L440-L456
train
classgraph/classgraph
src/main/java/io/github/classgraph/ScanResult.java
ScanResult.getAllResources
public ResourceList getAllResources() { if (allWhitelistedResourcesCached == null) { // Index Resource objects by path final ResourceList whitelistedResourcesList = new ResourceList(); for (final ClasspathElement classpathElt : classpathOrder) { if (classpathElt.whitelistedResources != null) { whitelistedResourcesList.addAll(classpathElt.whitelistedResources); } } // Set atomically for thread safety allWhitelistedResourcesCached = whitelistedResourcesList; } return allWhitelistedResourcesCached; }
java
public ResourceList getAllResources() { if (allWhitelistedResourcesCached == null) { // Index Resource objects by path final ResourceList whitelistedResourcesList = new ResourceList(); for (final ClasspathElement classpathElt : classpathOrder) { if (classpathElt.whitelistedResources != null) { whitelistedResourcesList.addAll(classpathElt.whitelistedResources); } } // Set atomically for thread safety allWhitelistedResourcesCached = whitelistedResourcesList; } return allWhitelistedResourcesCached; }
[ "public", "ResourceList", "getAllResources", "(", ")", "{", "if", "(", "allWhitelistedResourcesCached", "==", "null", ")", "{", "// Index Resource objects by path", "final", "ResourceList", "whitelistedResourcesList", "=", "new", "ResourceList", "(", ")", ";", "for", ...
Get the list of all resources. @return A list of all resources (including classfiles and non-classfiles) found in whitelisted packages.
[ "Get", "the", "list", "of", "all", "resources", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ScanResult.java#L525-L538
train
classgraph/classgraph
src/main/java/io/github/classgraph/ScanResult.java
ScanResult.getResourcesWithPath
public ResourceList getResourcesWithPath(final String resourcePath) { if (closed.get()) { throw new IllegalArgumentException("Cannot use a ScanResult after it has been closed"); } final ResourceList allWhitelistedResources = getAllResources(); if (allWhitelistedResources.isEmpty()) { return ResourceList.EMPTY_LIST; } else { final String path = FileUtils.sanitizeEntryPath(resourcePath, /* removeInitialSlash = */ true); final ResourceList resourceList = getAllResourcesAsMap().get(path); return (resourceList == null ? new ResourceList(1) : resourceList); } }
java
public ResourceList getResourcesWithPath(final String resourcePath) { if (closed.get()) { throw new IllegalArgumentException("Cannot use a ScanResult after it has been closed"); } final ResourceList allWhitelistedResources = getAllResources(); if (allWhitelistedResources.isEmpty()) { return ResourceList.EMPTY_LIST; } else { final String path = FileUtils.sanitizeEntryPath(resourcePath, /* removeInitialSlash = */ true); final ResourceList resourceList = getAllResourcesAsMap().get(path); return (resourceList == null ? new ResourceList(1) : resourceList); } }
[ "public", "ResourceList", "getResourcesWithPath", "(", "final", "String", "resourcePath", ")", "{", "if", "(", "closed", ".", "get", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Cannot use a ScanResult after it has been closed\"", ")", ";", ...
Get the list of all resources found in whitelisted packages that have the given path, relative to the package root of the classpath element. May match several resources, up to one per classpath element. @param resourcePath A complete resource path, relative to the classpath entry package root. @return A list of all resources found in whitelisted packages that have the given path, relative to the package root of the classpath element. May match several resources, up to one per classpath element.
[ "Get", "the", "list", "of", "all", "resources", "found", "in", "whitelisted", "packages", "that", "have", "the", "given", "path", "relative", "to", "the", "package", "root", "of", "the", "classpath", "element", ".", "May", "match", "several", "resources", "u...
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ScanResult.java#L572-L584
train
classgraph/classgraph
src/main/java/io/github/classgraph/ScanResult.java
ScanResult.getResourcesWithLeafName
public ResourceList getResourcesWithLeafName(final String leafName) { if (closed.get()) { throw new IllegalArgumentException("Cannot use a ScanResult after it has been closed"); } final ResourceList allWhitelistedResources = getAllResources(); if (allWhitelistedResources.isEmpty()) { return ResourceList.EMPTY_LIST; } else { final ResourceList filteredResources = new ResourceList(); for (final Resource classpathResource : allWhitelistedResources) { final String relativePath = classpathResource.getPath(); final int lastSlashIdx = relativePath.lastIndexOf('/'); if (relativePath.substring(lastSlashIdx + 1).equals(leafName)) { filteredResources.add(classpathResource); } } return filteredResources; } }
java
public ResourceList getResourcesWithLeafName(final String leafName) { if (closed.get()) { throw new IllegalArgumentException("Cannot use a ScanResult after it has been closed"); } final ResourceList allWhitelistedResources = getAllResources(); if (allWhitelistedResources.isEmpty()) { return ResourceList.EMPTY_LIST; } else { final ResourceList filteredResources = new ResourceList(); for (final Resource classpathResource : allWhitelistedResources) { final String relativePath = classpathResource.getPath(); final int lastSlashIdx = relativePath.lastIndexOf('/'); if (relativePath.substring(lastSlashIdx + 1).equals(leafName)) { filteredResources.add(classpathResource); } } return filteredResources; } }
[ "public", "ResourceList", "getResourcesWithLeafName", "(", "final", "String", "leafName", ")", "{", "if", "(", "closed", ".", "get", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Cannot use a ScanResult after it has been closed\"", ")", ";", ...
Get the list of all resources found in whitelisted packages that have the requested leafname. @param leafName A resource leaf filename. @return A list of all resources found in whitelisted packages that have the requested leafname.
[ "Get", "the", "list", "of", "all", "resources", "found", "in", "whitelisted", "packages", "that", "have", "the", "requested", "leafname", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ScanResult.java#L619-L637
train
classgraph/classgraph
src/main/java/io/github/classgraph/ScanResult.java
ScanResult.getResourcesWithExtension
public ResourceList getResourcesWithExtension(final String extension) { if (closed.get()) { throw new IllegalArgumentException("Cannot use a ScanResult after it has been closed"); } final ResourceList allWhitelistedResources = getAllResources(); if (allWhitelistedResources.isEmpty()) { return ResourceList.EMPTY_LIST; } else { String bareExtension = extension; while (bareExtension.startsWith(".")) { bareExtension = bareExtension.substring(1); } final ResourceList filteredResources = new ResourceList(); for (final Resource classpathResource : allWhitelistedResources) { final String relativePath = classpathResource.getPath(); final int lastSlashIdx = relativePath.lastIndexOf('/'); final int lastDotIdx = relativePath.lastIndexOf('.'); if (lastDotIdx > lastSlashIdx && relativePath.substring(lastDotIdx + 1).equalsIgnoreCase(bareExtension)) { filteredResources.add(classpathResource); } } return filteredResources; } }
java
public ResourceList getResourcesWithExtension(final String extension) { if (closed.get()) { throw new IllegalArgumentException("Cannot use a ScanResult after it has been closed"); } final ResourceList allWhitelistedResources = getAllResources(); if (allWhitelistedResources.isEmpty()) { return ResourceList.EMPTY_LIST; } else { String bareExtension = extension; while (bareExtension.startsWith(".")) { bareExtension = bareExtension.substring(1); } final ResourceList filteredResources = new ResourceList(); for (final Resource classpathResource : allWhitelistedResources) { final String relativePath = classpathResource.getPath(); final int lastSlashIdx = relativePath.lastIndexOf('/'); final int lastDotIdx = relativePath.lastIndexOf('.'); if (lastDotIdx > lastSlashIdx && relativePath.substring(lastDotIdx + 1).equalsIgnoreCase(bareExtension)) { filteredResources.add(classpathResource); } } return filteredResources; } }
[ "public", "ResourceList", "getResourcesWithExtension", "(", "final", "String", "extension", ")", "{", "if", "(", "closed", ".", "get", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Cannot use a ScanResult after it has been closed\"", ")", ";"...
Get the list of all resources found in whitelisted packages that have the requested filename extension. @param extension A filename extension, e.g. "xml" to match all resources ending in ".xml". @return A list of all resources found in whitelisted packages that have the requested filename extension.
[ "Get", "the", "list", "of", "all", "resources", "found", "in", "whitelisted", "packages", "that", "have", "the", "requested", "filename", "extension", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ScanResult.java#L646-L670
train
classgraph/classgraph
src/main/java/io/github/classgraph/ScanResult.java
ScanResult.getResourcesMatchingPattern
public ResourceList getResourcesMatchingPattern(final Pattern pattern) { if (closed.get()) { throw new IllegalArgumentException("Cannot use a ScanResult after it has been closed"); } final ResourceList allWhitelistedResources = getAllResources(); if (allWhitelistedResources.isEmpty()) { return ResourceList.EMPTY_LIST; } else { final ResourceList filteredResources = new ResourceList(); for (final Resource classpathResource : allWhitelistedResources) { final String relativePath = classpathResource.getPath(); if (pattern.matcher(relativePath).matches()) { filteredResources.add(classpathResource); } } return filteredResources; } }
java
public ResourceList getResourcesMatchingPattern(final Pattern pattern) { if (closed.get()) { throw new IllegalArgumentException("Cannot use a ScanResult after it has been closed"); } final ResourceList allWhitelistedResources = getAllResources(); if (allWhitelistedResources.isEmpty()) { return ResourceList.EMPTY_LIST; } else { final ResourceList filteredResources = new ResourceList(); for (final Resource classpathResource : allWhitelistedResources) { final String relativePath = classpathResource.getPath(); if (pattern.matcher(relativePath).matches()) { filteredResources.add(classpathResource); } } return filteredResources; } }
[ "public", "ResourceList", "getResourcesMatchingPattern", "(", "final", "Pattern", "pattern", ")", "{", "if", "(", "closed", ".", "get", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Cannot use a ScanResult after it has been closed\"", ")", ";...
Get the list of all resources found in whitelisted packages that have a path matching the requested pattern. @param pattern A pattern to match {@link Resource} paths with. @return A list of all resources found in whitelisted packages that have a path matching the requested pattern.
[ "Get", "the", "list", "of", "all", "resources", "found", "in", "whitelisted", "packages", "that", "have", "a", "path", "matching", "the", "requested", "pattern", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ScanResult.java#L680-L697
train
classgraph/classgraph
src/main/java/io/github/classgraph/ScanResult.java
ScanResult.getModuleInfo
public ModuleInfoList getModuleInfo() { if (closed.get()) { throw new IllegalArgumentException("Cannot use a ScanResult after it has been closed"); } if (!scanSpec.enableClassInfo) { throw new IllegalArgumentException("Please call ClassGraph#enableClassInfo() before #scan()"); } return new ModuleInfoList(moduleNameToModuleInfo.values()); }
java
public ModuleInfoList getModuleInfo() { if (closed.get()) { throw new IllegalArgumentException("Cannot use a ScanResult after it has been closed"); } if (!scanSpec.enableClassInfo) { throw new IllegalArgumentException("Please call ClassGraph#enableClassInfo() before #scan()"); } return new ModuleInfoList(moduleNameToModuleInfo.values()); }
[ "public", "ModuleInfoList", "getModuleInfo", "(", ")", "{", "if", "(", "closed", ".", "get", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Cannot use a ScanResult after it has been closed\"", ")", ";", "}", "if", "(", "!", "scanSpec", "...
Get all modules found during the scan. @return A list of all modules found during the scan, or the empty list if none.
[ "Get", "all", "modules", "found", "during", "the", "scan", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ScanResult.java#L725-L733
train
classgraph/classgraph
src/main/java/io/github/classgraph/ScanResult.java
ScanResult.getPackageInfo
public PackageInfoList getPackageInfo() { if (closed.get()) { throw new IllegalArgumentException("Cannot use a ScanResult after it has been closed"); } if (!scanSpec.enableClassInfo) { throw new IllegalArgumentException("Please call ClassGraph#enableClassInfo() before #scan()"); } return new PackageInfoList(packageNameToPackageInfo.values()); }
java
public PackageInfoList getPackageInfo() { if (closed.get()) { throw new IllegalArgumentException("Cannot use a ScanResult after it has been closed"); } if (!scanSpec.enableClassInfo) { throw new IllegalArgumentException("Please call ClassGraph#enableClassInfo() before #scan()"); } return new PackageInfoList(packageNameToPackageInfo.values()); }
[ "public", "PackageInfoList", "getPackageInfo", "(", ")", "{", "if", "(", "closed", ".", "get", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Cannot use a ScanResult after it has been closed\"", ")", ";", "}", "if", "(", "!", "scanSpec", ...
Get all packages found during the scan. @return A list of all packages found during the scan, or the empty list if none.
[ "Get", "all", "packages", "found", "during", "the", "scan", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ScanResult.java#L761-L769
train
classgraph/classgraph
src/main/java/io/github/classgraph/ScanResult.java
ScanResult.getAllClasses
public ClassInfoList getAllClasses() { if (closed.get()) { throw new IllegalArgumentException("Cannot use a ScanResult after it has been closed"); } if (!scanSpec.enableClassInfo) { throw new IllegalArgumentException("Please call ClassGraph#enableClassInfo() before #scan()"); } return ClassInfo.getAllClasses(classNameToClassInfo.values(), scanSpec); }
java
public ClassInfoList getAllClasses() { if (closed.get()) { throw new IllegalArgumentException("Cannot use a ScanResult after it has been closed"); } if (!scanSpec.enableClassInfo) { throw new IllegalArgumentException("Please call ClassGraph#enableClassInfo() before #scan()"); } return ClassInfo.getAllClasses(classNameToClassInfo.values(), scanSpec); }
[ "public", "ClassInfoList", "getAllClasses", "(", ")", "{", "if", "(", "closed", ".", "get", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Cannot use a ScanResult after it has been closed\"", ")", ";", "}", "if", "(", "!", "scanSpec", "....
Get all classes, interfaces and annotations found during the scan. @return A list of all whitelisted classes found during the scan, or the empty list if none.
[ "Get", "all", "classes", "interfaces", "and", "annotations", "found", "during", "the", "scan", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ScanResult.java#L850-L858
train
classgraph/classgraph
src/main/java/io/github/classgraph/ScanResult.java
ScanResult.getSubclasses
public ClassInfoList getSubclasses(final String superclassName) { if (closed.get()) { throw new IllegalArgumentException("Cannot use a ScanResult after it has been closed"); } if (!scanSpec.enableClassInfo) { throw new IllegalArgumentException("Please call ClassGraph#enableClassInfo() before #scan()"); } if (superclassName.equals("java.lang.Object")) { // Return all standard classes (interfaces don't extend Object) return getAllStandardClasses(); } else { final ClassInfo superclass = classNameToClassInfo.get(superclassName); return superclass == null ? ClassInfoList.EMPTY_LIST : superclass.getSubclasses(); } }
java
public ClassInfoList getSubclasses(final String superclassName) { if (closed.get()) { throw new IllegalArgumentException("Cannot use a ScanResult after it has been closed"); } if (!scanSpec.enableClassInfo) { throw new IllegalArgumentException("Please call ClassGraph#enableClassInfo() before #scan()"); } if (superclassName.equals("java.lang.Object")) { // Return all standard classes (interfaces don't extend Object) return getAllStandardClasses(); } else { final ClassInfo superclass = classNameToClassInfo.get(superclassName); return superclass == null ? ClassInfoList.EMPTY_LIST : superclass.getSubclasses(); } }
[ "public", "ClassInfoList", "getSubclasses", "(", "final", "String", "superclassName", ")", "{", "if", "(", "closed", ".", "get", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Cannot use a ScanResult after it has been closed\"", ")", ";", "}...
Get all subclasses of the named superclass. @param superclassName The name of the superclass. @return A list of subclasses of the named superclass, or the empty list if none.
[ "Get", "all", "subclasses", "of", "the", "named", "superclass", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ScanResult.java#L899-L913
train
classgraph/classgraph
src/main/java/io/github/classgraph/ScanResult.java
ScanResult.getSuperclasses
public ClassInfoList getSuperclasses(final String subclassName) { if (closed.get()) { throw new IllegalArgumentException("Cannot use a ScanResult after it has been closed"); } if (!scanSpec.enableClassInfo) { throw new IllegalArgumentException("Please call ClassGraph#enableClassInfo() before #scan()"); } final ClassInfo subclass = classNameToClassInfo.get(subclassName); return subclass == null ? ClassInfoList.EMPTY_LIST : subclass.getSuperclasses(); }
java
public ClassInfoList getSuperclasses(final String subclassName) { if (closed.get()) { throw new IllegalArgumentException("Cannot use a ScanResult after it has been closed"); } if (!scanSpec.enableClassInfo) { throw new IllegalArgumentException("Please call ClassGraph#enableClassInfo() before #scan()"); } final ClassInfo subclass = classNameToClassInfo.get(subclassName); return subclass == null ? ClassInfoList.EMPTY_LIST : subclass.getSuperclasses(); }
[ "public", "ClassInfoList", "getSuperclasses", "(", "final", "String", "subclassName", ")", "{", "if", "(", "closed", ".", "get", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Cannot use a ScanResult after it has been closed\"", ")", ";", "}...
Get superclasses of the named subclass. @param subclassName The name of the subclass. @return A list of superclasses of the named subclass, or the empty list if none.
[ "Get", "superclasses", "of", "the", "named", "subclass", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ScanResult.java#L922-L931
train
classgraph/classgraph
src/main/java/io/github/classgraph/ScanResult.java
ScanResult.getClassesWithMethodAnnotation
public ClassInfoList getClassesWithMethodAnnotation(final String methodAnnotationName) { if (closed.get()) { throw new IllegalArgumentException("Cannot use a ScanResult after it has been closed"); } if (!scanSpec.enableClassInfo || !scanSpec.enableMethodInfo || !scanSpec.enableAnnotationInfo) { throw new IllegalArgumentException("Please call ClassGraph#enableClassInfo(), #enableMethodInfo(), " + "and #enableAnnotationInfo() before #scan()"); } final ClassInfo classInfo = classNameToClassInfo.get(methodAnnotationName); return classInfo == null ? ClassInfoList.EMPTY_LIST : classInfo.getClassesWithMethodAnnotation(); }
java
public ClassInfoList getClassesWithMethodAnnotation(final String methodAnnotationName) { if (closed.get()) { throw new IllegalArgumentException("Cannot use a ScanResult after it has been closed"); } if (!scanSpec.enableClassInfo || !scanSpec.enableMethodInfo || !scanSpec.enableAnnotationInfo) { throw new IllegalArgumentException("Please call ClassGraph#enableClassInfo(), #enableMethodInfo(), " + "and #enableAnnotationInfo() before #scan()"); } final ClassInfo classInfo = classNameToClassInfo.get(methodAnnotationName); return classInfo == null ? ClassInfoList.EMPTY_LIST : classInfo.getClassesWithMethodAnnotation(); }
[ "public", "ClassInfoList", "getClassesWithMethodAnnotation", "(", "final", "String", "methodAnnotationName", ")", "{", "if", "(", "closed", ".", "get", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Cannot use a ScanResult after it has been closed...
Get classes that have a method with an annotation of the named type. @param methodAnnotationName the name of the method annotation. @return A list of classes with a method that has an annotation of the named type, or the empty list if none.
[ "Get", "classes", "that", "have", "a", "method", "with", "an", "annotation", "of", "the", "named", "type", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ScanResult.java#L940-L950
train
classgraph/classgraph
src/main/java/io/github/classgraph/ScanResult.java
ScanResult.getClassesWithMethodParameterAnnotation
public ClassInfoList getClassesWithMethodParameterAnnotation(final String methodParameterAnnotationName) { if (closed.get()) { throw new IllegalArgumentException("Cannot use a ScanResult after it has been closed"); } if (!scanSpec.enableClassInfo || !scanSpec.enableMethodInfo || !scanSpec.enableAnnotationInfo) { throw new IllegalArgumentException("Please call ClassGraph#enableClassInfo(), #enableMethodInfo(), " + "and #enableAnnotationInfo() before #scan()"); } final ClassInfo classInfo = classNameToClassInfo.get(methodParameterAnnotationName); return classInfo == null ? ClassInfoList.EMPTY_LIST : classInfo.getClassesWithMethodParameterAnnotation(); }
java
public ClassInfoList getClassesWithMethodParameterAnnotation(final String methodParameterAnnotationName) { if (closed.get()) { throw new IllegalArgumentException("Cannot use a ScanResult after it has been closed"); } if (!scanSpec.enableClassInfo || !scanSpec.enableMethodInfo || !scanSpec.enableAnnotationInfo) { throw new IllegalArgumentException("Please call ClassGraph#enableClassInfo(), #enableMethodInfo(), " + "and #enableAnnotationInfo() before #scan()"); } final ClassInfo classInfo = classNameToClassInfo.get(methodParameterAnnotationName); return classInfo == null ? ClassInfoList.EMPTY_LIST : classInfo.getClassesWithMethodParameterAnnotation(); }
[ "public", "ClassInfoList", "getClassesWithMethodParameterAnnotation", "(", "final", "String", "methodParameterAnnotationName", ")", "{", "if", "(", "closed", ".", "get", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Cannot use a ScanResult after ...
Get classes that have a method with a parameter that is annotated with an annotation of the named type. @param methodParameterAnnotationName the name of the method parameter annotation. @return A list of classes that have a method with a parameter annotated with the named annotation type, or the empty list if none.
[ "Get", "classes", "that", "have", "a", "method", "with", "a", "parameter", "that", "is", "annotated", "with", "an", "annotation", "of", "the", "named", "type", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ScanResult.java#L960-L970
train
classgraph/classgraph
src/main/java/io/github/classgraph/ScanResult.java
ScanResult.getClassesWithFieldAnnotation
public ClassInfoList getClassesWithFieldAnnotation(final String fieldAnnotationName) { if (closed.get()) { throw new IllegalArgumentException("Cannot use a ScanResult after it has been closed"); } if (!scanSpec.enableClassInfo || !scanSpec.enableFieldInfo || !scanSpec.enableAnnotationInfo) { throw new IllegalArgumentException("Please call ClassGraph#enableClassInfo(), #enableFieldInfo(), " + "and #enableAnnotationInfo() before #scan()"); } final ClassInfo classInfo = classNameToClassInfo.get(fieldAnnotationName); return classInfo == null ? ClassInfoList.EMPTY_LIST : classInfo.getClassesWithFieldAnnotation(); }
java
public ClassInfoList getClassesWithFieldAnnotation(final String fieldAnnotationName) { if (closed.get()) { throw new IllegalArgumentException("Cannot use a ScanResult after it has been closed"); } if (!scanSpec.enableClassInfo || !scanSpec.enableFieldInfo || !scanSpec.enableAnnotationInfo) { throw new IllegalArgumentException("Please call ClassGraph#enableClassInfo(), #enableFieldInfo(), " + "and #enableAnnotationInfo() before #scan()"); } final ClassInfo classInfo = classNameToClassInfo.get(fieldAnnotationName); return classInfo == null ? ClassInfoList.EMPTY_LIST : classInfo.getClassesWithFieldAnnotation(); }
[ "public", "ClassInfoList", "getClassesWithFieldAnnotation", "(", "final", "String", "fieldAnnotationName", ")", "{", "if", "(", "closed", ".", "get", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Cannot use a ScanResult after it has been closed\"...
Get classes that have a field with an annotation of the named type. @param fieldAnnotationName the name of the field annotation. @return A list of classes that have a field with an annotation of the named type, or the empty list if none.
[ "Get", "classes", "that", "have", "a", "field", "with", "an", "annotation", "of", "the", "named", "type", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ScanResult.java#L979-L989
train
classgraph/classgraph
src/main/java/io/github/classgraph/ScanResult.java
ScanResult.getInterfaces
public ClassInfoList getInterfaces(final String className) { if (closed.get()) { throw new IllegalArgumentException("Cannot use a ScanResult after it has been closed"); } if (!scanSpec.enableClassInfo) { throw new IllegalArgumentException("Please call ClassGraph#enableClassInfo() before #scan()"); } final ClassInfo classInfo = classNameToClassInfo.get(className); return classInfo == null ? ClassInfoList.EMPTY_LIST : classInfo.getInterfaces(); }
java
public ClassInfoList getInterfaces(final String className) { if (closed.get()) { throw new IllegalArgumentException("Cannot use a ScanResult after it has been closed"); } if (!scanSpec.enableClassInfo) { throw new IllegalArgumentException("Please call ClassGraph#enableClassInfo() before #scan()"); } final ClassInfo classInfo = classNameToClassInfo.get(className); return classInfo == null ? ClassInfoList.EMPTY_LIST : classInfo.getInterfaces(); }
[ "public", "ClassInfoList", "getInterfaces", "(", "final", "String", "className", ")", "{", "if", "(", "closed", ".", "get", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Cannot use a ScanResult after it has been closed\"", ")", ";", "}", ...
Get all interfaces implemented by the named 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. @param className The class name. @return A list of interfaces implemented by the named class (or superinterfaces extended by the named interface), or the empty list if none.
[ "Get", "all", "interfaces", "implemented", "by", "the", "named", "class", "or", "by", "one", "of", "its", "superclasses", "if", "this", "is", "a", "standard", "class", "or", "the", "superinterfaces", "extended", "by", "this", "interface", "if", "this", "is",...
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ScanResult.java#L1019-L1028
train
classgraph/classgraph
src/main/java/io/github/classgraph/ScanResult.java
ScanResult.getClassesWithAnnotation
public ClassInfoList getClassesWithAnnotation(final String annotationName) { if (closed.get()) { throw new IllegalArgumentException("Cannot use a ScanResult after it has been closed"); } if (!scanSpec.enableClassInfo || !scanSpec.enableAnnotationInfo) { throw new IllegalArgumentException( "Please call ClassGraph#enableClassInfo() and #enableAnnotationInfo() before #scan()"); } final ClassInfo classInfo = classNameToClassInfo.get(annotationName); return classInfo == null ? ClassInfoList.EMPTY_LIST : classInfo.getClassesWithAnnotation(); }
java
public ClassInfoList getClassesWithAnnotation(final String annotationName) { if (closed.get()) { throw new IllegalArgumentException("Cannot use a ScanResult after it has been closed"); } if (!scanSpec.enableClassInfo || !scanSpec.enableAnnotationInfo) { throw new IllegalArgumentException( "Please call ClassGraph#enableClassInfo() and #enableAnnotationInfo() before #scan()"); } final ClassInfo classInfo = classNameToClassInfo.get(annotationName); return classInfo == null ? ClassInfoList.EMPTY_LIST : classInfo.getClassesWithAnnotation(); }
[ "public", "ClassInfoList", "getClassesWithAnnotation", "(", "final", "String", "annotationName", ")", "{", "if", "(", "closed", ".", "get", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Cannot use a ScanResult after it has been closed\"", ")", ...
Get classes with the named class annotation or meta-annotation. @param annotationName The name of the class annotation or meta-annotation. @return A list of all non-annotation classes that were found with the named class annotation during the scan, or the empty list if none.
[ "Get", "classes", "with", "the", "named", "class", "annotation", "or", "meta", "-", "annotation", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ScanResult.java#L1093-L1103
train
classgraph/classgraph
src/main/java/io/github/classgraph/ScanResult.java
ScanResult.fromJSON
public static ScanResult fromJSON(final String json) { final Matcher matcher = Pattern.compile("\\{[\\n\\r ]*\"format\"[ ]?:[ ]?\"([^\"]+)\"").matcher(json); if (!matcher.find()) { throw new IllegalArgumentException("JSON is not in correct format"); } if (!CURRENT_SERIALIZATION_FORMAT.equals(matcher.group(1))) { throw new IllegalArgumentException( "JSON was serialized in a different format from the format used by the current version of " + "ClassGraph -- please serialize and deserialize your ScanResult using " + "the same version of ClassGraph"); } // Deserialize the JSON final SerializationFormat deserialized = JSONDeserializer.deserializeObject(SerializationFormat.class, json); if (!deserialized.format.equals(CURRENT_SERIALIZATION_FORMAT)) { // Probably the deserialization failed before now anyway, if fields have changed, etc. throw new IllegalArgumentException("JSON was serialized by newer version of ClassGraph"); } // Perform a new "scan" with performScan set to false, which resolves all the ClasspathElement objects // and scans classpath element paths (needed for classloading), but does not scan the actual classfiles final ClassGraph classGraph = new ClassGraph(); classGraph.scanSpec = deserialized.scanSpec; classGraph.scanSpec.performScan = false; if (classGraph.scanSpec.overrideClasspath == null) { // Use the same classpath as before, if classpath was not overridden classGraph.overrideClasspath(deserialized.classpath); } final ScanResult scanResult = classGraph.scan(); scanResult.rawClasspathEltOrderStrs = deserialized.classpath; scanResult.scanSpec.performScan = true; // Set the fields related to ClassInfo in the new ScanResult, based on the deserialized JSON scanResult.scanSpec = deserialized.scanSpec; scanResult.classNameToClassInfo = new HashMap<>(); if (deserialized.classInfo != null) { for (final ClassInfo ci : deserialized.classInfo) { scanResult.classNameToClassInfo.put(ci.getName(), ci); ci.setScanResult(scanResult); } } scanResult.moduleNameToModuleInfo = new HashMap<>(); if (deserialized.moduleInfo != null) { for (final ModuleInfo mi : deserialized.moduleInfo) { scanResult.moduleNameToModuleInfo.put(mi.getName(), mi); } } scanResult.packageNameToPackageInfo = new HashMap<>(); if (deserialized.packageInfo != null) { for (final PackageInfo pi : deserialized.packageInfo) { scanResult.packageNameToPackageInfo.put(pi.getName(), pi); } } // Index Resource and ClassInfo objects scanResult.indexResourcesAndClassInfo(); scanResult.isObtainedFromDeserialization = true; return scanResult; }
java
public static ScanResult fromJSON(final String json) { final Matcher matcher = Pattern.compile("\\{[\\n\\r ]*\"format\"[ ]?:[ ]?\"([^\"]+)\"").matcher(json); if (!matcher.find()) { throw new IllegalArgumentException("JSON is not in correct format"); } if (!CURRENT_SERIALIZATION_FORMAT.equals(matcher.group(1))) { throw new IllegalArgumentException( "JSON was serialized in a different format from the format used by the current version of " + "ClassGraph -- please serialize and deserialize your ScanResult using " + "the same version of ClassGraph"); } // Deserialize the JSON final SerializationFormat deserialized = JSONDeserializer.deserializeObject(SerializationFormat.class, json); if (!deserialized.format.equals(CURRENT_SERIALIZATION_FORMAT)) { // Probably the deserialization failed before now anyway, if fields have changed, etc. throw new IllegalArgumentException("JSON was serialized by newer version of ClassGraph"); } // Perform a new "scan" with performScan set to false, which resolves all the ClasspathElement objects // and scans classpath element paths (needed for classloading), but does not scan the actual classfiles final ClassGraph classGraph = new ClassGraph(); classGraph.scanSpec = deserialized.scanSpec; classGraph.scanSpec.performScan = false; if (classGraph.scanSpec.overrideClasspath == null) { // Use the same classpath as before, if classpath was not overridden classGraph.overrideClasspath(deserialized.classpath); } final ScanResult scanResult = classGraph.scan(); scanResult.rawClasspathEltOrderStrs = deserialized.classpath; scanResult.scanSpec.performScan = true; // Set the fields related to ClassInfo in the new ScanResult, based on the deserialized JSON scanResult.scanSpec = deserialized.scanSpec; scanResult.classNameToClassInfo = new HashMap<>(); if (deserialized.classInfo != null) { for (final ClassInfo ci : deserialized.classInfo) { scanResult.classNameToClassInfo.put(ci.getName(), ci); ci.setScanResult(scanResult); } } scanResult.moduleNameToModuleInfo = new HashMap<>(); if (deserialized.moduleInfo != null) { for (final ModuleInfo mi : deserialized.moduleInfo) { scanResult.moduleNameToModuleInfo.put(mi.getName(), mi); } } scanResult.packageNameToPackageInfo = new HashMap<>(); if (deserialized.packageInfo != null) { for (final PackageInfo pi : deserialized.packageInfo) { scanResult.packageNameToPackageInfo.put(pi.getName(), pi); } } // Index Resource and ClassInfo objects scanResult.indexResourcesAndClassInfo(); scanResult.isObtainedFromDeserialization = true; return scanResult; }
[ "public", "static", "ScanResult", "fromJSON", "(", "final", "String", "json", ")", "{", "final", "Matcher", "matcher", "=", "Pattern", ".", "compile", "(", "\"\\\\{[\\\\n\\\\r ]*\\\"format\\\"[ ]?:[ ]?\\\"([^\\\"]+)\\\"\"", ")", ".", "matcher", "(", "json", ")", ";"...
Deserialize a ScanResult from previously-serialized JSON. @param json The JSON string for the serialized {@link ScanResult}. @return The deserialized {@link ScanResult}.
[ "Deserialize", "a", "ScanResult", "from", "previously", "-", "serialized", "JSON", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ScanResult.java#L1308-L1368
train
classgraph/classgraph
src/main/java/io/github/classgraph/ScanResult.java
ScanResult.toJSON
public String toJSON(final int indentWidth) { if (closed.get()) { throw new IllegalArgumentException("Cannot use a ScanResult after it has been closed"); } if (!scanSpec.enableClassInfo) { throw new IllegalArgumentException("Please call ClassGraph#enableClassInfo() before #scan()"); } final List<ClassInfo> allClassInfo = new ArrayList<>(classNameToClassInfo.values()); CollectionUtils.sortIfNotEmpty(allClassInfo); final List<PackageInfo> allPackageInfo = new ArrayList<>(packageNameToPackageInfo.values()); CollectionUtils.sortIfNotEmpty(allPackageInfo); final List<ModuleInfo> allModuleInfo = new ArrayList<>(moduleNameToModuleInfo.values()); CollectionUtils.sortIfNotEmpty(allModuleInfo); return JSONSerializer.serializeObject(new SerializationFormat(CURRENT_SERIALIZATION_FORMAT, scanSpec, allClassInfo, allPackageInfo, allModuleInfo, rawClasspathEltOrderStrs), indentWidth, false); }
java
public String toJSON(final int indentWidth) { if (closed.get()) { throw new IllegalArgumentException("Cannot use a ScanResult after it has been closed"); } if (!scanSpec.enableClassInfo) { throw new IllegalArgumentException("Please call ClassGraph#enableClassInfo() before #scan()"); } final List<ClassInfo> allClassInfo = new ArrayList<>(classNameToClassInfo.values()); CollectionUtils.sortIfNotEmpty(allClassInfo); final List<PackageInfo> allPackageInfo = new ArrayList<>(packageNameToPackageInfo.values()); CollectionUtils.sortIfNotEmpty(allPackageInfo); final List<ModuleInfo> allModuleInfo = new ArrayList<>(moduleNameToModuleInfo.values()); CollectionUtils.sortIfNotEmpty(allModuleInfo); return JSONSerializer.serializeObject(new SerializationFormat(CURRENT_SERIALIZATION_FORMAT, scanSpec, allClassInfo, allPackageInfo, allModuleInfo, rawClasspathEltOrderStrs), indentWidth, false); }
[ "public", "String", "toJSON", "(", "final", "int", "indentWidth", ")", "{", "if", "(", "closed", ".", "get", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Cannot use a ScanResult after it has been closed\"", ")", ";", "}", "if", "(", ...
Serialize a ScanResult to JSON. @param indentWidth If greater than 0, JSON will be formatted (indented), otherwise it will be minified (un-indented). @return This {@link ScanResult}, serialized as a JSON string.
[ "Serialize", "a", "ScanResult", "to", "JSON", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ScanResult.java#L1377-L1392
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/json/TypeResolutions.java
TypeResolutions.resolveTypeVariables
Type resolveTypeVariables(final Type type) { if (type instanceof Class<?>) { // Arrays and non-generic classes have no type variables return type; } else if (type instanceof ParameterizedType) { // Recursively resolve parameterized types final ParameterizedType parameterizedType = (ParameterizedType) type; final Type[] typeArgs = parameterizedType.getActualTypeArguments(); Type[] typeArgsResolved = null; for (int i = 0; i < typeArgs.length; i++) { // Recursively revolve each parameter of the type final Type typeArgResolved = resolveTypeVariables(typeArgs[i]); // Only compare typeArgs to typeArgResolved until the first difference is found if (typeArgsResolved == null) { if (!typeArgResolved.equals(typeArgs[i])) { // After the first difference is found, lazily allocate typeArgsResolved typeArgsResolved = new Type[typeArgs.length]; // Go back and copy all the previous args System.arraycopy(typeArgs, 0, typeArgsResolved, 0, i); // Insert the first different arg typeArgsResolved[i] = typeArgResolved; } } else { // After the first difference is found, keep copying the resolved args into the array typeArgsResolved[i] = typeArgResolved; } } if (typeArgsResolved == null) { // There were no type parameters to resolve return type; } else { // Return new ParameterizedType that wraps the resolved type args return new ParameterizedTypeImpl((Class<?>) parameterizedType.getRawType(), typeArgsResolved, parameterizedType.getOwnerType()); } } else if (type instanceof TypeVariable<?>) { // Look up concrete type for type variable final TypeVariable<?> typeVariable = (TypeVariable<?>) type; for (int i = 0; i < typeVariables.length; i++) { if (typeVariables[i].getName().equals(typeVariable.getName())) { return resolvedTypeArguments[i]; } } // Could not resolve type variable return type; } else if (type instanceof GenericArrayType) { // Count the array dimensions, and resolve the innermost type of the array int numArrayDims = 0; Type t = type; while (t instanceof GenericArrayType) { numArrayDims++; t = ((GenericArrayType) t).getGenericComponentType(); } final Type innermostType = t; final Type innermostTypeResolved = resolveTypeVariables(innermostType); if (!(innermostTypeResolved instanceof Class<?>)) { throw new IllegalArgumentException("Could not resolve generic array type " + type); } final Class<?> innermostTypeResolvedClass = (Class<?>) innermostTypeResolved; // Build an array to hold the size of each dimension, filled with zeroes final int[] dims = (int[]) Array.newInstance(int.class, numArrayDims); // Build a zero-sized array of the required number of dimensions, using the resolved innermost class final Object arrayInstance = Array.newInstance(innermostTypeResolvedClass, dims); // Get the class of this array instance -- this is the resolved array type return arrayInstance.getClass(); } else if (type instanceof WildcardType) { // TODO: Support WildcardType throw ClassGraphException.newClassGraphException("WildcardType not yet supported: " + type); } else { throw ClassGraphException.newClassGraphException("Got unexpected type: " + type); } }
java
Type resolveTypeVariables(final Type type) { if (type instanceof Class<?>) { // Arrays and non-generic classes have no type variables return type; } else if (type instanceof ParameterizedType) { // Recursively resolve parameterized types final ParameterizedType parameterizedType = (ParameterizedType) type; final Type[] typeArgs = parameterizedType.getActualTypeArguments(); Type[] typeArgsResolved = null; for (int i = 0; i < typeArgs.length; i++) { // Recursively revolve each parameter of the type final Type typeArgResolved = resolveTypeVariables(typeArgs[i]); // Only compare typeArgs to typeArgResolved until the first difference is found if (typeArgsResolved == null) { if (!typeArgResolved.equals(typeArgs[i])) { // After the first difference is found, lazily allocate typeArgsResolved typeArgsResolved = new Type[typeArgs.length]; // Go back and copy all the previous args System.arraycopy(typeArgs, 0, typeArgsResolved, 0, i); // Insert the first different arg typeArgsResolved[i] = typeArgResolved; } } else { // After the first difference is found, keep copying the resolved args into the array typeArgsResolved[i] = typeArgResolved; } } if (typeArgsResolved == null) { // There were no type parameters to resolve return type; } else { // Return new ParameterizedType that wraps the resolved type args return new ParameterizedTypeImpl((Class<?>) parameterizedType.getRawType(), typeArgsResolved, parameterizedType.getOwnerType()); } } else if (type instanceof TypeVariable<?>) { // Look up concrete type for type variable final TypeVariable<?> typeVariable = (TypeVariable<?>) type; for (int i = 0; i < typeVariables.length; i++) { if (typeVariables[i].getName().equals(typeVariable.getName())) { return resolvedTypeArguments[i]; } } // Could not resolve type variable return type; } else if (type instanceof GenericArrayType) { // Count the array dimensions, and resolve the innermost type of the array int numArrayDims = 0; Type t = type; while (t instanceof GenericArrayType) { numArrayDims++; t = ((GenericArrayType) t).getGenericComponentType(); } final Type innermostType = t; final Type innermostTypeResolved = resolveTypeVariables(innermostType); if (!(innermostTypeResolved instanceof Class<?>)) { throw new IllegalArgumentException("Could not resolve generic array type " + type); } final Class<?> innermostTypeResolvedClass = (Class<?>) innermostTypeResolved; // Build an array to hold the size of each dimension, filled with zeroes final int[] dims = (int[]) Array.newInstance(int.class, numArrayDims); // Build a zero-sized array of the required number of dimensions, using the resolved innermost class final Object arrayInstance = Array.newInstance(innermostTypeResolvedClass, dims); // Get the class of this array instance -- this is the resolved array type return arrayInstance.getClass(); } else if (type instanceof WildcardType) { // TODO: Support WildcardType throw ClassGraphException.newClassGraphException("WildcardType not yet supported: " + type); } else { throw ClassGraphException.newClassGraphException("Got unexpected type: " + type); } }
[ "Type", "resolveTypeVariables", "(", "final", "Type", "type", ")", "{", "if", "(", "type", "instanceof", "Class", "<", "?", ">", ")", "{", "// Arrays and non-generic classes have no type variables", "return", "type", ";", "}", "else", "if", "(", "type", "instanc...
Resolve the type variables in a type using a type variable resolution list, producing a resolved type. @param type the type @return the resolved type
[ "Resolve", "the", "type", "variables", "in", "a", "type", "using", "a", "type", "variable", "resolution", "list", "producing", "a", "resolved", "type", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/json/TypeResolutions.java#L71-L150
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/json/JSONSerializer.java
JSONSerializer.assignObjectIds
private static void assignObjectIds(final Object jsonVal, final Map<ReferenceEqualityKey<Object>, JSONObject> objToJSONVal, final ClassFieldCache classFieldCache, final Map<ReferenceEqualityKey<JSONReference>, CharSequence> jsonReferenceToId, final AtomicInteger objId, final boolean onlySerializePublicFields) { if (jsonVal instanceof JSONObject) { for (final Entry<String, Object> item : ((JSONObject) jsonVal).items) { assignObjectIds(item.getValue(), objToJSONVal, classFieldCache, jsonReferenceToId, objId, onlySerializePublicFields); } } else if (jsonVal instanceof JSONArray) { for (final Object item : ((JSONArray) jsonVal).items) { assignObjectIds(item, objToJSONVal, classFieldCache, jsonReferenceToId, objId, onlySerializePublicFields); } } else if (jsonVal instanceof JSONReference) { // Get the referenced (non-JSON) object final Object refdObj = ((JSONReference) jsonVal).idObject; if (refdObj == null) { // Should not happen throw ClassGraphException.newClassGraphException("Internal inconsistency"); } // Look up the JSON object corresponding to the referenced object final ReferenceEqualityKey<Object> refdObjKey = new ReferenceEqualityKey<>(refdObj); final JSONObject refdJsonVal = objToJSONVal.get(refdObjKey); if (refdJsonVal == null) { // Should not happen throw ClassGraphException.newClassGraphException("Internal inconsistency"); } // See if the JSON object has an @Id field // (for serialization, typeResolutions can be null) final Field annotatedField = classFieldCache.get(refdObj.getClass()).idField; CharSequence idStr = null; if (annotatedField != null) { // Get id value from field annotated with @Id try { final Object idObject = annotatedField.get(refdObj); if (idObject != null) { idStr = idObject.toString(); refdJsonVal.objectId = idStr; } } catch (IllegalArgumentException | IllegalAccessException e) { // Should not happen throw new IllegalArgumentException("Could not access @Id-annotated field " + annotatedField, e); } } if (idStr == null) { // No @Id field, or field value is null -- check if ref'd JSON Object already has an id if (refdJsonVal.objectId == null) { // Ref'd JSON object doesn't have an id yet -- generate unique integer id idStr = JSONUtils.ID_PREFIX + objId.getAndIncrement() + JSONUtils.ID_SUFFIX; refdJsonVal.objectId = idStr; } else { idStr = refdJsonVal.objectId; } } // Link both the JSON representation ob the object to the id jsonReferenceToId.put(new ReferenceEqualityKey<>((JSONReference) jsonVal), idStr); } // if (jsonVal == null) then do nothing }
java
private static void assignObjectIds(final Object jsonVal, final Map<ReferenceEqualityKey<Object>, JSONObject> objToJSONVal, final ClassFieldCache classFieldCache, final Map<ReferenceEqualityKey<JSONReference>, CharSequence> jsonReferenceToId, final AtomicInteger objId, final boolean onlySerializePublicFields) { if (jsonVal instanceof JSONObject) { for (final Entry<String, Object> item : ((JSONObject) jsonVal).items) { assignObjectIds(item.getValue(), objToJSONVal, classFieldCache, jsonReferenceToId, objId, onlySerializePublicFields); } } else if (jsonVal instanceof JSONArray) { for (final Object item : ((JSONArray) jsonVal).items) { assignObjectIds(item, objToJSONVal, classFieldCache, jsonReferenceToId, objId, onlySerializePublicFields); } } else if (jsonVal instanceof JSONReference) { // Get the referenced (non-JSON) object final Object refdObj = ((JSONReference) jsonVal).idObject; if (refdObj == null) { // Should not happen throw ClassGraphException.newClassGraphException("Internal inconsistency"); } // Look up the JSON object corresponding to the referenced object final ReferenceEqualityKey<Object> refdObjKey = new ReferenceEqualityKey<>(refdObj); final JSONObject refdJsonVal = objToJSONVal.get(refdObjKey); if (refdJsonVal == null) { // Should not happen throw ClassGraphException.newClassGraphException("Internal inconsistency"); } // See if the JSON object has an @Id field // (for serialization, typeResolutions can be null) final Field annotatedField = classFieldCache.get(refdObj.getClass()).idField; CharSequence idStr = null; if (annotatedField != null) { // Get id value from field annotated with @Id try { final Object idObject = annotatedField.get(refdObj); if (idObject != null) { idStr = idObject.toString(); refdJsonVal.objectId = idStr; } } catch (IllegalArgumentException | IllegalAccessException e) { // Should not happen throw new IllegalArgumentException("Could not access @Id-annotated field " + annotatedField, e); } } if (idStr == null) { // No @Id field, or field value is null -- check if ref'd JSON Object already has an id if (refdJsonVal.objectId == null) { // Ref'd JSON object doesn't have an id yet -- generate unique integer id idStr = JSONUtils.ID_PREFIX + objId.getAndIncrement() + JSONUtils.ID_SUFFIX; refdJsonVal.objectId = idStr; } else { idStr = refdJsonVal.objectId; } } // Link both the JSON representation ob the object to the id jsonReferenceToId.put(new ReferenceEqualityKey<>((JSONReference) jsonVal), idStr); } // if (jsonVal == null) then do nothing }
[ "private", "static", "void", "assignObjectIds", "(", "final", "Object", "jsonVal", ",", "final", "Map", "<", "ReferenceEqualityKey", "<", "Object", ">", ",", "JSONObject", ">", "objToJSONVal", ",", "final", "ClassFieldCache", "classFieldCache", ",", "final", "Map"...
Create a unique id for each referenced JSON object. @param jsonVal the json val @param objToJSONVal a map from obj to JSON val @param classFieldCache the class field cache @param jsonReferenceToId a map from json reference to id @param objId the object id @param onlySerializePublicFields whether to only serialize public fields
[ "Create", "a", "unique", "id", "for", "each", "referenced", "JSON", "object", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/json/JSONSerializer.java#L78-L137
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/json/JSONSerializer.java
JSONSerializer.jsonValToJSONString
static void jsonValToJSONString(final Object jsonVal, final Map<ReferenceEqualityKey<JSONReference>, CharSequence> jsonReferenceToId, final boolean includeNullValuedFields, final int depth, final int indentWidth, final StringBuilder buf) { if (jsonVal == null) { buf.append("null"); } else if (jsonVal instanceof JSONObject) { // Serialize JSONObject to string ((JSONObject) jsonVal).toJSONString(jsonReferenceToId, includeNullValuedFields, depth, indentWidth, buf); } else if (jsonVal instanceof JSONArray) { // Serialize JSONArray to string ((JSONArray) jsonVal).toJSONString(jsonReferenceToId, includeNullValuedFields, depth, indentWidth, buf); } else if (jsonVal instanceof JSONReference) { // Serialize JSONReference to string final Object referencedObjectId = jsonReferenceToId .get(new ReferenceEqualityKey<>((JSONReference) jsonVal)); jsonValToJSONString(referencedObjectId, jsonReferenceToId, includeNullValuedFields, depth, indentWidth, buf); } else if (jsonVal instanceof CharSequence || jsonVal instanceof Character || jsonVal.getClass().isEnum()) { // Serialize String, Character or enum val to quoted/escaped string buf.append('"'); JSONUtils.escapeJSONString(jsonVal.toString(), buf); buf.append('"'); } else { // Serialize a numeric or Boolean type (Integer, Long, Short, Float, Double, Boolean, Byte) to string // (doesn't need quoting or escaping) buf.append(jsonVal.toString()); } }
java
static void jsonValToJSONString(final Object jsonVal, final Map<ReferenceEqualityKey<JSONReference>, CharSequence> jsonReferenceToId, final boolean includeNullValuedFields, final int depth, final int indentWidth, final StringBuilder buf) { if (jsonVal == null) { buf.append("null"); } else if (jsonVal instanceof JSONObject) { // Serialize JSONObject to string ((JSONObject) jsonVal).toJSONString(jsonReferenceToId, includeNullValuedFields, depth, indentWidth, buf); } else if (jsonVal instanceof JSONArray) { // Serialize JSONArray to string ((JSONArray) jsonVal).toJSONString(jsonReferenceToId, includeNullValuedFields, depth, indentWidth, buf); } else if (jsonVal instanceof JSONReference) { // Serialize JSONReference to string final Object referencedObjectId = jsonReferenceToId .get(new ReferenceEqualityKey<>((JSONReference) jsonVal)); jsonValToJSONString(referencedObjectId, jsonReferenceToId, includeNullValuedFields, depth, indentWidth, buf); } else if (jsonVal instanceof CharSequence || jsonVal instanceof Character || jsonVal.getClass().isEnum()) { // Serialize String, Character or enum val to quoted/escaped string buf.append('"'); JSONUtils.escapeJSONString(jsonVal.toString(), buf); buf.append('"'); } else { // Serialize a numeric or Boolean type (Integer, Long, Short, Float, Double, Boolean, Byte) to string // (doesn't need quoting or escaping) buf.append(jsonVal.toString()); } }
[ "static", "void", "jsonValToJSONString", "(", "final", "Object", "jsonVal", ",", "final", "Map", "<", "ReferenceEqualityKey", "<", "JSONReference", ">", ",", "CharSequence", ">", "jsonReferenceToId", ",", "final", "boolean", "includeNullValuedFields", ",", "final", ...
Serialize a JSON object, array, or value. @param jsonVal the json val @param jsonReferenceToId a map from json reference to id @param includeNullValuedFields the include null valued fields @param depth the depth @param indentWidth the indent width @param buf the buf
[ "Serialize", "a", "JSON", "object", "array", "or", "value", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/json/JSONSerializer.java#L417-L452
train
classgraph/classgraph
src/main/java/io/github/classgraph/Classfile.java
Classfile.scheduleScanningIfExternalClass
private void scheduleScanningIfExternalClass(final String className, final String relationship) { // Don't scan Object if (className != null && !className.equals("java.lang.Object") // Only schedule each external class once for scanning, across all threads && classNamesScheduledForScanning.add(className)) { // Search for the named class' classfile among classpath elements, in classpath order (this is O(N) // for each class, but there shouldn't be too many cases of extending scanning upwards) final String classfilePath = JarUtils.classNameToClassfilePath(className); // First check current classpath element, to avoid iterating through other classpath elements Resource classResource = classpathElement.getResource(classfilePath); ClasspathElement foundInClasspathElt = null; if (classResource != null) { // Found the classfile in the current classpath element foundInClasspathElt = classpathElement; } else { // Didn't find the classfile in the current classpath element -- iterate through other elements for (final ClasspathElement classpathOrderElt : classpathOrder) { if (classpathOrderElt != classpathElement) { classResource = classpathOrderElt.getResource(classfilePath); if (classResource != null) { foundInClasspathElt = classpathOrderElt; break; } } } } if (classResource != null) { // Found class resource if (log != null) { log.log("Scheduling external class for scanning: " + relationship + " " + className + (foundInClasspathElt == classpathElement ? "" : " -- found in classpath element " + foundInClasspathElt)); } if (additionalWorkUnits == null) { additionalWorkUnits = new ArrayList<>(); } // Schedule class resource for scanning additionalWorkUnits.add(new ClassfileScanWorkUnit(foundInClasspathElt, classResource, /* isExternalClass = */ true)); } else { if (log != null) { log.log("External " + relationship + " " + className + " was not found in " + "non-blacklisted packages -- cannot extend scanning to this class"); } } } }
java
private void scheduleScanningIfExternalClass(final String className, final String relationship) { // Don't scan Object if (className != null && !className.equals("java.lang.Object") // Only schedule each external class once for scanning, across all threads && classNamesScheduledForScanning.add(className)) { // Search for the named class' classfile among classpath elements, in classpath order (this is O(N) // for each class, but there shouldn't be too many cases of extending scanning upwards) final String classfilePath = JarUtils.classNameToClassfilePath(className); // First check current classpath element, to avoid iterating through other classpath elements Resource classResource = classpathElement.getResource(classfilePath); ClasspathElement foundInClasspathElt = null; if (classResource != null) { // Found the classfile in the current classpath element foundInClasspathElt = classpathElement; } else { // Didn't find the classfile in the current classpath element -- iterate through other elements for (final ClasspathElement classpathOrderElt : classpathOrder) { if (classpathOrderElt != classpathElement) { classResource = classpathOrderElt.getResource(classfilePath); if (classResource != null) { foundInClasspathElt = classpathOrderElt; break; } } } } if (classResource != null) { // Found class resource if (log != null) { log.log("Scheduling external class for scanning: " + relationship + " " + className + (foundInClasspathElt == classpathElement ? "" : " -- found in classpath element " + foundInClasspathElt)); } if (additionalWorkUnits == null) { additionalWorkUnits = new ArrayList<>(); } // Schedule class resource for scanning additionalWorkUnits.add(new ClassfileScanWorkUnit(foundInClasspathElt, classResource, /* isExternalClass = */ true)); } else { if (log != null) { log.log("External " + relationship + " " + className + " was not found in " + "non-blacklisted packages -- cannot extend scanning to this class"); } } } }
[ "private", "void", "scheduleScanningIfExternalClass", "(", "final", "String", "className", ",", "final", "String", "relationship", ")", "{", "// Don't scan Object", "if", "(", "className", "!=", "null", "&&", "!", "className", ".", "equals", "(", "\"java.lang.Object...
Extend scanning to a superclass, interface or annotation. @param className the class name @param relationship the relationship type
[ "Extend", "scanning", "to", "a", "superclass", "interface", "or", "annotation", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/Classfile.java#L231-L277
train
classgraph/classgraph
src/main/java/io/github/classgraph/Classfile.java
Classfile.extendScanningUpwards
private void extendScanningUpwards() { // Check superclass if (superclassName != null) { scheduleScanningIfExternalClass(superclassName, "superclass"); } // Check implemented interfaces if (implementedInterfaces != null) { for (final String interfaceName : implementedInterfaces) { scheduleScanningIfExternalClass(interfaceName, "interface"); } } // Check class annotations if (classAnnotations != null) { for (final AnnotationInfo annotationInfo : classAnnotations) { scheduleScanningIfExternalClass(annotationInfo.getName(), "class annotation"); } } // Check method annotations and method parameter annotations if (methodInfoList != null) { for (final MethodInfo methodInfo : methodInfoList) { if (methodInfo.annotationInfo != null) { for (final AnnotationInfo methodAnnotationInfo : methodInfo.annotationInfo) { scheduleScanningIfExternalClass(methodAnnotationInfo.getName(), "method annotation"); } if (methodInfo.parameterAnnotationInfo != null && methodInfo.parameterAnnotationInfo.length > 0) { for (final AnnotationInfo[] paramAnns : methodInfo.parameterAnnotationInfo) { if (paramAnns != null && paramAnns.length > 0) { for (final AnnotationInfo paramAnn : paramAnns) { scheduleScanningIfExternalClass(paramAnn.getName(), "method parameter annotation"); } } } } } } } // Check field annotations if (fieldInfoList != null) { for (final FieldInfo fieldInfo : fieldInfoList) { if (fieldInfo.annotationInfo != null) { for (final AnnotationInfo fieldAnnotationInfo : fieldInfo.annotationInfo) { scheduleScanningIfExternalClass(fieldAnnotationInfo.getName(), "field annotation"); } } } } }
java
private void extendScanningUpwards() { // Check superclass if (superclassName != null) { scheduleScanningIfExternalClass(superclassName, "superclass"); } // Check implemented interfaces if (implementedInterfaces != null) { for (final String interfaceName : implementedInterfaces) { scheduleScanningIfExternalClass(interfaceName, "interface"); } } // Check class annotations if (classAnnotations != null) { for (final AnnotationInfo annotationInfo : classAnnotations) { scheduleScanningIfExternalClass(annotationInfo.getName(), "class annotation"); } } // Check method annotations and method parameter annotations if (methodInfoList != null) { for (final MethodInfo methodInfo : methodInfoList) { if (methodInfo.annotationInfo != null) { for (final AnnotationInfo methodAnnotationInfo : methodInfo.annotationInfo) { scheduleScanningIfExternalClass(methodAnnotationInfo.getName(), "method annotation"); } if (methodInfo.parameterAnnotationInfo != null && methodInfo.parameterAnnotationInfo.length > 0) { for (final AnnotationInfo[] paramAnns : methodInfo.parameterAnnotationInfo) { if (paramAnns != null && paramAnns.length > 0) { for (final AnnotationInfo paramAnn : paramAnns) { scheduleScanningIfExternalClass(paramAnn.getName(), "method parameter annotation"); } } } } } } } // Check field annotations if (fieldInfoList != null) { for (final FieldInfo fieldInfo : fieldInfoList) { if (fieldInfo.annotationInfo != null) { for (final AnnotationInfo fieldAnnotationInfo : fieldInfo.annotationInfo) { scheduleScanningIfExternalClass(fieldAnnotationInfo.getName(), "field annotation"); } } } } }
[ "private", "void", "extendScanningUpwards", "(", ")", "{", "// Check superclass", "if", "(", "superclassName", "!=", "null", ")", "{", "scheduleScanningIfExternalClass", "(", "superclassName", ",", "\"superclass\"", ")", ";", "}", "// Check implemented interfaces", "if"...
Check if scanning needs to be extended upwards to an external superclass, interface or annotation.
[ "Check", "if", "scanning", "needs", "to", "be", "extended", "upwards", "to", "an", "external", "superclass", "interface", "or", "annotation", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/Classfile.java#L282-L330
train
classgraph/classgraph
src/main/java/io/github/classgraph/Classfile.java
Classfile.link
void link(final Map<String, ClassInfo> classNameToClassInfo, final Map<String, PackageInfo> packageNameToPackageInfo, final Map<String, ModuleInfo> moduleNameToModuleInfo) { boolean isModuleDescriptor = false; boolean isPackageDescriptor = false; ClassInfo classInfo = null; if (className.equals("module-info")) { isModuleDescriptor = true; } else if (className.equals("package-info") || className.endsWith(".package-info")) { isPackageDescriptor = true; } else { // Handle regular classfile classInfo = ClassInfo.addScannedClass(className, classModifiers, isExternalClass, classNameToClassInfo, classpathElement, classfileResource); classInfo.setModifiers(classModifiers); classInfo.setIsInterface(isInterface); classInfo.setIsAnnotation(isAnnotation); if (superclassName != null) { classInfo.addSuperclass(superclassName, classNameToClassInfo); } if (implementedInterfaces != null) { for (final String interfaceName : implementedInterfaces) { classInfo.addImplementedInterface(interfaceName, classNameToClassInfo); } } if (classAnnotations != null) { for (final AnnotationInfo classAnnotation : classAnnotations) { classInfo.addClassAnnotation(classAnnotation, classNameToClassInfo); } } if (classContainmentEntries != null) { ClassInfo.addClassContainment(classContainmentEntries, classNameToClassInfo); } if (annotationParamDefaultValues != null) { classInfo.addAnnotationParamDefaultValues(annotationParamDefaultValues); } if (fullyQualifiedDefiningMethodName != null) { classInfo.addFullyQualifiedDefiningMethodName(fullyQualifiedDefiningMethodName); } if (fieldInfoList != null) { classInfo.addFieldInfo(fieldInfoList, classNameToClassInfo); } if (methodInfoList != null) { classInfo.addMethodInfo(methodInfoList, classNameToClassInfo); } if (typeSignature != null) { classInfo.setTypeSignature(typeSignature); } if (refdClassNames != null) { classInfo.addReferencedClassNames(refdClassNames); } } // Get or create PackageInfo, if this is not a module descriptor (the module descriptor's package is "") PackageInfo packageInfo = null; if (!isModuleDescriptor) { // Get package for this class or package descriptor packageInfo = PackageInfo.getOrCreatePackage(PackageInfo.getParentPackageName(className), packageNameToPackageInfo); if (isPackageDescriptor) { // Add any class annotations on the package-info.class file to the ModuleInfo packageInfo.addAnnotations(classAnnotations); } else if (classInfo != null) { // Add ClassInfo to PackageInfo, and vice versa packageInfo.addClassInfo(classInfo); classInfo.packageInfo = packageInfo; } } // Get or create ModuleInfo, if there is a module name final String moduleName = classpathElement.getModuleName(); if (moduleName != null) { // Get or create a ModuleInfo object for this module ModuleInfo moduleInfo = moduleNameToModuleInfo.get(moduleName); if (moduleInfo == null) { moduleNameToModuleInfo.put(moduleName, moduleInfo = new ModuleInfo(classfileResource.getModuleRef(), classpathElement)); } if (isModuleDescriptor) { // Add any class annotations on the module-info.class file to the ModuleInfo moduleInfo.addAnnotations(classAnnotations); } if (classInfo != null) { // Add ClassInfo to ModuleInfo, and vice versa moduleInfo.addClassInfo(classInfo); classInfo.moduleInfo = moduleInfo; } if (packageInfo != null) { // Add PackageInfo to ModuleInfo moduleInfo.addPackageInfo(packageInfo); } } }
java
void link(final Map<String, ClassInfo> classNameToClassInfo, final Map<String, PackageInfo> packageNameToPackageInfo, final Map<String, ModuleInfo> moduleNameToModuleInfo) { boolean isModuleDescriptor = false; boolean isPackageDescriptor = false; ClassInfo classInfo = null; if (className.equals("module-info")) { isModuleDescriptor = true; } else if (className.equals("package-info") || className.endsWith(".package-info")) { isPackageDescriptor = true; } else { // Handle regular classfile classInfo = ClassInfo.addScannedClass(className, classModifiers, isExternalClass, classNameToClassInfo, classpathElement, classfileResource); classInfo.setModifiers(classModifiers); classInfo.setIsInterface(isInterface); classInfo.setIsAnnotation(isAnnotation); if (superclassName != null) { classInfo.addSuperclass(superclassName, classNameToClassInfo); } if (implementedInterfaces != null) { for (final String interfaceName : implementedInterfaces) { classInfo.addImplementedInterface(interfaceName, classNameToClassInfo); } } if (classAnnotations != null) { for (final AnnotationInfo classAnnotation : classAnnotations) { classInfo.addClassAnnotation(classAnnotation, classNameToClassInfo); } } if (classContainmentEntries != null) { ClassInfo.addClassContainment(classContainmentEntries, classNameToClassInfo); } if (annotationParamDefaultValues != null) { classInfo.addAnnotationParamDefaultValues(annotationParamDefaultValues); } if (fullyQualifiedDefiningMethodName != null) { classInfo.addFullyQualifiedDefiningMethodName(fullyQualifiedDefiningMethodName); } if (fieldInfoList != null) { classInfo.addFieldInfo(fieldInfoList, classNameToClassInfo); } if (methodInfoList != null) { classInfo.addMethodInfo(methodInfoList, classNameToClassInfo); } if (typeSignature != null) { classInfo.setTypeSignature(typeSignature); } if (refdClassNames != null) { classInfo.addReferencedClassNames(refdClassNames); } } // Get or create PackageInfo, if this is not a module descriptor (the module descriptor's package is "") PackageInfo packageInfo = null; if (!isModuleDescriptor) { // Get package for this class or package descriptor packageInfo = PackageInfo.getOrCreatePackage(PackageInfo.getParentPackageName(className), packageNameToPackageInfo); if (isPackageDescriptor) { // Add any class annotations on the package-info.class file to the ModuleInfo packageInfo.addAnnotations(classAnnotations); } else if (classInfo != null) { // Add ClassInfo to PackageInfo, and vice versa packageInfo.addClassInfo(classInfo); classInfo.packageInfo = packageInfo; } } // Get or create ModuleInfo, if there is a module name final String moduleName = classpathElement.getModuleName(); if (moduleName != null) { // Get or create a ModuleInfo object for this module ModuleInfo moduleInfo = moduleNameToModuleInfo.get(moduleName); if (moduleInfo == null) { moduleNameToModuleInfo.put(moduleName, moduleInfo = new ModuleInfo(classfileResource.getModuleRef(), classpathElement)); } if (isModuleDescriptor) { // Add any class annotations on the module-info.class file to the ModuleInfo moduleInfo.addAnnotations(classAnnotations); } if (classInfo != null) { // Add ClassInfo to ModuleInfo, and vice versa moduleInfo.addClassInfo(classInfo); classInfo.moduleInfo = moduleInfo; } if (packageInfo != null) { // Add PackageInfo to ModuleInfo moduleInfo.addPackageInfo(packageInfo); } } }
[ "void", "link", "(", "final", "Map", "<", "String", ",", "ClassInfo", ">", "classNameToClassInfo", ",", "final", "Map", "<", "String", ",", "PackageInfo", ">", "packageNameToPackageInfo", ",", "final", "Map", "<", "String", ",", "ModuleInfo", ">", "moduleNameT...
Link classes. Not threadsafe, should be run in a single-threaded context. @param classNameToClassInfo map from class name to class info @param packageNameToPackageInfo map from package name to package info @param moduleNameToModuleInfo map from module name to module info
[ "Link", "classes", ".", "Not", "threadsafe", "should", "be", "run", "in", "a", "single", "-", "threaded", "context", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/Classfile.java#L344-L439
train
classgraph/classgraph
src/main/java/io/github/classgraph/Classfile.java
Classfile.intern
private String intern(final String str) { if (str == null) { return null; } final String interned = stringInternMap.putIfAbsent(str, str); if (interned != null) { return interned; } return str; }
java
private String intern(final String str) { if (str == null) { return null; } final String interned = stringInternMap.putIfAbsent(str, str); if (interned != null) { return interned; } return str; }
[ "private", "String", "intern", "(", "final", "String", "str", ")", "{", "if", "(", "str", "==", "null", ")", "{", "return", "null", ";", "}", "final", "String", "interned", "=", "stringInternMap", ".", "putIfAbsent", "(", "str", ",", "str", ")", ";", ...
Intern a string.
[ "Intern", "a", "string", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/Classfile.java#L446-L455
train
classgraph/classgraph
src/main/java/io/github/classgraph/Classfile.java
Classfile.getConstantPoolStringOffset
private int getConstantPoolStringOffset(final int cpIdx, final int subFieldIdx) throws ClassfileFormatException { if (cpIdx < 1 || cpIdx >= cpCount) { throw new ClassfileFormatException("Constant pool index " + cpIdx + ", should be in range [1, " + (cpCount - 1) + "] -- cannot continue reading class. " + "Please report this at https://github.com/classgraph/classgraph/issues"); } final int t = entryTag[cpIdx]; if ((t != 12 && subFieldIdx != 0) || (t == 12 && subFieldIdx != 0 && subFieldIdx != 1)) { throw new ClassfileFormatException( "Bad subfield index " + subFieldIdx + " for tag " + t + ", cannot continue reading class. " + "Please report this at https://github.com/classgraph/classgraph/issues"); } int cpIdxToUse; if (t == 0) { // Assume this means null return 0; } else if (t == 1) { // CONSTANT_Utf8 cpIdxToUse = cpIdx; } else if (t == 7 || t == 8 || t == 19) { // t == 7 => CONSTANT_Class, e.g. "[[I", "[Ljava/lang/Thread;"; t == 8 => CONSTANT_String; // t == 19 => CONSTANT_Method_Info final int indirIdx = indirectStringRefs[cpIdx]; if (indirIdx == -1) { // Should not happen throw new ClassfileFormatException("Bad string indirection index, cannot continue reading class. " + "Please report this at https://github.com/classgraph/classgraph/issues"); } if (indirIdx == 0) { // I assume this represents a null string, since the zeroeth entry is unused return 0; } cpIdxToUse = indirIdx; } else if (t == 12) { // CONSTANT_NameAndType_info final int compoundIndirIdx = indirectStringRefs[cpIdx]; if (compoundIndirIdx == -1) { // Should not happen throw new ClassfileFormatException("Bad string indirection index, cannot continue reading class. " + "Please report this at https://github.com/classgraph/classgraph/issues"); } final int indirIdx = (subFieldIdx == 0 ? (compoundIndirIdx >> 16) : compoundIndirIdx) & 0xffff; if (indirIdx == 0) { // Should not happen throw new ClassfileFormatException("Bad string indirection index, cannot continue reading class. " + "Please report this at https://github.com/classgraph/classgraph/issues"); } cpIdxToUse = indirIdx; } else { throw new ClassfileFormatException("Wrong tag number " + t + " at constant pool index " + cpIdx + ", " + "cannot continue reading class. Please report this at " + "https://github.com/classgraph/classgraph/issues"); } if (cpIdxToUse < 1 || cpIdxToUse >= cpCount) { throw new ClassfileFormatException("Constant pool index " + cpIdx + ", should be in range [1, " + (cpCount - 1) + "] -- cannot continue reading class. " + "Please report this at https://github.com/classgraph/classgraph/issues"); } return entryOffset[cpIdxToUse]; }
java
private int getConstantPoolStringOffset(final int cpIdx, final int subFieldIdx) throws ClassfileFormatException { if (cpIdx < 1 || cpIdx >= cpCount) { throw new ClassfileFormatException("Constant pool index " + cpIdx + ", should be in range [1, " + (cpCount - 1) + "] -- cannot continue reading class. " + "Please report this at https://github.com/classgraph/classgraph/issues"); } final int t = entryTag[cpIdx]; if ((t != 12 && subFieldIdx != 0) || (t == 12 && subFieldIdx != 0 && subFieldIdx != 1)) { throw new ClassfileFormatException( "Bad subfield index " + subFieldIdx + " for tag " + t + ", cannot continue reading class. " + "Please report this at https://github.com/classgraph/classgraph/issues"); } int cpIdxToUse; if (t == 0) { // Assume this means null return 0; } else if (t == 1) { // CONSTANT_Utf8 cpIdxToUse = cpIdx; } else if (t == 7 || t == 8 || t == 19) { // t == 7 => CONSTANT_Class, e.g. "[[I", "[Ljava/lang/Thread;"; t == 8 => CONSTANT_String; // t == 19 => CONSTANT_Method_Info final int indirIdx = indirectStringRefs[cpIdx]; if (indirIdx == -1) { // Should not happen throw new ClassfileFormatException("Bad string indirection index, cannot continue reading class. " + "Please report this at https://github.com/classgraph/classgraph/issues"); } if (indirIdx == 0) { // I assume this represents a null string, since the zeroeth entry is unused return 0; } cpIdxToUse = indirIdx; } else if (t == 12) { // CONSTANT_NameAndType_info final int compoundIndirIdx = indirectStringRefs[cpIdx]; if (compoundIndirIdx == -1) { // Should not happen throw new ClassfileFormatException("Bad string indirection index, cannot continue reading class. " + "Please report this at https://github.com/classgraph/classgraph/issues"); } final int indirIdx = (subFieldIdx == 0 ? (compoundIndirIdx >> 16) : compoundIndirIdx) & 0xffff; if (indirIdx == 0) { // Should not happen throw new ClassfileFormatException("Bad string indirection index, cannot continue reading class. " + "Please report this at https://github.com/classgraph/classgraph/issues"); } cpIdxToUse = indirIdx; } else { throw new ClassfileFormatException("Wrong tag number " + t + " at constant pool index " + cpIdx + ", " + "cannot continue reading class. Please report this at " + "https://github.com/classgraph/classgraph/issues"); } if (cpIdxToUse < 1 || cpIdxToUse >= cpCount) { throw new ClassfileFormatException("Constant pool index " + cpIdx + ", should be in range [1, " + (cpCount - 1) + "] -- cannot continue reading class. " + "Please report this at https://github.com/classgraph/classgraph/issues"); } return entryOffset[cpIdxToUse]; }
[ "private", "int", "getConstantPoolStringOffset", "(", "final", "int", "cpIdx", ",", "final", "int", "subFieldIdx", ")", "throws", "ClassfileFormatException", "{", "if", "(", "cpIdx", "<", "1", "||", "cpIdx", ">=", "cpCount", ")", "{", "throw", "new", "Classfil...
Get the byte offset within the buffer of a string from the constant pool, or 0 for a null string. @param cpIdx the constant pool index @param subFieldIdx should be 0 for CONSTANT_Utf8, CONSTANT_Class and CONSTANT_String, and for CONSTANT_NameAndType_info, fetches the name for value 0, or the type descriptor for value 1. @return the constant pool string offset @throws ClassfileFormatException If a problem is detected
[ "Get", "the", "byte", "offset", "within", "the", "buffer", "of", "a", "string", "from", "the", "constant", "pool", "or", "0", "for", "a", "null", "string", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/Classfile.java#L469-L529
train
classgraph/classgraph
src/main/java/io/github/classgraph/Classfile.java
Classfile.getConstantPoolString
private String getConstantPoolString(final int cpIdx, final int subFieldIdx) throws ClassfileFormatException, IOException { final int constantPoolStringOffset = getConstantPoolStringOffset(cpIdx, subFieldIdx); return constantPoolStringOffset == 0 ? null : intern(inputStreamOrByteBuffer.readString(constantPoolStringOffset, /* replaceSlashWithDot = */ false, /* stripLSemicolon = */ false)); }
java
private String getConstantPoolString(final int cpIdx, final int subFieldIdx) throws ClassfileFormatException, IOException { final int constantPoolStringOffset = getConstantPoolStringOffset(cpIdx, subFieldIdx); return constantPoolStringOffset == 0 ? null : intern(inputStreamOrByteBuffer.readString(constantPoolStringOffset, /* replaceSlashWithDot = */ false, /* stripLSemicolon = */ false)); }
[ "private", "String", "getConstantPoolString", "(", "final", "int", "cpIdx", ",", "final", "int", "subFieldIdx", ")", "throws", "ClassfileFormatException", ",", "IOException", "{", "final", "int", "constantPoolStringOffset", "=", "getConstantPoolStringOffset", "(", "cpId...
Get a string from the constant pool. @param cpIdx the constant pool index @param subFieldIdx should be 0 for CONSTANT_Utf8, CONSTANT_Class and CONSTANT_String, and for CONSTANT_NameAndType_info, fetches the name for value 0, or the type descriptor for value 1. @return the constant pool string @throws ClassfileFormatException If a problem occurs. @throws IOException If an IO exception occurs.
[ "Get", "a", "string", "from", "the", "constant", "pool", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/Classfile.java#L569-L575
train
classgraph/classgraph
src/main/java/io/github/classgraph/Classfile.java
Classfile.getConstantPoolStringFirstByte
private byte getConstantPoolStringFirstByte(final int cpIdx) throws ClassfileFormatException, IOException { final int constantPoolStringOffset = getConstantPoolStringOffset(cpIdx, /* subFieldIdx = */ 0); if (constantPoolStringOffset == 0) { return '\0'; } final int utfLen = inputStreamOrByteBuffer.readUnsignedShort(constantPoolStringOffset); if (utfLen == 0) { return '\0'; } return inputStreamOrByteBuffer.buf[constantPoolStringOffset + 2]; }
java
private byte getConstantPoolStringFirstByte(final int cpIdx) throws ClassfileFormatException, IOException { final int constantPoolStringOffset = getConstantPoolStringOffset(cpIdx, /* subFieldIdx = */ 0); if (constantPoolStringOffset == 0) { return '\0'; } final int utfLen = inputStreamOrByteBuffer.readUnsignedShort(constantPoolStringOffset); if (utfLen == 0) { return '\0'; } return inputStreamOrByteBuffer.buf[constantPoolStringOffset + 2]; }
[ "private", "byte", "getConstantPoolStringFirstByte", "(", "final", "int", "cpIdx", ")", "throws", "ClassfileFormatException", ",", "IOException", "{", "final", "int", "constantPoolStringOffset", "=", "getConstantPoolStringOffset", "(", "cpIdx", ",", "/* subFieldIdx = */", ...
Get the first UTF8 byte of a string in the constant pool, or '\0' if the string is null or empty. @param cpIdx the constant pool index @return the first byte of the constant pool string @throws ClassfileFormatException If a problem occurs. @throws IOException If an IO exception occurs.
[ "Get", "the", "first", "UTF8", "byte", "of", "a", "string", "in", "the", "constant", "pool", "or", "\\", "0", "if", "the", "string", "is", "null", "or", "empty", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/Classfile.java#L603-L613
train
classgraph/classgraph
src/main/java/io/github/classgraph/Classfile.java
Classfile.constantPoolStringEquals
private boolean constantPoolStringEquals(final int cpIdx, final String asciiString) throws ClassfileFormatException, IOException { final int strOffset = getConstantPoolStringOffset(cpIdx, /* subFieldIdx = */ 0); if (strOffset == 0) { return asciiString == null; } else if (asciiString == null) { return false; } final int strLen = inputStreamOrByteBuffer.readUnsignedShort(strOffset); final int otherLen = asciiString.length(); if (strLen != otherLen) { return false; } final int strStart = strOffset + 2; for (int i = 0; i < strLen; i++) { if ((char) (inputStreamOrByteBuffer.buf[strStart + i] & 0xff) != asciiString.charAt(i)) { return false; } } return true; }
java
private boolean constantPoolStringEquals(final int cpIdx, final String asciiString) throws ClassfileFormatException, IOException { final int strOffset = getConstantPoolStringOffset(cpIdx, /* subFieldIdx = */ 0); if (strOffset == 0) { return asciiString == null; } else if (asciiString == null) { return false; } final int strLen = inputStreamOrByteBuffer.readUnsignedShort(strOffset); final int otherLen = asciiString.length(); if (strLen != otherLen) { return false; } final int strStart = strOffset + 2; for (int i = 0; i < strLen; i++) { if ((char) (inputStreamOrByteBuffer.buf[strStart + i] & 0xff) != asciiString.charAt(i)) { return false; } } return true; }
[ "private", "boolean", "constantPoolStringEquals", "(", "final", "int", "cpIdx", ",", "final", "String", "asciiString", ")", "throws", "ClassfileFormatException", ",", "IOException", "{", "final", "int", "strOffset", "=", "getConstantPoolStringOffset", "(", "cpIdx", ",...
Compare a string in the constant pool with a given ASCII string, without constructing the constant pool String object. @param cpIdx the constant pool index @param asciiString the ASCII string to compare to @return true, if successful @throws ClassfileFormatException If a problem occurs. @throws IOException If an IO exception occurs.
[ "Compare", "a", "string", "in", "the", "constant", "pool", "with", "a", "given", "ASCII", "string", "without", "constructing", "the", "constant", "pool", "String", "object", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/Classfile.java#L661-L681
train
classgraph/classgraph
src/main/java/io/github/classgraph/Classfile.java
Classfile.cpReadUnsignedShort
private int cpReadUnsignedShort(final int cpIdx) throws IOException { if (cpIdx < 1 || cpIdx >= cpCount) { throw new ClassfileFormatException("Constant pool index " + cpIdx + ", should be in range [1, " + (cpCount - 1) + "] -- cannot continue reading class. " + "Please report this at https://github.com/classgraph/classgraph/issues"); } return inputStreamOrByteBuffer.readUnsignedShort(entryOffset[cpIdx]); }
java
private int cpReadUnsignedShort(final int cpIdx) throws IOException { if (cpIdx < 1 || cpIdx >= cpCount) { throw new ClassfileFormatException("Constant pool index " + cpIdx + ", should be in range [1, " + (cpCount - 1) + "] -- cannot continue reading class. " + "Please report this at https://github.com/classgraph/classgraph/issues"); } return inputStreamOrByteBuffer.readUnsignedShort(entryOffset[cpIdx]); }
[ "private", "int", "cpReadUnsignedShort", "(", "final", "int", "cpIdx", ")", "throws", "IOException", "{", "if", "(", "cpIdx", "<", "1", "||", "cpIdx", ">=", "cpCount", ")", "{", "throw", "new", "ClassfileFormatException", "(", "\"Constant pool index \"", "+", ...
Read an unsigned short from the constant pool. @param cpIdx the constant pool index. @return the unsigned short @throws IOException If an I/O exception occurred.
[ "Read", "an", "unsigned", "short", "from", "the", "constant", "pool", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/Classfile.java#L694-L701
train
classgraph/classgraph
src/main/java/io/github/classgraph/Classfile.java
Classfile.cpReadInt
private int cpReadInt(final int cpIdx) throws IOException { if (cpIdx < 1 || cpIdx >= cpCount) { throw new ClassfileFormatException("Constant pool index " + cpIdx + ", should be in range [1, " + (cpCount - 1) + "] -- cannot continue reading class. " + "Please report this at https://github.com/classgraph/classgraph/issues"); } return inputStreamOrByteBuffer.readInt(entryOffset[cpIdx]); }
java
private int cpReadInt(final int cpIdx) throws IOException { if (cpIdx < 1 || cpIdx >= cpCount) { throw new ClassfileFormatException("Constant pool index " + cpIdx + ", should be in range [1, " + (cpCount - 1) + "] -- cannot continue reading class. " + "Please report this at https://github.com/classgraph/classgraph/issues"); } return inputStreamOrByteBuffer.readInt(entryOffset[cpIdx]); }
[ "private", "int", "cpReadInt", "(", "final", "int", "cpIdx", ")", "throws", "IOException", "{", "if", "(", "cpIdx", "<", "1", "||", "cpIdx", ">=", "cpCount", ")", "{", "throw", "new", "ClassfileFormatException", "(", "\"Constant pool index \"", "+", "cpIdx", ...
Read an int from the constant pool. @param cpIdx the constant pool index. @return the int @throws IOException If an I/O exception occurred.
[ "Read", "an", "int", "from", "the", "constant", "pool", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/Classfile.java#L712-L719
train
classgraph/classgraph
src/main/java/io/github/classgraph/Classfile.java
Classfile.cpReadLong
private long cpReadLong(final int cpIdx) throws IOException { if (cpIdx < 1 || cpIdx >= cpCount) { throw new ClassfileFormatException("Constant pool index " + cpIdx + ", should be in range [1, " + (cpCount - 1) + "] -- cannot continue reading class. " + "Please report this at https://github.com/classgraph/classgraph/issues"); } return inputStreamOrByteBuffer.readLong(entryOffset[cpIdx]); }
java
private long cpReadLong(final int cpIdx) throws IOException { if (cpIdx < 1 || cpIdx >= cpCount) { throw new ClassfileFormatException("Constant pool index " + cpIdx + ", should be in range [1, " + (cpCount - 1) + "] -- cannot continue reading class. " + "Please report this at https://github.com/classgraph/classgraph/issues"); } return inputStreamOrByteBuffer.readLong(entryOffset[cpIdx]); }
[ "private", "long", "cpReadLong", "(", "final", "int", "cpIdx", ")", "throws", "IOException", "{", "if", "(", "cpIdx", "<", "1", "||", "cpIdx", ">=", "cpCount", ")", "{", "throw", "new", "ClassfileFormatException", "(", "\"Constant pool index \"", "+", "cpIdx",...
Read a long from the constant pool. @param cpIdx the constant pool index. @return the long @throws IOException If an I/O exception occurred.
[ "Read", "a", "long", "from", "the", "constant", "pool", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/Classfile.java#L730-L737
train
classgraph/classgraph
src/main/java/io/github/classgraph/Classfile.java
Classfile.getFieldConstantPoolValue
private Object getFieldConstantPoolValue(final int tag, final char fieldTypeDescriptorFirstChar, final int cpIdx) throws ClassfileFormatException, IOException { switch (tag) { case 1: // Modified UTF8 case 7: // Class -- N.B. Unused? Class references do not seem to actually be stored as constant initalizers case 8: // String // Forward or backward indirect reference to a modified UTF8 entry return getConstantPoolString(cpIdx); case 3: // int, short, char, byte, boolean are all represented by Constant_INTEGER final int intVal = cpReadInt(cpIdx); switch (fieldTypeDescriptorFirstChar) { case 'I': return intVal; case 'S': return (short) intVal; case 'C': return (char) intVal; case 'B': return (byte) intVal; case 'Z': return intVal != 0; default: // Fall through } throw new ClassfileFormatException("Unknown Constant_INTEGER type " + fieldTypeDescriptorFirstChar + ", " + "cannot continue reading class. Please report this at " + "https://github.com/classgraph/classgraph/issues"); case 4: // float return Float.intBitsToFloat(cpReadInt(cpIdx)); case 5: // long return cpReadLong(cpIdx); case 6: // double return Double.longBitsToDouble(cpReadLong(cpIdx)); default: // ClassGraph doesn't expect other types // (N.B. in particular, enum values are not stored in the constant pool, so don't need to be handled) throw new ClassfileFormatException("Unknown constant pool tag " + tag + ", " + "cannot continue reading class. Please report this at " + "https://github.com/classgraph/classgraph/issues"); } }
java
private Object getFieldConstantPoolValue(final int tag, final char fieldTypeDescriptorFirstChar, final int cpIdx) throws ClassfileFormatException, IOException { switch (tag) { case 1: // Modified UTF8 case 7: // Class -- N.B. Unused? Class references do not seem to actually be stored as constant initalizers case 8: // String // Forward or backward indirect reference to a modified UTF8 entry return getConstantPoolString(cpIdx); case 3: // int, short, char, byte, boolean are all represented by Constant_INTEGER final int intVal = cpReadInt(cpIdx); switch (fieldTypeDescriptorFirstChar) { case 'I': return intVal; case 'S': return (short) intVal; case 'C': return (char) intVal; case 'B': return (byte) intVal; case 'Z': return intVal != 0; default: // Fall through } throw new ClassfileFormatException("Unknown Constant_INTEGER type " + fieldTypeDescriptorFirstChar + ", " + "cannot continue reading class. Please report this at " + "https://github.com/classgraph/classgraph/issues"); case 4: // float return Float.intBitsToFloat(cpReadInt(cpIdx)); case 5: // long return cpReadLong(cpIdx); case 6: // double return Double.longBitsToDouble(cpReadLong(cpIdx)); default: // ClassGraph doesn't expect other types // (N.B. in particular, enum values are not stored in the constant pool, so don't need to be handled) throw new ClassfileFormatException("Unknown constant pool tag " + tag + ", " + "cannot continue reading class. Please report this at " + "https://github.com/classgraph/classgraph/issues"); } }
[ "private", "Object", "getFieldConstantPoolValue", "(", "final", "int", "tag", ",", "final", "char", "fieldTypeDescriptorFirstChar", ",", "final", "int", "cpIdx", ")", "throws", "ClassfileFormatException", ",", "IOException", "{", "switch", "(", "tag", ")", "{", "c...
Get a field constant from the constant pool. @param tag the tag @param fieldTypeDescriptorFirstChar the first char of the field type descriptor @param cpIdx the constant pool index @return the field constant pool value @throws ClassfileFormatException If a problem occurs. @throws IOException If an IO exception occurs.
[ "Get", "a", "field", "constant", "from", "the", "constant", "pool", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/Classfile.java#L756-L796
train
classgraph/classgraph
src/main/java/io/github/classgraph/Classfile.java
Classfile.readAnnotation
private AnnotationInfo readAnnotation() throws IOException { // Lcom/xyz/Annotation; -> Lcom.xyz.Annotation; final String annotationClassName = getConstantPoolClassDescriptor( inputStreamOrByteBuffer.readUnsignedShort()); final int numElementValuePairs = inputStreamOrByteBuffer.readUnsignedShort(); AnnotationParameterValueList paramVals = null; if (numElementValuePairs > 0) { paramVals = new AnnotationParameterValueList(numElementValuePairs); for (int i = 0; i < numElementValuePairs; i++) { final String paramName = getConstantPoolString(inputStreamOrByteBuffer.readUnsignedShort()); final Object paramValue = readAnnotationElementValue(); paramVals.add(new AnnotationParameterValue(paramName, paramValue)); } } return new AnnotationInfo(annotationClassName, paramVals); }
java
private AnnotationInfo readAnnotation() throws IOException { // Lcom/xyz/Annotation; -> Lcom.xyz.Annotation; final String annotationClassName = getConstantPoolClassDescriptor( inputStreamOrByteBuffer.readUnsignedShort()); final int numElementValuePairs = inputStreamOrByteBuffer.readUnsignedShort(); AnnotationParameterValueList paramVals = null; if (numElementValuePairs > 0) { paramVals = new AnnotationParameterValueList(numElementValuePairs); for (int i = 0; i < numElementValuePairs; i++) { final String paramName = getConstantPoolString(inputStreamOrByteBuffer.readUnsignedShort()); final Object paramValue = readAnnotationElementValue(); paramVals.add(new AnnotationParameterValue(paramName, paramValue)); } } return new AnnotationInfo(annotationClassName, paramVals); }
[ "private", "AnnotationInfo", "readAnnotation", "(", ")", "throws", "IOException", "{", "// Lcom/xyz/Annotation; -> Lcom.xyz.Annotation;", "final", "String", "annotationClassName", "=", "getConstantPoolClassDescriptor", "(", "inputStreamOrByteBuffer", ".", "readUnsignedShort", "("...
Read annotation entry from classfile. @return the annotation, as an {@link AnnotationInfo} object. @throws IOException If an IO exception occurs.
[ "Read", "annotation", "entry", "from", "classfile", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/Classfile.java#L807-L822
train
classgraph/classgraph
src/main/java/io/github/classgraph/Classfile.java
Classfile.readAnnotationElementValue
private Object readAnnotationElementValue() throws IOException { final int tag = (char) inputStreamOrByteBuffer.readUnsignedByte(); switch (tag) { case 'B': return (byte) cpReadInt(inputStreamOrByteBuffer.readUnsignedShort()); case 'C': return (char) cpReadInt(inputStreamOrByteBuffer.readUnsignedShort()); case 'D': return Double.longBitsToDouble(cpReadLong(inputStreamOrByteBuffer.readUnsignedShort())); case 'F': return Float.intBitsToFloat(cpReadInt(inputStreamOrByteBuffer.readUnsignedShort())); case 'I': return cpReadInt(inputStreamOrByteBuffer.readUnsignedShort()); case 'J': return cpReadLong(inputStreamOrByteBuffer.readUnsignedShort()); case 'S': return (short) cpReadUnsignedShort(inputStreamOrByteBuffer.readUnsignedShort()); case 'Z': return cpReadInt(inputStreamOrByteBuffer.readUnsignedShort()) != 0; case 's': return getConstantPoolString(inputStreamOrByteBuffer.readUnsignedShort()); case 'e': { // Return type is AnnotationEnumVal. final String annotationClassName = getConstantPoolClassDescriptor( inputStreamOrByteBuffer.readUnsignedShort()); final String annotationConstName = getConstantPoolString(inputStreamOrByteBuffer.readUnsignedShort()); return new AnnotationEnumValue(annotationClassName, annotationConstName); } case 'c': // Return type is AnnotationClassRef (for class references in annotations) final String classRefTypeDescriptor = getConstantPoolString( inputStreamOrByteBuffer.readUnsignedShort()); return new AnnotationClassRef(classRefTypeDescriptor); case '@': // Complex (nested) annotation. Return type is AnnotationInfo. return readAnnotation(); case '[': // Return type is Object[] (of nested annotation element values) final int count = inputStreamOrByteBuffer.readUnsignedShort(); final Object[] arr = new Object[count]; for (int i = 0; i < count; ++i) { // Nested annotation element value arr[i] = readAnnotationElementValue(); } return arr; default: throw new ClassfileFormatException("Class " + className + " has unknown annotation element type tag '" + ((char) tag) + "': element size unknown, cannot continue reading class. " + "Please report this at https://github.com/classgraph/classgraph/issues"); } }
java
private Object readAnnotationElementValue() throws IOException { final int tag = (char) inputStreamOrByteBuffer.readUnsignedByte(); switch (tag) { case 'B': return (byte) cpReadInt(inputStreamOrByteBuffer.readUnsignedShort()); case 'C': return (char) cpReadInt(inputStreamOrByteBuffer.readUnsignedShort()); case 'D': return Double.longBitsToDouble(cpReadLong(inputStreamOrByteBuffer.readUnsignedShort())); case 'F': return Float.intBitsToFloat(cpReadInt(inputStreamOrByteBuffer.readUnsignedShort())); case 'I': return cpReadInt(inputStreamOrByteBuffer.readUnsignedShort()); case 'J': return cpReadLong(inputStreamOrByteBuffer.readUnsignedShort()); case 'S': return (short) cpReadUnsignedShort(inputStreamOrByteBuffer.readUnsignedShort()); case 'Z': return cpReadInt(inputStreamOrByteBuffer.readUnsignedShort()) != 0; case 's': return getConstantPoolString(inputStreamOrByteBuffer.readUnsignedShort()); case 'e': { // Return type is AnnotationEnumVal. final String annotationClassName = getConstantPoolClassDescriptor( inputStreamOrByteBuffer.readUnsignedShort()); final String annotationConstName = getConstantPoolString(inputStreamOrByteBuffer.readUnsignedShort()); return new AnnotationEnumValue(annotationClassName, annotationConstName); } case 'c': // Return type is AnnotationClassRef (for class references in annotations) final String classRefTypeDescriptor = getConstantPoolString( inputStreamOrByteBuffer.readUnsignedShort()); return new AnnotationClassRef(classRefTypeDescriptor); case '@': // Complex (nested) annotation. Return type is AnnotationInfo. return readAnnotation(); case '[': // Return type is Object[] (of nested annotation element values) final int count = inputStreamOrByteBuffer.readUnsignedShort(); final Object[] arr = new Object[count]; for (int i = 0; i < count; ++i) { // Nested annotation element value arr[i] = readAnnotationElementValue(); } return arr; default: throw new ClassfileFormatException("Class " + className + " has unknown annotation element type tag '" + ((char) tag) + "': element size unknown, cannot continue reading class. " + "Please report this at https://github.com/classgraph/classgraph/issues"); } }
[ "private", "Object", "readAnnotationElementValue", "(", ")", "throws", "IOException", "{", "final", "int", "tag", "=", "(", "char", ")", "inputStreamOrByteBuffer", ".", "readUnsignedByte", "(", ")", ";", "switch", "(", "tag", ")", "{", "case", "'", "'", ":",...
Read annotation element value from classfile. @return the annotation element value @throws IOException If an IO exception occurs.
[ "Read", "annotation", "element", "value", "from", "classfile", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/Classfile.java#L831-L881
train
classgraph/classgraph
src/main/java/io/github/classgraph/Classfile.java
Classfile.readBasicClassInfo
private void readBasicClassInfo() throws IOException, ClassfileFormatException, SkipClassException { // Modifier flags classModifiers = inputStreamOrByteBuffer.readUnsignedShort(); isInterface = (classModifiers & 0x0200) != 0; isAnnotation = (classModifiers & 0x2000) != 0; // The fully-qualified class name of this class, with slashes replaced with dots final String classNamePath = getConstantPoolString(inputStreamOrByteBuffer.readUnsignedShort()); if (classNamePath == null) { throw new ClassfileFormatException("Class name is null"); } className = classNamePath.replace('/', '.'); if ("java.lang.Object".equals(className)) { // Don't process java.lang.Object (it has a null superclass), though you can still search for classes // that are subclasses of java.lang.Object (as an external class). throw new SkipClassException("No need to scan java.lang.Object"); } // Check class visibility modifiers final boolean isModule = (classModifiers & 0x8000) != 0; // Equivalently filename is "module-info.class" final boolean isPackage = relativePath.regionMatches(relativePath.lastIndexOf('/') + 1, "package-info.class", 0, 18); if (!scanSpec.ignoreClassVisibility && !Modifier.isPublic(classModifiers) && !isModule && !isPackage) { throw new SkipClassException("Class is not public, and ignoreClassVisibility() was not called"); } // Make sure classname matches relative path if (!relativePath.endsWith(".class")) { // Should not happen throw new SkipClassException("Classfile filename " + relativePath + " does not end in \".class\""); } final int len = classNamePath.length(); if (relativePath.length() != len + 6 || !classNamePath.regionMatches(0, relativePath, 0, len)) { throw new SkipClassException( "Relative path " + relativePath + " does not match class name " + className); } // Superclass name, with slashes replaced with dots final int superclassNameCpIdx = inputStreamOrByteBuffer.readUnsignedShort(); if (superclassNameCpIdx > 0) { superclassName = getConstantPoolClassName(superclassNameCpIdx); } }
java
private void readBasicClassInfo() throws IOException, ClassfileFormatException, SkipClassException { // Modifier flags classModifiers = inputStreamOrByteBuffer.readUnsignedShort(); isInterface = (classModifiers & 0x0200) != 0; isAnnotation = (classModifiers & 0x2000) != 0; // The fully-qualified class name of this class, with slashes replaced with dots final String classNamePath = getConstantPoolString(inputStreamOrByteBuffer.readUnsignedShort()); if (classNamePath == null) { throw new ClassfileFormatException("Class name is null"); } className = classNamePath.replace('/', '.'); if ("java.lang.Object".equals(className)) { // Don't process java.lang.Object (it has a null superclass), though you can still search for classes // that are subclasses of java.lang.Object (as an external class). throw new SkipClassException("No need to scan java.lang.Object"); } // Check class visibility modifiers final boolean isModule = (classModifiers & 0x8000) != 0; // Equivalently filename is "module-info.class" final boolean isPackage = relativePath.regionMatches(relativePath.lastIndexOf('/') + 1, "package-info.class", 0, 18); if (!scanSpec.ignoreClassVisibility && !Modifier.isPublic(classModifiers) && !isModule && !isPackage) { throw new SkipClassException("Class is not public, and ignoreClassVisibility() was not called"); } // Make sure classname matches relative path if (!relativePath.endsWith(".class")) { // Should not happen throw new SkipClassException("Classfile filename " + relativePath + " does not end in \".class\""); } final int len = classNamePath.length(); if (relativePath.length() != len + 6 || !classNamePath.regionMatches(0, relativePath, 0, len)) { throw new SkipClassException( "Relative path " + relativePath + " does not match class name " + className); } // Superclass name, with slashes replaced with dots final int superclassNameCpIdx = inputStreamOrByteBuffer.readUnsignedShort(); if (superclassNameCpIdx > 0) { superclassName = getConstantPoolClassName(superclassNameCpIdx); } }
[ "private", "void", "readBasicClassInfo", "(", ")", "throws", "IOException", ",", "ClassfileFormatException", ",", "SkipClassException", "{", "// Modifier flags", "classModifiers", "=", "inputStreamOrByteBuffer", ".", "readUnsignedShort", "(", ")", ";", "isInterface", "=",...
Read basic class information. @throws IOException if an I/O exception occurs. @throws ClassfileFormatException if the classfile is incorrectly formatted. @throws SkipClassException if the classfile needs to be skipped (e.g. the class is non-public, and ignoreClassVisibility is false)
[ "Read", "basic", "class", "information", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/Classfile.java#L1056-L1098
train
classgraph/classgraph
src/main/java/io/github/classgraph/Classfile.java
Classfile.readInterfaces
private void readInterfaces() throws IOException { // Interfaces final int interfaceCount = inputStreamOrByteBuffer.readUnsignedShort(); for (int i = 0; i < interfaceCount; i++) { final String interfaceName = getConstantPoolClassName(inputStreamOrByteBuffer.readUnsignedShort()); if (implementedInterfaces == null) { implementedInterfaces = new ArrayList<>(); } implementedInterfaces.add(interfaceName); } }
java
private void readInterfaces() throws IOException { // Interfaces final int interfaceCount = inputStreamOrByteBuffer.readUnsignedShort(); for (int i = 0; i < interfaceCount; i++) { final String interfaceName = getConstantPoolClassName(inputStreamOrByteBuffer.readUnsignedShort()); if (implementedInterfaces == null) { implementedInterfaces = new ArrayList<>(); } implementedInterfaces.add(interfaceName); } }
[ "private", "void", "readInterfaces", "(", ")", "throws", "IOException", "{", "// Interfaces", "final", "int", "interfaceCount", "=", "inputStreamOrByteBuffer", ".", "readUnsignedShort", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "interface...
Read the class' interfaces. @throws IOException if an I/O exception occurs.
[ "Read", "the", "class", "interfaces", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/Classfile.java#L1108-L1118
train
classgraph/classgraph
src/main/java/io/github/classgraph/Classfile.java
Classfile.readClassAttributes
private void readClassAttributes() throws IOException, ClassfileFormatException { // Class attributes (including class annotations, class type variables, module info, etc.) final int attributesCount = inputStreamOrByteBuffer.readUnsignedShort(); for (int i = 0; i < attributesCount; i++) { final int attributeNameCpIdx = inputStreamOrByteBuffer.readUnsignedShort(); final int attributeLength = inputStreamOrByteBuffer.readInt(); if (scanSpec.enableAnnotationInfo // && (constantPoolStringEquals(attributeNameCpIdx, "RuntimeVisibleAnnotations") || (!scanSpec.disableRuntimeInvisibleAnnotations && constantPoolStringEquals( attributeNameCpIdx, "RuntimeInvisibleAnnotations")))) { final int annotationCount = inputStreamOrByteBuffer.readUnsignedShort(); if (annotationCount > 0) { if (classAnnotations == null) { classAnnotations = new AnnotationInfoList(); } for (int m = 0; m < annotationCount; m++) { classAnnotations.add(readAnnotation()); } } } else if (constantPoolStringEquals(attributeNameCpIdx, "InnerClasses")) { final int numInnerClasses = inputStreamOrByteBuffer.readUnsignedShort(); for (int j = 0; j < numInnerClasses; j++) { final int innerClassInfoCpIdx = inputStreamOrByteBuffer.readUnsignedShort(); final int outerClassInfoCpIdx = inputStreamOrByteBuffer.readUnsignedShort(); if (innerClassInfoCpIdx != 0 && outerClassInfoCpIdx != 0) { if (classContainmentEntries == null) { classContainmentEntries = new ArrayList<>(); } classContainmentEntries.add(new SimpleEntry<>(getConstantPoolClassName(innerClassInfoCpIdx), getConstantPoolClassName(outerClassInfoCpIdx))); } inputStreamOrByteBuffer.skip(2); // inner_name_idx inputStreamOrByteBuffer.skip(2); // inner_class_access_flags } } else if (constantPoolStringEquals(attributeNameCpIdx, "Signature")) { // Get class type signature, including type variables typeSignature = getConstantPoolString(inputStreamOrByteBuffer.readUnsignedShort()); } else if (constantPoolStringEquals(attributeNameCpIdx, "EnclosingMethod")) { final String innermostEnclosingClassName = getConstantPoolClassName( inputStreamOrByteBuffer.readUnsignedShort()); final int enclosingMethodCpIdx = inputStreamOrByteBuffer.readUnsignedShort(); String definingMethodName; if (enclosingMethodCpIdx == 0) { // A cpIdx of 0 (which is an invalid value) is used for anonymous inner classes declared in // class initializer code, e.g. assigned to a class field. definingMethodName = "<clinit>"; } else { definingMethodName = getConstantPoolString(enclosingMethodCpIdx, /* subFieldIdx = */ 0); // Could also fetch method type signature using subFieldIdx = 1, if needed } // Link anonymous inner classes into the class with their containing method if (classContainmentEntries == null) { classContainmentEntries = new ArrayList<>(); } classContainmentEntries.add(new SimpleEntry<>(className, innermostEnclosingClassName)); // Also store the fully-qualified name of the enclosing method, to mark this as an anonymous inner // class this.fullyQualifiedDefiningMethodName = innermostEnclosingClassName + "." + definingMethodName; } else if (constantPoolStringEquals(attributeNameCpIdx, "Module")) { final int moduleNameCpIdx = inputStreamOrByteBuffer.readUnsignedShort(); classpathElement.moduleNameFromModuleDescriptor = getConstantPoolString(moduleNameCpIdx); // (Future work): parse the rest of the module descriptor fields, and add to ModuleInfo: // https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.25 inputStreamOrByteBuffer.skip(attributeLength - 2); } else { inputStreamOrByteBuffer.skip(attributeLength); } } }
java
private void readClassAttributes() throws IOException, ClassfileFormatException { // Class attributes (including class annotations, class type variables, module info, etc.) final int attributesCount = inputStreamOrByteBuffer.readUnsignedShort(); for (int i = 0; i < attributesCount; i++) { final int attributeNameCpIdx = inputStreamOrByteBuffer.readUnsignedShort(); final int attributeLength = inputStreamOrByteBuffer.readInt(); if (scanSpec.enableAnnotationInfo // && (constantPoolStringEquals(attributeNameCpIdx, "RuntimeVisibleAnnotations") || (!scanSpec.disableRuntimeInvisibleAnnotations && constantPoolStringEquals( attributeNameCpIdx, "RuntimeInvisibleAnnotations")))) { final int annotationCount = inputStreamOrByteBuffer.readUnsignedShort(); if (annotationCount > 0) { if (classAnnotations == null) { classAnnotations = new AnnotationInfoList(); } for (int m = 0; m < annotationCount; m++) { classAnnotations.add(readAnnotation()); } } } else if (constantPoolStringEquals(attributeNameCpIdx, "InnerClasses")) { final int numInnerClasses = inputStreamOrByteBuffer.readUnsignedShort(); for (int j = 0; j < numInnerClasses; j++) { final int innerClassInfoCpIdx = inputStreamOrByteBuffer.readUnsignedShort(); final int outerClassInfoCpIdx = inputStreamOrByteBuffer.readUnsignedShort(); if (innerClassInfoCpIdx != 0 && outerClassInfoCpIdx != 0) { if (classContainmentEntries == null) { classContainmentEntries = new ArrayList<>(); } classContainmentEntries.add(new SimpleEntry<>(getConstantPoolClassName(innerClassInfoCpIdx), getConstantPoolClassName(outerClassInfoCpIdx))); } inputStreamOrByteBuffer.skip(2); // inner_name_idx inputStreamOrByteBuffer.skip(2); // inner_class_access_flags } } else if (constantPoolStringEquals(attributeNameCpIdx, "Signature")) { // Get class type signature, including type variables typeSignature = getConstantPoolString(inputStreamOrByteBuffer.readUnsignedShort()); } else if (constantPoolStringEquals(attributeNameCpIdx, "EnclosingMethod")) { final String innermostEnclosingClassName = getConstantPoolClassName( inputStreamOrByteBuffer.readUnsignedShort()); final int enclosingMethodCpIdx = inputStreamOrByteBuffer.readUnsignedShort(); String definingMethodName; if (enclosingMethodCpIdx == 0) { // A cpIdx of 0 (which is an invalid value) is used for anonymous inner classes declared in // class initializer code, e.g. assigned to a class field. definingMethodName = "<clinit>"; } else { definingMethodName = getConstantPoolString(enclosingMethodCpIdx, /* subFieldIdx = */ 0); // Could also fetch method type signature using subFieldIdx = 1, if needed } // Link anonymous inner classes into the class with their containing method if (classContainmentEntries == null) { classContainmentEntries = new ArrayList<>(); } classContainmentEntries.add(new SimpleEntry<>(className, innermostEnclosingClassName)); // Also store the fully-qualified name of the enclosing method, to mark this as an anonymous inner // class this.fullyQualifiedDefiningMethodName = innermostEnclosingClassName + "." + definingMethodName; } else if (constantPoolStringEquals(attributeNameCpIdx, "Module")) { final int moduleNameCpIdx = inputStreamOrByteBuffer.readUnsignedShort(); classpathElement.moduleNameFromModuleDescriptor = getConstantPoolString(moduleNameCpIdx); // (Future work): parse the rest of the module descriptor fields, and add to ModuleInfo: // https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.25 inputStreamOrByteBuffer.skip(attributeLength - 2); } else { inputStreamOrByteBuffer.skip(attributeLength); } } }
[ "private", "void", "readClassAttributes", "(", ")", "throws", "IOException", ",", "ClassfileFormatException", "{", "// Class attributes (including class annotations, class type variables, module info, etc.)", "final", "int", "attributesCount", "=", "inputStreamOrByteBuffer", ".", "...
Read class attributes. @throws IOException if an I/O exception occurs. @throws ClassfileFormatException if the classfile is incorrectly formatted.
[ "Read", "class", "attributes", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/Classfile.java#L1365-L1433
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/fastzipfilereader/ZipFileSlice.java
ZipFileSlice.appendPath
private void appendPath(final StringBuilder buf) { if (parentZipFileSlice != null) { parentZipFileSlice.appendPath(buf); if (buf.length() > 0) { buf.append("!/"); } } buf.append(pathWithinParentZipFileSlice); }
java
private void appendPath(final StringBuilder buf) { if (parentZipFileSlice != null) { parentZipFileSlice.appendPath(buf); if (buf.length() > 0) { buf.append("!/"); } } buf.append(pathWithinParentZipFileSlice); }
[ "private", "void", "appendPath", "(", "final", "StringBuilder", "buf", ")", "{", "if", "(", "parentZipFileSlice", "!=", "null", ")", "{", "parentZipFileSlice", ".", "appendPath", "(", "buf", ")", ";", "if", "(", "buf", ".", "length", "(", ")", ">", "0", ...
Recursively append the path in top down ancestral order. @param buf the buf to append the path to
[ "Recursively", "append", "the", "path", "in", "top", "down", "ancestral", "order", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/fastzipfilereader/ZipFileSlice.java#L178-L186
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/ScanSpec.java
ScanSpec.filterClasspathElements
public void filterClasspathElements(final ClasspathElementFilter classpathElementFilter) { if (this.classpathElementFilters == null) { this.classpathElementFilters = new ArrayList<>(2); } this.classpathElementFilters.add(classpathElementFilter); }
java
public void filterClasspathElements(final ClasspathElementFilter classpathElementFilter) { if (this.classpathElementFilters == null) { this.classpathElementFilters = new ArrayList<>(2); } this.classpathElementFilters.add(classpathElementFilter); }
[ "public", "void", "filterClasspathElements", "(", "final", "ClasspathElementFilter", "classpathElementFilter", ")", "{", "if", "(", "this", ".", "classpathElementFilters", "==", "null", ")", "{", "this", ".", "classpathElementFilters", "=", "new", "ArrayList", "<>", ...
Add a classpath element filter. The provided ClasspathElementFilter should return true if the path string passed to it is a path you want to scan. @param classpathElementFilter The classpath element filter to apply to all discovered classpath elements, to decide which should be scanned.
[ "Add", "a", "classpath", "element", "filter", ".", "The", "provided", "ClasspathElementFilter", "should", "return", "true", "if", "the", "path", "string", "passed", "to", "it", "is", "a", "path", "you", "want", "to", "scan", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/ScanSpec.java#L270-L275
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/ScanSpec.java
ScanSpec.isModuleLayer
private static boolean isModuleLayer(final Object moduleLayer) { if (moduleLayer == null) { throw new IllegalArgumentException("ModuleLayer references must not be null"); } for (Class<?> currClass = moduleLayer.getClass(); currClass != null; currClass = currClass .getSuperclass()) { if (currClass.getName().equals("java.lang.ModuleLayer")) { return true; } } return false; }
java
private static boolean isModuleLayer(final Object moduleLayer) { if (moduleLayer == null) { throw new IllegalArgumentException("ModuleLayer references must not be null"); } for (Class<?> currClass = moduleLayer.getClass(); currClass != null; currClass = currClass .getSuperclass()) { if (currClass.getName().equals("java.lang.ModuleLayer")) { return true; } } return false; }
[ "private", "static", "boolean", "isModuleLayer", "(", "final", "Object", "moduleLayer", ")", "{", "if", "(", "moduleLayer", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"ModuleLayer references must not be null\"", ")", ";", "}", "for", ...
Return true if the argument is a ModuleLayer or a subclass of ModuleLayer. @param moduleLayer the module layer @return true if the argument is a ModuleLayer or a subclass of ModuleLayer.
[ "Return", "true", "if", "the", "argument", "is", "a", "ModuleLayer", "or", "a", "subclass", "of", "ModuleLayer", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/ScanSpec.java#L320-L331
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/ScanSpec.java
ScanSpec.addModuleLayer
public void addModuleLayer(final Object moduleLayer) { if (!isModuleLayer(moduleLayer)) { throw new IllegalArgumentException("moduleLayer must be of type java.lang.ModuleLayer"); } if (this.addedModuleLayers == null) { this.addedModuleLayers = new ArrayList<>(); } this.addedModuleLayers.add(moduleLayer); }
java
public void addModuleLayer(final Object moduleLayer) { if (!isModuleLayer(moduleLayer)) { throw new IllegalArgumentException("moduleLayer must be of type java.lang.ModuleLayer"); } if (this.addedModuleLayers == null) { this.addedModuleLayers = new ArrayList<>(); } this.addedModuleLayers.add(moduleLayer); }
[ "public", "void", "addModuleLayer", "(", "final", "Object", "moduleLayer", ")", "{", "if", "(", "!", "isModuleLayer", "(", "moduleLayer", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"moduleLayer must be of type java.lang.ModuleLayer\"", ")", ";",...
Add a ModuleLayer to the list of ModuleLayers to scan. Use this method if you define your own ModuleLayer, but the scanning code is not running within that custom ModuleLayer. <p> This call is ignored if it is called before {@link #overrideModuleLayers(Object...)}. @param moduleLayer The additional ModuleLayer to scan. (The parameter is of type {@link Object} for backwards compatibility with JDK 7 and JDK 8, but the argument should be of type ModuleLayer.)
[ "Add", "a", "ModuleLayer", "to", "the", "list", "of", "ModuleLayers", "to", "scan", ".", "Use", "this", "method", "if", "you", "define", "your", "own", "ModuleLayer", "but", "the", "scanning", "code", "is", "not", "running", "within", "that", "custom", "Mo...
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/ScanSpec.java#L344-L352
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/ScanSpec.java
ScanSpec.log
public void log(final LogNode log) { if (log != null) { final LogNode scanSpecLog = log.log("ScanSpec:"); for (final Field field : ScanSpec.class.getDeclaredFields()) { try { scanSpecLog.log(field.getName() + ": " + field.get(this)); } catch (final ReflectiveOperationException e) { // Ignore } } } }
java
public void log(final LogNode log) { if (log != null) { final LogNode scanSpecLog = log.log("ScanSpec:"); for (final Field field : ScanSpec.class.getDeclaredFields()) { try { scanSpecLog.log(field.getName() + ": " + field.get(this)); } catch (final ReflectiveOperationException e) { // Ignore } } } }
[ "public", "void", "log", "(", "final", "LogNode", "log", ")", "{", "if", "(", "log", "!=", "null", ")", "{", "final", "LogNode", "scanSpecLog", "=", "log", ".", "log", "(", "\"ScanSpec:\"", ")", ";", "for", "(", "final", "Field", "field", ":", "ScanS...
Write to log. @param log The {@link LogNode} to log to.
[ "Write", "to", "log", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/ScanSpec.java#L493-L504
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/classpath/CallStackReader.java
CallStackReader.getCallStackViaSecurityManager
private static Class<?>[] getCallStackViaSecurityManager(final LogNode log) { try { return new CallerResolver().getClassContext(); } catch (final SecurityException e) { // Creating a SecurityManager can fail if the current SecurityManager does not allow // RuntimePermission("createSecurityManager") if (log != null) { log.log("Exception while trying to obtain call stack via SecurityManager", e); } return null; } }
java
private static Class<?>[] getCallStackViaSecurityManager(final LogNode log) { try { return new CallerResolver().getClassContext(); } catch (final SecurityException e) { // Creating a SecurityManager can fail if the current SecurityManager does not allow // RuntimePermission("createSecurityManager") if (log != null) { log.log("Exception while trying to obtain call stack via SecurityManager", e); } return null; } }
[ "private", "static", "Class", "<", "?", ">", "[", "]", "getCallStackViaSecurityManager", "(", "final", "LogNode", "log", ")", "{", "try", "{", "return", "new", "CallerResolver", "(", ")", ".", "getClassContext", "(", ")", ";", "}", "catch", "(", "final", ...
Get the call stack via the SecurityManager API. @param log the log @return the call stack.
[ "Get", "the", "call", "stack", "via", "the", "SecurityManager", "API", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/classpath/CallStackReader.java#L121-L132
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/classpath/CallStackReader.java
CallStackReader.getClassContext
static Class<?>[] getClassContext(final LogNode log) { // For JRE 9+, use StackWalker to get call stack. // N.B. need to work around StackWalker bug fixed in JDK 13, and backported to 12.0.2 and 11.0.4 // (probably introduced in JDK 9, when StackWalker was introduced): // https://github.com/classgraph/classgraph/issues/341 // https://bugs.openjdk.java.net/browse/JDK-8210457 Class<?>[] stackClasses = null; if ((VersionFinder.JAVA_MAJOR_VERSION == 11 && (VersionFinder.JAVA_MINOR_VERSION >= 1 || VersionFinder.JAVA_SUB_VERSION >= 4) && !VersionFinder.JAVA_IS_EA_VERSION) || (VersionFinder.JAVA_MAJOR_VERSION == 12 && (VersionFinder.JAVA_MINOR_VERSION >= 1 || VersionFinder.JAVA_SUB_VERSION >= 2) && !VersionFinder.JAVA_IS_EA_VERSION) || (VersionFinder.JAVA_MAJOR_VERSION == 13 && !VersionFinder.JAVA_IS_EA_VERSION) || VersionFinder.JAVA_MAJOR_VERSION > 13) { // Invoke with doPrivileged -- see: // http://mail.openjdk.java.net/pipermail/jigsaw-dev/2018-October/013974.html stackClasses = AccessController.doPrivileged(new PrivilegedAction<Class<?>[]>() { @Override public Class<?>[] run() { return getCallStackViaStackWalker(); } }); } // For JRE 7 and 8, use SecurityManager to get call stack if (stackClasses == null || stackClasses.length == 0) { stackClasses = AccessController.doPrivileged(new PrivilegedAction<Class<?>[]>() { @Override public Class<?>[] run() { return getCallStackViaSecurityManager(log); } }); } // As a fallback, use getStackTrace() to try to get the call stack if (stackClasses == null || stackClasses.length == 0) { StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); if (stackTrace == null || stackTrace.length == 0) { try { throw new Exception(); } catch (final Exception e) { stackTrace = e.getStackTrace(); } } final List<Class<?>> stackClassesList = new ArrayList<>(); for (final StackTraceElement elt : stackTrace) { try { stackClassesList.add(Class.forName(elt.getClassName())); } catch (final ClassNotFoundException | LinkageError ignored) { // Ignored } } if (!stackClassesList.isEmpty()) { stackClasses = stackClassesList.toArray(new Class<?>[0]); } else { // Last-ditch effort -- include just this class in the call stack stackClasses = new Class<?>[] { CallStackReader.class }; } } return stackClasses; }
java
static Class<?>[] getClassContext(final LogNode log) { // For JRE 9+, use StackWalker to get call stack. // N.B. need to work around StackWalker bug fixed in JDK 13, and backported to 12.0.2 and 11.0.4 // (probably introduced in JDK 9, when StackWalker was introduced): // https://github.com/classgraph/classgraph/issues/341 // https://bugs.openjdk.java.net/browse/JDK-8210457 Class<?>[] stackClasses = null; if ((VersionFinder.JAVA_MAJOR_VERSION == 11 && (VersionFinder.JAVA_MINOR_VERSION >= 1 || VersionFinder.JAVA_SUB_VERSION >= 4) && !VersionFinder.JAVA_IS_EA_VERSION) || (VersionFinder.JAVA_MAJOR_VERSION == 12 && (VersionFinder.JAVA_MINOR_VERSION >= 1 || VersionFinder.JAVA_SUB_VERSION >= 2) && !VersionFinder.JAVA_IS_EA_VERSION) || (VersionFinder.JAVA_MAJOR_VERSION == 13 && !VersionFinder.JAVA_IS_EA_VERSION) || VersionFinder.JAVA_MAJOR_VERSION > 13) { // Invoke with doPrivileged -- see: // http://mail.openjdk.java.net/pipermail/jigsaw-dev/2018-October/013974.html stackClasses = AccessController.doPrivileged(new PrivilegedAction<Class<?>[]>() { @Override public Class<?>[] run() { return getCallStackViaStackWalker(); } }); } // For JRE 7 and 8, use SecurityManager to get call stack if (stackClasses == null || stackClasses.length == 0) { stackClasses = AccessController.doPrivileged(new PrivilegedAction<Class<?>[]>() { @Override public Class<?>[] run() { return getCallStackViaSecurityManager(log); } }); } // As a fallback, use getStackTrace() to try to get the call stack if (stackClasses == null || stackClasses.length == 0) { StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); if (stackTrace == null || stackTrace.length == 0) { try { throw new Exception(); } catch (final Exception e) { stackTrace = e.getStackTrace(); } } final List<Class<?>> stackClassesList = new ArrayList<>(); for (final StackTraceElement elt : stackTrace) { try { stackClassesList.add(Class.forName(elt.getClassName())); } catch (final ClassNotFoundException | LinkageError ignored) { // Ignored } } if (!stackClassesList.isEmpty()) { stackClasses = stackClassesList.toArray(new Class<?>[0]); } else { // Last-ditch effort -- include just this class in the call stack stackClasses = new Class<?>[] { CallStackReader.class }; } } return stackClasses; }
[ "static", "Class", "<", "?", ">", "[", "]", "getClassContext", "(", "final", "LogNode", "log", ")", "{", "// For JRE 9+, use StackWalker to get call stack.", "// N.B. need to work around StackWalker bug fixed in JDK 13, and backported to 12.0.2 and 11.0.4", "// (probably introduced i...
Get the class context. @param log the log @return The classes in the call stack.
[ "Get", "the", "class", "context", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/classpath/CallStackReader.java#L143-L204
train
classgraph/classgraph
src/main/java/nonapi/io/github/classgraph/concurrency/SingletonMap.java
SingletonMap.values
public List<V> values() throws InterruptedException { final List<V> entries = new ArrayList<>(map.size()); for (final Entry<K, SingletonHolder<V>> ent : map.entrySet()) { final V entryValue = ent.getValue().get(); if (entryValue != null) { entries.add(entryValue); } } return entries; }
java
public List<V> values() throws InterruptedException { final List<V> entries = new ArrayList<>(map.size()); for (final Entry<K, SingletonHolder<V>> ent : map.entrySet()) { final V entryValue = ent.getValue().get(); if (entryValue != null) { entries.add(entryValue); } } return entries; }
[ "public", "List", "<", "V", ">", "values", "(", ")", "throws", "InterruptedException", "{", "final", "List", "<", "V", ">", "entries", "=", "new", "ArrayList", "<>", "(", "map", ".", "size", "(", ")", ")", ";", "for", "(", "final", "Entry", "<", "K...
Get all valid singleton values in the map. @return the singleton values in the map, skipping over any value for which newInstance() threw an exception or returned null. @throws InterruptedException If getting the values was interrupted.
[ "Get", "all", "valid", "singleton", "values", "in", "the", "map", "." ]
c8c8b2ca1eb76339f69193fdac33d735c864215c
https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/concurrency/SingletonMap.java#L212-L221
train