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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
brianwhu/xillium | base/src/main/java/org/xillium/base/beans/Strings.java | Strings.toHexString | public static String toHexString(byte[] raw) {
byte[] hex = new byte[2 * raw.length];
int index = 0;
for (byte b : raw) {
int v = b & 0x00ff;
hex[index++] = HEX_CHARS[v >>> 4];
hex[index++] = HEX_CHARS[v & 0xf];
}
try {
return new String(hex, "ASCII");
} catch (java.io.UnsupportedEncodingException x) {
throw new RuntimeException(x.getMessage(), x);
}
} | java | public static String toHexString(byte[] raw) {
byte[] hex = new byte[2 * raw.length];
int index = 0;
for (byte b : raw) {
int v = b & 0x00ff;
hex[index++] = HEX_CHARS[v >>> 4];
hex[index++] = HEX_CHARS[v & 0xf];
}
try {
return new String(hex, "ASCII");
} catch (java.io.UnsupportedEncodingException x) {
throw new RuntimeException(x.getMessage(), x);
}
} | [
"public",
"static",
"String",
"toHexString",
"(",
"byte",
"[",
"]",
"raw",
")",
"{",
"byte",
"[",
"]",
"hex",
"=",
"new",
"byte",
"[",
"2",
"*",
"raw",
".",
"length",
"]",
";",
"int",
"index",
"=",
"0",
";",
"for",
"(",
"byte",
"b",
":",
"raw",... | Converts an array of bytes into a hexadecimal representation.
This implementation is significantly faster than DatatypeConverter.printHexBinary().
@param raw the byte array to convert to a hexadecimal String
@return a hexadecimal String representing the bytes | [
"Converts",
"an",
"array",
"of",
"bytes",
"into",
"a",
"hexadecimal",
"representation",
"."
] | e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799 | https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/base/src/main/java/org/xillium/base/beans/Strings.java#L32-L45 | train |
brianwhu/xillium | base/src/main/java/org/xillium/base/beans/Strings.java | Strings.toCamelCase | public static String toCamelCase(String text, char separator, boolean strict) {
char[] chars = text.toCharArray();
int base = 0, top = 0;
while (top < chars.length) {
while (top < chars.length && chars[top] == separator) {
++top;
}
if (top < chars.length) {
chars[base++] = Character.toUpperCase(chars[top++]);
}
if (strict) {
while (top < chars.length && chars[top] != separator) {
chars[base++] = Character.toLowerCase(chars[top++]);
}
} else {
while (top < chars.length && chars[top] != separator) {
chars[base++] = chars[top++];
}
}
}
return new String(chars, 0, base);
} | java | public static String toCamelCase(String text, char separator, boolean strict) {
char[] chars = text.toCharArray();
int base = 0, top = 0;
while (top < chars.length) {
while (top < chars.length && chars[top] == separator) {
++top;
}
if (top < chars.length) {
chars[base++] = Character.toUpperCase(chars[top++]);
}
if (strict) {
while (top < chars.length && chars[top] != separator) {
chars[base++] = Character.toLowerCase(chars[top++]);
}
} else {
while (top < chars.length && chars[top] != separator) {
chars[base++] = chars[top++];
}
}
}
return new String(chars, 0, base);
} | [
"public",
"static",
"String",
"toCamelCase",
"(",
"String",
"text",
",",
"char",
"separator",
",",
"boolean",
"strict",
")",
"{",
"char",
"[",
"]",
"chars",
"=",
"text",
".",
"toCharArray",
"(",
")",
";",
"int",
"base",
"=",
"0",
",",
"top",
"=",
"0"... | Converts a word sequence into a single camel-case sequence.
@param text - a word sequence with the given separator
@param separator - a word separator
@param strict - if true, all letters following the first are forced into lower case in each word
@return a single camel-case word | [
"Converts",
"a",
"word",
"sequence",
"into",
"a",
"single",
"camel",
"-",
"case",
"sequence",
"."
] | e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799 | https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/base/src/main/java/org/xillium/base/beans/Strings.java#L76-L99 | train |
brianwhu/xillium | base/src/main/java/org/xillium/base/beans/Strings.java | Strings.toLowerCamelCase | public static String toLowerCamelCase(String text, char separator) {
char[] chars = text.toCharArray();
int base = 0, top = 0;
do {
while (top < chars.length && chars[top] != separator) {
chars[base++] = Character.toLowerCase(chars[top++]);
}
while (top < chars.length && chars[top] == separator) {
++top;
}
if (top < chars.length) {
chars[base++] = Character.toUpperCase(chars[top++]);
}
} while (top < chars.length);
return new String(chars, 0, base);
} | java | public static String toLowerCamelCase(String text, char separator) {
char[] chars = text.toCharArray();
int base = 0, top = 0;
do {
while (top < chars.length && chars[top] != separator) {
chars[base++] = Character.toLowerCase(chars[top++]);
}
while (top < chars.length && chars[top] == separator) {
++top;
}
if (top < chars.length) {
chars[base++] = Character.toUpperCase(chars[top++]);
}
} while (top < chars.length);
return new String(chars, 0, base);
} | [
"public",
"static",
"String",
"toLowerCamelCase",
"(",
"String",
"text",
",",
"char",
"separator",
")",
"{",
"char",
"[",
"]",
"chars",
"=",
"text",
".",
"toCharArray",
"(",
")",
";",
"int",
"base",
"=",
"0",
",",
"top",
"=",
"0",
";",
"do",
"{",
"... | Converts a word sequence into a single camel-case word that starts with a lowercase letter.
@param text - a word sequence with the given separator
@param separator - a word separator
@return a single camel-case word | [
"Converts",
"a",
"word",
"sequence",
"into",
"a",
"single",
"camel",
"-",
"case",
"word",
"that",
"starts",
"with",
"a",
"lowercase",
"letter",
"."
] | e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799 | https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/base/src/main/java/org/xillium/base/beans/Strings.java#L108-L125 | train |
brianwhu/xillium | base/src/main/java/org/xillium/base/beans/Strings.java | Strings.splitCamelCase | public static String splitCamelCase(String text, String separator) {
return CAMEL_REGEX.matcher(text).replaceAll(separator);
} | java | public static String splitCamelCase(String text, String separator) {
return CAMEL_REGEX.matcher(text).replaceAll(separator);
} | [
"public",
"static",
"String",
"splitCamelCase",
"(",
"String",
"text",
",",
"String",
"separator",
")",
"{",
"return",
"CAMEL_REGEX",
".",
"matcher",
"(",
"text",
")",
".",
"replaceAll",
"(",
"separator",
")",
";",
"}"
] | Splits a single camel-case word into a word sequence.
@param text - a single camel-case word
@param separator - a word separator
@return a word sequence with each word separated by the given separator | [
"Splits",
"a",
"single",
"camel",
"-",
"case",
"word",
"into",
"a",
"word",
"sequence",
"."
] | e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799 | https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/base/src/main/java/org/xillium/base/beans/Strings.java#L138-L140 | train |
brianwhu/xillium | base/src/main/java/org/xillium/base/beans/Strings.java | Strings.hash | public static String hash(String text) throws NoSuchAlgorithmException, UnsupportedEncodingException {
return Strings.toHexString(MessageDigest.getInstance("SHA").digest(text.getBytes("UTF-8")));
} | java | public static String hash(String text) throws NoSuchAlgorithmException, UnsupportedEncodingException {
return Strings.toHexString(MessageDigest.getInstance("SHA").digest(text.getBytes("UTF-8")));
} | [
"public",
"static",
"String",
"hash",
"(",
"String",
"text",
")",
"throws",
"NoSuchAlgorithmException",
",",
"UnsupportedEncodingException",
"{",
"return",
"Strings",
".",
"toHexString",
"(",
"MessageDigest",
".",
"getInstance",
"(",
"\"SHA\"",
")",
".",
"digest",
... | Generates a secure hash from a given text.
@param text - any text string
@return the SHA-1 hash as a hexadecimal string
@throws NoSuchAlgorithmException if the Java platform does not support SHA-1 algorithm
@throws UnsupportedEncodingException if the Java platform does not support UTF-8 encoding | [
"Generates",
"a",
"secure",
"hash",
"from",
"a",
"given",
"text",
"."
] | e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799 | https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/base/src/main/java/org/xillium/base/beans/Strings.java#L162-L164 | train |
brianwhu/xillium | base/src/main/java/org/xillium/base/beans/Strings.java | Strings.extend | public static String extend(String text, char filler, int length) {
if (text.length() < length) {
char[] buffer = new char[length];
Arrays.fill(buffer, 0, length, filler);
System.arraycopy(text.toCharArray(), 0, buffer, 0, text.length());
return new String(buffer);
} else {
return text;
}
} | java | public static String extend(String text, char filler, int length) {
if (text.length() < length) {
char[] buffer = new char[length];
Arrays.fill(buffer, 0, length, filler);
System.arraycopy(text.toCharArray(), 0, buffer, 0, text.length());
return new String(buffer);
} else {
return text;
}
} | [
"public",
"static",
"String",
"extend",
"(",
"String",
"text",
",",
"char",
"filler",
",",
"int",
"length",
")",
"{",
"if",
"(",
"text",
".",
"length",
"(",
")",
"<",
"length",
")",
"{",
"char",
"[",
"]",
"buffer",
"=",
"new",
"char",
"[",
"length"... | Extends a string to have at least the given length. If the original string is already as long, it is returned
without modification.
@param text - a text string
@param filler - the filler character
@param length - the specified length
@return the extended string | [
"Extends",
"a",
"string",
"to",
"have",
"at",
"least",
"the",
"given",
"length",
".",
"If",
"the",
"original",
"string",
"is",
"already",
"as",
"long",
"it",
"is",
"returned",
"without",
"modification",
"."
] | e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799 | https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/base/src/main/java/org/xillium/base/beans/Strings.java#L175-L184 | train |
brianwhu/xillium | base/src/main/java/org/xillium/base/beans/Strings.java | Strings.substringBefore | public static String substringBefore(String text, char stopper) {
int p = text.indexOf(stopper);
return p < 0 ? text : text.substring(0, p);
} | java | public static String substringBefore(String text, char stopper) {
int p = text.indexOf(stopper);
return p < 0 ? text : text.substring(0, p);
} | [
"public",
"static",
"String",
"substringBefore",
"(",
"String",
"text",
",",
"char",
"stopper",
")",
"{",
"int",
"p",
"=",
"text",
".",
"indexOf",
"(",
"stopper",
")",
";",
"return",
"p",
"<",
"0",
"?",
"text",
":",
"text",
".",
"substring",
"(",
"0"... | Returns a substring from position 0 up to just before the stopper character.
@param text - a text string
@param stopper - a stopper character
@return the substring | [
"Returns",
"a",
"substring",
"from",
"position",
"0",
"up",
"to",
"just",
"before",
"the",
"stopper",
"character",
"."
] | e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799 | https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/base/src/main/java/org/xillium/base/beans/Strings.java#L193-L196 | train |
brianwhu/xillium | base/src/main/java/org/xillium/base/beans/Strings.java | Strings.substringAfter | public static String substringAfter(String text, char match) {
return text.substring(text.indexOf(match)+1);
} | java | public static String substringAfter(String text, char match) {
return text.substring(text.indexOf(match)+1);
} | [
"public",
"static",
"String",
"substringAfter",
"(",
"String",
"text",
",",
"char",
"match",
")",
"{",
"return",
"text",
".",
"substring",
"(",
"text",
".",
"indexOf",
"(",
"match",
")",
"+",
"1",
")",
";",
"}"
] | Returns the substring following a given character, or the original if the character is not found.
@param text - a text string
@param match - a match character
@return the substring | [
"Returns",
"the",
"substring",
"following",
"a",
"given",
"character",
"or",
"the",
"original",
"if",
"the",
"character",
"is",
"not",
"found",
"."
] | e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799 | https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/base/src/main/java/org/xillium/base/beans/Strings.java#L205-L207 | train |
brianwhu/xillium | base/src/main/java/org/xillium/base/beans/Strings.java | Strings.join | public static String join(Object array, char separator, Object... pieces) {
StringBuilder sb = new StringBuilder();
for (int i = 0, ii = Array.getLength(array); i < ii; ++i) {
Object element = Array.get(array, i);
sb.append(element != null ? element.toString() : "null").append(separator);
}
for (int i = 0; i < pieces.length; ++i) {
sb.append(pieces[i] != null ? pieces[i].toString() : "null").append(separator);
}
if (sb.length() > 0) sb.setLength(sb.length()-1);
return sb.toString();
} | java | public static String join(Object array, char separator, Object... pieces) {
StringBuilder sb = new StringBuilder();
for (int i = 0, ii = Array.getLength(array); i < ii; ++i) {
Object element = Array.get(array, i);
sb.append(element != null ? element.toString() : "null").append(separator);
}
for (int i = 0; i < pieces.length; ++i) {
sb.append(pieces[i] != null ? pieces[i].toString() : "null").append(separator);
}
if (sb.length() > 0) sb.setLength(sb.length()-1);
return sb.toString();
} | [
"public",
"static",
"String",
"join",
"(",
"Object",
"array",
",",
"char",
"separator",
",",
"Object",
"...",
"pieces",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"ii",
"=",
"Ar... | Concatenates elements in an array into a single String, with elements separated by the given separator.
@param array - an array
@param separator - a separator character
@return the string from joining elements in the array | [
"Concatenates",
"elements",
"in",
"an",
"array",
"into",
"a",
"single",
"String",
"with",
"elements",
"separated",
"by",
"the",
"given",
"separator",
"."
] | e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799 | https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/base/src/main/java/org/xillium/base/beans/Strings.java#L347-L358 | train |
brianwhu/xillium | base/src/main/java/org/xillium/base/beans/Strings.java | Strings.join | public static <T> String join(Iterable<T> iterable, char separator, T... pieces) {
StringBuilder sb = new StringBuilder();
for (T element: iterable) {
sb.append(element != null ? element.toString() : "null").append(separator);
}
for (int i = 0; i < pieces.length; ++i) {
sb.append(pieces[i] != null ? pieces[i].toString() : "null").append(separator);
}
if (sb.length() > 0) sb.setLength(sb.length()-1);
return sb.toString();
} | java | public static <T> String join(Iterable<T> iterable, char separator, T... pieces) {
StringBuilder sb = new StringBuilder();
for (T element: iterable) {
sb.append(element != null ? element.toString() : "null").append(separator);
}
for (int i = 0; i < pieces.length; ++i) {
sb.append(pieces[i] != null ? pieces[i].toString() : "null").append(separator);
}
if (sb.length() > 0) sb.setLength(sb.length()-1);
return sb.toString();
} | [
"public",
"static",
"<",
"T",
">",
"String",
"join",
"(",
"Iterable",
"<",
"T",
">",
"iterable",
",",
"char",
"separator",
",",
"T",
"...",
"pieces",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"T",
"eleme... | Concatenates elements in an Iterable into a single String, with elements separated by the given separator.
@param <T> - the type of the elements in the iterable
@param iterable - an iterable
@param separator - a separator character
@return the string from joining elements in the iterable | [
"Concatenates",
"elements",
"in",
"an",
"Iterable",
"into",
"a",
"single",
"String",
"with",
"elements",
"separated",
"by",
"the",
"given",
"separator",
"."
] | e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799 | https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/base/src/main/java/org/xillium/base/beans/Strings.java#L368-L378 | train |
seedstack/shed | src/main/java/org/seedstack/shed/reflect/Types.java | Types.rawClassOf | public static Class<?> rawClassOf(Type type) {
if (type instanceof Class<?>) {
return (Class<?>) type;
} else if (type instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType) type;
Type rawType = parameterizedType.getRawType();
return (Class<?>) rawType;
} else if (type instanceof GenericArrayType) {
Type componentType = ((GenericArrayType) type).getGenericComponentType();
return Array.newInstance(rawClassOf(componentType), 0).getClass();
} else if (type instanceof TypeVariable) {
return Object.class;
} else {
throw new IllegalArgumentException("Unsupported type " + type.getTypeName());
}
} | java | public static Class<?> rawClassOf(Type type) {
if (type instanceof Class<?>) {
return (Class<?>) type;
} else if (type instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType) type;
Type rawType = parameterizedType.getRawType();
return (Class<?>) rawType;
} else if (type instanceof GenericArrayType) {
Type componentType = ((GenericArrayType) type).getGenericComponentType();
return Array.newInstance(rawClassOf(componentType), 0).getClass();
} else if (type instanceof TypeVariable) {
return Object.class;
} else {
throw new IllegalArgumentException("Unsupported type " + type.getTypeName());
}
} | [
"public",
"static",
"Class",
"<",
"?",
">",
"rawClassOf",
"(",
"Type",
"type",
")",
"{",
"if",
"(",
"type",
"instanceof",
"Class",
"<",
"?",
">",
")",
"{",
"return",
"(",
"Class",
"<",
"?",
">",
")",
"type",
";",
"}",
"else",
"if",
"(",
"type",
... | Returns the raw class of the specified type.
@param type the type.
@return the raw class. | [
"Returns",
"the",
"raw",
"class",
"of",
"the",
"specified",
"type",
"."
] | 49ecb25aa3777539ab0f29f89abaae5ee93b572e | https://github.com/seedstack/shed/blob/49ecb25aa3777539ab0f29f89abaae5ee93b572e/src/main/java/org/seedstack/shed/reflect/Types.java#L41-L56 | train |
seedstack/shed | src/main/java/org/seedstack/shed/reflect/ClassPredicates.java | ClassPredicates.classIs | public static Predicate<Class<?>> classIs(final Class<?> reference) {
return candidate -> candidate != null && candidate.equals(reference);
} | java | public static Predicate<Class<?>> classIs(final Class<?> reference) {
return candidate -> candidate != null && candidate.equals(reference);
} | [
"public",
"static",
"Predicate",
"<",
"Class",
"<",
"?",
">",
">",
"classIs",
"(",
"final",
"Class",
"<",
"?",
">",
"reference",
")",
"{",
"return",
"candidate",
"->",
"candidate",
"!=",
"null",
"&&",
"candidate",
".",
"equals",
"(",
"reference",
")",
... | Checks if a candidate class is equal to the specified class.
@param reference the class to check for.
@return the predicate. | [
"Checks",
"if",
"a",
"candidate",
"class",
"is",
"equal",
"to",
"the",
"specified",
"class",
"."
] | 49ecb25aa3777539ab0f29f89abaae5ee93b572e | https://github.com/seedstack/shed/blob/49ecb25aa3777539ab0f29f89abaae5ee93b572e/src/main/java/org/seedstack/shed/reflect/ClassPredicates.java#L25-L27 | train |
seedstack/shed | src/main/java/org/seedstack/shed/reflect/ClassPredicates.java | ClassPredicates.classIsAssignableFrom | public static Predicate<Class<?>> classIsAssignableFrom(Class<?> ancestor) {
return candidate -> candidate != null && ancestor.isAssignableFrom(candidate);
} | java | public static Predicate<Class<?>> classIsAssignableFrom(Class<?> ancestor) {
return candidate -> candidate != null && ancestor.isAssignableFrom(candidate);
} | [
"public",
"static",
"Predicate",
"<",
"Class",
"<",
"?",
">",
">",
"classIsAssignableFrom",
"(",
"Class",
"<",
"?",
">",
"ancestor",
")",
"{",
"return",
"candidate",
"->",
"candidate",
"!=",
"null",
"&&",
"ancestor",
".",
"isAssignableFrom",
"(",
"candidate"... | Check if a candidate class is assignable to the specified class.
@param ancestor the class to check for.
@return the predicate. | [
"Check",
"if",
"a",
"candidate",
"class",
"is",
"assignable",
"to",
"the",
"specified",
"class",
"."
] | 49ecb25aa3777539ab0f29f89abaae5ee93b572e | https://github.com/seedstack/shed/blob/49ecb25aa3777539ab0f29f89abaae5ee93b572e/src/main/java/org/seedstack/shed/reflect/ClassPredicates.java#L35-L37 | train |
seedstack/shed | src/main/java/org/seedstack/shed/reflect/ClassPredicates.java | ClassPredicates.classImplements | public static Predicate<Class<?>> classImplements(Class<?> anInterface) {
if (!anInterface.isInterface()) {
throw new IllegalArgumentException("Class " + anInterface.getName() + " is not an interface");
}
return candidate -> candidate != null && !candidate.isInterface() && anInterface
.isAssignableFrom(candidate);
} | java | public static Predicate<Class<?>> classImplements(Class<?> anInterface) {
if (!anInterface.isInterface()) {
throw new IllegalArgumentException("Class " + anInterface.getName() + " is not an interface");
}
return candidate -> candidate != null && !candidate.isInterface() && anInterface
.isAssignableFrom(candidate);
} | [
"public",
"static",
"Predicate",
"<",
"Class",
"<",
"?",
">",
">",
"classImplements",
"(",
"Class",
"<",
"?",
">",
"anInterface",
")",
"{",
"if",
"(",
"!",
"anInterface",
".",
"isInterface",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
... | Checks if a candidate class is an interface.
@return the predicate. | [
"Checks",
"if",
"a",
"candidate",
"class",
"is",
"an",
"interface",
"."
] | 49ecb25aa3777539ab0f29f89abaae5ee93b572e | https://github.com/seedstack/shed/blob/49ecb25aa3777539ab0f29f89abaae5ee93b572e/src/main/java/org/seedstack/shed/reflect/ClassPredicates.java#L56-L62 | train |
seedstack/shed | src/main/java/org/seedstack/shed/reflect/ClassPredicates.java | ClassPredicates.executableModifierIs | public static <T extends Executable> Predicate<T> executableModifierIs(final int modifier) {
return candidate -> (candidate.getModifiers() & modifier) != 0;
} | java | public static <T extends Executable> Predicate<T> executableModifierIs(final int modifier) {
return candidate -> (candidate.getModifiers() & modifier) != 0;
} | [
"public",
"static",
"<",
"T",
"extends",
"Executable",
">",
"Predicate",
"<",
"T",
">",
"executableModifierIs",
"(",
"final",
"int",
"modifier",
")",
"{",
"return",
"candidate",
"->",
"(",
"candidate",
".",
"getModifiers",
"(",
")",
"&",
"modifier",
")",
"... | Checks if a candidate class has the specified modifier.
@param modifier the modifier to check for.
@return the predicate. | [
"Checks",
"if",
"a",
"candidate",
"class",
"has",
"the",
"specified",
"modifier",
"."
] | 49ecb25aa3777539ab0f29f89abaae5ee93b572e | https://github.com/seedstack/shed/blob/49ecb25aa3777539ab0f29f89abaae5ee93b572e/src/main/java/org/seedstack/shed/reflect/ClassPredicates.java#L98-L100 | train |
seedstack/shed | src/main/java/org/seedstack/shed/reflect/ClassPredicates.java | ClassPredicates.atLeastOneConstructorIsPublic | public static Predicate<Class<?>> atLeastOneConstructorIsPublic() {
return candidate -> candidate != null && Classes.from(candidate)
.constructors()
.anyMatch(executableModifierIs(Modifier.PUBLIC));
} | java | public static Predicate<Class<?>> atLeastOneConstructorIsPublic() {
return candidate -> candidate != null && Classes.from(candidate)
.constructors()
.anyMatch(executableModifierIs(Modifier.PUBLIC));
} | [
"public",
"static",
"Predicate",
"<",
"Class",
"<",
"?",
">",
">",
"atLeastOneConstructorIsPublic",
"(",
")",
"{",
"return",
"candidate",
"->",
"candidate",
"!=",
"null",
"&&",
"Classes",
".",
"from",
"(",
"candidate",
")",
".",
"constructors",
"(",
")",
"... | Checks if a candidate class has at least one public constructor.
@return the predicate. | [
"Checks",
"if",
"a",
"candidate",
"class",
"has",
"at",
"least",
"one",
"public",
"constructor",
"."
] | 49ecb25aa3777539ab0f29f89abaae5ee93b572e | https://github.com/seedstack/shed/blob/49ecb25aa3777539ab0f29f89abaae5ee93b572e/src/main/java/org/seedstack/shed/reflect/ClassPredicates.java#L116-L120 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/documents/Workbook.java | Workbook.getOffset | protected int getOffset(long dt)
{
int ret = 0;
TimeZone tz = DateUtilities.getCurrentTimeZone();
if(tz != null)
ret = tz.getOffset(dt);
return ret;
} | java | protected int getOffset(long dt)
{
int ret = 0;
TimeZone tz = DateUtilities.getCurrentTimeZone();
if(tz != null)
ret = tz.getOffset(dt);
return ret;
} | [
"protected",
"int",
"getOffset",
"(",
"long",
"dt",
")",
"{",
"int",
"ret",
"=",
"0",
";",
"TimeZone",
"tz",
"=",
"DateUtilities",
".",
"getCurrentTimeZone",
"(",
")",
";",
"if",
"(",
"tz",
"!=",
"null",
")",
"ret",
"=",
"tz",
".",
"getOffset",
"(",
... | Returns the current offset for the given date allowing for daylight savings.
@param dt The date to be checked
@return The current offset for the given date allowing for daylight savings | [
"Returns",
"the",
"current",
"offset",
"for",
"the",
"given",
"date",
"allowing",
"for",
"daylight",
"savings",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/documents/Workbook.java#L189-L196 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java | Util.isDeprecated | public static boolean isDeprecated(Doc doc) {
if (doc.tags("deprecated").length > 0) {
return true;
}
AnnotationDesc[] annotationDescList;
if (doc instanceof PackageDoc)
annotationDescList = ((PackageDoc)doc).annotations();
else
annotationDescList = ((ProgramElementDoc)doc).annotations();
for (int i = 0; i < annotationDescList.length; i++) {
if (annotationDescList[i].annotationType().qualifiedName().equals(
java.lang.Deprecated.class.getName())){
return true;
}
}
return false;
} | java | public static boolean isDeprecated(Doc doc) {
if (doc.tags("deprecated").length > 0) {
return true;
}
AnnotationDesc[] annotationDescList;
if (doc instanceof PackageDoc)
annotationDescList = ((PackageDoc)doc).annotations();
else
annotationDescList = ((ProgramElementDoc)doc).annotations();
for (int i = 0; i < annotationDescList.length; i++) {
if (annotationDescList[i].annotationType().qualifiedName().equals(
java.lang.Deprecated.class.getName())){
return true;
}
}
return false;
} | [
"public",
"static",
"boolean",
"isDeprecated",
"(",
"Doc",
"doc",
")",
"{",
"if",
"(",
"doc",
".",
"tags",
"(",
"\"deprecated\"",
")",
".",
"length",
">",
"0",
")",
"{",
"return",
"true",
";",
"}",
"AnnotationDesc",
"[",
"]",
"annotationDescList",
";",
... | Return true if the given Doc is deprecated.
@param doc the Doc to check.
@return true if the given Doc is deprecated. | [
"Return",
"true",
"if",
"the",
"given",
"Doc",
"is",
"deprecated",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java#L704-L720 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java | Util.propertyNameFromMethodName | public static String propertyNameFromMethodName(Configuration configuration, String name) {
String propertyName = null;
if (name.startsWith("get") || name.startsWith("set")) {
propertyName = name.substring(3);
} else if (name.startsWith("is")) {
propertyName = name.substring(2);
}
if ((propertyName == null) || propertyName.isEmpty()){
return "";
}
return propertyName.substring(0, 1).toLowerCase(configuration.getLocale())
+ propertyName.substring(1);
} | java | public static String propertyNameFromMethodName(Configuration configuration, String name) {
String propertyName = null;
if (name.startsWith("get") || name.startsWith("set")) {
propertyName = name.substring(3);
} else if (name.startsWith("is")) {
propertyName = name.substring(2);
}
if ((propertyName == null) || propertyName.isEmpty()){
return "";
}
return propertyName.substring(0, 1).toLowerCase(configuration.getLocale())
+ propertyName.substring(1);
} | [
"public",
"static",
"String",
"propertyNameFromMethodName",
"(",
"Configuration",
"configuration",
",",
"String",
"name",
")",
"{",
"String",
"propertyName",
"=",
"null",
";",
"if",
"(",
"name",
".",
"startsWith",
"(",
"\"get\"",
")",
"||",
"name",
".",
"start... | A convenience method to get property name from the name of the
getter or setter method.
@param name name of the getter or setter method.
@return the name of the property of the given setter of getter. | [
"A",
"convenience",
"method",
"to",
"get",
"property",
"name",
"from",
"the",
"name",
"of",
"the",
"getter",
"or",
"setter",
"method",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java#L728-L740 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java | Util.isJava5DeclarationElementType | public static boolean isJava5DeclarationElementType(FieldDoc elt) {
return elt.name().contentEquals(ElementType.ANNOTATION_TYPE.name()) ||
elt.name().contentEquals(ElementType.CONSTRUCTOR.name()) ||
elt.name().contentEquals(ElementType.FIELD.name()) ||
elt.name().contentEquals(ElementType.LOCAL_VARIABLE.name()) ||
elt.name().contentEquals(ElementType.METHOD.name()) ||
elt.name().contentEquals(ElementType.PACKAGE.name()) ||
elt.name().contentEquals(ElementType.PARAMETER.name()) ||
elt.name().contentEquals(ElementType.TYPE.name());
} | java | public static boolean isJava5DeclarationElementType(FieldDoc elt) {
return elt.name().contentEquals(ElementType.ANNOTATION_TYPE.name()) ||
elt.name().contentEquals(ElementType.CONSTRUCTOR.name()) ||
elt.name().contentEquals(ElementType.FIELD.name()) ||
elt.name().contentEquals(ElementType.LOCAL_VARIABLE.name()) ||
elt.name().contentEquals(ElementType.METHOD.name()) ||
elt.name().contentEquals(ElementType.PACKAGE.name()) ||
elt.name().contentEquals(ElementType.PARAMETER.name()) ||
elt.name().contentEquals(ElementType.TYPE.name());
} | [
"public",
"static",
"boolean",
"isJava5DeclarationElementType",
"(",
"FieldDoc",
"elt",
")",
"{",
"return",
"elt",
".",
"name",
"(",
")",
".",
"contentEquals",
"(",
"ElementType",
".",
"ANNOTATION_TYPE",
".",
"name",
"(",
")",
")",
"||",
"elt",
".",
"name",
... | Test whether the given FieldDoc is one of the declaration annotation ElementTypes
defined in Java 5.
Instead of testing for one of the new enum constants added in Java 8, test for
the old constants. This prevents bootstrapping problems.
@param elt The FieldDoc to test
@return true, iff the given ElementType is one of the constants defined in Java 5
@since 1.8 | [
"Test",
"whether",
"the",
"given",
"FieldDoc",
"is",
"one",
"of",
"the",
"declaration",
"annotation",
"ElementTypes",
"defined",
"in",
"Java",
"5",
".",
"Instead",
"of",
"testing",
"for",
"one",
"of",
"the",
"new",
"enum",
"constants",
"added",
"in",
"Java",... | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java#L782-L791 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/jvm/Gen.java | Gen.normalizeMethod | void normalizeMethod(JCMethodDecl md, List<JCStatement> initCode, List<TypeCompound> initTAs) {
if (md.name == names.init && TreeInfo.isInitialConstructor(md)) {
// We are seeing a constructor that does not call another
// constructor of the same class.
List<JCStatement> stats = md.body.stats;
ListBuffer<JCStatement> newstats = new ListBuffer<JCStatement>();
if (stats.nonEmpty()) {
// Copy initializers of synthetic variables generated in
// the translation of inner classes.
while (TreeInfo.isSyntheticInit(stats.head)) {
newstats.append(stats.head);
stats = stats.tail;
}
// Copy superclass constructor call
newstats.append(stats.head);
stats = stats.tail;
// Copy remaining synthetic initializers.
while (stats.nonEmpty() &&
TreeInfo.isSyntheticInit(stats.head)) {
newstats.append(stats.head);
stats = stats.tail;
}
// Now insert the initializer code.
newstats.appendList(initCode);
// And copy all remaining statements.
while (stats.nonEmpty()) {
newstats.append(stats.head);
stats = stats.tail;
}
}
md.body.stats = newstats.toList();
if (md.body.endpos == Position.NOPOS)
md.body.endpos = TreeInfo.endPos(md.body.stats.last());
md.sym.appendUniqueTypeAttributes(initTAs);
}
} | java | void normalizeMethod(JCMethodDecl md, List<JCStatement> initCode, List<TypeCompound> initTAs) {
if (md.name == names.init && TreeInfo.isInitialConstructor(md)) {
// We are seeing a constructor that does not call another
// constructor of the same class.
List<JCStatement> stats = md.body.stats;
ListBuffer<JCStatement> newstats = new ListBuffer<JCStatement>();
if (stats.nonEmpty()) {
// Copy initializers of synthetic variables generated in
// the translation of inner classes.
while (TreeInfo.isSyntheticInit(stats.head)) {
newstats.append(stats.head);
stats = stats.tail;
}
// Copy superclass constructor call
newstats.append(stats.head);
stats = stats.tail;
// Copy remaining synthetic initializers.
while (stats.nonEmpty() &&
TreeInfo.isSyntheticInit(stats.head)) {
newstats.append(stats.head);
stats = stats.tail;
}
// Now insert the initializer code.
newstats.appendList(initCode);
// And copy all remaining statements.
while (stats.nonEmpty()) {
newstats.append(stats.head);
stats = stats.tail;
}
}
md.body.stats = newstats.toList();
if (md.body.endpos == Position.NOPOS)
md.body.endpos = TreeInfo.endPos(md.body.stats.last());
md.sym.appendUniqueTypeAttributes(initTAs);
}
} | [
"void",
"normalizeMethod",
"(",
"JCMethodDecl",
"md",
",",
"List",
"<",
"JCStatement",
">",
"initCode",
",",
"List",
"<",
"TypeCompound",
">",
"initTAs",
")",
"{",
"if",
"(",
"md",
".",
"name",
"==",
"names",
".",
"init",
"&&",
"TreeInfo",
".",
"isInitia... | Insert instance initializer code into initial constructor.
@param md The tree potentially representing a
constructor's definition.
@param initCode The list of instance initializer statements.
@param initTAs Type annotations from the initializer expression. | [
"Insert",
"instance",
"initializer",
"code",
"into",
"initial",
"constructor",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/jvm/Gen.java#L601-L638 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/jvm/Gen.java | Gen.implementInterfaceMethods | void implementInterfaceMethods(ClassSymbol c, ClassSymbol site) {
for (List<Type> l = types.interfaces(c.type); l.nonEmpty(); l = l.tail) {
ClassSymbol i = (ClassSymbol)l.head.tsym;
for (Scope.Entry e = i.members().elems;
e != null;
e = e.sibling)
{
if (e.sym.kind == MTH && (e.sym.flags() & STATIC) == 0)
{
MethodSymbol absMeth = (MethodSymbol)e.sym;
MethodSymbol implMeth = absMeth.binaryImplementation(site, types);
if (implMeth == null)
addAbstractMethod(site, absMeth);
else if ((implMeth.flags() & IPROXY) != 0)
adjustAbstractMethod(site, implMeth, absMeth);
}
}
implementInterfaceMethods(i, site);
}
} | java | void implementInterfaceMethods(ClassSymbol c, ClassSymbol site) {
for (List<Type> l = types.interfaces(c.type); l.nonEmpty(); l = l.tail) {
ClassSymbol i = (ClassSymbol)l.head.tsym;
for (Scope.Entry e = i.members().elems;
e != null;
e = e.sibling)
{
if (e.sym.kind == MTH && (e.sym.flags() & STATIC) == 0)
{
MethodSymbol absMeth = (MethodSymbol)e.sym;
MethodSymbol implMeth = absMeth.binaryImplementation(site, types);
if (implMeth == null)
addAbstractMethod(site, absMeth);
else if ((implMeth.flags() & IPROXY) != 0)
adjustAbstractMethod(site, implMeth, absMeth);
}
}
implementInterfaceMethods(i, site);
}
} | [
"void",
"implementInterfaceMethods",
"(",
"ClassSymbol",
"c",
",",
"ClassSymbol",
"site",
")",
"{",
"for",
"(",
"List",
"<",
"Type",
">",
"l",
"=",
"types",
".",
"interfaces",
"(",
"c",
".",
"type",
")",
";",
"l",
".",
"nonEmpty",
"(",
")",
";",
"l",... | Add abstract methods for all methods defined in one of
the interfaces of a given class,
provided they are not already implemented in the class.
@param c The class whose interfaces are searched for methods
for which Miranda methods should be added.
@param site The class in which a definition may be needed. | [
"Add",
"abstract",
"methods",
"for",
"all",
"methods",
"defined",
"in",
"one",
"of",
"the",
"interfaces",
"of",
"a",
"given",
"class",
"provided",
"they",
"are",
"not",
"already",
"implemented",
"in",
"the",
"class",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/jvm/Gen.java#L663-L682 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/jvm/Gen.java | Gen.addAbstractMethod | private void addAbstractMethod(ClassSymbol c,
MethodSymbol m) {
MethodSymbol absMeth = new MethodSymbol(
m.flags() | IPROXY | SYNTHETIC, m.name,
m.type, // was c.type.memberType(m), but now only !generics supported
c);
c.members().enter(absMeth); // add to symbol table
} | java | private void addAbstractMethod(ClassSymbol c,
MethodSymbol m) {
MethodSymbol absMeth = new MethodSymbol(
m.flags() | IPROXY | SYNTHETIC, m.name,
m.type, // was c.type.memberType(m), but now only !generics supported
c);
c.members().enter(absMeth); // add to symbol table
} | [
"private",
"void",
"addAbstractMethod",
"(",
"ClassSymbol",
"c",
",",
"MethodSymbol",
"m",
")",
"{",
"MethodSymbol",
"absMeth",
"=",
"new",
"MethodSymbol",
"(",
"m",
".",
"flags",
"(",
")",
"|",
"IPROXY",
"|",
"SYNTHETIC",
",",
"m",
".",
"name",
",",
"m"... | Add an abstract methods to a class
which implicitly implements a method defined in some interface
implemented by the class. These methods are called "Miranda methods".
Enter the newly created method into its enclosing class scope.
Note that it is not entered into the class tree, as the emitter
doesn't need to see it there to emit an abstract method.
@param c The class to which the Miranda method is added.
@param m The interface method symbol for which a Miranda method
is added. | [
"Add",
"an",
"abstract",
"methods",
"to",
"a",
"class",
"which",
"implicitly",
"implements",
"a",
"method",
"defined",
"in",
"some",
"interface",
"implemented",
"by",
"the",
"class",
".",
"These",
"methods",
"are",
"called",
"Miranda",
"methods",
".",
"Enter",... | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/jvm/Gen.java#L695-L702 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/jvm/Gen.java | Gen.makeStringBuffer | void makeStringBuffer(DiagnosticPosition pos) {
code.emitop2(new_, makeRef(pos, stringBufferType));
code.emitop0(dup);
callMethod(
pos, stringBufferType, names.init, List.<Type>nil(), false);
} | java | void makeStringBuffer(DiagnosticPosition pos) {
code.emitop2(new_, makeRef(pos, stringBufferType));
code.emitop0(dup);
callMethod(
pos, stringBufferType, names.init, List.<Type>nil(), false);
} | [
"void",
"makeStringBuffer",
"(",
"DiagnosticPosition",
"pos",
")",
"{",
"code",
".",
"emitop2",
"(",
"new_",
",",
"makeRef",
"(",
"pos",
",",
"stringBufferType",
")",
")",
";",
"code",
".",
"emitop0",
"(",
"dup",
")",
";",
"callMethod",
"(",
"pos",
",",
... | Make a new string buffer. | [
"Make",
"a",
"new",
"string",
"buffer",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/jvm/Gen.java#L2159-L2164 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/jvm/Gen.java | Gen.appendStrings | void appendStrings(JCTree tree) {
tree = TreeInfo.skipParens(tree);
if (tree.hasTag(PLUS) && tree.type.constValue() == null) {
JCBinary op = (JCBinary) tree;
if (op.operator.kind == MTH &&
((OperatorSymbol) op.operator).opcode == string_add) {
appendStrings(op.lhs);
appendStrings(op.rhs);
return;
}
}
genExpr(tree, tree.type).load();
appendString(tree);
} | java | void appendStrings(JCTree tree) {
tree = TreeInfo.skipParens(tree);
if (tree.hasTag(PLUS) && tree.type.constValue() == null) {
JCBinary op = (JCBinary) tree;
if (op.operator.kind == MTH &&
((OperatorSymbol) op.operator).opcode == string_add) {
appendStrings(op.lhs);
appendStrings(op.rhs);
return;
}
}
genExpr(tree, tree.type).load();
appendString(tree);
} | [
"void",
"appendStrings",
"(",
"JCTree",
"tree",
")",
"{",
"tree",
"=",
"TreeInfo",
".",
"skipParens",
"(",
"tree",
")",
";",
"if",
"(",
"tree",
".",
"hasTag",
"(",
"PLUS",
")",
"&&",
"tree",
".",
"type",
".",
"constValue",
"(",
")",
"==",
"null",
"... | Add all strings in tree to string buffer. | [
"Add",
"all",
"strings",
"in",
"tree",
"to",
"string",
"buffer",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/jvm/Gen.java#L2192-L2205 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/jvm/Gen.java | Gen.bufferToString | void bufferToString(DiagnosticPosition pos) {
callMethod(
pos,
stringBufferType,
names.toString,
List.<Type>nil(),
false);
} | java | void bufferToString(DiagnosticPosition pos) {
callMethod(
pos,
stringBufferType,
names.toString,
List.<Type>nil(),
false);
} | [
"void",
"bufferToString",
"(",
"DiagnosticPosition",
"pos",
")",
"{",
"callMethod",
"(",
"pos",
",",
"stringBufferType",
",",
"names",
".",
"toString",
",",
"List",
".",
"<",
"Type",
">",
"nil",
"(",
")",
",",
"false",
")",
";",
"}"
] | Convert string buffer on tos to string. | [
"Convert",
"string",
"buffer",
"on",
"tos",
"to",
"string",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/jvm/Gen.java#L2209-L2216 | train |
devnull-tools/trugger | src/main/java/tools/devnull/trugger/element/Elements.java | Elements.getValue | public static <E> OptionalFunction<Selection<Element>, E> getValue() {
return OptionalFunction.of(selection -> selection.result().getValue());
} | java | public static <E> OptionalFunction<Selection<Element>, E> getValue() {
return OptionalFunction.of(selection -> selection.result().getValue());
} | [
"public",
"static",
"<",
"E",
">",
"OptionalFunction",
"<",
"Selection",
"<",
"Element",
">",
",",
"E",
">",
"getValue",
"(",
")",
"{",
"return",
"OptionalFunction",
".",
"of",
"(",
"selection",
"->",
"selection",
".",
"result",
"(",
")",
".",
"getValue"... | Returns a function that gets the value of a selected element.
@return a function that gets the value of a selected element. | [
"Returns",
"a",
"function",
"that",
"gets",
"the",
"value",
"of",
"a",
"selected",
"element",
"."
] | 614d5f0b30daf82fc251a46fb436d0fc5e787627 | https://github.com/devnull-tools/trugger/blob/614d5f0b30daf82fc251a46fb436d0fc5e787627/src/main/java/tools/devnull/trugger/element/Elements.java#L98-L100 | train |
devnull-tools/trugger | src/main/java/tools/devnull/trugger/element/Elements.java | Elements.setValue | public static Consumer<Selection<Element>> setValue(Object newValue) {
return selection -> selection.result().setValue(newValue);
} | java | public static Consumer<Selection<Element>> setValue(Object newValue) {
return selection -> selection.result().setValue(newValue);
} | [
"public",
"static",
"Consumer",
"<",
"Selection",
"<",
"Element",
">",
">",
"setValue",
"(",
"Object",
"newValue",
")",
"{",
"return",
"selection",
"->",
"selection",
".",
"result",
"(",
")",
".",
"setValue",
"(",
"newValue",
")",
";",
"}"
] | Returns a function that sets the value of a selected element.
@param newValue the value to set
@return a function that sets the value of a selected element. | [
"Returns",
"a",
"function",
"that",
"sets",
"the",
"value",
"of",
"a",
"selected",
"element",
"."
] | 614d5f0b30daf82fc251a46fb436d0fc5e787627 | https://github.com/devnull-tools/trugger/blob/614d5f0b30daf82fc251a46fb436d0fc5e787627/src/main/java/tools/devnull/trugger/element/Elements.java#L108-L110 | train |
qsardb/qsardb | model/src/main/java/org/qsardb/model/IdUtil.java | IdUtil.validate | static
public boolean validate(String id){
if(id.equals("")){
return false;
} else
if(id.equals(".") || id.equals("..")){
return false;
}
Matcher matcher = IdUtil.pattern.matcher(id);
return matcher.matches();
} | java | static
public boolean validate(String id){
if(id.equals("")){
return false;
} else
if(id.equals(".") || id.equals("..")){
return false;
}
Matcher matcher = IdUtil.pattern.matcher(id);
return matcher.matches();
} | [
"static",
"public",
"boolean",
"validate",
"(",
"String",
"id",
")",
"{",
"if",
"(",
"id",
".",
"equals",
"(",
"\"\"",
")",
")",
"{",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"id",
".",
"equals",
"(",
"\".\"",
")",
"||",
"id",
".",
"equals... | Verifies the correctness of an identifier.
A valid identifier consists of one or more visible US-ASCII characters,
except for the path delimiter characters '/', '\' and ':'.
<p>
Additionally, an identifier is considered invalid if it:
<ul>
<li>Equals to path components "." or "..".
</ul>
@see Container#getId()
@see Cargo#getId() | [
"Verifies",
"the",
"correctness",
"of",
"an",
"identifier",
"."
] | 9798f524abd973878b9040927aed8131885127fa | https://github.com/qsardb/qsardb/blob/9798f524abd973878b9040927aed8131885127fa/model/src/main/java/org/qsardb/model/IdUtil.java#L28-L42 | train |
wanglinsong/thx-android | uia-client/src/main/java/com/android/uiautomator/stub/UiSelector.java | UiSelector.buildSelector | private UiSelector buildSelector(int selectorId, Object selectorValue) {
if (selectorId == SELECTOR_CHILD || selectorId == SELECTOR_PARENT) {
throw new UnsupportedOperationException();
// selector.getLastSubSelector().mSelectorAttributes.put(selectorId, selectorValue);
} else {
this.mSelectorAttributes.put(selectorId, selectorValue);
}
return this;
} | java | private UiSelector buildSelector(int selectorId, Object selectorValue) {
if (selectorId == SELECTOR_CHILD || selectorId == SELECTOR_PARENT) {
throw new UnsupportedOperationException();
// selector.getLastSubSelector().mSelectorAttributes.put(selectorId, selectorValue);
} else {
this.mSelectorAttributes.put(selectorId, selectorValue);
}
return this;
} | [
"private",
"UiSelector",
"buildSelector",
"(",
"int",
"selectorId",
",",
"Object",
"selectorValue",
")",
"{",
"if",
"(",
"selectorId",
"==",
"SELECTOR_CHILD",
"||",
"selectorId",
"==",
"SELECTOR_PARENT",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"("... | Building a UiSelector always returns a new UiSelector and never modifies the
existing UiSelector being used. | [
"Building",
"a",
"UiSelector",
"always",
"returns",
"a",
"new",
"UiSelector",
"and",
"never",
"modifies",
"the",
"existing",
"UiSelector",
"being",
"used",
"."
] | 4a98c4181b3e8876e688591737da37627c07e72b | https://github.com/wanglinsong/thx-android/blob/4a98c4181b3e8876e688591737da37627c07e72b/uia-client/src/main/java/com/android/uiautomator/stub/UiSelector.java#L649-L657 | train |
magik6k/JWWF | src/main/java/net/magik6k/jwwf/core/UserData.java | UserData.get | public void get(String key, UserDataHandler handler) {
if (cache.containsKey(key)) {
try {
handler.data(key, cache.get(key));
} catch (Exception e) {
e.printStackTrace();
}
return;
}
user.sendGlobal("JWWF-storageGet", "{\"key\":" + Json.escapeString(key) + "}");
if (waitingHandlers.containsKey(key)) {
waitingHandlers.get(key).push(handler);
} else {
LinkedList<UserDataHandler> ll = new LinkedList<UserDataHandler>();
ll.push(handler);
waitingHandlers.put(key, ll);
}
} | java | public void get(String key, UserDataHandler handler) {
if (cache.containsKey(key)) {
try {
handler.data(key, cache.get(key));
} catch (Exception e) {
e.printStackTrace();
}
return;
}
user.sendGlobal("JWWF-storageGet", "{\"key\":" + Json.escapeString(key) + "}");
if (waitingHandlers.containsKey(key)) {
waitingHandlers.get(key).push(handler);
} else {
LinkedList<UserDataHandler> ll = new LinkedList<UserDataHandler>();
ll.push(handler);
waitingHandlers.put(key, ll);
}
} | [
"public",
"void",
"get",
"(",
"String",
"key",
",",
"UserDataHandler",
"handler",
")",
"{",
"if",
"(",
"cache",
".",
"containsKey",
"(",
"key",
")",
")",
"{",
"try",
"{",
"handler",
".",
"data",
"(",
"key",
",",
"cache",
".",
"get",
"(",
"key",
")"... | Gets userData string. if data exists in cache the callback is fired
immediately, if not async request is sent to user. If user don't have
requested data, empty string will arrive
@param key Requested key
@param handler Handler to be invoked when data arrives | [
"Gets",
"userData",
"string",
".",
"if",
"data",
"exists",
"in",
"cache",
"the",
"callback",
"is",
"fired",
"immediately",
"if",
"not",
"async",
"request",
"is",
"sent",
"to",
"user",
".",
"If",
"user",
"don",
"t",
"have",
"requested",
"data",
"empty",
"... | 8ba334501396c3301495da8708733f6014f20665 | https://github.com/magik6k/JWWF/blob/8ba334501396c3301495da8708733f6014f20665/src/main/java/net/magik6k/jwwf/core/UserData.java#L32-L51 | train |
magik6k/JWWF | src/main/java/net/magik6k/jwwf/core/UserData.java | UserData.set | public void set(String key, String value) {
cache.put(key, value);
user.sendGlobal("JWWF-storageSet", "{\"key\":" + Json.escapeString(key) + ",\"value\":" + Json.escapeString(value) + "}");
} | java | public void set(String key, String value) {
cache.put(key, value);
user.sendGlobal("JWWF-storageSet", "{\"key\":" + Json.escapeString(key) + ",\"value\":" + Json.escapeString(value) + "}");
} | [
"public",
"void",
"set",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"cache",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"user",
".",
"sendGlobal",
"(",
"\"JWWF-storageSet\"",
",",
"\"{\\\"key\\\":\"",
"+",
"Json",
".",
"escapeString",
"... | Sets userData for user, data is set in cache and sent to user
@param key Name of value
@param value Data to be set | [
"Sets",
"userData",
"for",
"user",
"data",
"is",
"set",
"in",
"cache",
"and",
"sent",
"to",
"user"
] | 8ba334501396c3301495da8708733f6014f20665 | https://github.com/magik6k/JWWF/blob/8ba334501396c3301495da8708733f6014f20665/src/main/java/net/magik6k/jwwf/core/UserData.java#L70-L73 | train |
brianwhu/xillium | core/src/main/java/org/xillium/core/util/Scriptable.java | Scriptable.setObjects | public void setObjects(Map<String, Object> objects) {
for (Map.Entry<String, Object> entry: objects.entrySet()) {
js.put(entry.getKey(), entry.getValue());
}
} | java | public void setObjects(Map<String, Object> objects) {
for (Map.Entry<String, Object> entry: objects.entrySet()) {
js.put(entry.getKey(), entry.getValue());
}
} | [
"public",
"void",
"setObjects",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"objects",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Object",
">",
"entry",
":",
"objects",
".",
"entrySet",
"(",
")",
")",
"{",
"js",
".",
"put",
... | Provides objects to the JavaScript engine under various names. | [
"Provides",
"objects",
"to",
"the",
"JavaScript",
"engine",
"under",
"various",
"names",
"."
] | e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799 | https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/core/src/main/java/org/xillium/core/util/Scriptable.java#L32-L36 | train |
petrbouda/joyrest | joyrest-core/src/main/java/org/joyrest/context/configurer/AbstractConfigurer.java | AbstractConfigurer.initializeContext | protected ApplicationContext initializeContext() {
Function<Class<Object>, List<Object>> getBeans = this::getBeans;
BeanFactory beanFactory = new BeanFactory(getBeans);
InitContext context = new InitContext();
AutoConfigurer.configureInitializers()
.forEach(initializer -> initializer.init(context, beanFactory));
List<AbstractReaderWriter> readersWriters = AutoConfigurer.configureReadersWriters();
ExceptionHandlerInterceptor exceptionHandlerInterceptor = new ExceptionHandlerInterceptor();
COMMON_INTERCEPTORS.add(exceptionHandlerInterceptor);
Map<Boolean, List<Reader>> readers = createTransformers(
concat(beanFactory.getAll(Reader.class), context.getReaders(), readersWriters));
Map<Boolean, List<Writer>> writers = createTransformers(
concat(beanFactory.getAll(Writer.class), context.getWriters(), readersWriters));
List<Interceptor> interceptors = sort(
concat(beanFactory.getAll(Interceptor.class), context.getInterceptors(), COMMON_INTERCEPTORS));
List<ExceptionConfiguration> handlers =
concat(beanFactory.getAll(ExceptionConfiguration.class), context.getExceptionConfigurations(), COMMON_HANDLERS);
List<ControllerConfiguration> controllers =
concat(beanFactory.getAll(ControllerConfiguration.class), context.getControllerConfigurations());
orderDuplicationCheck(interceptors);
Map<Class<? extends Exception>, InternalExceptionHandler> handlerMap =
handlers.stream()
.peek(ExceptionConfiguration::initialize)
.flatMap(config -> config.getExceptionHandlers().stream())
.peek(handler -> {
populateHandlerWriters(writers, handler, nonNull(handler.getResponseType()));
logExceptionHandler(handler);
})
.collect(toMap(InternalExceptionHandler::getExceptionClass, identity()));
context.setExceptionHandlers(handlerMap);
controllers.stream()
.peek(ControllerConfiguration::initialize)
.flatMap(config -> config.getRoutes().stream())
.peek(route -> {
route.interceptor(interceptors.toArray(new Interceptor[interceptors.size()]));
populateRouteReaders(readers, route);
populateRouteWriters(writers, route);
logRoute(route);
}).forEach(context::addRoute);
ApplicationContextImpl applicationContext = new ApplicationContextImpl();
applicationContext.setRoutes(context.getRoutes());
applicationContext.setExceptionHandlers(context.getExceptionHandlers());
exceptionHandlerInterceptor.setApplicationContext(applicationContext);
return applicationContext;
} | java | protected ApplicationContext initializeContext() {
Function<Class<Object>, List<Object>> getBeans = this::getBeans;
BeanFactory beanFactory = new BeanFactory(getBeans);
InitContext context = new InitContext();
AutoConfigurer.configureInitializers()
.forEach(initializer -> initializer.init(context, beanFactory));
List<AbstractReaderWriter> readersWriters = AutoConfigurer.configureReadersWriters();
ExceptionHandlerInterceptor exceptionHandlerInterceptor = new ExceptionHandlerInterceptor();
COMMON_INTERCEPTORS.add(exceptionHandlerInterceptor);
Map<Boolean, List<Reader>> readers = createTransformers(
concat(beanFactory.getAll(Reader.class), context.getReaders(), readersWriters));
Map<Boolean, List<Writer>> writers = createTransformers(
concat(beanFactory.getAll(Writer.class), context.getWriters(), readersWriters));
List<Interceptor> interceptors = sort(
concat(beanFactory.getAll(Interceptor.class), context.getInterceptors(), COMMON_INTERCEPTORS));
List<ExceptionConfiguration> handlers =
concat(beanFactory.getAll(ExceptionConfiguration.class), context.getExceptionConfigurations(), COMMON_HANDLERS);
List<ControllerConfiguration> controllers =
concat(beanFactory.getAll(ControllerConfiguration.class), context.getControllerConfigurations());
orderDuplicationCheck(interceptors);
Map<Class<? extends Exception>, InternalExceptionHandler> handlerMap =
handlers.stream()
.peek(ExceptionConfiguration::initialize)
.flatMap(config -> config.getExceptionHandlers().stream())
.peek(handler -> {
populateHandlerWriters(writers, handler, nonNull(handler.getResponseType()));
logExceptionHandler(handler);
})
.collect(toMap(InternalExceptionHandler::getExceptionClass, identity()));
context.setExceptionHandlers(handlerMap);
controllers.stream()
.peek(ControllerConfiguration::initialize)
.flatMap(config -> config.getRoutes().stream())
.peek(route -> {
route.interceptor(interceptors.toArray(new Interceptor[interceptors.size()]));
populateRouteReaders(readers, route);
populateRouteWriters(writers, route);
logRoute(route);
}).forEach(context::addRoute);
ApplicationContextImpl applicationContext = new ApplicationContextImpl();
applicationContext.setRoutes(context.getRoutes());
applicationContext.setExceptionHandlers(context.getExceptionHandlers());
exceptionHandlerInterceptor.setApplicationContext(applicationContext);
return applicationContext;
} | [
"protected",
"ApplicationContext",
"initializeContext",
"(",
")",
"{",
"Function",
"<",
"Class",
"<",
"Object",
">",
",",
"List",
"<",
"Object",
">",
">",
"getBeans",
"=",
"this",
"::",
"getBeans",
";",
"BeanFactory",
"beanFactory",
"=",
"new",
"BeanFactory",
... | Method causes the initialization of the application context using the methods which returns a collection of beans such as
@return initialized {@code application context} | [
"Method",
"causes",
"the",
"initialization",
"of",
"the",
"application",
"context",
"using",
"the",
"methods",
"which",
"returns",
"a",
"collection",
"of",
"beans",
"such",
"as"
] | 58903f06fb7f0b8fdf1ef91318fb48a88bf970e0 | https://github.com/petrbouda/joyrest/blob/58903f06fb7f0b8fdf1ef91318fb48a88bf970e0/joyrest-core/src/main/java/org/joyrest/context/configurer/AbstractConfigurer.java#L83-L136 | train |
brianwhu/xillium | base/src/main/java/org/xillium/base/Singleton.java | Singleton.slow | public synchronized T slow(Factory<T> p, Object... args) throws Exception {
T result = _value;
if (isMissing(result)) {
_value = result = p.make(args);
}
return result;
} | java | public synchronized T slow(Factory<T> p, Object... args) throws Exception {
T result = _value;
if (isMissing(result)) {
_value = result = p.make(args);
}
return result;
} | [
"public",
"synchronized",
"T",
"slow",
"(",
"Factory",
"<",
"T",
">",
"p",
",",
"Object",
"...",
"args",
")",
"throws",
"Exception",
"{",
"T",
"result",
"=",
"_value",
";",
"if",
"(",
"isMissing",
"(",
"result",
")",
")",
"{",
"_value",
"=",
"result"... | For performance evaluation only - do not use.
@param p a {@link org.xillium.base.Factory Factory} that can be called to create a new value with more than 1 arguments
@param args the arguments to pass to the factory
@return the singleton object
@throws Exception if the factory fails to create a new value | [
"For",
"performance",
"evaluation",
"only",
"-",
"do",
"not",
"use",
"."
] | e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799 | https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/base/src/main/java/org/xillium/base/Singleton.java#L101-L107 | train |
wanglinsong/thx-android | uia-client/src/main/java/com/android/uiautomator/stub/PointerCoords.java | PointerCoords.clear | public void clear() {
mPackedAxisBits = 0;
x = 0;
y = 0;
pressure = 0;
size = 0;
touchMajor = 0;
touchMinor = 0;
toolMajor = 0;
toolMinor = 0;
orientation = 0;
} | java | public void clear() {
mPackedAxisBits = 0;
x = 0;
y = 0;
pressure = 0;
size = 0;
touchMajor = 0;
touchMinor = 0;
toolMajor = 0;
toolMinor = 0;
orientation = 0;
} | [
"public",
"void",
"clear",
"(",
")",
"{",
"mPackedAxisBits",
"=",
"0",
";",
"x",
"=",
"0",
";",
"y",
"=",
"0",
";",
"pressure",
"=",
"0",
";",
"size",
"=",
"0",
";",
"touchMajor",
"=",
"0",
";",
"touchMinor",
"=",
"0",
";",
"toolMajor",
"=",
"0... | Clears the contents of this object.
Resets all axes to zero. | [
"Clears",
"the",
"contents",
"of",
"this",
"object",
".",
"Resets",
"all",
"axes",
"to",
"zero",
"."
] | 4a98c4181b3e8876e688591737da37627c07e72b | https://github.com/wanglinsong/thx-android/blob/4a98c4181b3e8876e688591737da37627c07e72b/uia-client/src/main/java/com/android/uiautomator/stub/PointerCoords.java#L397-L409 | train |
wanglinsong/thx-android | uia-client/src/main/java/com/android/uiautomator/stub/PointerCoords.java | PointerCoords.copyFrom | public void copyFrom(PointerCoords other) {
final long bits = other.mPackedAxisBits;
mPackedAxisBits = bits;
if (bits != 0) {
final float[] otherValues = other.mPackedAxisValues;
final int count = Long.bitCount(bits);
float[] values = mPackedAxisValues;
if (values == null || count > values.length) {
values = new float[otherValues.length];
mPackedAxisValues = values;
}
System.arraycopy(otherValues, 0, values, 0, count);
}
x = other.x;
y = other.y;
pressure = other.pressure;
size = other.size;
touchMajor = other.touchMajor;
touchMinor = other.touchMinor;
toolMajor = other.toolMajor;
toolMinor = other.toolMinor;
orientation = other.orientation;
} | java | public void copyFrom(PointerCoords other) {
final long bits = other.mPackedAxisBits;
mPackedAxisBits = bits;
if (bits != 0) {
final float[] otherValues = other.mPackedAxisValues;
final int count = Long.bitCount(bits);
float[] values = mPackedAxisValues;
if (values == null || count > values.length) {
values = new float[otherValues.length];
mPackedAxisValues = values;
}
System.arraycopy(otherValues, 0, values, 0, count);
}
x = other.x;
y = other.y;
pressure = other.pressure;
size = other.size;
touchMajor = other.touchMajor;
touchMinor = other.touchMinor;
toolMajor = other.toolMajor;
toolMinor = other.toolMinor;
orientation = other.orientation;
} | [
"public",
"void",
"copyFrom",
"(",
"PointerCoords",
"other",
")",
"{",
"final",
"long",
"bits",
"=",
"other",
".",
"mPackedAxisBits",
";",
"mPackedAxisBits",
"=",
"bits",
";",
"if",
"(",
"bits",
"!=",
"0",
")",
"{",
"final",
"float",
"[",
"]",
"otherValu... | Copies the contents of another pointer coords object.
@param other The pointer coords object to copy. | [
"Copies",
"the",
"contents",
"of",
"another",
"pointer",
"coords",
"object",
"."
] | 4a98c4181b3e8876e688591737da37627c07e72b | https://github.com/wanglinsong/thx-android/blob/4a98c4181b3e8876e688591737da37627c07e72b/uia-client/src/main/java/com/android/uiautomator/stub/PointerCoords.java#L416-L439 | train |
wanglinsong/thx-android | uia-client/src/main/java/com/android/uiautomator/stub/PointerCoords.java | PointerCoords.getAxisValue | public float getAxisValue(int axis) {
switch (axis) {
case AXIS_X:
return x;
case AXIS_Y:
return y;
case AXIS_PRESSURE:
return pressure;
case AXIS_SIZE:
return size;
case AXIS_TOUCH_MAJOR:
return touchMajor;
case AXIS_TOUCH_MINOR:
return touchMinor;
case AXIS_TOOL_MAJOR:
return toolMajor;
case AXIS_TOOL_MINOR:
return toolMinor;
case AXIS_ORIENTATION:
return orientation;
default: {
if (axis < 0 || axis > 63) {
throw new IllegalArgumentException("Axis out of range.");
}
final long bits = mPackedAxisBits;
final long axisBit = 1L << axis;
if ((bits & axisBit) == 0) {
return 0;
}
final int index = Long.bitCount(bits & (axisBit - 1L));
return mPackedAxisValues[index];
}
}
} | java | public float getAxisValue(int axis) {
switch (axis) {
case AXIS_X:
return x;
case AXIS_Y:
return y;
case AXIS_PRESSURE:
return pressure;
case AXIS_SIZE:
return size;
case AXIS_TOUCH_MAJOR:
return touchMajor;
case AXIS_TOUCH_MINOR:
return touchMinor;
case AXIS_TOOL_MAJOR:
return toolMajor;
case AXIS_TOOL_MINOR:
return toolMinor;
case AXIS_ORIENTATION:
return orientation;
default: {
if (axis < 0 || axis > 63) {
throw new IllegalArgumentException("Axis out of range.");
}
final long bits = mPackedAxisBits;
final long axisBit = 1L << axis;
if ((bits & axisBit) == 0) {
return 0;
}
final int index = Long.bitCount(bits & (axisBit - 1L));
return mPackedAxisValues[index];
}
}
} | [
"public",
"float",
"getAxisValue",
"(",
"int",
"axis",
")",
"{",
"switch",
"(",
"axis",
")",
"{",
"case",
"AXIS_X",
":",
"return",
"x",
";",
"case",
"AXIS_Y",
":",
"return",
"y",
";",
"case",
"AXIS_PRESSURE",
":",
"return",
"pressure",
";",
"case",
"AX... | Gets the value associated with the specified axis.
@param axis The axis identifier for the axis value to retrieve.
@return The value associated with the axis, or 0 if none. | [
"Gets",
"the",
"value",
"associated",
"with",
"the",
"specified",
"axis",
"."
] | 4a98c4181b3e8876e688591737da37627c07e72b | https://github.com/wanglinsong/thx-android/blob/4a98c4181b3e8876e688591737da37627c07e72b/uia-client/src/main/java/com/android/uiautomator/stub/PointerCoords.java#L448-L481 | train |
wanglinsong/thx-android | uia-client/src/main/java/com/android/uiautomator/stub/PointerCoords.java | PointerCoords.setAxisValue | public void setAxisValue(int axis, float value) {
switch (axis) {
case AXIS_X:
x = value;
break;
case AXIS_Y:
y = value;
break;
case AXIS_PRESSURE:
pressure = value;
break;
case AXIS_SIZE:
size = value;
break;
case AXIS_TOUCH_MAJOR:
touchMajor = value;
break;
case AXIS_TOUCH_MINOR:
touchMinor = value;
break;
case AXIS_TOOL_MAJOR:
toolMajor = value;
break;
case AXIS_TOOL_MINOR:
toolMinor = value;
break;
case AXIS_ORIENTATION:
orientation = value;
break;
default: {
if (axis < 0 || axis > 63) {
throw new IllegalArgumentException("Axis out of range.");
}
final long bits = mPackedAxisBits;
final long axisBit = 1L << axis;
final int index = Long.bitCount(bits & (axisBit - 1L));
float[] values = mPackedAxisValues;
if ((bits & axisBit) == 0) {
if (values == null) {
values = new float[INITIAL_PACKED_AXIS_VALUES];
mPackedAxisValues = values;
} else {
final int count = Long.bitCount(bits);
if (count < values.length) {
if (index != count) {
System.arraycopy(values, index, values, index + 1,
count - index);
}
} else {
float[] newValues = new float[count * 2];
System.arraycopy(values, 0, newValues, 0, index);
System.arraycopy(values, index, newValues, index + 1,
count - index);
values = newValues;
mPackedAxisValues = values;
}
}
mPackedAxisBits = bits | axisBit;
}
values[index] = value;
}
}
} | java | public void setAxisValue(int axis, float value) {
switch (axis) {
case AXIS_X:
x = value;
break;
case AXIS_Y:
y = value;
break;
case AXIS_PRESSURE:
pressure = value;
break;
case AXIS_SIZE:
size = value;
break;
case AXIS_TOUCH_MAJOR:
touchMajor = value;
break;
case AXIS_TOUCH_MINOR:
touchMinor = value;
break;
case AXIS_TOOL_MAJOR:
toolMajor = value;
break;
case AXIS_TOOL_MINOR:
toolMinor = value;
break;
case AXIS_ORIENTATION:
orientation = value;
break;
default: {
if (axis < 0 || axis > 63) {
throw new IllegalArgumentException("Axis out of range.");
}
final long bits = mPackedAxisBits;
final long axisBit = 1L << axis;
final int index = Long.bitCount(bits & (axisBit - 1L));
float[] values = mPackedAxisValues;
if ((bits & axisBit) == 0) {
if (values == null) {
values = new float[INITIAL_PACKED_AXIS_VALUES];
mPackedAxisValues = values;
} else {
final int count = Long.bitCount(bits);
if (count < values.length) {
if (index != count) {
System.arraycopy(values, index, values, index + 1,
count - index);
}
} else {
float[] newValues = new float[count * 2];
System.arraycopy(values, 0, newValues, 0, index);
System.arraycopy(values, index, newValues, index + 1,
count - index);
values = newValues;
mPackedAxisValues = values;
}
}
mPackedAxisBits = bits | axisBit;
}
values[index] = value;
}
}
} | [
"public",
"void",
"setAxisValue",
"(",
"int",
"axis",
",",
"float",
"value",
")",
"{",
"switch",
"(",
"axis",
")",
"{",
"case",
"AXIS_X",
":",
"x",
"=",
"value",
";",
"break",
";",
"case",
"AXIS_Y",
":",
"y",
"=",
"value",
";",
"break",
";",
"case"... | Sets the value associated with the specified axis.
@param axis The axis identifier for the axis value to assign.
@param value The value to set. | [
"Sets",
"the",
"value",
"associated",
"with",
"the",
"specified",
"axis",
"."
] | 4a98c4181b3e8876e688591737da37627c07e72b | https://github.com/wanglinsong/thx-android/blob/4a98c4181b3e8876e688591737da37627c07e72b/uia-client/src/main/java/com/android/uiautomator/stub/PointerCoords.java#L489-L551 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/sjavac/Util.java | Util.set | public static Set<String> set(String... ss) {
Set<String> set = new HashSet<String>();
set.addAll(Arrays.asList(ss));
return set;
} | java | public static Set<String> set(String... ss) {
Set<String> set = new HashSet<String>();
set.addAll(Arrays.asList(ss));
return set;
} | [
"public",
"static",
"Set",
"<",
"String",
">",
"set",
"(",
"String",
"...",
"ss",
")",
"{",
"Set",
"<",
"String",
">",
"set",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"set",
".",
"addAll",
"(",
"Arrays",
".",
"asList",
"(",
"ss",... | Convenience method to create a set with strings. | [
"Convenience",
"method",
"to",
"create",
"a",
"set",
"with",
"strings",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/sjavac/Util.java#L123-L127 | train |
arakelian/more-commons | src/main/java/com/arakelian/core/utils/ExecutorUtils.java | ExecutorUtils.newThreadFactory | public static ThreadFactory newThreadFactory(final String format, final boolean daemon) {
final String nameFormat;
if (!format.contains("%d")) {
nameFormat = format + "-%d";
} else {
nameFormat = format;
}
return new ThreadFactoryBuilder() //
.setNameFormat(nameFormat) //
.setDaemon(daemon) //
.build();
} | java | public static ThreadFactory newThreadFactory(final String format, final boolean daemon) {
final String nameFormat;
if (!format.contains("%d")) {
nameFormat = format + "-%d";
} else {
nameFormat = format;
}
return new ThreadFactoryBuilder() //
.setNameFormat(nameFormat) //
.setDaemon(daemon) //
.build();
} | [
"public",
"static",
"ThreadFactory",
"newThreadFactory",
"(",
"final",
"String",
"format",
",",
"final",
"boolean",
"daemon",
")",
"{",
"final",
"String",
"nameFormat",
";",
"if",
"(",
"!",
"format",
".",
"contains",
"(",
"\"%d\"",
")",
")",
"{",
"nameFormat... | Returns a new thread factory that uses the given pattern to set the thread name.
@param format
thread name pattern, where %d can be used to specify the thread number.
@param daemon
true for daemon threads
@return thread factory that uses the given pattern to set the thread name | [
"Returns",
"a",
"new",
"thread",
"factory",
"that",
"uses",
"the",
"given",
"pattern",
"to",
"set",
"the",
"thread",
"name",
"."
] | 83c607044f64a7f6c005a67866c0ef7cb68d6e29 | https://github.com/arakelian/more-commons/blob/83c607044f64a7f6c005a67866c0ef7cb68d6e29/src/main/java/com/arakelian/core/utils/ExecutorUtils.java#L89-L101 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javadoc/Comment.java | Comment.tags | Tag[] tags(String tagname) {
ListBuffer<Tag> found = new ListBuffer<Tag>();
String target = tagname;
if (target.charAt(0) != '@') {
target = "@" + target;
}
for (Tag tag : tagList) {
if (tag.kind().equals(target)) {
found.append(tag);
}
}
return found.toArray(new Tag[found.length()]);
} | java | Tag[] tags(String tagname) {
ListBuffer<Tag> found = new ListBuffer<Tag>();
String target = tagname;
if (target.charAt(0) != '@') {
target = "@" + target;
}
for (Tag tag : tagList) {
if (tag.kind().equals(target)) {
found.append(tag);
}
}
return found.toArray(new Tag[found.length()]);
} | [
"Tag",
"[",
"]",
"tags",
"(",
"String",
"tagname",
")",
"{",
"ListBuffer",
"<",
"Tag",
">",
"found",
"=",
"new",
"ListBuffer",
"<",
"Tag",
">",
"(",
")",
";",
"String",
"target",
"=",
"tagname",
";",
"if",
"(",
"target",
".",
"charAt",
"(",
"0",
... | Return tags of the specified kind in this comment. | [
"Return",
"tags",
"of",
"the",
"specified",
"kind",
"in",
"this",
"comment",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javadoc/Comment.java#L210-L222 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javadoc/Comment.java | Comment.paramTags | private ParamTag[] paramTags(boolean typeParams) {
ListBuffer<ParamTag> found = new ListBuffer<ParamTag>();
for (Tag next : tagList) {
if (next instanceof ParamTag) {
ParamTag p = (ParamTag)next;
if (typeParams == p.isTypeParameter()) {
found.append(p);
}
}
}
return found.toArray(new ParamTag[found.length()]);
} | java | private ParamTag[] paramTags(boolean typeParams) {
ListBuffer<ParamTag> found = new ListBuffer<ParamTag>();
for (Tag next : tagList) {
if (next instanceof ParamTag) {
ParamTag p = (ParamTag)next;
if (typeParams == p.isTypeParameter()) {
found.append(p);
}
}
}
return found.toArray(new ParamTag[found.length()]);
} | [
"private",
"ParamTag",
"[",
"]",
"paramTags",
"(",
"boolean",
"typeParams",
")",
"{",
"ListBuffer",
"<",
"ParamTag",
">",
"found",
"=",
"new",
"ListBuffer",
"<",
"ParamTag",
">",
"(",
")",
";",
"for",
"(",
"Tag",
"next",
":",
"tagList",
")",
"{",
"if",... | Return param tags in this comment. If typeParams is true
include only type param tags, otherwise include only ordinary
param tags. | [
"Return",
"param",
"tags",
"in",
"this",
"comment",
".",
"If",
"typeParams",
"is",
"true",
"include",
"only",
"type",
"param",
"tags",
"otherwise",
"include",
"only",
"ordinary",
"param",
"tags",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javadoc/Comment.java#L256-L267 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javadoc/Comment.java | Comment.seeTags | SeeTag[] seeTags() {
ListBuffer<SeeTag> found = new ListBuffer<SeeTag>();
for (Tag next : tagList) {
if (next instanceof SeeTag) {
found.append((SeeTag)next);
}
}
return found.toArray(new SeeTag[found.length()]);
} | java | SeeTag[] seeTags() {
ListBuffer<SeeTag> found = new ListBuffer<SeeTag>();
for (Tag next : tagList) {
if (next instanceof SeeTag) {
found.append((SeeTag)next);
}
}
return found.toArray(new SeeTag[found.length()]);
} | [
"SeeTag",
"[",
"]",
"seeTags",
"(",
")",
"{",
"ListBuffer",
"<",
"SeeTag",
">",
"found",
"=",
"new",
"ListBuffer",
"<",
"SeeTag",
">",
"(",
")",
";",
"for",
"(",
"Tag",
"next",
":",
"tagList",
")",
"{",
"if",
"(",
"next",
"instanceof",
"SeeTag",
")... | Return see also tags in this comment. | [
"Return",
"see",
"also",
"tags",
"in",
"this",
"comment",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javadoc/Comment.java#L272-L280 | train |
qsardb/qsardb | model/src/main/java/org/qsardb/model/ContainerRegistry.java | ContainerRegistry.get | public C get(String id){
C container = this.containerMap.get(id);
if(container != null && (container.getState()).equals(State.REMOVED)){
return null;
}
return container;
} | java | public C get(String id){
C container = this.containerMap.get(id);
if(container != null && (container.getState()).equals(State.REMOVED)){
return null;
}
return container;
} | [
"public",
"C",
"get",
"(",
"String",
"id",
")",
"{",
"C",
"container",
"=",
"this",
".",
"containerMap",
".",
"get",
"(",
"id",
")",
";",
"if",
"(",
"container",
"!=",
"null",
"&&",
"(",
"container",
".",
"getState",
"(",
")",
")",
".",
"equals",
... | Looks up a Container by its identifier.
@return The Container instance or <code>null</code> | [
"Looks",
"up",
"a",
"Container",
"by",
"its",
"identifier",
"."
] | 9798f524abd973878b9040927aed8131885127fa | https://github.com/qsardb/qsardb/blob/9798f524abd973878b9040927aed8131885127fa/model/src/main/java/org/qsardb/model/ContainerRegistry.java#L94-L102 | train |
qsardb/qsardb | model/src/main/java/org/qsardb/model/ContainerRegistry.java | ContainerRegistry.getAll | public Collection<C> getAll(Collection<String> ids){
Set<C> list = new LinkedHashSet<C>();
for(String id : ids){
C container = get(id);
if(container != null){
list.add(container);
}
}
return list;
} | java | public Collection<C> getAll(Collection<String> ids){
Set<C> list = new LinkedHashSet<C>();
for(String id : ids){
C container = get(id);
if(container != null){
list.add(container);
}
}
return list;
} | [
"public",
"Collection",
"<",
"C",
">",
"getAll",
"(",
"Collection",
"<",
"String",
">",
"ids",
")",
"{",
"Set",
"<",
"C",
">",
"list",
"=",
"new",
"LinkedHashSet",
"<",
"C",
">",
"(",
")",
";",
"for",
"(",
"String",
"id",
":",
"ids",
")",
"{",
... | Looks up a Collection of Containers by their identifiers.
The returned Collection preserves the iteration order of the passed-in Collection.
@return Collection of Containers. | [
"Looks",
"up",
"a",
"Collection",
"of",
"Containers",
"by",
"their",
"identifiers",
"."
] | 9798f524abd973878b9040927aed8131885127fa | https://github.com/qsardb/qsardb/blob/9798f524abd973878b9040927aed8131885127fa/model/src/main/java/org/qsardb/model/ContainerRegistry.java#L111-L123 | train |
coopernurse/barrister-java | src/main/java/com/bitmechanic/barrister/Idl2Java.java | Idl2Java.main | public static void main(String argv[]) throws Exception {
String idlFile = null;
String pkgName = null;
String outDir = null;
String nsPkgName = null;
boolean allImmutable = false;
List<String> immutableSubstr = new ArrayList<String>();
for (int i = 0; i < argv.length; i++) {
if (argv[i].equals("-j")) {
idlFile = argv[++i];
}
else if (argv[i].equals("-p")) {
pkgName = argv[++i];
}
else if (argv[i].equals("-o")) {
outDir = argv[++i];
}
else if (argv[i].equals("-b")) {
nsPkgName = argv[++i];
}
else if (argv[i].equals("-s")) {
immutableSubstr.add(argv[++i]);
}
else if (argv[i].equals("-i")) {
allImmutable = true;
}
}
if (isBlank(idlFile) || isBlank(pkgName) || isBlank(outDir)) {
out("Usage: java com.bitmechanic.barrister.Idl2Java -j [idl file] -p [Java package prefix] -b [Java package prefix for namespaced entities] -o [out dir] -i -s [immutable class substr]");
System.exit(1);
}
if (nsPkgName == null) {
nsPkgName = pkgName;
}
new Idl2Java(idlFile, pkgName, nsPkgName, outDir, allImmutable, immutableSubstr);
} | java | public static void main(String argv[]) throws Exception {
String idlFile = null;
String pkgName = null;
String outDir = null;
String nsPkgName = null;
boolean allImmutable = false;
List<String> immutableSubstr = new ArrayList<String>();
for (int i = 0; i < argv.length; i++) {
if (argv[i].equals("-j")) {
idlFile = argv[++i];
}
else if (argv[i].equals("-p")) {
pkgName = argv[++i];
}
else if (argv[i].equals("-o")) {
outDir = argv[++i];
}
else if (argv[i].equals("-b")) {
nsPkgName = argv[++i];
}
else if (argv[i].equals("-s")) {
immutableSubstr.add(argv[++i]);
}
else if (argv[i].equals("-i")) {
allImmutable = true;
}
}
if (isBlank(idlFile) || isBlank(pkgName) || isBlank(outDir)) {
out("Usage: java com.bitmechanic.barrister.Idl2Java -j [idl file] -p [Java package prefix] -b [Java package prefix for namespaced entities] -o [out dir] -i -s [immutable class substr]");
System.exit(1);
}
if (nsPkgName == null) {
nsPkgName = pkgName;
}
new Idl2Java(idlFile, pkgName, nsPkgName, outDir, allImmutable, immutableSubstr);
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"argv",
"[",
"]",
")",
"throws",
"Exception",
"{",
"String",
"idlFile",
"=",
"null",
";",
"String",
"pkgName",
"=",
"null",
";",
"String",
"outDir",
"=",
"null",
";",
"String",
"nsPkgName",
"=",
"null",
... | Runs the code generator on the command line. | [
"Runs",
"the",
"code",
"generator",
"on",
"the",
"command",
"line",
"."
] | c2b639634c88a25002b66d1fb4a8f5fb51ade6a2 | https://github.com/coopernurse/barrister-java/blob/c2b639634c88a25002b66d1fb4a8f5fb51ade6a2/src/main/java/com/bitmechanic/barrister/Idl2Java.java#L24-L63 | train |
brianwhu/xillium | core/src/main/java/org/xillium/core/HttpServiceDispatcher.java | HttpServiceDispatcher.init | public void init() throws ServletException {
_application = ((ManagedPlatform)ServicePlatform.getService(ManagedPlatform.INSTANCE).first).getName();
/*
ApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
if (wac.containsBean("persistence")) { // persistence may not be there if persistent storage is not required
_persistence = (Persistence)wac.getBean("persistence");
}
*/
} | java | public void init() throws ServletException {
_application = ((ManagedPlatform)ServicePlatform.getService(ManagedPlatform.INSTANCE).first).getName();
/*
ApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
if (wac.containsBean("persistence")) { // persistence may not be there if persistent storage is not required
_persistence = (Persistence)wac.getBean("persistence");
}
*/
} | [
"public",
"void",
"init",
"(",
")",
"throws",
"ServletException",
"{",
"_application",
"=",
"(",
"(",
"ManagedPlatform",
")",
"ServicePlatform",
".",
"getService",
"(",
"ManagedPlatform",
".",
"INSTANCE",
")",
".",
"first",
")",
".",
"getName",
"(",
")",
";"... | Initializes the servlet | [
"Initializes",
"the",
"servlet"
] | e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799 | https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/core/src/main/java/org/xillium/core/HttpServiceDispatcher.java#L50-L59 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java | ProfileSummaryBuilder.getInstance | public static ProfileSummaryBuilder getInstance(Context context,
Profile profile, ProfileSummaryWriter profileWriter) {
return new ProfileSummaryBuilder(context, profile, profileWriter);
} | java | public static ProfileSummaryBuilder getInstance(Context context,
Profile profile, ProfileSummaryWriter profileWriter) {
return new ProfileSummaryBuilder(context, profile, profileWriter);
} | [
"public",
"static",
"ProfileSummaryBuilder",
"getInstance",
"(",
"Context",
"context",
",",
"Profile",
"profile",
",",
"ProfileSummaryWriter",
"profileWriter",
")",
"{",
"return",
"new",
"ProfileSummaryBuilder",
"(",
"context",
",",
"profile",
",",
"profileWriter",
")... | Construct a new ProfileSummaryBuilder.
@param context the build context.
@param profile the profile being documented.
@param profileWriter the doclet specific writer that will output the
result.
@return an instance of a ProfileSummaryBuilder. | [
"Construct",
"a",
"new",
"ProfileSummaryBuilder",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java#L96-L99 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java | ProfileSummaryBuilder.buildProfileDoc | public void buildProfileDoc(XMLNode node, Content contentTree) throws Exception {
contentTree = profileWriter.getProfileHeader(profile.name);
buildChildren(node, contentTree);
profileWriter.addProfileFooter(contentTree);
profileWriter.printDocument(contentTree);
profileWriter.close();
Util.copyDocFiles(configuration, DocPaths.profileSummary(profile.name));
} | java | public void buildProfileDoc(XMLNode node, Content contentTree) throws Exception {
contentTree = profileWriter.getProfileHeader(profile.name);
buildChildren(node, contentTree);
profileWriter.addProfileFooter(contentTree);
profileWriter.printDocument(contentTree);
profileWriter.close();
Util.copyDocFiles(configuration, DocPaths.profileSummary(profile.name));
} | [
"public",
"void",
"buildProfileDoc",
"(",
"XMLNode",
"node",
",",
"Content",
"contentTree",
")",
"throws",
"Exception",
"{",
"contentTree",
"=",
"profileWriter",
".",
"getProfileHeader",
"(",
"profile",
".",
"name",
")",
";",
"buildChildren",
"(",
"node",
",",
... | Build the profile documentation.
@param node the XML element that specifies which components to document
@param contentTree the content tree to which the documentation will be added | [
"Build",
"the",
"profile",
"documentation",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java#L125-L132 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java | ProfileSummaryBuilder.buildContent | public void buildContent(XMLNode node, Content contentTree) {
Content profileContentTree = profileWriter.getContentHeader();
buildChildren(node, profileContentTree);
contentTree.addContent(profileContentTree);
} | java | public void buildContent(XMLNode node, Content contentTree) {
Content profileContentTree = profileWriter.getContentHeader();
buildChildren(node, profileContentTree);
contentTree.addContent(profileContentTree);
} | [
"public",
"void",
"buildContent",
"(",
"XMLNode",
"node",
",",
"Content",
"contentTree",
")",
"{",
"Content",
"profileContentTree",
"=",
"profileWriter",
".",
"getContentHeader",
"(",
")",
";",
"buildChildren",
"(",
"node",
",",
"profileContentTree",
")",
";",
"... | Build the content for the profile doc.
@param node the XML element that specifies which components to document
@param contentTree the content tree to which the profile contents
will be added | [
"Build",
"the",
"content",
"for",
"the",
"profile",
"doc",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java#L141-L145 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java | ProfileSummaryBuilder.buildSummary | public void buildSummary(XMLNode node, Content profileContentTree) {
Content summaryContentTree = profileWriter.getSummaryHeader();
buildChildren(node, summaryContentTree);
profileContentTree.addContent(profileWriter.getSummaryTree(summaryContentTree));
} | java | public void buildSummary(XMLNode node, Content profileContentTree) {
Content summaryContentTree = profileWriter.getSummaryHeader();
buildChildren(node, summaryContentTree);
profileContentTree.addContent(profileWriter.getSummaryTree(summaryContentTree));
} | [
"public",
"void",
"buildSummary",
"(",
"XMLNode",
"node",
",",
"Content",
"profileContentTree",
")",
"{",
"Content",
"summaryContentTree",
"=",
"profileWriter",
".",
"getSummaryHeader",
"(",
")",
";",
"buildChildren",
"(",
"node",
",",
"summaryContentTree",
")",
"... | Build the profile summary.
@param node the XML element that specifies which components to document
@param profileContentTree the profile content tree to which the summaries will
be added | [
"Build",
"the",
"profile",
"summary",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java#L154-L158 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java | ProfileSummaryBuilder.buildPackageSummary | public void buildPackageSummary(XMLNode node, Content summaryContentTree) {
PackageDoc[] packages = configuration.profilePackages.get(profile.name);
for (int i = 0; i < packages.length; i++) {
this.pkg = packages[i];
Content packageSummaryContentTree = profileWriter.getPackageSummaryHeader(this.pkg);
buildChildren(node, packageSummaryContentTree);
summaryContentTree.addContent(profileWriter.getPackageSummaryTree(
packageSummaryContentTree));
}
} | java | public void buildPackageSummary(XMLNode node, Content summaryContentTree) {
PackageDoc[] packages = configuration.profilePackages.get(profile.name);
for (int i = 0; i < packages.length; i++) {
this.pkg = packages[i];
Content packageSummaryContentTree = profileWriter.getPackageSummaryHeader(this.pkg);
buildChildren(node, packageSummaryContentTree);
summaryContentTree.addContent(profileWriter.getPackageSummaryTree(
packageSummaryContentTree));
}
} | [
"public",
"void",
"buildPackageSummary",
"(",
"XMLNode",
"node",
",",
"Content",
"summaryContentTree",
")",
"{",
"PackageDoc",
"[",
"]",
"packages",
"=",
"configuration",
".",
"profilePackages",
".",
"get",
"(",
"profile",
".",
"name",
")",
";",
"for",
"(",
... | Build the profile package summary.
@param node the XML element that specifies which components to document
@param summaryContentTree the content tree to which the summaries will
be added | [
"Build",
"the",
"profile",
"package",
"summary",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java#L167-L176 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java | ProfileSummaryBuilder.buildInterfaceSummary | public void buildInterfaceSummary(XMLNode node, Content packageSummaryContentTree) {
String interfaceTableSummary =
configuration.getText("doclet.Member_Table_Summary",
configuration.getText("doclet.Interface_Summary"),
configuration.getText("doclet.interfaces"));
String[] interfaceTableHeader = new String[] {
configuration.getText("doclet.Interface"),
configuration.getText("doclet.Description")
};
ClassDoc[] interfaces = pkg.interfaces();
if (interfaces.length > 0) {
profileWriter.addClassesSummary(
interfaces,
configuration.getText("doclet.Interface_Summary"),
interfaceTableSummary, interfaceTableHeader, packageSummaryContentTree);
}
} | java | public void buildInterfaceSummary(XMLNode node, Content packageSummaryContentTree) {
String interfaceTableSummary =
configuration.getText("doclet.Member_Table_Summary",
configuration.getText("doclet.Interface_Summary"),
configuration.getText("doclet.interfaces"));
String[] interfaceTableHeader = new String[] {
configuration.getText("doclet.Interface"),
configuration.getText("doclet.Description")
};
ClassDoc[] interfaces = pkg.interfaces();
if (interfaces.length > 0) {
profileWriter.addClassesSummary(
interfaces,
configuration.getText("doclet.Interface_Summary"),
interfaceTableSummary, interfaceTableHeader, packageSummaryContentTree);
}
} | [
"public",
"void",
"buildInterfaceSummary",
"(",
"XMLNode",
"node",
",",
"Content",
"packageSummaryContentTree",
")",
"{",
"String",
"interfaceTableSummary",
"=",
"configuration",
".",
"getText",
"(",
"\"doclet.Member_Table_Summary\"",
",",
"configuration",
".",
"getText",... | Build the summary for the interfaces in the package.
@param node the XML element that specifies which components to document
@param packageSummaryContentTree the tree to which the interface summary
will be added | [
"Build",
"the",
"summary",
"for",
"the",
"interfaces",
"in",
"the",
"package",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java#L185-L201 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java | ProfileSummaryBuilder.buildClassSummary | public void buildClassSummary(XMLNode node, Content packageSummaryContentTree) {
String classTableSummary =
configuration.getText("doclet.Member_Table_Summary",
configuration.getText("doclet.Class_Summary"),
configuration.getText("doclet.classes"));
String[] classTableHeader = new String[] {
configuration.getText("doclet.Class"),
configuration.getText("doclet.Description")
};
ClassDoc[] classes = pkg.ordinaryClasses();
if (classes.length > 0) {
profileWriter.addClassesSummary(
classes,
configuration.getText("doclet.Class_Summary"),
classTableSummary, classTableHeader, packageSummaryContentTree);
}
} | java | public void buildClassSummary(XMLNode node, Content packageSummaryContentTree) {
String classTableSummary =
configuration.getText("doclet.Member_Table_Summary",
configuration.getText("doclet.Class_Summary"),
configuration.getText("doclet.classes"));
String[] classTableHeader = new String[] {
configuration.getText("doclet.Class"),
configuration.getText("doclet.Description")
};
ClassDoc[] classes = pkg.ordinaryClasses();
if (classes.length > 0) {
profileWriter.addClassesSummary(
classes,
configuration.getText("doclet.Class_Summary"),
classTableSummary, classTableHeader, packageSummaryContentTree);
}
} | [
"public",
"void",
"buildClassSummary",
"(",
"XMLNode",
"node",
",",
"Content",
"packageSummaryContentTree",
")",
"{",
"String",
"classTableSummary",
"=",
"configuration",
".",
"getText",
"(",
"\"doclet.Member_Table_Summary\"",
",",
"configuration",
".",
"getText",
"(",
... | Build the summary for the classes in the package.
@param node the XML element that specifies which components to document
@param packageSummaryContentTree the tree to which the class summary will
be added | [
"Build",
"the",
"summary",
"for",
"the",
"classes",
"in",
"the",
"package",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java#L210-L226 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java | ProfileSummaryBuilder.buildEnumSummary | public void buildEnumSummary(XMLNode node, Content packageSummaryContentTree) {
String enumTableSummary =
configuration.getText("doclet.Member_Table_Summary",
configuration.getText("doclet.Enum_Summary"),
configuration.getText("doclet.enums"));
String[] enumTableHeader = new String[] {
configuration.getText("doclet.Enum"),
configuration.getText("doclet.Description")
};
ClassDoc[] enums = pkg.enums();
if (enums.length > 0) {
profileWriter.addClassesSummary(
enums,
configuration.getText("doclet.Enum_Summary"),
enumTableSummary, enumTableHeader, packageSummaryContentTree);
}
} | java | public void buildEnumSummary(XMLNode node, Content packageSummaryContentTree) {
String enumTableSummary =
configuration.getText("doclet.Member_Table_Summary",
configuration.getText("doclet.Enum_Summary"),
configuration.getText("doclet.enums"));
String[] enumTableHeader = new String[] {
configuration.getText("doclet.Enum"),
configuration.getText("doclet.Description")
};
ClassDoc[] enums = pkg.enums();
if (enums.length > 0) {
profileWriter.addClassesSummary(
enums,
configuration.getText("doclet.Enum_Summary"),
enumTableSummary, enumTableHeader, packageSummaryContentTree);
}
} | [
"public",
"void",
"buildEnumSummary",
"(",
"XMLNode",
"node",
",",
"Content",
"packageSummaryContentTree",
")",
"{",
"String",
"enumTableSummary",
"=",
"configuration",
".",
"getText",
"(",
"\"doclet.Member_Table_Summary\"",
",",
"configuration",
".",
"getText",
"(",
... | Build the summary for the enums in the package.
@param node the XML element that specifies which components to document
@param packageSummaryContentTree the tree to which the enum summary will
be added | [
"Build",
"the",
"summary",
"for",
"the",
"enums",
"in",
"the",
"package",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java#L235-L251 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java | ProfileSummaryBuilder.buildExceptionSummary | public void buildExceptionSummary(XMLNode node, Content packageSummaryContentTree) {
String exceptionTableSummary =
configuration.getText("doclet.Member_Table_Summary",
configuration.getText("doclet.Exception_Summary"),
configuration.getText("doclet.exceptions"));
String[] exceptionTableHeader = new String[] {
configuration.getText("doclet.Exception"),
configuration.getText("doclet.Description")
};
ClassDoc[] exceptions = pkg.exceptions();
if (exceptions.length > 0) {
profileWriter.addClassesSummary(
exceptions,
configuration.getText("doclet.Exception_Summary"),
exceptionTableSummary, exceptionTableHeader, packageSummaryContentTree);
}
} | java | public void buildExceptionSummary(XMLNode node, Content packageSummaryContentTree) {
String exceptionTableSummary =
configuration.getText("doclet.Member_Table_Summary",
configuration.getText("doclet.Exception_Summary"),
configuration.getText("doclet.exceptions"));
String[] exceptionTableHeader = new String[] {
configuration.getText("doclet.Exception"),
configuration.getText("doclet.Description")
};
ClassDoc[] exceptions = pkg.exceptions();
if (exceptions.length > 0) {
profileWriter.addClassesSummary(
exceptions,
configuration.getText("doclet.Exception_Summary"),
exceptionTableSummary, exceptionTableHeader, packageSummaryContentTree);
}
} | [
"public",
"void",
"buildExceptionSummary",
"(",
"XMLNode",
"node",
",",
"Content",
"packageSummaryContentTree",
")",
"{",
"String",
"exceptionTableSummary",
"=",
"configuration",
".",
"getText",
"(",
"\"doclet.Member_Table_Summary\"",
",",
"configuration",
".",
"getText",... | Build the summary for the exceptions in the package.
@param node the XML element that specifies which components to document
@param packageSummaryContentTree the tree to which the exception summary will
be added | [
"Build",
"the",
"summary",
"for",
"the",
"exceptions",
"in",
"the",
"package",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java#L260-L276 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java | ProfileSummaryBuilder.buildErrorSummary | public void buildErrorSummary(XMLNode node, Content packageSummaryContentTree) {
String errorTableSummary =
configuration.getText("doclet.Member_Table_Summary",
configuration.getText("doclet.Error_Summary"),
configuration.getText("doclet.errors"));
String[] errorTableHeader = new String[] {
configuration.getText("doclet.Error"),
configuration.getText("doclet.Description")
};
ClassDoc[] errors = pkg.errors();
if (errors.length > 0) {
profileWriter.addClassesSummary(
errors,
configuration.getText("doclet.Error_Summary"),
errorTableSummary, errorTableHeader, packageSummaryContentTree);
}
} | java | public void buildErrorSummary(XMLNode node, Content packageSummaryContentTree) {
String errorTableSummary =
configuration.getText("doclet.Member_Table_Summary",
configuration.getText("doclet.Error_Summary"),
configuration.getText("doclet.errors"));
String[] errorTableHeader = new String[] {
configuration.getText("doclet.Error"),
configuration.getText("doclet.Description")
};
ClassDoc[] errors = pkg.errors();
if (errors.length > 0) {
profileWriter.addClassesSummary(
errors,
configuration.getText("doclet.Error_Summary"),
errorTableSummary, errorTableHeader, packageSummaryContentTree);
}
} | [
"public",
"void",
"buildErrorSummary",
"(",
"XMLNode",
"node",
",",
"Content",
"packageSummaryContentTree",
")",
"{",
"String",
"errorTableSummary",
"=",
"configuration",
".",
"getText",
"(",
"\"doclet.Member_Table_Summary\"",
",",
"configuration",
".",
"getText",
"(",
... | Build the summary for the errors in the package.
@param node the XML element that specifies which components to document
@param packageSummaryContentTree the tree to which the error summary will
be added | [
"Build",
"the",
"summary",
"for",
"the",
"errors",
"in",
"the",
"package",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java#L285-L301 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java | ProfileSummaryBuilder.buildAnnotationTypeSummary | public void buildAnnotationTypeSummary(XMLNode node, Content packageSummaryContentTree) {
String annotationtypeTableSummary =
configuration.getText("doclet.Member_Table_Summary",
configuration.getText("doclet.Annotation_Types_Summary"),
configuration.getText("doclet.annotationtypes"));
String[] annotationtypeTableHeader = new String[] {
configuration.getText("doclet.AnnotationType"),
configuration.getText("doclet.Description")
};
ClassDoc[] annotationTypes = pkg.annotationTypes();
if (annotationTypes.length > 0) {
profileWriter.addClassesSummary(
annotationTypes,
configuration.getText("doclet.Annotation_Types_Summary"),
annotationtypeTableSummary, annotationtypeTableHeader,
packageSummaryContentTree);
}
} | java | public void buildAnnotationTypeSummary(XMLNode node, Content packageSummaryContentTree) {
String annotationtypeTableSummary =
configuration.getText("doclet.Member_Table_Summary",
configuration.getText("doclet.Annotation_Types_Summary"),
configuration.getText("doclet.annotationtypes"));
String[] annotationtypeTableHeader = new String[] {
configuration.getText("doclet.AnnotationType"),
configuration.getText("doclet.Description")
};
ClassDoc[] annotationTypes = pkg.annotationTypes();
if (annotationTypes.length > 0) {
profileWriter.addClassesSummary(
annotationTypes,
configuration.getText("doclet.Annotation_Types_Summary"),
annotationtypeTableSummary, annotationtypeTableHeader,
packageSummaryContentTree);
}
} | [
"public",
"void",
"buildAnnotationTypeSummary",
"(",
"XMLNode",
"node",
",",
"Content",
"packageSummaryContentTree",
")",
"{",
"String",
"annotationtypeTableSummary",
"=",
"configuration",
".",
"getText",
"(",
"\"doclet.Member_Table_Summary\"",
",",
"configuration",
".",
... | Build the summary for the annotation type in the package.
@param node the XML element that specifies which components to document
@param packageSummaryContentTree the tree to which the annotation type
summary will be added | [
"Build",
"the",
"summary",
"for",
"the",
"annotation",
"type",
"in",
"the",
"package",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java#L310-L327 | train |
lightblueseas/jcommons-lang | src/main/java/de/alpharogroup/lang/BooleanExtensions.java | BooleanExtensions.trueOrFalse | public static <T> T trueOrFalse(final T trueCase, final T falseCase, final boolean... flags)
{
boolean interlink = true;
if (flags != null && 0 < flags.length)
{
interlink = false;
}
for (int i = 0; i < flags.length; i++)
{
if (i == 0)
{
interlink = !flags[i];
continue;
}
interlink &= !flags[i];
}
if (interlink)
{
return falseCase;
}
return trueCase;
} | java | public static <T> T trueOrFalse(final T trueCase, final T falseCase, final boolean... flags)
{
boolean interlink = true;
if (flags != null && 0 < flags.length)
{
interlink = false;
}
for (int i = 0; i < flags.length; i++)
{
if (i == 0)
{
interlink = !flags[i];
continue;
}
interlink &= !flags[i];
}
if (interlink)
{
return falseCase;
}
return trueCase;
} | [
"public",
"static",
"<",
"T",
">",
"T",
"trueOrFalse",
"(",
"final",
"T",
"trueCase",
",",
"final",
"T",
"falseCase",
",",
"final",
"boolean",
"...",
"flags",
")",
"{",
"boolean",
"interlink",
"=",
"true",
";",
"if",
"(",
"flags",
"!=",
"null",
"&&",
... | Decides over the given flags if the true-case or the false-case will be return.
@param <T>
the generic type
@param trueCase
the object to return in true case
@param falseCase
the object to return in false case
@param flags
the flags whice decide what to return
@return the false-case if all false or empty otherwise the true-case. | [
"Decides",
"over",
"the",
"given",
"flags",
"if",
"the",
"true",
"-",
"case",
"or",
"the",
"false",
"-",
"case",
"will",
"be",
"return",
"."
] | 000e1f198e949ec3e721fd0fc3f5946e945232a3 | https://github.com/lightblueseas/jcommons-lang/blob/000e1f198e949ec3e721fd0fc3f5946e945232a3/src/main/java/de/alpharogroup/lang/BooleanExtensions.java#L49-L70 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/provider/newrelic/AlertChannelCache.java | AlertChannelCache.add | public void add(Collection<AlertChannel> channels)
{
for(AlertChannel channel : channels)
this.channels.put(channel.getId(), channel);
} | java | public void add(Collection<AlertChannel> channels)
{
for(AlertChannel channel : channels)
this.channels.put(channel.getId(), channel);
} | [
"public",
"void",
"add",
"(",
"Collection",
"<",
"AlertChannel",
">",
"channels",
")",
"{",
"for",
"(",
"AlertChannel",
"channel",
":",
"channels",
")",
"this",
".",
"channels",
".",
"put",
"(",
"channel",
".",
"getId",
"(",
")",
",",
"channel",
")",
"... | Adds the channel list to the channels for the account.
@param channels The channels to add | [
"Adds",
"the",
"channel",
"list",
"to",
"the",
"channels",
"for",
"the",
"account",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/provider/newrelic/AlertChannelCache.java#L75-L79 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java | ClassDocImpl.addAllClasses | void addAllClasses(ListBuffer<ClassDocImpl> l, boolean filtered) {
try {
if (isSynthetic()) return;
// sometimes synthetic classes are not marked synthetic
if (!JavadocTool.isValidClassName(tsym.name.toString())) return;
if (filtered && !env.shouldDocument(tsym)) return;
if (l.contains(this)) return;
l.append(this);
List<ClassDocImpl> more = List.nil();
for (Scope.Entry e = tsym.members().elems; e != null;
e = e.sibling) {
if (e.sym != null && e.sym.kind == Kinds.TYP) {
ClassSymbol s = (ClassSymbol)e.sym;
ClassDocImpl c = env.getClassDoc(s);
if (c.isSynthetic()) continue;
if (c != null) more = more.prepend(c);
}
}
// this extra step preserves the ordering from oldjavadoc
for (; more.nonEmpty(); more=more.tail) {
more.head.addAllClasses(l, filtered);
}
} catch (CompletionFailure e) {
// quietly ignore completion failures
}
} | java | void addAllClasses(ListBuffer<ClassDocImpl> l, boolean filtered) {
try {
if (isSynthetic()) return;
// sometimes synthetic classes are not marked synthetic
if (!JavadocTool.isValidClassName(tsym.name.toString())) return;
if (filtered && !env.shouldDocument(tsym)) return;
if (l.contains(this)) return;
l.append(this);
List<ClassDocImpl> more = List.nil();
for (Scope.Entry e = tsym.members().elems; e != null;
e = e.sibling) {
if (e.sym != null && e.sym.kind == Kinds.TYP) {
ClassSymbol s = (ClassSymbol)e.sym;
ClassDocImpl c = env.getClassDoc(s);
if (c.isSynthetic()) continue;
if (c != null) more = more.prepend(c);
}
}
// this extra step preserves the ordering from oldjavadoc
for (; more.nonEmpty(); more=more.tail) {
more.head.addAllClasses(l, filtered);
}
} catch (CompletionFailure e) {
// quietly ignore completion failures
}
} | [
"void",
"addAllClasses",
"(",
"ListBuffer",
"<",
"ClassDocImpl",
">",
"l",
",",
"boolean",
"filtered",
")",
"{",
"try",
"{",
"if",
"(",
"isSynthetic",
"(",
")",
")",
"return",
";",
"// sometimes synthetic classes are not marked synthetic",
"if",
"(",
"!",
"Javad... | Adds all inner classes of this class, and their
inner classes recursively, to the list l. | [
"Adds",
"all",
"inner",
"classes",
"of",
"this",
"class",
"and",
"their",
"inner",
"classes",
"recursively",
"to",
"the",
"list",
"l",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java#L674-L699 | train |
defei/codelogger-utils | src/main/java/org/codelogger/utils/MathUtils.java | MathUtils.randomLong | public static long randomLong(final long min, final long max) {
return Math.round(Math.random() * (max - min) + min);
} | java | public static long randomLong(final long min, final long max) {
return Math.round(Math.random() * (max - min) + min);
} | [
"public",
"static",
"long",
"randomLong",
"(",
"final",
"long",
"min",
",",
"final",
"long",
"max",
")",
"{",
"return",
"Math",
".",
"round",
"(",
"Math",
".",
"random",
"(",
")",
"*",
"(",
"max",
"-",
"min",
")",
"+",
"min",
")",
";",
"}"
] | Returns a natural long value between given minimum value and max value.
@param min
the minimum value to random.
@param max
the max value to random.
@return a natural long value between given minimum value and max value. | [
"Returns",
"a",
"natural",
"long",
"value",
"between",
"given",
"minimum",
"value",
"and",
"max",
"value",
"."
] | d906f5d217b783c7ae3e53442cd6fb87b20ecc0a | https://github.com/defei/codelogger-utils/blob/d906f5d217b783c7ae3e53442cd6fb87b20ecc0a/src/main/java/org/codelogger/utils/MathUtils.java#L88-L91 | train |
lightblueseas/jcommons-lang | src/main/java/de/alpharogroup/lang/AnnotationExtensions.java | AnnotationExtensions.getAllAnnotatedClasses | public static Set<Class<?>> getAllAnnotatedClasses(final String packagePath,
final Class<? extends Annotation> annotationClass)
throws ClassNotFoundException, IOException, URISyntaxException
{
final List<File> directories = ClassExtensions.getDirectoriesFromResources(packagePath,
true);
final Set<Class<?>> classes = new HashSet<>();
for (final File directory : directories)
{
classes.addAll(scanForAnnotatedClasses(directory, packagePath, annotationClass));
}
return classes;
} | java | public static Set<Class<?>> getAllAnnotatedClasses(final String packagePath,
final Class<? extends Annotation> annotationClass)
throws ClassNotFoundException, IOException, URISyntaxException
{
final List<File> directories = ClassExtensions.getDirectoriesFromResources(packagePath,
true);
final Set<Class<?>> classes = new HashSet<>();
for (final File directory : directories)
{
classes.addAll(scanForAnnotatedClasses(directory, packagePath, annotationClass));
}
return classes;
} | [
"public",
"static",
"Set",
"<",
"Class",
"<",
"?",
">",
">",
"getAllAnnotatedClasses",
"(",
"final",
"String",
"packagePath",
",",
"final",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"annotationClass",
")",
"throws",
"ClassNotFoundException",
",",
"IOExcep... | Gets all annotated classes that belongs from the given package path and the given annotation
class.
@param packagePath
the package path
@param annotationClass
the annotation class
@return the all classes
@throws ClassNotFoundException
occurs if a given class cannot be located by the specified class loader
@throws IOException
Signals that an I/O exception has occurred.
@throws URISyntaxException
is thrown if a string could not be parsed as a URI reference. | [
"Gets",
"all",
"annotated",
"classes",
"that",
"belongs",
"from",
"the",
"given",
"package",
"path",
"and",
"the",
"given",
"annotation",
"class",
"."
] | 000e1f198e949ec3e721fd0fc3f5946e945232a3 | https://github.com/lightblueseas/jcommons-lang/blob/000e1f198e949ec3e721fd0fc3f5946e945232a3/src/main/java/de/alpharogroup/lang/AnnotationExtensions.java#L70-L82 | train |
lightblueseas/jcommons-lang | src/main/java/de/alpharogroup/lang/AnnotationExtensions.java | AnnotationExtensions.getAllAnnotatedClassesFromSet | public static Set<Class<?>> getAllAnnotatedClassesFromSet(final String packagePath,
final Set<Class<? extends Annotation>> annotationClasses)
throws ClassNotFoundException, IOException, URISyntaxException
{
final List<File> directories = ClassExtensions.getDirectoriesFromResources(packagePath,
true);
final Set<Class<?>> classes = new HashSet<>();
for (final File directory : directories)
{
classes
.addAll(scanForAnnotatedClassesFromSet(directory, packagePath, annotationClasses));
}
return classes;
} | java | public static Set<Class<?>> getAllAnnotatedClassesFromSet(final String packagePath,
final Set<Class<? extends Annotation>> annotationClasses)
throws ClassNotFoundException, IOException, URISyntaxException
{
final List<File> directories = ClassExtensions.getDirectoriesFromResources(packagePath,
true);
final Set<Class<?>> classes = new HashSet<>();
for (final File directory : directories)
{
classes
.addAll(scanForAnnotatedClassesFromSet(directory, packagePath, annotationClasses));
}
return classes;
} | [
"public",
"static",
"Set",
"<",
"Class",
"<",
"?",
">",
">",
"getAllAnnotatedClassesFromSet",
"(",
"final",
"String",
"packagePath",
",",
"final",
"Set",
"<",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
">",
"annotationClasses",
")",
"throws",
"ClassNotFo... | Gets all annotated classes that belongs from the given package path and the given list with
annotation classes.
@param packagePath
the package path
@param annotationClasses
the list with the annotation classes
@return the all classes
@throws ClassNotFoundException
occurs if a given class cannot be located by the specified class loader
@throws IOException
Signals that an I/O exception has occurred.
@throws URISyntaxException
is thrown if a string could not be parsed as a URI reference. | [
"Gets",
"all",
"annotated",
"classes",
"that",
"belongs",
"from",
"the",
"given",
"package",
"path",
"and",
"the",
"given",
"list",
"with",
"annotation",
"classes",
"."
] | 000e1f198e949ec3e721fd0fc3f5946e945232a3 | https://github.com/lightblueseas/jcommons-lang/blob/000e1f198e949ec3e721fd0fc3f5946e945232a3/src/main/java/de/alpharogroup/lang/AnnotationExtensions.java#L103-L116 | train |
lightblueseas/jcommons-lang | src/main/java/de/alpharogroup/lang/AnnotationExtensions.java | AnnotationExtensions.getAnnotation | public static <T extends Annotation> T getAnnotation(final Class<?> componentClass,
final Class<T> annotationClass)
{
T annotation = componentClass.getAnnotation(annotationClass);
if (annotation != null)
{
return annotation;
}
for (final Class<?> ifc : componentClass.getInterfaces())
{
annotation = getAnnotation(ifc, annotationClass);
if (annotation != null)
{
return annotation;
}
}
if (!Annotation.class.isAssignableFrom(componentClass))
{
for (final Annotation ann : componentClass.getAnnotations())
{
annotation = getAnnotation(ann.annotationType(), annotationClass);
if (annotation != null)
{
return annotation;
}
}
}
final Class<?> superClass = componentClass.getSuperclass();
if (superClass == null || superClass.equals(Object.class))
{
return null;
}
return getAnnotation(superClass, annotationClass);
} | java | public static <T extends Annotation> T getAnnotation(final Class<?> componentClass,
final Class<T> annotationClass)
{
T annotation = componentClass.getAnnotation(annotationClass);
if (annotation != null)
{
return annotation;
}
for (final Class<?> ifc : componentClass.getInterfaces())
{
annotation = getAnnotation(ifc, annotationClass);
if (annotation != null)
{
return annotation;
}
}
if (!Annotation.class.isAssignableFrom(componentClass))
{
for (final Annotation ann : componentClass.getAnnotations())
{
annotation = getAnnotation(ann.annotationType(), annotationClass);
if (annotation != null)
{
return annotation;
}
}
}
final Class<?> superClass = componentClass.getSuperclass();
if (superClass == null || superClass.equals(Object.class))
{
return null;
}
return getAnnotation(superClass, annotationClass);
} | [
"public",
"static",
"<",
"T",
"extends",
"Annotation",
">",
"T",
"getAnnotation",
"(",
"final",
"Class",
"<",
"?",
">",
"componentClass",
",",
"final",
"Class",
"<",
"T",
">",
"annotationClass",
")",
"{",
"T",
"annotation",
"=",
"componentClass",
".",
"get... | Search for the given annotationClass in the given componentClass and return it if search was
successful.
@param <T>
the generic type
@param componentClass
the component class
@param annotationClass
the annotation class
@return the annotation | [
"Search",
"for",
"the",
"given",
"annotationClass",
"in",
"the",
"given",
"componentClass",
"and",
"return",
"it",
"if",
"search",
"was",
"successful",
"."
] | 000e1f198e949ec3e721fd0fc3f5946e945232a3 | https://github.com/lightblueseas/jcommons-lang/blob/000e1f198e949ec3e721fd0fc3f5946e945232a3/src/main/java/de/alpharogroup/lang/AnnotationExtensions.java#L175-L208 | train |
lightblueseas/jcommons-lang | src/main/java/de/alpharogroup/lang/AnnotationExtensions.java | AnnotationExtensions.scanForClasses | public static Set<Class<?>> scanForClasses(final File directory, final String packagePath)
throws ClassNotFoundException
{
return AnnotationExtensions.scanForAnnotatedClasses(directory, packagePath, null);
} | java | public static Set<Class<?>> scanForClasses(final File directory, final String packagePath)
throws ClassNotFoundException
{
return AnnotationExtensions.scanForAnnotatedClasses(directory, packagePath, null);
} | [
"public",
"static",
"Set",
"<",
"Class",
"<",
"?",
">",
">",
"scanForClasses",
"(",
"final",
"File",
"directory",
",",
"final",
"String",
"packagePath",
")",
"throws",
"ClassNotFoundException",
"{",
"return",
"AnnotationExtensions",
".",
"scanForAnnotatedClasses",
... | Scan recursive for classes in the given directory.
@param directory
the directory
@param packagePath
the package path
@return the list
@throws ClassNotFoundException
occurs if a given class cannot be located by the specified class loader | [
"Scan",
"recursive",
"for",
"classes",
"in",
"the",
"given",
"directory",
"."
] | 000e1f198e949ec3e721fd0fc3f5946e945232a3 | https://github.com/lightblueseas/jcommons-lang/blob/000e1f198e949ec3e721fd0fc3f5946e945232a3/src/main/java/de/alpharogroup/lang/AnnotationExtensions.java#L416-L420 | train |
lightblueseas/jcommons-lang | src/main/java/de/alpharogroup/lang/AnnotationExtensions.java | AnnotationExtensions.setAnnotationValue | @SuppressWarnings("unchecked")
public static Object setAnnotationValue(final Annotation annotation, final String key,
final Object value) throws NoSuchFieldException, SecurityException,
IllegalArgumentException, IllegalAccessException
{
final Object invocationHandler = Proxy.getInvocationHandler(annotation);
final Field field = invocationHandler.getClass().getDeclaredField("memberValues");
field.setAccessible(true);
final Map<String, Object> memberValues = (Map<String, Object>)field.get(invocationHandler);
final Object oldValue = memberValues.get(key);
if (oldValue == null || oldValue.getClass() != value.getClass())
{
throw new IllegalArgumentException();
}
memberValues.put(key, value);
return oldValue;
} | java | @SuppressWarnings("unchecked")
public static Object setAnnotationValue(final Annotation annotation, final String key,
final Object value) throws NoSuchFieldException, SecurityException,
IllegalArgumentException, IllegalAccessException
{
final Object invocationHandler = Proxy.getInvocationHandler(annotation);
final Field field = invocationHandler.getClass().getDeclaredField("memberValues");
field.setAccessible(true);
final Map<String, Object> memberValues = (Map<String, Object>)field.get(invocationHandler);
final Object oldValue = memberValues.get(key);
if (oldValue == null || oldValue.getClass() != value.getClass())
{
throw new IllegalArgumentException();
}
memberValues.put(key, value);
return oldValue;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"Object",
"setAnnotationValue",
"(",
"final",
"Annotation",
"annotation",
",",
"final",
"String",
"key",
",",
"final",
"Object",
"value",
")",
"throws",
"NoSuchFieldException",
",",
"SecurityExc... | Sets the annotation value for the given key of the given annotation to the given new value at
runtime.
@param annotation
the annotation
@param key
the key
@param value
the value to set
@return the old value or default value if not set
@throws NoSuchFieldException
the no such field exception
@throws SecurityException
Thrown if the security manager indicates a security violation.
@throws IllegalArgumentException
the illegal argument exception
@throws IllegalAccessException
the illegal access exception | [
"Sets",
"the",
"annotation",
"value",
"for",
"the",
"given",
"key",
"of",
"the",
"given",
"annotation",
"to",
"the",
"given",
"new",
"value",
"at",
"runtime",
"."
] | 000e1f198e949ec3e721fd0fc3f5946e945232a3 | https://github.com/lightblueseas/jcommons-lang/blob/000e1f198e949ec3e721fd0fc3f5946e945232a3/src/main/java/de/alpharogroup/lang/AnnotationExtensions.java#L442-L458 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/util/ServiceLoader.java | ServiceLoader.iterator | public Iterator<S> iterator() {
return new Iterator<S>() {
Iterator<Map.Entry<String,S>> knownProviders
= providers.entrySet().iterator();
public boolean hasNext() {
if (knownProviders.hasNext())
return true;
return lookupIterator.hasNext();
}
public S next() {
if (knownProviders.hasNext())
return knownProviders.next().getValue();
return lookupIterator.next();
}
public void remove() {
throw new UnsupportedOperationException();
}
};
} | java | public Iterator<S> iterator() {
return new Iterator<S>() {
Iterator<Map.Entry<String,S>> knownProviders
= providers.entrySet().iterator();
public boolean hasNext() {
if (knownProviders.hasNext())
return true;
return lookupIterator.hasNext();
}
public S next() {
if (knownProviders.hasNext())
return knownProviders.next().getValue();
return lookupIterator.next();
}
public void remove() {
throw new UnsupportedOperationException();
}
};
} | [
"public",
"Iterator",
"<",
"S",
">",
"iterator",
"(",
")",
"{",
"return",
"new",
"Iterator",
"<",
"S",
">",
"(",
")",
"{",
"Iterator",
"<",
"Map",
".",
"Entry",
"<",
"String",
",",
"S",
">",
">",
"knownProviders",
"=",
"providers",
".",
"entrySet",
... | Lazily loads the available providers of this loader's service.
<p> The iterator returned by this method first yields all of the
elements of the provider cache, in instantiation order. It then lazily
loads and instantiates any remaining providers, adding each one to the
cache in turn.
<p> To achieve laziness the actual work of parsing the available
provider-configuration files and instantiating providers must be done by
the iterator itself. Its {@link java.util.Iterator#hasNext hasNext} and
{@link java.util.Iterator#next next} methods can therefore throw a
{@link ServiceConfigurationError} if a provider-configuration file
violates the specified format, or if it names a provider class that
cannot be found and instantiated, or if the result of instantiating the
class is not assignable to the service type, or if any other kind of
exception or error is thrown as the next provider is located and
instantiated. To write robust code it is only necessary to catch {@link
ServiceConfigurationError} when using a service iterator.
<p> If such an error is thrown then subsequent invocations of the
iterator will make a best effort to locate and instantiate the next
available provider, but in general such recovery cannot be guaranteed.
<blockquote style="font-size: smaller; line-height: 1.2"><span
style="padding-right: 1em; font-weight: bold">Design Note</span>
Throwing an error in these cases may seem extreme. The rationale for
this behavior is that a malformed provider-configuration file, like a
malformed class file, indicates a serious problem with the way the Java
virtual machine is configured or is being used. As such it is
preferable to throw an error rather than try to recover or, even worse,
fail silently.</blockquote>
<p> The iterator returned by this method does not support removal.
Invoking its {@link java.util.Iterator#remove() remove} method will
cause an {@link UnsupportedOperationException} to be thrown.
@return An iterator that lazily loads providers for this loader's
service | [
"Lazily",
"loads",
"the",
"available",
"providers",
"of",
"this",
"loader",
"s",
"service",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/util/ServiceLoader.java#L322-L345 | train |
coopernurse/barrister-java | src/main/java/com/bitmechanic/barrister/Interface.java | Interface.getFunction | public Function getFunction(String name) {
for (Function f : functions) {
if (f.getName().equals(name))
return f;
}
return null;
} | java | public Function getFunction(String name) {
for (Function f : functions) {
if (f.getName().equals(name))
return f;
}
return null;
} | [
"public",
"Function",
"getFunction",
"(",
"String",
"name",
")",
"{",
"for",
"(",
"Function",
"f",
":",
"functions",
")",
"{",
"if",
"(",
"f",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"name",
")",
")",
"return",
"f",
";",
"}",
"return",
"null"... | Returns the Function with the given name, or null if none matches. | [
"Returns",
"the",
"Function",
"with",
"the",
"given",
"name",
"or",
"null",
"if",
"none",
"matches",
"."
] | c2b639634c88a25002b66d1fb4a8f5fb51ade6a2 | https://github.com/coopernurse/barrister-java/blob/c2b639634c88a25002b66d1fb4a8f5fb51ade6a2/src/main/java/com/bitmechanic/barrister/Interface.java#L40-L47 | train |
coopernurse/barrister-java | src/main/java/com/bitmechanic/barrister/Interface.java | Interface.setContract | @Override
public void setContract(Contract c) {
super.setContract(c);
for (Function f : functions) {
f.setContract(c);
}
} | java | @Override
public void setContract(Contract c) {
super.setContract(c);
for (Function f : functions) {
f.setContract(c);
}
} | [
"@",
"Override",
"public",
"void",
"setContract",
"(",
"Contract",
"c",
")",
"{",
"super",
".",
"setContract",
"(",
"c",
")",
";",
"for",
"(",
"Function",
"f",
":",
"functions",
")",
"{",
"f",
".",
"setContract",
"(",
"c",
")",
";",
"}",
"}"
] | Sets the Contract this Interface is a part of. Propegates to its Functions | [
"Sets",
"the",
"Contract",
"this",
"Interface",
"is",
"a",
"part",
"of",
".",
"Propegates",
"to",
"its",
"Functions"
] | c2b639634c88a25002b66d1fb4a8f5fb51ade6a2 | https://github.com/coopernurse/barrister-java/blob/c2b639634c88a25002b66d1fb4a8f5fb51ade6a2/src/main/java/com/bitmechanic/barrister/Interface.java#L52-L58 | train |
trellis-ldp-archive/trellis-api | src/main/java/org/trellisldp/api/RDFUtils.java | RDFUtils.toGraph | public static Collector<Triple, ?, Graph> toGraph() {
return of(rdf::createGraph, Graph::add, (left, right) -> {
right.iterate().forEach(left::add);
return left;
}, UNORDERED);
} | java | public static Collector<Triple, ?, Graph> toGraph() {
return of(rdf::createGraph, Graph::add, (left, right) -> {
right.iterate().forEach(left::add);
return left;
}, UNORDERED);
} | [
"public",
"static",
"Collector",
"<",
"Triple",
",",
"?",
",",
"Graph",
">",
"toGraph",
"(",
")",
"{",
"return",
"of",
"(",
"rdf",
"::",
"createGraph",
",",
"Graph",
"::",
"add",
",",
"(",
"left",
",",
"right",
")",
"->",
"{",
"right",
".",
"iterat... | Collect a stream of Triples into a Graph
@return a graph | [
"Collect",
"a",
"stream",
"of",
"Triples",
"into",
"a",
"Graph"
] | 9538979dc90e2d37c83d98870cd3795a2c96915e | https://github.com/trellis-ldp-archive/trellis-api/blob/9538979dc90e2d37c83d98870cd3795a2c96915e/src/main/java/org/trellisldp/api/RDFUtils.java#L61-L66 | train |
trellis-ldp-archive/trellis-api | src/main/java/org/trellisldp/api/RDFUtils.java | RDFUtils.toDataset | public static Collector<Quad, ?, Dataset> toDataset() {
return of(rdf::createDataset, Dataset::add, (left, right) -> {
right.iterate().forEach(left::add);
return left;
}, UNORDERED);
} | java | public static Collector<Quad, ?, Dataset> toDataset() {
return of(rdf::createDataset, Dataset::add, (left, right) -> {
right.iterate().forEach(left::add);
return left;
}, UNORDERED);
} | [
"public",
"static",
"Collector",
"<",
"Quad",
",",
"?",
",",
"Dataset",
">",
"toDataset",
"(",
")",
"{",
"return",
"of",
"(",
"rdf",
"::",
"createDataset",
",",
"Dataset",
"::",
"add",
",",
"(",
"left",
",",
"right",
")",
"->",
"{",
"right",
".",
"... | Collect a stream of Quads into a Dataset
@return a dataset | [
"Collect",
"a",
"stream",
"of",
"Quads",
"into",
"a",
"Dataset"
] | 9538979dc90e2d37c83d98870cd3795a2c96915e | https://github.com/trellis-ldp-archive/trellis-api/blob/9538979dc90e2d37c83d98870cd3795a2c96915e/src/main/java/org/trellisldp/api/RDFUtils.java#L72-L77 | train |
devnull-tools/trugger | src/main/java/tools/devnull/trugger/util/factory/ContextFactory.java | ContextFactory.toCreate | public ContextFactory toCreate(BiFunction<Constructor, Object[], Object> function) {
return new ContextFactory(this.context, function);
} | java | public ContextFactory toCreate(BiFunction<Constructor, Object[], Object> function) {
return new ContextFactory(this.context, function);
} | [
"public",
"ContextFactory",
"toCreate",
"(",
"BiFunction",
"<",
"Constructor",
",",
"Object",
"[",
"]",
",",
"Object",
">",
"function",
")",
"{",
"return",
"new",
"ContextFactory",
"(",
"this",
".",
"context",
",",
"function",
")",
";",
"}"
] | Changes the way the objects are created by using the given function.
@param function the function to use for creating the objects.
@return a new ContextFactory that uses the given function and this context | [
"Changes",
"the",
"way",
"the",
"objects",
"are",
"created",
"by",
"using",
"the",
"given",
"function",
"."
] | 614d5f0b30daf82fc251a46fb436d0fc5e787627 | https://github.com/devnull-tools/trugger/blob/614d5f0b30daf82fc251a46fb436d0fc5e787627/src/main/java/tools/devnull/trugger/util/factory/ContextFactory.java#L89-L91 | train |
devnull-tools/trugger | src/main/java/tools/devnull/trugger/util/factory/ContextFactory.java | ContextFactory.create | public <E> Optional<E> create(Class<E> type) {
List<Constructor<?>> constructors = reflect().constructors()
.filter(declared(Modifier.PUBLIC))
.from(type);
Optional created;
for (Constructor<?> constructor : constructors) {
created = tryCreate(constructor);
if (created.isPresent()) {
return created;
}
}
return Optional.empty();
} | java | public <E> Optional<E> create(Class<E> type) {
List<Constructor<?>> constructors = reflect().constructors()
.filter(declared(Modifier.PUBLIC))
.from(type);
Optional created;
for (Constructor<?> constructor : constructors) {
created = tryCreate(constructor);
if (created.isPresent()) {
return created;
}
}
return Optional.empty();
} | [
"public",
"<",
"E",
">",
"Optional",
"<",
"E",
">",
"create",
"(",
"Class",
"<",
"E",
">",
"type",
")",
"{",
"List",
"<",
"Constructor",
"<",
"?",
">",
">",
"constructors",
"=",
"reflect",
"(",
")",
".",
"constructors",
"(",
")",
".",
"filter",
"... | Creates a new instance of the given type by looping through its public
constructors to find one which all parameters are resolved by the context.
@param type the type of the object to create.
@return the created object | [
"Creates",
"a",
"new",
"instance",
"of",
"the",
"given",
"type",
"by",
"looping",
"through",
"its",
"public",
"constructors",
"to",
"find",
"one",
"which",
"all",
"parameters",
"are",
"resolved",
"by",
"the",
"context",
"."
] | 614d5f0b30daf82fc251a46fb436d0fc5e787627 | https://github.com/devnull-tools/trugger/blob/614d5f0b30daf82fc251a46fb436d0fc5e787627/src/main/java/tools/devnull/trugger/util/factory/ContextFactory.java#L100-L112 | train |
devnull-tools/trugger | src/main/java/tools/devnull/trugger/util/factory/ContextFactory.java | ContextFactory.tryCreate | private Optional tryCreate(Constructor<?> constructor) {
Object[] args = new Object[constructor.getParameterCount()];
Object arg;
Optional<Object> resolved;
int i = 0;
for (Parameter parameter : constructor.getParameters()) {
resolved = context.resolve(parameter);
if (!resolved.isPresent()) {
return Optional.empty();
}
arg = resolved.value();
args[i++] = arg;
}
return Optional.of(createFunction.apply(constructor, args));
} | java | private Optional tryCreate(Constructor<?> constructor) {
Object[] args = new Object[constructor.getParameterCount()];
Object arg;
Optional<Object> resolved;
int i = 0;
for (Parameter parameter : constructor.getParameters()) {
resolved = context.resolve(parameter);
if (!resolved.isPresent()) {
return Optional.empty();
}
arg = resolved.value();
args[i++] = arg;
}
return Optional.of(createFunction.apply(constructor, args));
} | [
"private",
"Optional",
"tryCreate",
"(",
"Constructor",
"<",
"?",
">",
"constructor",
")",
"{",
"Object",
"[",
"]",
"args",
"=",
"new",
"Object",
"[",
"constructor",
".",
"getParameterCount",
"(",
")",
"]",
";",
"Object",
"arg",
";",
"Optional",
"<",
"Ob... | tries to create the object using the given constructor | [
"tries",
"to",
"create",
"the",
"object",
"using",
"the",
"given",
"constructor"
] | 614d5f0b30daf82fc251a46fb436d0fc5e787627 | https://github.com/devnull-tools/trugger/blob/614d5f0b30daf82fc251a46fb436d0fc5e787627/src/main/java/tools/devnull/trugger/util/factory/ContextFactory.java#L115-L129 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/sjavac/comp/JavaCompilerWithDeps.java | JavaCompilerWithDeps.reportPublicApi | @Override
public void reportPublicApi(ClassSymbol sym) {
// The next test will catch when source files are located in the wrong directory!
// This ought to be moved into javac as a new warning, or perhaps as part
// of the auxiliary class warning.
// For example if sun.swing.BeanInfoUtils
// is in fact stored in: /mybuild/jdk/gensrc/javax/swing/beaninfo/BeanInfoUtils.java
// We do not need to test that BeanInfoUtils is stored in a file named BeanInfoUtils
// since this is checked earlier.
if (sym.sourcefile != null) {
// Rewrite sun.swing.BeanInfoUtils into /sun/swing/
StringBuilder pathb = new StringBuilder();
StringTokenizer qn = new StringTokenizer(sym.packge().toString(), ".");
boolean first = true;
while (qn.hasMoreTokens()) {
String o = qn.nextToken();
pathb.append("/");
pathb.append(o);
first = false;
}
pathb.append("/");
String path = pathb.toString();
// Now cut the uri to be: file:///mybuild/jdk/gensrc/javax/swing/beaninfo/
String p = sym.sourcefile.toUri().getPath();
// Do not use File.separatorChar here, a URI always uses slashes /.
int i = p.lastIndexOf("/");
String pp = p.substring(0,i+1);
// Now check if the truncated uri ends with the path. (It does not == failure!)
if (path.length() > 0 && !path.equals("/unnamed package/") && !pp.endsWith(path)) {
compilerThread.logError("Error: The source file "+sym.sourcefile.getName()+
" is located in the wrong package directory, because it contains the class "+
sym.getQualifiedName());
}
}
deps.visitPubapi(sym);
} | java | @Override
public void reportPublicApi(ClassSymbol sym) {
// The next test will catch when source files are located in the wrong directory!
// This ought to be moved into javac as a new warning, or perhaps as part
// of the auxiliary class warning.
// For example if sun.swing.BeanInfoUtils
// is in fact stored in: /mybuild/jdk/gensrc/javax/swing/beaninfo/BeanInfoUtils.java
// We do not need to test that BeanInfoUtils is stored in a file named BeanInfoUtils
// since this is checked earlier.
if (sym.sourcefile != null) {
// Rewrite sun.swing.BeanInfoUtils into /sun/swing/
StringBuilder pathb = new StringBuilder();
StringTokenizer qn = new StringTokenizer(sym.packge().toString(), ".");
boolean first = true;
while (qn.hasMoreTokens()) {
String o = qn.nextToken();
pathb.append("/");
pathb.append(o);
first = false;
}
pathb.append("/");
String path = pathb.toString();
// Now cut the uri to be: file:///mybuild/jdk/gensrc/javax/swing/beaninfo/
String p = sym.sourcefile.toUri().getPath();
// Do not use File.separatorChar here, a URI always uses slashes /.
int i = p.lastIndexOf("/");
String pp = p.substring(0,i+1);
// Now check if the truncated uri ends with the path. (It does not == failure!)
if (path.length() > 0 && !path.equals("/unnamed package/") && !pp.endsWith(path)) {
compilerThread.logError("Error: The source file "+sym.sourcefile.getName()+
" is located in the wrong package directory, because it contains the class "+
sym.getQualifiedName());
}
}
deps.visitPubapi(sym);
} | [
"@",
"Override",
"public",
"void",
"reportPublicApi",
"(",
"ClassSymbol",
"sym",
")",
"{",
"// The next test will catch when source files are located in the wrong directory!",
"// This ought to be moved into javac as a new warning, or perhaps as part",
"// of the auxiliary class warning.",
... | Collect the public apis of classes supplied explicitly for compilation.
@param sym The class to visit. | [
"Collect",
"the",
"public",
"apis",
"of",
"classes",
"supplied",
"explicitly",
"for",
"compilation",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/sjavac/comp/JavaCompilerWithDeps.java#L69-L108 | train |
mcpat/microjiac-public | tools/microjiac-midlet-maven-plugin/src/main/java/de/jiac/micro/mojo/JADMojo.java | JADMojo.execute | public void execute() throws MojoExecutionException {
getLog().debug("starting packaging");
AbstractConfiguration[] configurations= (AbstractConfiguration[]) getPluginContext().get(ConfiguratorMojo.GENERATED_CONFIGURATIONS_KEY);
try {
for(AbstractConfiguration configuration : configurations) {
if(!(configuration instanceof NodeConfiguration)) {
continue;
}
String classifier= configuration.className.substring(configuration.className.lastIndexOf('.') + 1);
File jarFile= checkJarFile(classifier);
JavaApplicationDescriptor descriptor= getDescriptor();
descriptor.setNodeConfiguration(configuration.className);
descriptor.setJarFile(jarFile);
File jadFile= getJadFile(classifier);
getDescriptor().writeDescriptor(jadFile);
getProjectHelper().attachArtifact(getProject(), "jad", classifier, jadFile);
}
} catch (IOException ioe) {
throw new MojoExecutionException("could not create .jad file", ioe);
} catch (RuntimeException e) {
throw new MojoExecutionException("could not create .jad file", e);
}
getLog().debug("finished packaging");
} | java | public void execute() throws MojoExecutionException {
getLog().debug("starting packaging");
AbstractConfiguration[] configurations= (AbstractConfiguration[]) getPluginContext().get(ConfiguratorMojo.GENERATED_CONFIGURATIONS_KEY);
try {
for(AbstractConfiguration configuration : configurations) {
if(!(configuration instanceof NodeConfiguration)) {
continue;
}
String classifier= configuration.className.substring(configuration.className.lastIndexOf('.') + 1);
File jarFile= checkJarFile(classifier);
JavaApplicationDescriptor descriptor= getDescriptor();
descriptor.setNodeConfiguration(configuration.className);
descriptor.setJarFile(jarFile);
File jadFile= getJadFile(classifier);
getDescriptor().writeDescriptor(jadFile);
getProjectHelper().attachArtifact(getProject(), "jad", classifier, jadFile);
}
} catch (IOException ioe) {
throw new MojoExecutionException("could not create .jad file", ioe);
} catch (RuntimeException e) {
throw new MojoExecutionException("could not create .jad file", e);
}
getLog().debug("finished packaging");
} | [
"public",
"void",
"execute",
"(",
")",
"throws",
"MojoExecutionException",
"{",
"getLog",
"(",
")",
".",
"debug",
"(",
"\"starting packaging\"",
")",
";",
"AbstractConfiguration",
"[",
"]",
"configurations",
"=",
"(",
"AbstractConfiguration",
"[",
"]",
")",
"get... | Generates the JAD. | [
"Generates",
"the",
"JAD",
"."
] | 3c649e44846981a68e84cc4578719532414d8d35 | https://github.com/mcpat/microjiac-public/blob/3c649e44846981a68e84cc4578719532414d8d35/tools/microjiac-midlet-maven-plugin/src/main/java/de/jiac/micro/mojo/JADMojo.java#L51-L77 | train |
base2Services/kagura | shared/reporting-core/src/main/java/com/base2/kagura/core/report/connectors/FreemarkerSQLDataReportConnector.java | FreemarkerSQLDataReportConnector.resultSetToMap | public List<Map<String,Object>> resultSetToMap(ResultSet rows) {
try {
List<Map<String,Object>> beans = new ArrayList<Map<String,Object>>();
int columnCount = rows.getMetaData().getColumnCount();
while (rows.next()) {
LinkedHashMap<String,Object> bean = new LinkedHashMap<String, Object>();
beans.add(bean);
for (int i = 0; i < columnCount; i++) {
Object object = rows.getObject(i + 1);
String columnLabel = rows.getMetaData().getColumnLabel(i + 1);
String columnName = rows.getMetaData().getColumnName(i + 1);
bean.put(StringUtils.defaultIfEmpty(columnLabel, columnName), object != null ? object.toString() : "");
}
}
return beans;
} catch (Exception ex) {
errors.add(ex.getMessage());
throw new RuntimeException(ex);
}
} | java | public List<Map<String,Object>> resultSetToMap(ResultSet rows) {
try {
List<Map<String,Object>> beans = new ArrayList<Map<String,Object>>();
int columnCount = rows.getMetaData().getColumnCount();
while (rows.next()) {
LinkedHashMap<String,Object> bean = new LinkedHashMap<String, Object>();
beans.add(bean);
for (int i = 0; i < columnCount; i++) {
Object object = rows.getObject(i + 1);
String columnLabel = rows.getMetaData().getColumnLabel(i + 1);
String columnName = rows.getMetaData().getColumnName(i + 1);
bean.put(StringUtils.defaultIfEmpty(columnLabel, columnName), object != null ? object.toString() : "");
}
}
return beans;
} catch (Exception ex) {
errors.add(ex.getMessage());
throw new RuntimeException(ex);
}
} | [
"public",
"List",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"resultSetToMap",
"(",
"ResultSet",
"rows",
")",
"{",
"try",
"{",
"List",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"beans",
"=",
"new",
"ArrayList",
"<",
"Map",
"<",
"... | Returns a preparedStatement result into a List of Maps. Not the most efficient way of storing the values, however
the results should be limited at this stage.
@param rows The result set.
@return Mapped results.
@throws RuntimeException upon any error, adds values to "errors" | [
"Returns",
"a",
"preparedStatement",
"result",
"into",
"a",
"List",
"of",
"Maps",
".",
"Not",
"the",
"most",
"efficient",
"way",
"of",
"storing",
"the",
"values",
"however",
"the",
"results",
"should",
"be",
"limited",
"at",
"this",
"stage",
"."
] | 5564aa71bfa2cb3baaae2eb098c6c673dd4e82ee | https://github.com/base2Services/kagura/blob/5564aa71bfa2cb3baaae2eb098c6c673dd4e82ee/shared/reporting-core/src/main/java/com/base2/kagura/core/report/connectors/FreemarkerSQLDataReportConnector.java#L234-L253 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java | LambdaToMethod.makeMetafactoryIndyCall | private JCExpression makeMetafactoryIndyCall(TranslationContext<?> context,
int refKind, Symbol refSym, List<JCExpression> indy_args) {
JCFunctionalExpression tree = context.tree;
//determine the static bsm args
MethodSymbol samSym = (MethodSymbol) types.findDescriptorSymbol(tree.type.tsym);
List<Object> staticArgs = List.<Object>of(
typeToMethodType(samSym.type),
new Pool.MethodHandle(refKind, refSym, types),
typeToMethodType(tree.getDescriptorType(types)));
//computed indy arg types
ListBuffer<Type> indy_args_types = new ListBuffer<>();
for (JCExpression arg : indy_args) {
indy_args_types.append(arg.type);
}
//finally, compute the type of the indy call
MethodType indyType = new MethodType(indy_args_types.toList(),
tree.type,
List.<Type>nil(),
syms.methodClass);
Name metafactoryName = context.needsAltMetafactory() ?
names.altMetafactory : names.metafactory;
if (context.needsAltMetafactory()) {
ListBuffer<Object> markers = new ListBuffer<>();
for (Type t : tree.targets.tail) {
if (t.tsym != syms.serializableType.tsym) {
markers.append(t.tsym);
}
}
int flags = context.isSerializable() ? FLAG_SERIALIZABLE : 0;
boolean hasMarkers = markers.nonEmpty();
boolean hasBridges = context.bridges.nonEmpty();
if (hasMarkers) {
flags |= FLAG_MARKERS;
}
if (hasBridges) {
flags |= FLAG_BRIDGES;
}
staticArgs = staticArgs.append(flags);
if (hasMarkers) {
staticArgs = staticArgs.append(markers.length());
staticArgs = staticArgs.appendList(markers.toList());
}
if (hasBridges) {
staticArgs = staticArgs.append(context.bridges.length() - 1);
for (Symbol s : context.bridges) {
Type s_erasure = s.erasure(types);
if (!types.isSameType(s_erasure, samSym.erasure(types))) {
staticArgs = staticArgs.append(s.erasure(types));
}
}
}
if (context.isSerializable()) {
int prevPos = make.pos;
try {
make.at(kInfo.clazz);
addDeserializationCase(refKind, refSym, tree.type, samSym,
tree, staticArgs, indyType);
} finally {
make.at(prevPos);
}
}
}
return makeIndyCall(tree, syms.lambdaMetafactory, metafactoryName, staticArgs, indyType, indy_args, samSym.name);
} | java | private JCExpression makeMetafactoryIndyCall(TranslationContext<?> context,
int refKind, Symbol refSym, List<JCExpression> indy_args) {
JCFunctionalExpression tree = context.tree;
//determine the static bsm args
MethodSymbol samSym = (MethodSymbol) types.findDescriptorSymbol(tree.type.tsym);
List<Object> staticArgs = List.<Object>of(
typeToMethodType(samSym.type),
new Pool.MethodHandle(refKind, refSym, types),
typeToMethodType(tree.getDescriptorType(types)));
//computed indy arg types
ListBuffer<Type> indy_args_types = new ListBuffer<>();
for (JCExpression arg : indy_args) {
indy_args_types.append(arg.type);
}
//finally, compute the type of the indy call
MethodType indyType = new MethodType(indy_args_types.toList(),
tree.type,
List.<Type>nil(),
syms.methodClass);
Name metafactoryName = context.needsAltMetafactory() ?
names.altMetafactory : names.metafactory;
if (context.needsAltMetafactory()) {
ListBuffer<Object> markers = new ListBuffer<>();
for (Type t : tree.targets.tail) {
if (t.tsym != syms.serializableType.tsym) {
markers.append(t.tsym);
}
}
int flags = context.isSerializable() ? FLAG_SERIALIZABLE : 0;
boolean hasMarkers = markers.nonEmpty();
boolean hasBridges = context.bridges.nonEmpty();
if (hasMarkers) {
flags |= FLAG_MARKERS;
}
if (hasBridges) {
flags |= FLAG_BRIDGES;
}
staticArgs = staticArgs.append(flags);
if (hasMarkers) {
staticArgs = staticArgs.append(markers.length());
staticArgs = staticArgs.appendList(markers.toList());
}
if (hasBridges) {
staticArgs = staticArgs.append(context.bridges.length() - 1);
for (Symbol s : context.bridges) {
Type s_erasure = s.erasure(types);
if (!types.isSameType(s_erasure, samSym.erasure(types))) {
staticArgs = staticArgs.append(s.erasure(types));
}
}
}
if (context.isSerializable()) {
int prevPos = make.pos;
try {
make.at(kInfo.clazz);
addDeserializationCase(refKind, refSym, tree.type, samSym,
tree, staticArgs, indyType);
} finally {
make.at(prevPos);
}
}
}
return makeIndyCall(tree, syms.lambdaMetafactory, metafactoryName, staticArgs, indyType, indy_args, samSym.name);
} | [
"private",
"JCExpression",
"makeMetafactoryIndyCall",
"(",
"TranslationContext",
"<",
"?",
">",
"context",
",",
"int",
"refKind",
",",
"Symbol",
"refSym",
",",
"List",
"<",
"JCExpression",
">",
"indy_args",
")",
"{",
"JCFunctionalExpression",
"tree",
"=",
"context... | Generate an indy method call to the meta factory | [
"Generate",
"an",
"indy",
"method",
"call",
"to",
"the",
"meta",
"factory"
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java#L983-L1051 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java | LambdaToMethod.makeIndyCall | private JCExpression makeIndyCall(DiagnosticPosition pos, Type site, Name bsmName,
List<Object> staticArgs, MethodType indyType, List<JCExpression> indyArgs,
Name methName) {
int prevPos = make.pos;
try {
make.at(pos);
List<Type> bsm_staticArgs = List.of(syms.methodHandleLookupType,
syms.stringType,
syms.methodTypeType).appendList(bsmStaticArgToTypes(staticArgs));
Symbol bsm = rs.resolveInternalMethod(pos, attrEnv, site,
bsmName, bsm_staticArgs, List.<Type>nil());
DynamicMethodSymbol dynSym =
new DynamicMethodSymbol(methName,
syms.noSymbol,
bsm.isStatic() ?
ClassFile.REF_invokeStatic :
ClassFile.REF_invokeVirtual,
(MethodSymbol)bsm,
indyType,
staticArgs.toArray());
JCFieldAccess qualifier = make.Select(make.QualIdent(site.tsym), bsmName);
qualifier.sym = dynSym;
qualifier.type = indyType.getReturnType();
JCMethodInvocation proxyCall = make.Apply(List.<JCExpression>nil(), qualifier, indyArgs);
proxyCall.type = indyType.getReturnType();
return proxyCall;
} finally {
make.at(prevPos);
}
} | java | private JCExpression makeIndyCall(DiagnosticPosition pos, Type site, Name bsmName,
List<Object> staticArgs, MethodType indyType, List<JCExpression> indyArgs,
Name methName) {
int prevPos = make.pos;
try {
make.at(pos);
List<Type> bsm_staticArgs = List.of(syms.methodHandleLookupType,
syms.stringType,
syms.methodTypeType).appendList(bsmStaticArgToTypes(staticArgs));
Symbol bsm = rs.resolveInternalMethod(pos, attrEnv, site,
bsmName, bsm_staticArgs, List.<Type>nil());
DynamicMethodSymbol dynSym =
new DynamicMethodSymbol(methName,
syms.noSymbol,
bsm.isStatic() ?
ClassFile.REF_invokeStatic :
ClassFile.REF_invokeVirtual,
(MethodSymbol)bsm,
indyType,
staticArgs.toArray());
JCFieldAccess qualifier = make.Select(make.QualIdent(site.tsym), bsmName);
qualifier.sym = dynSym;
qualifier.type = indyType.getReturnType();
JCMethodInvocation proxyCall = make.Apply(List.<JCExpression>nil(), qualifier, indyArgs);
proxyCall.type = indyType.getReturnType();
return proxyCall;
} finally {
make.at(prevPos);
}
} | [
"private",
"JCExpression",
"makeIndyCall",
"(",
"DiagnosticPosition",
"pos",
",",
"Type",
"site",
",",
"Name",
"bsmName",
",",
"List",
"<",
"Object",
">",
"staticArgs",
",",
"MethodType",
"indyType",
",",
"List",
"<",
"JCExpression",
">",
"indyArgs",
",",
"Nam... | Generate an indy method call with given name, type and static bootstrap
arguments types | [
"Generate",
"an",
"indy",
"method",
"call",
"with",
"given",
"name",
"type",
"and",
"static",
"bootstrap",
"arguments",
"types"
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java#L1057-L1090 | train |
brianwhu/xillium | core/src/main/java/org/xillium/core/util/ProxyService.java | ProxyService.lookupServerURL | protected String lookupServerURL(DataBinder binder) {
_logger.info("STANDARD lookupServerURL: servers=" + _servers + ", selector='" + _selector + '\'');
if (_servers != null) {
if (_selector != null) {
return _servers.get(binder.get(_selector));
} else if (_servers.size() == 1) {
return _servers.values().iterator().next();
} else {
return null;
}
} else {
return null;
}
} | java | protected String lookupServerURL(DataBinder binder) {
_logger.info("STANDARD lookupServerURL: servers=" + _servers + ", selector='" + _selector + '\'');
if (_servers != null) {
if (_selector != null) {
return _servers.get(binder.get(_selector));
} else if (_servers.size() == 1) {
return _servers.values().iterator().next();
} else {
return null;
}
} else {
return null;
}
} | [
"protected",
"String",
"lookupServerURL",
"(",
"DataBinder",
"binder",
")",
"{",
"_logger",
".",
"info",
"(",
"\"STANDARD lookupServerURL: servers=\"",
"+",
"_servers",
"+",
"\", selector='\"",
"+",
"_selector",
"+",
"'",
"'",
")",
";",
"if",
"(",
"_servers",
"!... | Looks up server URL based on request parameters in the data binder.
The default implementation uses a servers looup map and a selector parameter. You may choose not to use a selector if the
lookup map contains only 1 entry.
@return the URL to a remote server, or null if lookup fails | [
"Looks",
"up",
"server",
"URL",
"based",
"on",
"request",
"parameters",
"in",
"the",
"data",
"binder",
"."
] | e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799 | https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/core/src/main/java/org/xillium/core/util/ProxyService.java#L30-L43 | train |
theHilikus/JRoboCom | jrobocom-core/src/main/java/com/github/thehilikus/jrobocom/World.java | World.clean | public void clean() {
log.debug("[clean] Cleaning world");
for (Robot bot : robotsPosition.keySet()) {
bot.die("World cleanup");
if (robotsPosition.containsKey(bot)) {
log.warn("[clean] Robot did not unregister itself. Removing it");
remove(bot);
}
}
} | java | public void clean() {
log.debug("[clean] Cleaning world");
for (Robot bot : robotsPosition.keySet()) {
bot.die("World cleanup");
if (robotsPosition.containsKey(bot)) {
log.warn("[clean] Robot did not unregister itself. Removing it");
remove(bot);
}
}
} | [
"public",
"void",
"clean",
"(",
")",
"{",
"log",
".",
"debug",
"(",
"\"[clean] Cleaning world\"",
")",
";",
"for",
"(",
"Robot",
"bot",
":",
"robotsPosition",
".",
"keySet",
"(",
")",
")",
"{",
"bot",
".",
"die",
"(",
"\"World cleanup\"",
")",
";",
"if... | Called to dispose of the world | [
"Called",
"to",
"dispose",
"of",
"the",
"world"
] | 0e31c1ecf1006e35f68c229ff66c37640effffac | https://github.com/theHilikus/JRoboCom/blob/0e31c1ecf1006e35f68c229ff66c37640effffac/jrobocom-core/src/main/java/com/github/thehilikus/jrobocom/World.java#L170-L181 | train |
theHilikus/JRoboCom | jrobocom-core/src/main/java/com/github/thehilikus/jrobocom/World.java | World.move | public void move(Robot robot) {
if (!robotsPosition.containsKey(robot)) {
throw new IllegalArgumentException("Robot doesn't exist");
}
if (!robot.getData().isMobile()) {
throw new IllegalArgumentException("Robot can't move");
}
Point newPosition = getReferenceField(robot, 1);
if (!isOccupied(newPosition)) {
Point oldPosition = robotsPosition.get(robot);
robotsPosition.put(robot, newPosition);
eventDispatcher.fireEvent(new RobotMovedEvent(robot, oldPosition, newPosition));
}
} | java | public void move(Robot robot) {
if (!robotsPosition.containsKey(robot)) {
throw new IllegalArgumentException("Robot doesn't exist");
}
if (!robot.getData().isMobile()) {
throw new IllegalArgumentException("Robot can't move");
}
Point newPosition = getReferenceField(robot, 1);
if (!isOccupied(newPosition)) {
Point oldPosition = robotsPosition.get(robot);
robotsPosition.put(robot, newPosition);
eventDispatcher.fireEvent(new RobotMovedEvent(robot, oldPosition, newPosition));
}
} | [
"public",
"void",
"move",
"(",
"Robot",
"robot",
")",
"{",
"if",
"(",
"!",
"robotsPosition",
".",
"containsKey",
"(",
"robot",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Robot doesn't exist\"",
")",
";",
"}",
"if",
"(",
"!",
"robot"... | Changes the position of a robot to its current reference field
@param robot the robot | [
"Changes",
"the",
"position",
"of",
"a",
"robot",
"to",
"its",
"current",
"reference",
"field"
] | 0e31c1ecf1006e35f68c229ff66c37640effffac | https://github.com/theHilikus/JRoboCom/blob/0e31c1ecf1006e35f68c229ff66c37640effffac/jrobocom-core/src/main/java/com/github/thehilikus/jrobocom/World.java#L188-L203 | train |
theHilikus/JRoboCom | jrobocom-core/src/main/java/com/github/thehilikus/jrobocom/World.java | World.getNeighbour | public Robot getNeighbour(Robot robot) {
Point neighbourPos = getReferenceField(robot, 1);
return getRobotAt(neighbourPos);
} | java | public Robot getNeighbour(Robot robot) {
Point neighbourPos = getReferenceField(robot, 1);
return getRobotAt(neighbourPos);
} | [
"public",
"Robot",
"getNeighbour",
"(",
"Robot",
"robot",
")",
"{",
"Point",
"neighbourPos",
"=",
"getReferenceField",
"(",
"robot",
",",
"1",
")",
";",
"return",
"getRobotAt",
"(",
"neighbourPos",
")",
";",
"}"
] | Gets the robot in the reference field
@param robot the robot to use as centre
@return the robot in front, or null if field is empty | [
"Gets",
"the",
"robot",
"in",
"the",
"reference",
"field"
] | 0e31c1ecf1006e35f68c229ff66c37640effffac | https://github.com/theHilikus/JRoboCom/blob/0e31c1ecf1006e35f68c229ff66c37640effffac/jrobocom-core/src/main/java/com/github/thehilikus/jrobocom/World.java#L252-L256 | train |
theHilikus/JRoboCom | jrobocom-core/src/main/java/com/github/thehilikus/jrobocom/World.java | World.scan | public ScanResult scan(Robot robot, int dist) {
Point space = getReferenceField(robot, dist);
Robot inPosition = getRobotAt(space);
ScanResult ret = null;
if (inPosition == null) {
ret = new ScanResult(Found.EMPTY, dist);
} else {
if (robot.getData().getTeamId() == inPosition.getData().getTeamId()) {
ret = new ScanResult(Found.FRIEND, dist);
} else {
ret = new ScanResult(Found.ENEMY, dist);
}
}
return ret;
} | java | public ScanResult scan(Robot robot, int dist) {
Point space = getReferenceField(robot, dist);
Robot inPosition = getRobotAt(space);
ScanResult ret = null;
if (inPosition == null) {
ret = new ScanResult(Found.EMPTY, dist);
} else {
if (robot.getData().getTeamId() == inPosition.getData().getTeamId()) {
ret = new ScanResult(Found.FRIEND, dist);
} else {
ret = new ScanResult(Found.ENEMY, dist);
}
}
return ret;
} | [
"public",
"ScanResult",
"scan",
"(",
"Robot",
"robot",
",",
"int",
"dist",
")",
"{",
"Point",
"space",
"=",
"getReferenceField",
"(",
"robot",
",",
"dist",
")",
";",
"Robot",
"inPosition",
"=",
"getRobotAt",
"(",
"space",
")",
";",
"ScanResult",
"ret",
"... | Scans up to a number of fields in front of the robot, stopping on the first field that
contains a robot
@param robot scanning robot
@param dist maximum distance
@return a container of information about the scan
@see ScanResult | [
"Scans",
"up",
"to",
"a",
"number",
"of",
"fields",
"in",
"front",
"of",
"the",
"robot",
"stopping",
"on",
"the",
"first",
"field",
"that",
"contains",
"a",
"robot"
] | 0e31c1ecf1006e35f68c229ff66c37640effffac | https://github.com/theHilikus/JRoboCom/blob/0e31c1ecf1006e35f68c229ff66c37640effffac/jrobocom-core/src/main/java/com/github/thehilikus/jrobocom/World.java#L277-L292 | train |
theHilikus/JRoboCom | jrobocom-core/src/main/java/com/github/thehilikus/jrobocom/World.java | World.getBotsCount | public int getBotsCount(int teamId, boolean invert) {
int total = 0;
for (Robot bot : robotsPosition.keySet()) {
if (bot.getData().getTeamId() == teamId) {
if (!invert) {
total++;
}
} else {
if (invert) {
total++;
}
}
}
return total;
} | java | public int getBotsCount(int teamId, boolean invert) {
int total = 0;
for (Robot bot : robotsPosition.keySet()) {
if (bot.getData().getTeamId() == teamId) {
if (!invert) {
total++;
}
} else {
if (invert) {
total++;
}
}
}
return total;
} | [
"public",
"int",
"getBotsCount",
"(",
"int",
"teamId",
",",
"boolean",
"invert",
")",
"{",
"int",
"total",
"=",
"0",
";",
"for",
"(",
"Robot",
"bot",
":",
"robotsPosition",
".",
"keySet",
"(",
")",
")",
"{",
"if",
"(",
"bot",
".",
"getData",
"(",
"... | Get the total number of living robots from or not from a team
@param teamId the team to search for
@param invert if true, find robots NOT in teamId
@return number of robots in the specified group | [
"Get",
"the",
"total",
"number",
"of",
"living",
"robots",
"from",
"or",
"not",
"from",
"a",
"team"
] | 0e31c1ecf1006e35f68c229ff66c37640effffac | https://github.com/theHilikus/JRoboCom/blob/0e31c1ecf1006e35f68c229ff66c37640effffac/jrobocom-core/src/main/java/com/github/thehilikus/jrobocom/World.java#L301-L316 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/sjavac/server/CompilerPool.java | CompilerPool.grabCompilerThread | public CompilerThread grabCompilerThread() throws InterruptedException {
available.acquire();
if (compilers.empty()) {
return new CompilerThread(this);
}
return compilers.pop();
} | java | public CompilerThread grabCompilerThread() throws InterruptedException {
available.acquire();
if (compilers.empty()) {
return new CompilerThread(this);
}
return compilers.pop();
} | [
"public",
"CompilerThread",
"grabCompilerThread",
"(",
")",
"throws",
"InterruptedException",
"{",
"available",
".",
"acquire",
"(",
")",
";",
"if",
"(",
"compilers",
".",
"empty",
"(",
")",
")",
"{",
"return",
"new",
"CompilerThread",
"(",
"this",
")",
";",... | Acquire a compiler thread from the pool, or block until a thread is available.
If the pools is empty, create a new thread, but never more than is "available". | [
"Acquire",
"a",
"compiler",
"thread",
"from",
"the",
"pool",
"or",
"block",
"until",
"a",
"thread",
"is",
"available",
".",
"If",
"the",
"pools",
"is",
"empty",
"create",
"a",
"new",
"thread",
"but",
"never",
"more",
"than",
"is",
"available",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/sjavac/server/CompilerPool.java#L147-L153 | train |
opsmatters/opsmatters-core | src/main/java/com/opsmatters/core/provider/newrelic/ServerCache.java | ServerCache.add | public void add(Collection<Server> servers)
{
for(Server server : servers)
this.servers.put(server.getId(), server);
} | java | public void add(Collection<Server> servers)
{
for(Server server : servers)
this.servers.put(server.getId(), server);
} | [
"public",
"void",
"add",
"(",
"Collection",
"<",
"Server",
">",
"servers",
")",
"{",
"for",
"(",
"Server",
"server",
":",
"servers",
")",
"this",
".",
"servers",
".",
"put",
"(",
"server",
".",
"getId",
"(",
")",
",",
"server",
")",
";",
"}"
] | Adds the server list to the servers for the account.
@param servers The servers to add | [
"Adds",
"the",
"server",
"list",
"to",
"the",
"servers",
"for",
"the",
"account",
"."
] | c48904f7e8d029fd45357811ec38a735e261e3fd | https://github.com/opsmatters/opsmatters-core/blob/c48904f7e8d029fd45357811ec38a735e261e3fd/src/main/java/com/opsmatters/core/provider/newrelic/ServerCache.java#L55-L59 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/main/JavaCompiler.java | JavaCompiler.resolveIdent | public Symbol resolveIdent(String name) {
if (name.equals(""))
return syms.errSymbol;
JavaFileObject prev = log.useSource(null);
try {
JCExpression tree = null;
for (String s : name.split("\\.", -1)) {
if (!SourceVersion.isIdentifier(s)) // TODO: check for keywords
return syms.errSymbol;
tree = (tree == null) ? make.Ident(names.fromString(s))
: make.Select(tree, names.fromString(s));
}
JCCompilationUnit toplevel =
make.TopLevel(List.<JCTree.JCAnnotation>nil(), null, List.<JCTree>nil());
toplevel.packge = syms.unnamedPackage;
return attr.attribIdent(tree, toplevel);
} finally {
log.useSource(prev);
}
} | java | public Symbol resolveIdent(String name) {
if (name.equals(""))
return syms.errSymbol;
JavaFileObject prev = log.useSource(null);
try {
JCExpression tree = null;
for (String s : name.split("\\.", -1)) {
if (!SourceVersion.isIdentifier(s)) // TODO: check for keywords
return syms.errSymbol;
tree = (tree == null) ? make.Ident(names.fromString(s))
: make.Select(tree, names.fromString(s));
}
JCCompilationUnit toplevel =
make.TopLevel(List.<JCTree.JCAnnotation>nil(), null, List.<JCTree>nil());
toplevel.packge = syms.unnamedPackage;
return attr.attribIdent(tree, toplevel);
} finally {
log.useSource(prev);
}
} | [
"public",
"Symbol",
"resolveIdent",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"name",
".",
"equals",
"(",
"\"\"",
")",
")",
"return",
"syms",
".",
"errSymbol",
";",
"JavaFileObject",
"prev",
"=",
"log",
".",
"useSource",
"(",
"null",
")",
";",
"try",... | Resolve an identifier.
@param name The identifier to resolve | [
"Resolve",
"an",
"identifier",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java#L690-L709 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/main/JavaCompiler.java | JavaCompiler.printSource | JavaFileObject printSource(Env<AttrContext> env, JCClassDecl cdef) throws IOException {
JavaFileObject outFile
= fileManager.getJavaFileForOutput(CLASS_OUTPUT,
cdef.sym.flatname.toString(),
JavaFileObject.Kind.SOURCE,
null);
if (inputFiles.contains(outFile)) {
log.error(cdef.pos(), "source.cant.overwrite.input.file", outFile);
return null;
} else {
BufferedWriter out = new BufferedWriter(outFile.openWriter());
try {
new Pretty(out, true).printUnit(env.toplevel, cdef);
if (verbose)
log.printVerbose("wrote.file", outFile);
} finally {
out.close();
}
return outFile;
}
} | java | JavaFileObject printSource(Env<AttrContext> env, JCClassDecl cdef) throws IOException {
JavaFileObject outFile
= fileManager.getJavaFileForOutput(CLASS_OUTPUT,
cdef.sym.flatname.toString(),
JavaFileObject.Kind.SOURCE,
null);
if (inputFiles.contains(outFile)) {
log.error(cdef.pos(), "source.cant.overwrite.input.file", outFile);
return null;
} else {
BufferedWriter out = new BufferedWriter(outFile.openWriter());
try {
new Pretty(out, true).printUnit(env.toplevel, cdef);
if (verbose)
log.printVerbose("wrote.file", outFile);
} finally {
out.close();
}
return outFile;
}
} | [
"JavaFileObject",
"printSource",
"(",
"Env",
"<",
"AttrContext",
">",
"env",
",",
"JCClassDecl",
"cdef",
")",
"throws",
"IOException",
"{",
"JavaFileObject",
"outFile",
"=",
"fileManager",
".",
"getJavaFileForOutput",
"(",
"CLASS_OUTPUT",
",",
"cdef",
".",
"sym",
... | Emit plain Java source for a class.
@param env The attribution environment of the outermost class
containing this class.
@param cdef The class definition to be printed. | [
"Emit",
"plain",
"Java",
"source",
"for",
"a",
"class",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java#L716-L736 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/main/JavaCompiler.java | JavaCompiler.enterTreesIfNeeded | public List<JCCompilationUnit> enterTreesIfNeeded(List<JCCompilationUnit> roots) {
if (shouldStop(CompileState.ATTR))
return List.nil();
return enterTrees(roots);
} | java | public List<JCCompilationUnit> enterTreesIfNeeded(List<JCCompilationUnit> roots) {
if (shouldStop(CompileState.ATTR))
return List.nil();
return enterTrees(roots);
} | [
"public",
"List",
"<",
"JCCompilationUnit",
">",
"enterTreesIfNeeded",
"(",
"List",
"<",
"JCCompilationUnit",
">",
"roots",
")",
"{",
"if",
"(",
"shouldStop",
"(",
"CompileState",
".",
"ATTR",
")",
")",
"return",
"List",
".",
"nil",
"(",
")",
";",
"return"... | Enter the symbols found in a list of parse trees if the compilation
is expected to proceed beyond anno processing into attr.
As a side-effect, this puts elements on the "todo" list.
Also stores a list of all top level classes in rootClasses. | [
"Enter",
"the",
"symbols",
"found",
"in",
"a",
"list",
"of",
"parse",
"trees",
"if",
"the",
"compilation",
"is",
"expected",
"to",
"proceed",
"beyond",
"anno",
"processing",
"into",
"attr",
".",
"As",
"a",
"side",
"-",
"effect",
"this",
"puts",
"elements",... | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java#L962-L966 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/main/JavaCompiler.java | JavaCompiler.enterTrees | public List<JCCompilationUnit> enterTrees(List<JCCompilationUnit> roots) {
//enter symbols for all files
if (!taskListener.isEmpty()) {
for (JCCompilationUnit unit: roots) {
TaskEvent e = new TaskEvent(TaskEvent.Kind.ENTER, unit);
taskListener.started(e);
}
}
enter.main(roots);
if (!taskListener.isEmpty()) {
for (JCCompilationUnit unit: roots) {
TaskEvent e = new TaskEvent(TaskEvent.Kind.ENTER, unit);
taskListener.finished(e);
}
}
// If generating source, or if tracking public apis,
// then remember the classes declared in
// the original compilation units listed on the command line.
if (needRootClasses || sourceOutput || stubOutput) {
ListBuffer<JCClassDecl> cdefs = new ListBuffer<>();
for (JCCompilationUnit unit : roots) {
for (List<JCTree> defs = unit.defs;
defs.nonEmpty();
defs = defs.tail) {
if (defs.head instanceof JCClassDecl)
cdefs.append((JCClassDecl)defs.head);
}
}
rootClasses = cdefs.toList();
}
// Ensure the input files have been recorded. Although this is normally
// done by readSource, it may not have been done if the trees were read
// in a prior round of annotation processing, and the trees have been
// cleaned and are being reused.
for (JCCompilationUnit unit : roots) {
inputFiles.add(unit.sourcefile);
}
return roots;
} | java | public List<JCCompilationUnit> enterTrees(List<JCCompilationUnit> roots) {
//enter symbols for all files
if (!taskListener.isEmpty()) {
for (JCCompilationUnit unit: roots) {
TaskEvent e = new TaskEvent(TaskEvent.Kind.ENTER, unit);
taskListener.started(e);
}
}
enter.main(roots);
if (!taskListener.isEmpty()) {
for (JCCompilationUnit unit: roots) {
TaskEvent e = new TaskEvent(TaskEvent.Kind.ENTER, unit);
taskListener.finished(e);
}
}
// If generating source, or if tracking public apis,
// then remember the classes declared in
// the original compilation units listed on the command line.
if (needRootClasses || sourceOutput || stubOutput) {
ListBuffer<JCClassDecl> cdefs = new ListBuffer<>();
for (JCCompilationUnit unit : roots) {
for (List<JCTree> defs = unit.defs;
defs.nonEmpty();
defs = defs.tail) {
if (defs.head instanceof JCClassDecl)
cdefs.append((JCClassDecl)defs.head);
}
}
rootClasses = cdefs.toList();
}
// Ensure the input files have been recorded. Although this is normally
// done by readSource, it may not have been done if the trees were read
// in a prior round of annotation processing, and the trees have been
// cleaned and are being reused.
for (JCCompilationUnit unit : roots) {
inputFiles.add(unit.sourcefile);
}
return roots;
} | [
"public",
"List",
"<",
"JCCompilationUnit",
">",
"enterTrees",
"(",
"List",
"<",
"JCCompilationUnit",
">",
"roots",
")",
"{",
"//enter symbols for all files",
"if",
"(",
"!",
"taskListener",
".",
"isEmpty",
"(",
")",
")",
"{",
"for",
"(",
"JCCompilationUnit",
... | Enter the symbols found in a list of parse trees.
As a side-effect, this puts elements on the "todo" list.
Also stores a list of all top level classes in rootClasses. | [
"Enter",
"the",
"symbols",
"found",
"in",
"a",
"list",
"of",
"parse",
"trees",
".",
"As",
"a",
"side",
"-",
"effect",
"this",
"puts",
"elements",
"on",
"the",
"todo",
"list",
".",
"Also",
"stores",
"a",
"list",
"of",
"all",
"top",
"level",
"classes",
... | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java#L973-L1016 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/main/JavaCompiler.java | JavaCompiler.flow | protected void flow(Env<AttrContext> env, Queue<Env<AttrContext>> results) {
if (compileStates.isDone(env, CompileState.FLOW)) {
results.add(env);
return;
}
try {
if (shouldStop(CompileState.FLOW))
return;
if (relax) {
results.add(env);
return;
}
if (verboseCompilePolicy)
printNote("[flow " + env.enclClass.sym + "]");
JavaFileObject prev = log.useSource(
env.enclClass.sym.sourcefile != null ?
env.enclClass.sym.sourcefile :
env.toplevel.sourcefile);
try {
make.at(Position.FIRSTPOS);
TreeMaker localMake = make.forToplevel(env.toplevel);
flow.analyzeTree(env, localMake);
compileStates.put(env, CompileState.FLOW);
if (shouldStop(CompileState.FLOW))
return;
results.add(env);
}
finally {
log.useSource(prev);
}
}
finally {
if (!taskListener.isEmpty()) {
TaskEvent e = new TaskEvent(TaskEvent.Kind.ANALYZE, env.toplevel, env.enclClass.sym);
taskListener.finished(e);
}
}
} | java | protected void flow(Env<AttrContext> env, Queue<Env<AttrContext>> results) {
if (compileStates.isDone(env, CompileState.FLOW)) {
results.add(env);
return;
}
try {
if (shouldStop(CompileState.FLOW))
return;
if (relax) {
results.add(env);
return;
}
if (verboseCompilePolicy)
printNote("[flow " + env.enclClass.sym + "]");
JavaFileObject prev = log.useSource(
env.enclClass.sym.sourcefile != null ?
env.enclClass.sym.sourcefile :
env.toplevel.sourcefile);
try {
make.at(Position.FIRSTPOS);
TreeMaker localMake = make.forToplevel(env.toplevel);
flow.analyzeTree(env, localMake);
compileStates.put(env, CompileState.FLOW);
if (shouldStop(CompileState.FLOW))
return;
results.add(env);
}
finally {
log.useSource(prev);
}
}
finally {
if (!taskListener.isEmpty()) {
TaskEvent e = new TaskEvent(TaskEvent.Kind.ANALYZE, env.toplevel, env.enclClass.sym);
taskListener.finished(e);
}
}
} | [
"protected",
"void",
"flow",
"(",
"Env",
"<",
"AttrContext",
">",
"env",
",",
"Queue",
"<",
"Env",
"<",
"AttrContext",
">",
">",
"results",
")",
"{",
"if",
"(",
"compileStates",
".",
"isDone",
"(",
"env",
",",
"CompileState",
".",
"FLOW",
")",
")",
"... | Perform dataflow checks on an attributed parse tree. | [
"Perform",
"dataflow",
"checks",
"on",
"an",
"attributed",
"parse",
"tree",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java#L1303-L1345 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javac/main/JavaCompiler.java | JavaCompiler.desugar | public Queue<Pair<Env<AttrContext>, JCClassDecl>> desugar(Queue<Env<AttrContext>> envs) {
ListBuffer<Pair<Env<AttrContext>, JCClassDecl>> results = new ListBuffer<>();
for (Env<AttrContext> env: envs)
desugar(env, results);
return stopIfError(CompileState.FLOW, results);
}
HashMap<Env<AttrContext>, Queue<Pair<Env<AttrContext>, JCClassDecl>>> desugaredEnvs =
new HashMap<Env<AttrContext>, Queue<Pair<Env<AttrContext>, JCClassDecl>>>();
/**
* Prepare attributed parse trees, in conjunction with their attribution contexts,
* for source or code generation. If the file was not listed on the command line,
* the current implicitSourcePolicy is taken into account.
* The preparation stops as soon as an error is found.
*/
protected void desugar(final Env<AttrContext> env, Queue<Pair<Env<AttrContext>, JCClassDecl>> results) {
if (shouldStop(CompileState.TRANSTYPES))
return;
if (implicitSourcePolicy == ImplicitSourcePolicy.NONE
&& !inputFiles.contains(env.toplevel.sourcefile)) {
return;
}
if (compileStates.isDone(env, CompileState.LOWER)) {
results.addAll(desugaredEnvs.get(env));
return;
}
/**
* Ensure that superclasses of C are desugared before C itself. This is
* required for two reasons: (i) as erasure (TransTypes) destroys
* information needed in flow analysis and (ii) as some checks carried
* out during lowering require that all synthetic fields/methods have
* already been added to C and its superclasses.
*/
class ScanNested extends TreeScanner {
Set<Env<AttrContext>> dependencies = new LinkedHashSet<Env<AttrContext>>();
protected boolean hasLambdas;
@Override
public void visitClassDef(JCClassDecl node) {
Type st = types.supertype(node.sym.type);
boolean envForSuperTypeFound = false;
while (!envForSuperTypeFound && st.hasTag(CLASS)) {
ClassSymbol c = st.tsym.outermostClass();
Env<AttrContext> stEnv = enter.getEnv(c);
if (stEnv != null && env != stEnv) {
if (dependencies.add(stEnv)) {
boolean prevHasLambdas = hasLambdas;
try {
scan(stEnv.tree);
} finally {
/*
* ignore any updates to hasLambdas made during
* the nested scan, this ensures an initalized
* LambdaToMethod is available only to those
* classes that contain lambdas
*/
hasLambdas = prevHasLambdas;
}
}
envForSuperTypeFound = true;
}
st = types.supertype(st);
}
super.visitClassDef(node);
}
@Override
public void visitLambda(JCLambda tree) {
hasLambdas = true;
super.visitLambda(tree);
}
@Override
public void visitReference(JCMemberReference tree) {
hasLambdas = true;
super.visitReference(tree);
}
}
ScanNested scanner = new ScanNested();
scanner.scan(env.tree);
for (Env<AttrContext> dep: scanner.dependencies) {
if (!compileStates.isDone(dep, CompileState.FLOW))
desugaredEnvs.put(dep, desugar(flow(attribute(dep))));
}
//We need to check for error another time as more classes might
//have been attributed and analyzed at this stage
if (shouldStop(CompileState.TRANSTYPES))
return;
if (verboseCompilePolicy)
printNote("[desugar " + env.enclClass.sym + "]");
JavaFileObject prev = log.useSource(env.enclClass.sym.sourcefile != null ?
env.enclClass.sym.sourcefile :
env.toplevel.sourcefile);
try {
//save tree prior to rewriting
JCTree untranslated = env.tree;
make.at(Position.FIRSTPOS);
TreeMaker localMake = make.forToplevel(env.toplevel);
if (env.tree instanceof JCCompilationUnit) {
if (!(stubOutput || sourceOutput || printFlat)) {
if (shouldStop(CompileState.LOWER))
return;
List<JCTree> pdef = lower.translateTopLevelClass(env, env.tree, localMake);
if (pdef.head != null) {
Assert.check(pdef.tail.isEmpty());
results.add(new Pair<Env<AttrContext>, JCClassDecl>(env, (JCClassDecl)pdef.head));
}
}
return;
}
if (stubOutput) {
//emit stub Java source file, only for compilation
//units enumerated explicitly on the command line
JCClassDecl cdef = (JCClassDecl)env.tree;
if (untranslated instanceof JCClassDecl &&
rootClasses.contains((JCClassDecl)untranslated) &&
((cdef.mods.flags & (Flags.PROTECTED|Flags.PUBLIC)) != 0 ||
cdef.sym.packge().getQualifiedName() == names.java_lang)) {
results.add(new Pair<Env<AttrContext>, JCClassDecl>(env, removeMethodBodies(cdef)));
}
return;
}
if (shouldStop(CompileState.TRANSTYPES))
return;
env.tree = transTypes.translateTopLevelClass(env.tree, localMake);
compileStates.put(env, CompileState.TRANSTYPES);
if (source.allowLambda() && scanner.hasLambdas) {
if (shouldStop(CompileState.UNLAMBDA))
return;
env.tree = LambdaToMethod.instance(context).translateTopLevelClass(env, env.tree, localMake);
compileStates.put(env, CompileState.UNLAMBDA);
}
if (shouldStop(CompileState.LOWER))
return;
if (sourceOutput) {
//emit standard Java source file, only for compilation
//units enumerated explicitly on the command line
JCClassDecl cdef = (JCClassDecl)env.tree;
if (untranslated instanceof JCClassDecl &&
rootClasses.contains((JCClassDecl)untranslated)) {
results.add(new Pair<Env<AttrContext>, JCClassDecl>(env, cdef));
}
return;
}
//translate out inner classes
List<JCTree> cdefs = lower.translateTopLevelClass(env, env.tree, localMake);
compileStates.put(env, CompileState.LOWER);
if (shouldStop(CompileState.LOWER))
return;
//generate code for each class
for (List<JCTree> l = cdefs; l.nonEmpty(); l = l.tail) {
JCClassDecl cdef = (JCClassDecl)l.head;
results.add(new Pair<Env<AttrContext>, JCClassDecl>(env, cdef));
}
}
finally {
log.useSource(prev);
}
} | java | public Queue<Pair<Env<AttrContext>, JCClassDecl>> desugar(Queue<Env<AttrContext>> envs) {
ListBuffer<Pair<Env<AttrContext>, JCClassDecl>> results = new ListBuffer<>();
for (Env<AttrContext> env: envs)
desugar(env, results);
return stopIfError(CompileState.FLOW, results);
}
HashMap<Env<AttrContext>, Queue<Pair<Env<AttrContext>, JCClassDecl>>> desugaredEnvs =
new HashMap<Env<AttrContext>, Queue<Pair<Env<AttrContext>, JCClassDecl>>>();
/**
* Prepare attributed parse trees, in conjunction with their attribution contexts,
* for source or code generation. If the file was not listed on the command line,
* the current implicitSourcePolicy is taken into account.
* The preparation stops as soon as an error is found.
*/
protected void desugar(final Env<AttrContext> env, Queue<Pair<Env<AttrContext>, JCClassDecl>> results) {
if (shouldStop(CompileState.TRANSTYPES))
return;
if (implicitSourcePolicy == ImplicitSourcePolicy.NONE
&& !inputFiles.contains(env.toplevel.sourcefile)) {
return;
}
if (compileStates.isDone(env, CompileState.LOWER)) {
results.addAll(desugaredEnvs.get(env));
return;
}
/**
* Ensure that superclasses of C are desugared before C itself. This is
* required for two reasons: (i) as erasure (TransTypes) destroys
* information needed in flow analysis and (ii) as some checks carried
* out during lowering require that all synthetic fields/methods have
* already been added to C and its superclasses.
*/
class ScanNested extends TreeScanner {
Set<Env<AttrContext>> dependencies = new LinkedHashSet<Env<AttrContext>>();
protected boolean hasLambdas;
@Override
public void visitClassDef(JCClassDecl node) {
Type st = types.supertype(node.sym.type);
boolean envForSuperTypeFound = false;
while (!envForSuperTypeFound && st.hasTag(CLASS)) {
ClassSymbol c = st.tsym.outermostClass();
Env<AttrContext> stEnv = enter.getEnv(c);
if (stEnv != null && env != stEnv) {
if (dependencies.add(stEnv)) {
boolean prevHasLambdas = hasLambdas;
try {
scan(stEnv.tree);
} finally {
/*
* ignore any updates to hasLambdas made during
* the nested scan, this ensures an initalized
* LambdaToMethod is available only to those
* classes that contain lambdas
*/
hasLambdas = prevHasLambdas;
}
}
envForSuperTypeFound = true;
}
st = types.supertype(st);
}
super.visitClassDef(node);
}
@Override
public void visitLambda(JCLambda tree) {
hasLambdas = true;
super.visitLambda(tree);
}
@Override
public void visitReference(JCMemberReference tree) {
hasLambdas = true;
super.visitReference(tree);
}
}
ScanNested scanner = new ScanNested();
scanner.scan(env.tree);
for (Env<AttrContext> dep: scanner.dependencies) {
if (!compileStates.isDone(dep, CompileState.FLOW))
desugaredEnvs.put(dep, desugar(flow(attribute(dep))));
}
//We need to check for error another time as more classes might
//have been attributed and analyzed at this stage
if (shouldStop(CompileState.TRANSTYPES))
return;
if (verboseCompilePolicy)
printNote("[desugar " + env.enclClass.sym + "]");
JavaFileObject prev = log.useSource(env.enclClass.sym.sourcefile != null ?
env.enclClass.sym.sourcefile :
env.toplevel.sourcefile);
try {
//save tree prior to rewriting
JCTree untranslated = env.tree;
make.at(Position.FIRSTPOS);
TreeMaker localMake = make.forToplevel(env.toplevel);
if (env.tree instanceof JCCompilationUnit) {
if (!(stubOutput || sourceOutput || printFlat)) {
if (shouldStop(CompileState.LOWER))
return;
List<JCTree> pdef = lower.translateTopLevelClass(env, env.tree, localMake);
if (pdef.head != null) {
Assert.check(pdef.tail.isEmpty());
results.add(new Pair<Env<AttrContext>, JCClassDecl>(env, (JCClassDecl)pdef.head));
}
}
return;
}
if (stubOutput) {
//emit stub Java source file, only for compilation
//units enumerated explicitly on the command line
JCClassDecl cdef = (JCClassDecl)env.tree;
if (untranslated instanceof JCClassDecl &&
rootClasses.contains((JCClassDecl)untranslated) &&
((cdef.mods.flags & (Flags.PROTECTED|Flags.PUBLIC)) != 0 ||
cdef.sym.packge().getQualifiedName() == names.java_lang)) {
results.add(new Pair<Env<AttrContext>, JCClassDecl>(env, removeMethodBodies(cdef)));
}
return;
}
if (shouldStop(CompileState.TRANSTYPES))
return;
env.tree = transTypes.translateTopLevelClass(env.tree, localMake);
compileStates.put(env, CompileState.TRANSTYPES);
if (source.allowLambda() && scanner.hasLambdas) {
if (shouldStop(CompileState.UNLAMBDA))
return;
env.tree = LambdaToMethod.instance(context).translateTopLevelClass(env, env.tree, localMake);
compileStates.put(env, CompileState.UNLAMBDA);
}
if (shouldStop(CompileState.LOWER))
return;
if (sourceOutput) {
//emit standard Java source file, only for compilation
//units enumerated explicitly on the command line
JCClassDecl cdef = (JCClassDecl)env.tree;
if (untranslated instanceof JCClassDecl &&
rootClasses.contains((JCClassDecl)untranslated)) {
results.add(new Pair<Env<AttrContext>, JCClassDecl>(env, cdef));
}
return;
}
//translate out inner classes
List<JCTree> cdefs = lower.translateTopLevelClass(env, env.tree, localMake);
compileStates.put(env, CompileState.LOWER);
if (shouldStop(CompileState.LOWER))
return;
//generate code for each class
for (List<JCTree> l = cdefs; l.nonEmpty(); l = l.tail) {
JCClassDecl cdef = (JCClassDecl)l.head;
results.add(new Pair<Env<AttrContext>, JCClassDecl>(env, cdef));
}
}
finally {
log.useSource(prev);
}
} | [
"public",
"Queue",
"<",
"Pair",
"<",
"Env",
"<",
"AttrContext",
">",
",",
"JCClassDecl",
">",
">",
"desugar",
"(",
"Queue",
"<",
"Env",
"<",
"AttrContext",
">",
">",
"envs",
")",
"{",
"ListBuffer",
"<",
"Pair",
"<",
"Env",
"<",
"AttrContext",
">",
",... | Prepare attributed parse trees, in conjunction with their attribution contexts,
for source or code generation.
If any errors occur, an empty list will be returned.
@returns a list containing the classes to be generated | [
"Prepare",
"attributed",
"parse",
"trees",
"in",
"conjunction",
"with",
"their",
"attribution",
"contexts",
"for",
"source",
"or",
"code",
"generation",
".",
"If",
"any",
"errors",
"occur",
"an",
"empty",
"list",
"will",
"be",
"returned",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java#L1353-L1528 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javadoc/RootDocImpl.java | RootDocImpl.setPackages | private void setPackages(DocEnv env, List<String> packages) {
ListBuffer<PackageDocImpl> packlist = new ListBuffer<PackageDocImpl>();
for (String name : packages) {
PackageDocImpl pkg = env.lookupPackage(name);
if (pkg != null) {
pkg.isIncluded = true;
packlist.append(pkg);
} else {
env.warning(null, "main.no_source_files_for_package", name);
}
}
cmdLinePackages = packlist.toList();
} | java | private void setPackages(DocEnv env, List<String> packages) {
ListBuffer<PackageDocImpl> packlist = new ListBuffer<PackageDocImpl>();
for (String name : packages) {
PackageDocImpl pkg = env.lookupPackage(name);
if (pkg != null) {
pkg.isIncluded = true;
packlist.append(pkg);
} else {
env.warning(null, "main.no_source_files_for_package", name);
}
}
cmdLinePackages = packlist.toList();
} | [
"private",
"void",
"setPackages",
"(",
"DocEnv",
"env",
",",
"List",
"<",
"String",
">",
"packages",
")",
"{",
"ListBuffer",
"<",
"PackageDocImpl",
">",
"packlist",
"=",
"new",
"ListBuffer",
"<",
"PackageDocImpl",
">",
"(",
")",
";",
"for",
"(",
"String",
... | Initialize packages information.
@param env the compilation environment
@param packages a list of package names (String) | [
"Initialize",
"packages",
"information",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java#L139-L151 | train |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/javadoc/RootDocImpl.java | RootDocImpl.specifiedClasses | public ClassDoc[] specifiedClasses() {
ListBuffer<ClassDocImpl> classesToDocument = new ListBuffer<ClassDocImpl>();
for (ClassDocImpl cd : cmdLineClasses) {
cd.addAllClasses(classesToDocument, true);
}
return (ClassDoc[])classesToDocument.toArray(new ClassDocImpl[classesToDocument.length()]);
} | java | public ClassDoc[] specifiedClasses() {
ListBuffer<ClassDocImpl> classesToDocument = new ListBuffer<ClassDocImpl>();
for (ClassDocImpl cd : cmdLineClasses) {
cd.addAllClasses(classesToDocument, true);
}
return (ClassDoc[])classesToDocument.toArray(new ClassDocImpl[classesToDocument.length()]);
} | [
"public",
"ClassDoc",
"[",
"]",
"specifiedClasses",
"(",
")",
"{",
"ListBuffer",
"<",
"ClassDocImpl",
">",
"classesToDocument",
"=",
"new",
"ListBuffer",
"<",
"ClassDocImpl",
">",
"(",
")",
";",
"for",
"(",
"ClassDocImpl",
"cd",
":",
"cmdLineClasses",
")",
"... | Classes and interfaces specified on the command line. | [
"Classes",
"and",
"interfaces",
"specified",
"on",
"the",
"command",
"line",
"."
] | 8812d28c20f4de070a0dd6de1b45602431379834 | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java#L185-L191 | train |
coopernurse/barrister-java | src/main/java/com/bitmechanic/barrister/EnumTypeConverter.java | EnumTypeConverter.unmarshal | @SuppressWarnings("unchecked")
public Object unmarshal(Object obj) throws RpcException {
if (obj == null) {
return returnNullIfOptional();
}
else if (obj.getClass() != String.class) {
String msg = "'" + obj + "' enum must be String, got: " +
obj.getClass().getSimpleName();
throw RpcException.Error.INVALID_PARAMS.exc(msg);
}
else if (e.getValues().contains((String)obj)) {
try {
Class clz = getTypeClass();
return java.lang.Enum.valueOf(clz, (String)obj);
}
catch (Exception e) {
String msg = "Could not set enum value '" + obj + "' - " +
e.getClass().getSimpleName() + " - " + e.getMessage();
throw RpcException.Error.INTERNAL.exc(msg);
}
}
else {
String msg = "'" + obj + "' is not in enum: " + e.getValues();
throw RpcException.Error.INVALID_PARAMS.exc(msg);
}
} | java | @SuppressWarnings("unchecked")
public Object unmarshal(Object obj) throws RpcException {
if (obj == null) {
return returnNullIfOptional();
}
else if (obj.getClass() != String.class) {
String msg = "'" + obj + "' enum must be String, got: " +
obj.getClass().getSimpleName();
throw RpcException.Error.INVALID_PARAMS.exc(msg);
}
else if (e.getValues().contains((String)obj)) {
try {
Class clz = getTypeClass();
return java.lang.Enum.valueOf(clz, (String)obj);
}
catch (Exception e) {
String msg = "Could not set enum value '" + obj + "' - " +
e.getClass().getSimpleName() + " - " + e.getMessage();
throw RpcException.Error.INTERNAL.exc(msg);
}
}
else {
String msg = "'" + obj + "' is not in enum: " + e.getValues();
throw RpcException.Error.INVALID_PARAMS.exc(msg);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"Object",
"unmarshal",
"(",
"Object",
"obj",
")",
"throws",
"RpcException",
"{",
"if",
"(",
"obj",
"==",
"null",
")",
"{",
"return",
"returnNullIfOptional",
"(",
")",
";",
"}",
"else",
"if",
"("... | Enforces that obj is a String contained in the Enum's values list | [
"Enforces",
"that",
"obj",
"is",
"a",
"String",
"contained",
"in",
"the",
"Enum",
"s",
"values",
"list"
] | c2b639634c88a25002b66d1fb4a8f5fb51ade6a2 | https://github.com/coopernurse/barrister-java/blob/c2b639634c88a25002b66d1fb4a8f5fb51ade6a2/src/main/java/com/bitmechanic/barrister/EnumTypeConverter.java#L27-L52 | train |
base2Services/kagura | shared/reporting-core/src/main/java/com/base2/kagura/core/storage/ReportsProvider.java | ReportsProvider.loadReport | protected boolean loadReport(ReportsConfig result, InputStream report, String reportName) {
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
ReportConfig reportConfig = null;
try {
reportConfig = mapper.readValue(report, ReportConfig.class);
} catch (IOException e) {
e.printStackTrace();
errors.add("Error parsing " + reportName + " " + e.getMessage());
return false;
}
reportConfig.setReportId(reportName);
result.getReports().put(reportName, reportConfig);
return true;
} | java | protected boolean loadReport(ReportsConfig result, InputStream report, String reportName) {
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
ReportConfig reportConfig = null;
try {
reportConfig = mapper.readValue(report, ReportConfig.class);
} catch (IOException e) {
e.printStackTrace();
errors.add("Error parsing " + reportName + " " + e.getMessage());
return false;
}
reportConfig.setReportId(reportName);
result.getReports().put(reportName, reportConfig);
return true;
} | [
"protected",
"boolean",
"loadReport",
"(",
"ReportsConfig",
"result",
",",
"InputStream",
"report",
",",
"String",
"reportName",
")",
"{",
"ObjectMapper",
"mapper",
"=",
"new",
"ObjectMapper",
"(",
"new",
"YAMLFactory",
"(",
")",
")",
";",
"ReportConfig",
"repor... | Loads a report, this does the deserialization, this method can be substituted with another, called by child
classes. Once it has deserialized it, it put it into the map.
@param result
@param report
@param reportName
@return | [
"Loads",
"a",
"report",
"this",
"does",
"the",
"deserialization",
"this",
"method",
"can",
"be",
"substituted",
"with",
"another",
"called",
"by",
"child",
"classes",
".",
"Once",
"it",
"has",
"deserialized",
"it",
"it",
"put",
"it",
"into",
"the",
"map",
... | 5564aa71bfa2cb3baaae2eb098c6c673dd4e82ee | https://github.com/base2Services/kagura/blob/5564aa71bfa2cb3baaae2eb098c6c673dd4e82ee/shared/reporting-core/src/main/java/com/base2/kagura/core/storage/ReportsProvider.java#L64-L77 | train |
base2Services/kagura | shared/reporting-core/src/main/java/com/base2/kagura/core/storage/ReportsProvider.java | ReportsProvider.getReportsConfig | public ReportsConfig getReportsConfig(Collection<String> restrictToNamed) {
resetErrors();
ReportsConfig result = new ReportsConfig();
InternalType[] reports = getReportList();
if (reports == null)
{
errors.add("No reports found.");
return result;
}
for (InternalType report : reports)
{
String name = "Unknown";
final String named = reportToName(report);
if (restrictToNamed != null && !restrictToNamed.contains(named)) continue;
try {
name = loadReport(result, report);
} catch (Exception e) {
errors.add("Error in report " + named + ": " + e.getMessage());
e.printStackTrace();
continue;
}
}
return result;
} | java | public ReportsConfig getReportsConfig(Collection<String> restrictToNamed) {
resetErrors();
ReportsConfig result = new ReportsConfig();
InternalType[] reports = getReportList();
if (reports == null)
{
errors.add("No reports found.");
return result;
}
for (InternalType report : reports)
{
String name = "Unknown";
final String named = reportToName(report);
if (restrictToNamed != null && !restrictToNamed.contains(named)) continue;
try {
name = loadReport(result, report);
} catch (Exception e) {
errors.add("Error in report " + named + ": " + e.getMessage());
e.printStackTrace();
continue;
}
}
return result;
} | [
"public",
"ReportsConfig",
"getReportsConfig",
"(",
"Collection",
"<",
"String",
">",
"restrictToNamed",
")",
"{",
"resetErrors",
"(",
")",
";",
"ReportsConfig",
"result",
"=",
"new",
"ReportsConfig",
"(",
")",
";",
"InternalType",
"[",
"]",
"reports",
"=",
"g... | Returns a list of reports in a ReportsConfig-uration object, it only loads reports in "restrictedToNamed", this
is useful as a secondary report-restriction mechanism. So you would pass in all reports the user can access.
@param restrictToNamed A list of report names to load. No error if one is not found.
@return | [
"Returns",
"a",
"list",
"of",
"reports",
"in",
"a",
"ReportsConfig",
"-",
"uration",
"object",
"it",
"only",
"loads",
"reports",
"in",
"restrictedToNamed",
"this",
"is",
"useful",
"as",
"a",
"secondary",
"report",
"-",
"restriction",
"mechanism",
".",
"So",
... | 5564aa71bfa2cb3baaae2eb098c6c673dd4e82ee | https://github.com/base2Services/kagura/blob/5564aa71bfa2cb3baaae2eb098c6c673dd4e82ee/shared/reporting-core/src/main/java/com/base2/kagura/core/storage/ReportsProvider.java#L96-L119 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.