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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
facebookarchive/hive-dwrf | hive-dwrf/src/main/java/com/facebook/hive/orc/lazy/LazyIntDirectTreeReader.java | LazyIntDirectTreeReader.readInt | private int readInt() throws IOException {
latestRead = (int)SerializationUtils.readIntegerType(input, WriterImpl.INT_BYTE_SIZE,
true, input.useVInts());
return latestRead;
} | java | private int readInt() throws IOException {
latestRead = (int)SerializationUtils.readIntegerType(input, WriterImpl.INT_BYTE_SIZE,
true, input.useVInts());
return latestRead;
} | [
"private",
"int",
"readInt",
"(",
")",
"throws",
"IOException",
"{",
"latestRead",
"=",
"(",
"int",
")",
"SerializationUtils",
".",
"readIntegerType",
"(",
"input",
",",
"WriterImpl",
".",
"INT_BYTE_SIZE",
",",
"true",
",",
"input",
".",
"useVInts",
"(",
")"... | Read an int value from the stream. | [
"Read",
"an",
"int",
"value",
"from",
"the",
"stream",
"."
] | a7b4fcf28a57e006a2fc041d40cf7e5ad16e6b45 | https://github.com/facebookarchive/hive-dwrf/blob/a7b4fcf28a57e006a2fc041d40cf7e5ad16e6b45/hive-dwrf/src/main/java/com/facebook/hive/orc/lazy/LazyIntDirectTreeReader.java#L42-L46 | train |
rpau/javalang-compiler | src/main/java/org/walkmod/javalang/compiler/symbols/AnonymousClassUtil.java | AnonymousClassUtil.needsSymbolData | public static boolean needsSymbolData(ObjectCreationExpr n) {
final SymbolType st = symbolDataType(n);
return st == null || !st.isLoadedAnonymousClass();
} | java | public static boolean needsSymbolData(ObjectCreationExpr n) {
final SymbolType st = symbolDataType(n);
return st == null || !st.isLoadedAnonymousClass();
} | [
"public",
"static",
"boolean",
"needsSymbolData",
"(",
"ObjectCreationExpr",
"n",
")",
"{",
"final",
"SymbolType",
"st",
"=",
"symbolDataType",
"(",
"n",
")",
";",
"return",
"st",
"==",
"null",
"||",
"!",
"st",
".",
"isLoadedAnonymousClass",
"(",
")",
";",
... | For anonymous creations the initial symbol data is symbol data of super class.
That needs to be replaced with symbol data of anonymous class.
If we don't have symbol data we assume we need one. ;-)
@param n object creation expression
@return if the expression does NOT contains a resolved type | [
"For",
"anonymous",
"creations",
"the",
"initial",
"symbol",
"data",
"is",
"symbol",
"data",
"of",
"super",
"class",
".",
"That",
"needs",
"to",
"be",
"replaced",
"with",
"symbol",
"data",
"of",
"anonymous",
"class",
".",
"If",
"we",
"don",
"t",
"have",
... | d7da81359161feef2bc7ff186c4e1b73c6a5a8ef | https://github.com/rpau/javalang-compiler/blob/d7da81359161feef2bc7ff186c4e1b73c6a5a8ef/src/main/java/org/walkmod/javalang/compiler/symbols/AnonymousClassUtil.java#L20-L23 | train |
facebookarchive/hive-dwrf | hive-dwrf/src/main/java/com/facebook/hive/orc/OrcStruct.java | OrcStruct.setFieldNames | public void setFieldNames(List<String> fieldNames) {
this.fieldNames = fieldNames;
if (fields.length != fieldNames.size()) {
Object[] oldFields = fields;
fields = new Object[fieldNames.size()];
System.arraycopy(oldFields, 0, fields, 0,
Math.min(oldFields.length, fieldNames.size()));
}
} | java | public void setFieldNames(List<String> fieldNames) {
this.fieldNames = fieldNames;
if (fields.length != fieldNames.size()) {
Object[] oldFields = fields;
fields = new Object[fieldNames.size()];
System.arraycopy(oldFields, 0, fields, 0,
Math.min(oldFields.length, fieldNames.size()));
}
} | [
"public",
"void",
"setFieldNames",
"(",
"List",
"<",
"String",
">",
"fieldNames",
")",
"{",
"this",
".",
"fieldNames",
"=",
"fieldNames",
";",
"if",
"(",
"fields",
".",
"length",
"!=",
"fieldNames",
".",
"size",
"(",
")",
")",
"{",
"Object",
"[",
"]",
... | Change the names and number of fields in the struct. No effect if the number of
fields is the same. The old field values are copied to the new array.
@param numFields the new number of fields | [
"Change",
"the",
"names",
"and",
"number",
"of",
"fields",
"in",
"the",
"struct",
".",
"No",
"effect",
"if",
"the",
"number",
"of",
"fields",
"is",
"the",
"same",
".",
"The",
"old",
"field",
"values",
"are",
"copied",
"to",
"the",
"new",
"array",
"."
] | a7b4fcf28a57e006a2fc041d40cf7e5ad16e6b45 | https://github.com/facebookarchive/hive-dwrf/blob/a7b4fcf28a57e006a2fc041d40cf7e5ad16e6b45/hive-dwrf/src/main/java/com/facebook/hive/orc/OrcStruct.java#L81-L89 | train |
neo4j/license-maven-plugin | src/main/java/com/google/code/mojo/license/header/HeaderDefinition.java | HeaderDefinition.isSkipLine | public boolean isSkipLine(String line) {
return skipLinePattern != null && line != null && skipLinePattern.matcher(line).matches();
} | java | public boolean isSkipLine(String line) {
return skipLinePattern != null && line != null && skipLinePattern.matcher(line).matches();
} | [
"public",
"boolean",
"isSkipLine",
"(",
"String",
"line",
")",
"{",
"return",
"skipLinePattern",
"!=",
"null",
"&&",
"line",
"!=",
"null",
"&&",
"skipLinePattern",
".",
"matcher",
"(",
"line",
")",
".",
"matches",
"(",
")",
";",
"}"
] | Tells if the given content line must be skipped according to this header definition. The header is outputted
after any skipped line if any pattern defined on this point or on the first line if not pattern defined.
@param line The line to test.
@return true if this line must be skipped or false. | [
"Tells",
"if",
"the",
"given",
"content",
"line",
"must",
"be",
"skipped",
"according",
"to",
"this",
"header",
"definition",
".",
"The",
"header",
"is",
"outputted",
"after",
"any",
"skipped",
"line",
"if",
"any",
"pattern",
"defined",
"on",
"this",
"point"... | 2850cc6809820f15458400e687de2c84099a49c2 | https://github.com/neo4j/license-maven-plugin/blob/2850cc6809820f15458400e687de2c84099a49c2/src/main/java/com/google/code/mojo/license/header/HeaderDefinition.java#L114-L116 | train |
neo4j/license-maven-plugin | src/main/java/com/google/code/mojo/license/header/HeaderDefinition.java | HeaderDefinition.isFirstHeaderLine | public boolean isFirstHeaderLine(String line) {
return firstLineDetectionPattern != null && line != null && firstLineDetectionPattern.matcher(line).matches();
} | java | public boolean isFirstHeaderLine(String line) {
return firstLineDetectionPattern != null && line != null && firstLineDetectionPattern.matcher(line).matches();
} | [
"public",
"boolean",
"isFirstHeaderLine",
"(",
"String",
"line",
")",
"{",
"return",
"firstLineDetectionPattern",
"!=",
"null",
"&&",
"line",
"!=",
"null",
"&&",
"firstLineDetectionPattern",
".",
"matcher",
"(",
"line",
")",
".",
"matches",
"(",
")",
";",
"}"
... | Tells if the given content line is the first line of a possible header of this definition kind.
@param line The line to test.
@return true if the first line of a header have been recognized or false. | [
"Tells",
"if",
"the",
"given",
"content",
"line",
"is",
"the",
"first",
"line",
"of",
"a",
"possible",
"header",
"of",
"this",
"definition",
"kind",
"."
] | 2850cc6809820f15458400e687de2c84099a49c2 | https://github.com/neo4j/license-maven-plugin/blob/2850cc6809820f15458400e687de2c84099a49c2/src/main/java/com/google/code/mojo/license/header/HeaderDefinition.java#L124-L126 | train |
neo4j/license-maven-plugin | src/main/java/com/google/code/mojo/license/header/HeaderDefinition.java | HeaderDefinition.isLastHeaderLine | public boolean isLastHeaderLine(String line) {
return lastLineDetectionPattern != null && line != null && lastLineDetectionPattern.matcher(line).matches();
} | java | public boolean isLastHeaderLine(String line) {
return lastLineDetectionPattern != null && line != null && lastLineDetectionPattern.matcher(line).matches();
} | [
"public",
"boolean",
"isLastHeaderLine",
"(",
"String",
"line",
")",
"{",
"return",
"lastLineDetectionPattern",
"!=",
"null",
"&&",
"line",
"!=",
"null",
"&&",
"lastLineDetectionPattern",
".",
"matcher",
"(",
"line",
")",
".",
"matches",
"(",
")",
";",
"}"
] | Tells if the given content line is the last line of a possible header of this definition kind.
@param line The line to test.
@return true if the last line of a header have been recognized or false. | [
"Tells",
"if",
"the",
"given",
"content",
"line",
"is",
"the",
"last",
"line",
"of",
"a",
"possible",
"header",
"of",
"this",
"definition",
"kind",
"."
] | 2850cc6809820f15458400e687de2c84099a49c2 | https://github.com/neo4j/license-maven-plugin/blob/2850cc6809820f15458400e687de2c84099a49c2/src/main/java/com/google/code/mojo/license/header/HeaderDefinition.java#L134-L136 | train |
neo4j/license-maven-plugin | src/main/java/com/google/code/mojo/license/header/HeaderDefinition.java | HeaderDefinition.validate | public void validate() {
check("firstLine", this.firstLine);
check("beforeEachLine", this.beforeEachLine);
check("endLine", this.endLine);
check("firstLineDetectionPattern", this.firstLineDetectionPattern);
check("lastLineDetectionPattern", this.lastLineDetectionPattern);
check("isMultiline", this.isMultiline);
check("allowBlankLines", this.allowBlankLines);
// skip line can be null
} | java | public void validate() {
check("firstLine", this.firstLine);
check("beforeEachLine", this.beforeEachLine);
check("endLine", this.endLine);
check("firstLineDetectionPattern", this.firstLineDetectionPattern);
check("lastLineDetectionPattern", this.lastLineDetectionPattern);
check("isMultiline", this.isMultiline);
check("allowBlankLines", this.allowBlankLines);
// skip line can be null
} | [
"public",
"void",
"validate",
"(",
")",
"{",
"check",
"(",
"\"firstLine\"",
",",
"this",
".",
"firstLine",
")",
";",
"check",
"(",
"\"beforeEachLine\"",
",",
"this",
".",
"beforeEachLine",
")",
";",
"check",
"(",
"\"endLine\"",
",",
"this",
".",
"endLine",... | Checks this header definition consistency, in other words if all the mandatory properties of the definition have
been set.
@throws IllegalStateException If a mandatory property has not been set. | [
"Checks",
"this",
"header",
"definition",
"consistency",
"in",
"other",
"words",
"if",
"all",
"the",
"mandatory",
"properties",
"of",
"the",
"definition",
"have",
"been",
"set",
"."
] | 2850cc6809820f15458400e687de2c84099a49c2 | https://github.com/neo4j/license-maven-plugin/blob/2850cc6809820f15458400e687de2c84099a49c2/src/main/java/com/google/code/mojo/license/header/HeaderDefinition.java#L180-L189 | train |
xvik/guice-ext-annotations | src/main/java/ru/vyarus/guice/ext/ExtAnnotationsModule.java | ExtAnnotationsModule.configureManager | protected DestroyableManager configureManager(final DestroyableManager manager) {
bind(DestroyableManager.class).toInstance(manager);
// if logic will not call destroy at least it will be called before jvm shutdown
Runtime.getRuntime().addShutdownHook(new Thread(manager));
return manager;
} | java | protected DestroyableManager configureManager(final DestroyableManager manager) {
bind(DestroyableManager.class).toInstance(manager);
// if logic will not call destroy at least it will be called before jvm shutdown
Runtime.getRuntime().addShutdownHook(new Thread(manager));
return manager;
} | [
"protected",
"DestroyableManager",
"configureManager",
"(",
"final",
"DestroyableManager",
"manager",
")",
"{",
"bind",
"(",
"DestroyableManager",
".",
"class",
")",
".",
"toInstance",
"(",
"manager",
")",
";",
"// if logic will not call destroy at least it will be called b... | Registers destroyable manager in injector and adds shutdown hook to process destroy on jvm shutdown.
@param manager destroyable manager instance
@return manager instance | [
"Registers",
"destroyable",
"manager",
"in",
"injector",
"and",
"adds",
"shutdown",
"hook",
"to",
"process",
"destroy",
"on",
"jvm",
"shutdown",
"."
] | 101685e266a468298cb00e6b81f314e2ac95d724 | https://github.com/xvik/guice-ext-annotations/blob/101685e266a468298cb00e6b81f314e2ac95d724/src/main/java/ru/vyarus/guice/ext/ExtAnnotationsModule.java#L82-L87 | train |
boivie/skip32-java | src/main/java/com/boivie/skip32/Skip32.java | Skip32.skip32 | public static void skip32(byte[] key, int[] buf, boolean encrypt) {
int k; /* round number */
int i; /* round counter */
int kstep;
int wl, wr;
/* sort out direction */
if (encrypt) {
kstep = 1;
k = 0;
} else {
kstep = -1;
k = 23;
}
/* pack into words */
wl = (buf[0] << 8) + buf[1];
wr = (buf[2] << 8) + buf[3];
/* 24 feistel rounds, doubled up */
for (i = 0; i < 24 / 2; ++i) {
wr ^= g(key, k, wl) ^ k;
k += kstep;
wl ^= g(key, k, wr) ^ k;
k += kstep;
}
/* implicitly swap halves while unpacking */
buf[0] = (wr >> 8);
buf[1] = (wr & 0xFF);
buf[2] = (wl >> 8);
buf[3] = (wl & 0xFF);
} | java | public static void skip32(byte[] key, int[] buf, boolean encrypt) {
int k; /* round number */
int i; /* round counter */
int kstep;
int wl, wr;
/* sort out direction */
if (encrypt) {
kstep = 1;
k = 0;
} else {
kstep = -1;
k = 23;
}
/* pack into words */
wl = (buf[0] << 8) + buf[1];
wr = (buf[2] << 8) + buf[3];
/* 24 feistel rounds, doubled up */
for (i = 0; i < 24 / 2; ++i) {
wr ^= g(key, k, wl) ^ k;
k += kstep;
wl ^= g(key, k, wr) ^ k;
k += kstep;
}
/* implicitly swap halves while unpacking */
buf[0] = (wr >> 8);
buf[1] = (wr & 0xFF);
buf[2] = (wl >> 8);
buf[3] = (wl & 0xFF);
} | [
"public",
"static",
"void",
"skip32",
"(",
"byte",
"[",
"]",
"key",
",",
"int",
"[",
"]",
"buf",
",",
"boolean",
"encrypt",
")",
"{",
"int",
"k",
";",
"/* round number */",
"int",
"i",
";",
"/* round counter */",
"int",
"kstep",
";",
"int",
"wl",
",",
... | Applies the SKIP32 function on the provided value stored in buf and
modifies it inplace. This is a low-level function used by the encrypt and
decrypt functions.
@param key
@param buf
@param encrypt | [
"Applies",
"the",
"SKIP32",
"function",
"on",
"the",
"provided",
"value",
"stored",
"in",
"buf",
"and",
"modifies",
"it",
"inplace",
".",
"This",
"is",
"a",
"low",
"-",
"level",
"function",
"used",
"by",
"the",
"encrypt",
"and",
"decrypt",
"functions",
"."... | f95e5caf38d2ee5beea5e7cb834d441ddadd00a1 | https://github.com/boivie/skip32-java/blob/f95e5caf38d2ee5beea5e7cb834d441ddadd00a1/src/main/java/com/boivie/skip32/Skip32.java#L52-L84 | train |
boivie/skip32-java | src/main/java/com/boivie/skip32/Skip32.java | Skip32.encrypt | public static int encrypt(int value, byte[] key) {
int[] buf = new int[4];
buf[0] = ((value >> 24) & 0xff);
buf[1] = ((value >> 16) & 0xff);
buf[2] = ((value >> 8) & 0xff);
buf[3] = ((value >> 0) & 0xff);
skip32(key, buf, true);
int out = ((buf[0]) << 24) | ((buf[1]) << 16) | ((buf[2]) << 8)
| (buf[3]);
return out;
} | java | public static int encrypt(int value, byte[] key) {
int[] buf = new int[4];
buf[0] = ((value >> 24) & 0xff);
buf[1] = ((value >> 16) & 0xff);
buf[2] = ((value >> 8) & 0xff);
buf[3] = ((value >> 0) & 0xff);
skip32(key, buf, true);
int out = ((buf[0]) << 24) | ((buf[1]) << 16) | ((buf[2]) << 8)
| (buf[3]);
return out;
} | [
"public",
"static",
"int",
"encrypt",
"(",
"int",
"value",
",",
"byte",
"[",
"]",
"key",
")",
"{",
"int",
"[",
"]",
"buf",
"=",
"new",
"int",
"[",
"4",
"]",
";",
"buf",
"[",
"0",
"]",
"=",
"(",
"(",
"value",
">>",
"24",
")",
"&",
"0xff",
")... | Encrypts the provided value using the specified key
The key should be a byte array of 10 elements.
@param value
@param key
@return The encrypted value | [
"Encrypts",
"the",
"provided",
"value",
"using",
"the",
"specified",
"key"
] | f95e5caf38d2ee5beea5e7cb834d441ddadd00a1 | https://github.com/boivie/skip32-java/blob/f95e5caf38d2ee5beea5e7cb834d441ddadd00a1/src/main/java/com/boivie/skip32/Skip32.java#L95-L108 | train |
boivie/skip32-java | src/main/java/com/boivie/skip32/Skip32.java | Skip32.decrypt | public static int decrypt(int value, byte[] key) {
int[] buf = new int[4];
buf[0] = ((value >> 24) & 0xff);
buf[1] = ((value >> 16) & 0xff);
buf[2] = ((value >> 8) & 0xff);
buf[3] = ((value >> 0) & 0xff);
skip32(key, buf, false);
int out = ((buf[0]) << 24) | ((buf[1]) << 16) | ((buf[2]) << 8)
| (buf[3]);
return out;
} | java | public static int decrypt(int value, byte[] key) {
int[] buf = new int[4];
buf[0] = ((value >> 24) & 0xff);
buf[1] = ((value >> 16) & 0xff);
buf[2] = ((value >> 8) & 0xff);
buf[3] = ((value >> 0) & 0xff);
skip32(key, buf, false);
int out = ((buf[0]) << 24) | ((buf[1]) << 16) | ((buf[2]) << 8)
| (buf[3]);
return out;
} | [
"public",
"static",
"int",
"decrypt",
"(",
"int",
"value",
",",
"byte",
"[",
"]",
"key",
")",
"{",
"int",
"[",
"]",
"buf",
"=",
"new",
"int",
"[",
"4",
"]",
";",
"buf",
"[",
"0",
"]",
"=",
"(",
"(",
"value",
">>",
"24",
")",
"&",
"0xff",
")... | Decrypts the provided value using the specified key
The key should be a byte array of 10 elements.
@param value
@param key
@return The decrypted value | [
"Decrypts",
"the",
"provided",
"value",
"using",
"the",
"specified",
"key"
] | f95e5caf38d2ee5beea5e7cb834d441ddadd00a1 | https://github.com/boivie/skip32-java/blob/f95e5caf38d2ee5beea5e7cb834d441ddadd00a1/src/main/java/com/boivie/skip32/Skip32.java#L119-L133 | train |
wisdom-framework/wisdom-jdbc | wisdom-jdbc-drivers/abstract-jdbc-driver/src/main/java/org/wisdom/jdbc/driver/helpers/BeanUtils.java | BeanUtils.toBasicType | public static Object toBasicType(String value, String type) throws SQLException {
// Early return from first "if" condition that evaluates to true
if (value == null) {
return null;
}
if (type == null || type.equals(String.class.getName())) {
return value;
}
if (type.equals(Integer.class.getName()) || type.equals(int.class.getName())) {
try { return Integer.valueOf(value); }
catch (NumberFormatException e) {
throwSQLException(e, "Integer", value);
}
}
if (type.equals(Float.class.getName()) || type.equals(float.class.getName())) {
try { return Float.valueOf(value); }
catch (NumberFormatException e) {
throwSQLException(e, "Float", value);
}
}
if (type.equals(Long.class.getName()) || type.equals(long.class.getName())) {
try { return Long.valueOf(value); }
catch (NumberFormatException e) {
throwSQLException(e, "Long", value);
}
}
if (type.equals(Double.class.getName()) || type.equals(double.class.getName())) {
try { return Double.valueOf(value); }
catch (NumberFormatException e) {
throwSQLException(e, "Double", value);
}
}
if (type.equals(Character.class.getName()) || type.equals(char.class.getName())) {
if (value.length() != 1) {
throw new SQLException("Invalid Character value: " + value);
}
return value.charAt(0);
}
if (type.equals(Byte.class.getName()) || type.equals(byte.class.getName())) {
try { return Byte.valueOf(value); }
catch (NumberFormatException e) {
throwSQLException(e, "Byte", value);
}
}
if (type.equals(Short.class.getName()) || type.equals(short.class.getName())) {
try { return Short.valueOf(value); }
catch (NumberFormatException e) {
throwSQLException(e, "Short", value);
}
}
// Will be "false" if not in correct format...
if (type.equals(Boolean.class.getName()) || type.equals(boolean.class.getName())) {
return Boolean.valueOf(value);
}
throw new SQLException("Unrecognized property type: " + type);
} | java | public static Object toBasicType(String value, String type) throws SQLException {
// Early return from first "if" condition that evaluates to true
if (value == null) {
return null;
}
if (type == null || type.equals(String.class.getName())) {
return value;
}
if (type.equals(Integer.class.getName()) || type.equals(int.class.getName())) {
try { return Integer.valueOf(value); }
catch (NumberFormatException e) {
throwSQLException(e, "Integer", value);
}
}
if (type.equals(Float.class.getName()) || type.equals(float.class.getName())) {
try { return Float.valueOf(value); }
catch (NumberFormatException e) {
throwSQLException(e, "Float", value);
}
}
if (type.equals(Long.class.getName()) || type.equals(long.class.getName())) {
try { return Long.valueOf(value); }
catch (NumberFormatException e) {
throwSQLException(e, "Long", value);
}
}
if (type.equals(Double.class.getName()) || type.equals(double.class.getName())) {
try { return Double.valueOf(value); }
catch (NumberFormatException e) {
throwSQLException(e, "Double", value);
}
}
if (type.equals(Character.class.getName()) || type.equals(char.class.getName())) {
if (value.length() != 1) {
throw new SQLException("Invalid Character value: " + value);
}
return value.charAt(0);
}
if (type.equals(Byte.class.getName()) || type.equals(byte.class.getName())) {
try { return Byte.valueOf(value); }
catch (NumberFormatException e) {
throwSQLException(e, "Byte", value);
}
}
if (type.equals(Short.class.getName()) || type.equals(short.class.getName())) {
try { return Short.valueOf(value); }
catch (NumberFormatException e) {
throwSQLException(e, "Short", value);
}
}
// Will be "false" if not in correct format...
if (type.equals(Boolean.class.getName()) || type.equals(boolean.class.getName())) {
return Boolean.valueOf(value);
}
throw new SQLException("Unrecognized property type: " + type);
} | [
"public",
"static",
"Object",
"toBasicType",
"(",
"String",
"value",
",",
"String",
"type",
")",
"throws",
"SQLException",
"{",
"// Early return from first \"if\" condition that evaluates to true",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"return",
"null",
";",
"... | Transforms the given value to an instance of the given type.
@param value the value
@param type the type
@return an instance of the type having the wrapped value
@throws SQLException if the conversion is not possible. | [
"Transforms",
"the",
"given",
"value",
"to",
"an",
"instance",
"of",
"the",
"given",
"type",
"."
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jdbc-drivers/abstract-jdbc-driver/src/main/java/org/wisdom/jdbc/driver/helpers/BeanUtils.java#L91-L158 | train |
wisdom-framework/wisdom-jdbc | wisdom-jdbc-drivers/abstract-jdbc-driver/src/main/java/org/wisdom/jdbc/driver/helpers/BeanUtils.java | BeanUtils.throwSQLException | public static void throwSQLException(Exception cause, String theType, String value)
throws SQLException {
throw new SQLException("Invalid " + theType + " value: " + value, cause);
} | java | public static void throwSQLException(Exception cause, String theType, String value)
throws SQLException {
throw new SQLException("Invalid " + theType + " value: " + value, cause);
} | [
"public",
"static",
"void",
"throwSQLException",
"(",
"Exception",
"cause",
",",
"String",
"theType",
",",
"String",
"value",
")",
"throws",
"SQLException",
"{",
"throw",
"new",
"SQLException",
"(",
"\"Invalid \"",
"+",
"theType",
"+",
"\" value: \"",
"+",
"valu... | An helper method to build and throw a SQL Exception when a property cannot be set.
@param cause the cause
@param theType the type of the property
@param value the value of the property
@throws SQLException the SQL Exception | [
"An",
"helper",
"method",
"to",
"build",
"and",
"throw",
"a",
"SQL",
"Exception",
"when",
"a",
"property",
"cannot",
"be",
"set",
"."
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jdbc-drivers/abstract-jdbc-driver/src/main/java/org/wisdom/jdbc/driver/helpers/BeanUtils.java#L167-L170 | train |
nmdp-bioinformatics/genotype-list | gl-config/src/main/java/org/nmdp/gl/config/ConfigurationModule.java | ConfigurationModule.bindPropertiesWithOverrides | protected final void bindPropertiesWithOverrides(final String propertyFile) {
checkNotNull(propertyFile, "classpath resource property file must not be null");
Properties properties = new Properties();
// load classpath resource properties
InputStream inputStream = getClass().getResourceAsStream(propertyFile);
if (inputStream != null) {
try {
properties.load(inputStream);
}
catch (IOException e) {
// ignore
}
}
// override with system properties
properties.putAll(System.getProperties());
// override with environment variables
for (Map.Entry<String, String> entry : System.getenv().entrySet()) {
String reformattedKey = entry.getKey().replace('_', '.');
// only replace existing keys
if (properties.containsKey(reformattedKey)) {
properties.put(reformattedKey, entry.getValue());
}
}
// bind merged properties
bindProperties(properties);
} | java | protected final void bindPropertiesWithOverrides(final String propertyFile) {
checkNotNull(propertyFile, "classpath resource property file must not be null");
Properties properties = new Properties();
// load classpath resource properties
InputStream inputStream = getClass().getResourceAsStream(propertyFile);
if (inputStream != null) {
try {
properties.load(inputStream);
}
catch (IOException e) {
// ignore
}
}
// override with system properties
properties.putAll(System.getProperties());
// override with environment variables
for (Map.Entry<String, String> entry : System.getenv().entrySet()) {
String reformattedKey = entry.getKey().replace('_', '.');
// only replace existing keys
if (properties.containsKey(reformattedKey)) {
properties.put(reformattedKey, entry.getValue());
}
}
// bind merged properties
bindProperties(properties);
} | [
"protected",
"final",
"void",
"bindPropertiesWithOverrides",
"(",
"final",
"String",
"propertyFile",
")",
"{",
"checkNotNull",
"(",
"propertyFile",
",",
"\"classpath resource property file must not be null\"",
")",
";",
"Properties",
"properties",
"=",
"new",
"Properties",
... | Bind properties from the specified classpath resource property file, overriding those values
with system properties and with environment variables after replacing key underscores '_' by dots '.'.
@param propertyFile classpath resource property file, must not be null | [
"Bind",
"properties",
"from",
"the",
"specified",
"classpath",
"resource",
"property",
"file",
"overriding",
"those",
"values",
"with",
"system",
"properties",
"and",
"with",
"environment",
"variables",
"after",
"replacing",
"key",
"underscores",
"_",
"by",
"dots",
... | 03b2579552cb9f680a62ffaaecdca9c2a5d12ee4 | https://github.com/nmdp-bioinformatics/genotype-list/blob/03b2579552cb9f680a62ffaaecdca9c2a5d12ee4/gl-config/src/main/java/org/nmdp/gl/config/ConfigurationModule.java#L54-L85 | train |
nmdp-bioinformatics/genotype-list | gl-config/src/main/java/org/nmdp/gl/config/ConfigurationModule.java | ConfigurationModule.looksLikeAnnotationName | protected static final boolean looksLikeAnnotationName(final String name) {
return name.startsWith("org.nmdp") && Character.isUpperCase(name.charAt(name.lastIndexOf(".") + 1));
} | java | protected static final boolean looksLikeAnnotationName(final String name) {
return name.startsWith("org.nmdp") && Character.isUpperCase(name.charAt(name.lastIndexOf(".") + 1));
} | [
"protected",
"static",
"final",
"boolean",
"looksLikeAnnotationName",
"(",
"final",
"String",
"name",
")",
"{",
"return",
"name",
".",
"startsWith",
"(",
"\"org.nmdp\"",
")",
"&&",
"Character",
".",
"isUpperCase",
"(",
"name",
".",
"charAt",
"(",
"name",
".",
... | Return true if the specified property name looks like an annotation name.
@param name property name
@return true if the specified property name looks like an annotation name | [
"Return",
"true",
"if",
"the",
"specified",
"property",
"name",
"looks",
"like",
"an",
"annotation",
"name",
"."
] | 03b2579552cb9f680a62ffaaecdca9c2a5d12ee4 | https://github.com/nmdp-bioinformatics/genotype-list/blob/03b2579552cb9f680a62ffaaecdca9c2a5d12ee4/gl-config/src/main/java/org/nmdp/gl/config/ConfigurationModule.java#L111-L113 | train |
nmdp-bioinformatics/genotype-list | gl-config/src/main/java/org/nmdp/gl/config/ConfigurationModule.java | ConfigurationModule.annotation | @SuppressWarnings("unchecked")
protected static final <A extends Annotation> Class<A> annotation(final String annotationClassName) {
try {
return (Class<A>) Class.forName(annotationClassName);
}
catch (ClassNotFoundException e) {
throw new ProvisionException(format("could not create annotation class '%s': %s", annotationClassName, e.getMessage()));
}
} | java | @SuppressWarnings("unchecked")
protected static final <A extends Annotation> Class<A> annotation(final String annotationClassName) {
try {
return (Class<A>) Class.forName(annotationClassName);
}
catch (ClassNotFoundException e) {
throw new ProvisionException(format("could not create annotation class '%s': %s", annotationClassName, e.getMessage()));
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"protected",
"static",
"final",
"<",
"A",
"extends",
"Annotation",
">",
"Class",
"<",
"A",
">",
"annotation",
"(",
"final",
"String",
"annotationClassName",
")",
"{",
"try",
"{",
"return",
"(",
"Class",
"<"... | Return an instance of an annotation with the specified class name.
@param annotationClassName annotation class name
@return an instance of an annotation with the specified class name | [
"Return",
"an",
"instance",
"of",
"an",
"annotation",
"with",
"the",
"specified",
"class",
"name",
"."
] | 03b2579552cb9f680a62ffaaecdca9c2a5d12ee4 | https://github.com/nmdp-bioinformatics/genotype-list/blob/03b2579552cb9f680a62ffaaecdca9c2a5d12ee4/gl-config/src/main/java/org/nmdp/gl/config/ConfigurationModule.java#L121-L129 | train |
KayLerch/alexa-skills-kit-tellask-java | src/main/java/io/klerch/alexa/tellask/util/factory/AlexaIntentHandlerFactory.java | AlexaIntentHandlerFactory.createHandler | @SuppressWarnings("unchecked")
public static Optional<AlexaIntentHandler> createHandler(final AlexaInput input) {
try {
final Class factoryImpl = Class.forName(FACTORY_PACKAGE + "." + FACTORY_CLASS_NAME);
final Method method = factoryImpl.getMethod(FACTORY_METHOD_NAME, AlexaInput.class);
final Object handler = method.invoke(null, input);
return handler != null ? Optional.of((AlexaIntentHandler)handler) : Optional.empty();
} catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
LOG.error("Could not access generated factory to obtain intent handlers likely because there is no valid intent handler in your project at all.", e);
return Optional.empty();
}
} | java | @SuppressWarnings("unchecked")
public static Optional<AlexaIntentHandler> createHandler(final AlexaInput input) {
try {
final Class factoryImpl = Class.forName(FACTORY_PACKAGE + "." + FACTORY_CLASS_NAME);
final Method method = factoryImpl.getMethod(FACTORY_METHOD_NAME, AlexaInput.class);
final Object handler = method.invoke(null, input);
return handler != null ? Optional.of((AlexaIntentHandler)handler) : Optional.empty();
} catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
LOG.error("Could not access generated factory to obtain intent handlers likely because there is no valid intent handler in your project at all.", e);
return Optional.empty();
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"Optional",
"<",
"AlexaIntentHandler",
">",
"createHandler",
"(",
"final",
"AlexaInput",
"input",
")",
"{",
"try",
"{",
"final",
"Class",
"factoryImpl",
"=",
"Class",
".",
"forName",
"(",
... | Constructs the AlexaIntentHandler which is tagged with the AlexaIntentListener-annotation.
If more than one handler for an intent is found it returns the one whose verify-method returns
true. If even then there's more than one handler the one with the highest priority wins (you
set the priority of an AlexaIntentHanlder in the AlexaIntentListener-annotation.
@param input the input which should be handled. Most important is the intent name in the
input as it is the matching criteria for finding the right intent handler.
@return AlexaLaunchHandler to handle launch events of your skill | [
"Constructs",
"the",
"AlexaIntentHandler",
"which",
"is",
"tagged",
"with",
"the",
"AlexaIntentListener",
"-",
"annotation",
".",
"If",
"more",
"than",
"one",
"handler",
"for",
"an",
"intent",
"is",
"found",
"it",
"returns",
"the",
"one",
"whose",
"verify",
"-... | 2c19028e775c2512dd4649d12962c0b48bf7f2bc | https://github.com/KayLerch/alexa-skills-kit-tellask-java/blob/2c19028e775c2512dd4649d12962c0b48bf7f2bc/src/main/java/io/klerch/alexa/tellask/util/factory/AlexaIntentHandlerFactory.java#L42-L53 | train |
wisdom-framework/wisdom-jdbc | wisdom-jpa-manager/src/main/java/org/wisdom/framework/transaction/impl/HowlLog.java | HowlLog.setLogFileDir | public void setLogFileDir(String logDirName) {
File logDir = new File(logDirName);
if (!logDir.isAbsolute()) {
logDir = new File(serverBaseDir, logDirName);
}
this.logFileDir = logDirName;
if (started) {
configuration.setLogFileDir(logDir.getAbsolutePath());
}
} | java | public void setLogFileDir(String logDirName) {
File logDir = new File(logDirName);
if (!logDir.isAbsolute()) {
logDir = new File(serverBaseDir, logDirName);
}
this.logFileDir = logDirName;
if (started) {
configuration.setLogFileDir(logDir.getAbsolutePath());
}
} | [
"public",
"void",
"setLogFileDir",
"(",
"String",
"logDirName",
")",
"{",
"File",
"logDir",
"=",
"new",
"File",
"(",
"logDirName",
")",
";",
"if",
"(",
"!",
"logDir",
".",
"isAbsolute",
"(",
")",
")",
"{",
"logDir",
"=",
"new",
"File",
"(",
"serverBase... | Sets the log dir.
@param logDirName the directory name | [
"Sets",
"the",
"log",
"dir",
"."
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jpa-manager/src/main/java/org/wisdom/framework/transaction/impl/HowlLog.java#L122-L132 | train |
wisdom-framework/wisdom-jdbc | wisdom-jpa-manager/src/main/java/org/wisdom/framework/transaction/impl/HowlLog.java | HowlLog.start | public void start() throws Exception {
started = true;
setLogFileDir(logFileDir);
LOGGER.debug("Initiating transaction manager recovery");
recovered = new HashMap<>();
logger.open(null);
ReplayListener replayListener = new GeronimoReplayListener(xidFactory, recovered);
logger.replayActiveTx(replayListener);
LOGGER.debug("In doubt transactions recovered from log");
} | java | public void start() throws Exception {
started = true;
setLogFileDir(logFileDir);
LOGGER.debug("Initiating transaction manager recovery");
recovered = new HashMap<>();
logger.open(null);
ReplayListener replayListener = new GeronimoReplayListener(xidFactory, recovered);
logger.replayActiveTx(replayListener);
LOGGER.debug("In doubt transactions recovered from log");
} | [
"public",
"void",
"start",
"(",
")",
"throws",
"Exception",
"{",
"started",
"=",
"true",
";",
"setLogFileDir",
"(",
"logFileDir",
")",
";",
"LOGGER",
".",
"debug",
"(",
"\"Initiating transaction manager recovery\"",
")",
";",
"recovered",
"=",
"new",
"HashMap",
... | Starts the logger.
@throws Exception cannot be started | [
"Starts",
"the",
"logger",
"."
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jpa-manager/src/main/java/org/wisdom/framework/transaction/impl/HowlLog.java#L138-L150 | train |
wisdom-framework/wisdom-jdbc | wisdom-jpa-manager/src/main/java/org/wisdom/framework/transaction/impl/HowlLog.java | HowlLog.prepare | public Object prepare(Xid xid, List<? extends TransactionBranchInfo> branches) throws LogException {
int branchCount = branches.size();
byte[][] data = new byte[3 + 2 * branchCount][];
data[0] = intToBytes(xid.getFormatId());
data[1] = xid.getGlobalTransactionId();
data[2] = xid.getBranchQualifier();
int i = 3;
for (TransactionBranchInfo transactionBranchInfo : branches) {
data[i++] = transactionBranchInfo.getBranchXid().getBranchQualifier();
data[i++] = transactionBranchInfo.getResourceName().getBytes();
}
try {
return logger.putCommit(data);
} catch (LogClosedException | LogRecordSizeException | InterruptedException | LogFileOverflowException e) {
throw new IllegalStateException(e);
} catch (IOException e) {
throw new LogException(e);
}
} | java | public Object prepare(Xid xid, List<? extends TransactionBranchInfo> branches) throws LogException {
int branchCount = branches.size();
byte[][] data = new byte[3 + 2 * branchCount][];
data[0] = intToBytes(xid.getFormatId());
data[1] = xid.getGlobalTransactionId();
data[2] = xid.getBranchQualifier();
int i = 3;
for (TransactionBranchInfo transactionBranchInfo : branches) {
data[i++] = transactionBranchInfo.getBranchXid().getBranchQualifier();
data[i++] = transactionBranchInfo.getResourceName().getBytes();
}
try {
return logger.putCommit(data);
} catch (LogClosedException | LogRecordSizeException | InterruptedException | LogFileOverflowException e) {
throw new IllegalStateException(e);
} catch (IOException e) {
throw new LogException(e);
}
} | [
"public",
"Object",
"prepare",
"(",
"Xid",
"xid",
",",
"List",
"<",
"?",
"extends",
"TransactionBranchInfo",
">",
"branches",
")",
"throws",
"LogException",
"{",
"int",
"branchCount",
"=",
"branches",
".",
"size",
"(",
")",
";",
"byte",
"[",
"]",
"[",
"]... | Prepares a transaction
@param xid the id
@param branches the branches
@return the log mark to use in commit/rollback calls.
@throws LogException on error | [
"Prepares",
"a",
"transaction"
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jpa-manager/src/main/java/org/wisdom/framework/transaction/impl/HowlLog.java#L177-L195 | train |
wisdom-framework/wisdom-jdbc | wisdom-jpa-manager/src/main/java/org/wisdom/framework/transaction/impl/HowlLog.java | HowlLog.commit | public void commit(Xid xid, Object logMark) throws LogException {
//the data is theoretically unnecessary but is included to help with debugging
// and because HOWL currently requires it.
byte[][] data = new byte[4][];
data[0] = new byte[]{COMMIT};
data[1] = intToBytes(xid.getFormatId());
data[2] = xid.getGlobalTransactionId();
data[3] = xid.getBranchQualifier();
try {
logger.putDone(data, (XACommittingTx) logMark);
} catch (LogClosedException | LogRecordSizeException | InterruptedException | IOException | LogFileOverflowException e) {
throw new IllegalStateException(e);
}
} | java | public void commit(Xid xid, Object logMark) throws LogException {
//the data is theoretically unnecessary but is included to help with debugging
// and because HOWL currently requires it.
byte[][] data = new byte[4][];
data[0] = new byte[]{COMMIT};
data[1] = intToBytes(xid.getFormatId());
data[2] = xid.getGlobalTransactionId();
data[3] = xid.getBranchQualifier();
try {
logger.putDone(data, (XACommittingTx) logMark);
} catch (LogClosedException | LogRecordSizeException | InterruptedException | IOException | LogFileOverflowException e) {
throw new IllegalStateException(e);
}
} | [
"public",
"void",
"commit",
"(",
"Xid",
"xid",
",",
"Object",
"logMark",
")",
"throws",
"LogException",
"{",
"//the data is theoretically unnecessary but is included to help with debugging",
"// and because HOWL currently requires it.",
"byte",
"[",
"]",
"[",
"]",
"data",
"... | Commits a transaction
@param xid the id
@param logMark the mark
@throws LogException on error | [
"Commits",
"a",
"transaction"
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jpa-manager/src/main/java/org/wisdom/framework/transaction/impl/HowlLog.java#L203-L216 | train |
nmdp-bioinformatics/genotype-list | gl-service/src/main/java/org/nmdp/gl/service/nomenclature/AbstractNomenclature.java | AbstractNomenclature.loadAllele | protected final Allele loadAllele(final String glstring, final String accession) throws IOException {
final String id = glstringResolver.resolveAllele(glstring);
Allele allele = idResolver.findAllele(id);
if (allele == null) {
Matcher m = ALLELE_PATTERN.matcher(glstring);
if (m.matches()) {
String locusPart = m.group(1);
Locus locus = loadLocus(locusPart);
allele = new Allele(id, accession, glstring, locus);
glRegistry.registerAllele(allele);
}
else {
throw new IOException("allele \"" + glstring + "\" not a valid formatted glstring");
}
}
return allele;
} | java | protected final Allele loadAllele(final String glstring, final String accession) throws IOException {
final String id = glstringResolver.resolveAllele(glstring);
Allele allele = idResolver.findAllele(id);
if (allele == null) {
Matcher m = ALLELE_PATTERN.matcher(glstring);
if (m.matches()) {
String locusPart = m.group(1);
Locus locus = loadLocus(locusPart);
allele = new Allele(id, accession, glstring, locus);
glRegistry.registerAllele(allele);
}
else {
throw new IOException("allele \"" + glstring + "\" not a valid formatted glstring");
}
}
return allele;
} | [
"protected",
"final",
"Allele",
"loadAllele",
"(",
"final",
"String",
"glstring",
",",
"final",
"String",
"accession",
")",
"throws",
"IOException",
"{",
"final",
"String",
"id",
"=",
"glstringResolver",
".",
"resolveAllele",
"(",
"glstring",
")",
";",
"Allele",... | Load and register the specified allele in GL String format.
@param glstring allele in GL String format, must not be null or empty
@param accession allele accession, must not be null
@return the registered allele
@throws IOException if an I/O error occurs | [
"Load",
"and",
"register",
"the",
"specified",
"allele",
"in",
"GL",
"String",
"format",
"."
] | 03b2579552cb9f680a62ffaaecdca9c2a5d12ee4 | https://github.com/nmdp-bioinformatics/genotype-list/blob/03b2579552cb9f680a62ffaaecdca9c2a5d12ee4/gl-service/src/main/java/org/nmdp/gl/service/nomenclature/AbstractNomenclature.java#L96-L112 | train |
viltgroup/minium | minium-actions/src/main/java/minium/actions/internal/AbstractInteraction.java | AbstractInteraction.getFirst | protected Elements getFirst(Elements elems) {
@SuppressWarnings("unchecked")
IterableElements<Elements> iterableElems = elems.as(IterableElements.class);
return Iterables.getFirst(iterableElems, null);
} | java | protected Elements getFirst(Elements elems) {
@SuppressWarnings("unchecked")
IterableElements<Elements> iterableElems = elems.as(IterableElements.class);
return Iterables.getFirst(iterableElems, null);
} | [
"protected",
"Elements",
"getFirst",
"(",
"Elements",
"elems",
")",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"IterableElements",
"<",
"Elements",
">",
"iterableElems",
"=",
"elems",
".",
"as",
"(",
"IterableElements",
".",
"class",
")",
";",
"r... | Gets the first.
@param elems
the elems
@return the first | [
"Gets",
"the",
"first",
"."
] | f512fdd966ed4034d3ed53518eae7ad993562ab1 | https://github.com/viltgroup/minium/blob/f512fdd966ed4034d3ed53518eae7ad993562ab1/minium-actions/src/main/java/minium/actions/internal/AbstractInteraction.java#L148-L152 | train |
viltgroup/minium | minium-actions/src/main/java/minium/actions/internal/AbstractInteraction.java | AbstractInteraction.triggerReverse | protected boolean triggerReverse(Type type, Throwable e) {
return trigger(Lists.reverse(getAllListeners()), type, e);
} | java | protected boolean triggerReverse(Type type, Throwable e) {
return trigger(Lists.reverse(getAllListeners()), type, e);
} | [
"protected",
"boolean",
"triggerReverse",
"(",
"Type",
"type",
",",
"Throwable",
"e",
")",
"{",
"return",
"trigger",
"(",
"Lists",
".",
"reverse",
"(",
"getAllListeners",
"(",
")",
")",
",",
"type",
",",
"e",
")",
";",
"}"
] | Trigger reverse.
@param type
the type | [
"Trigger",
"reverse",
"."
] | f512fdd966ed4034d3ed53518eae7ad993562ab1 | https://github.com/viltgroup/minium/blob/f512fdd966ed4034d3ed53518eae7ad993562ab1/minium-actions/src/main/java/minium/actions/internal/AbstractInteraction.java#L170-L172 | train |
wisdom-framework/wisdom-jdbc | wisdom-jdbc-drivers/abstract-jdbc-driver/src/main/java/org/wisdom/jdbc/driver/helpers/AbstractDataSourceFactory.java | AbstractDataSourceFactory.createDataSource | public DataSource createDataSource(Properties props) throws SQLException {
if (props == null) {
props = new Properties();
}
DataSource dataSource = newDataSource();
setBeanProperties(dataSource, props);
return dataSource;
} | java | public DataSource createDataSource(Properties props) throws SQLException {
if (props == null) {
props = new Properties();
}
DataSource dataSource = newDataSource();
setBeanProperties(dataSource, props);
return dataSource;
} | [
"public",
"DataSource",
"createDataSource",
"(",
"Properties",
"props",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"props",
"==",
"null",
")",
"{",
"props",
"=",
"new",
"Properties",
"(",
")",
";",
"}",
"DataSource",
"dataSource",
"=",
"newDataSource",
"... | Creates a DataSource object.
@param props The properties that define the DataSource implementation to create and how the DataSource is
configured
@return The configured DataSource
@throws SQLException If the data source cannot be created | [
"Creates",
"a",
"DataSource",
"object",
"."
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jdbc-drivers/abstract-jdbc-driver/src/main/java/org/wisdom/jdbc/driver/helpers/AbstractDataSourceFactory.java#L62-L70 | train |
wisdom-framework/wisdom-jdbc | wisdom-jdbc-drivers/abstract-jdbc-driver/src/main/java/org/wisdom/jdbc/driver/helpers/AbstractDataSourceFactory.java | AbstractDataSourceFactory.createConnectionPoolDataSource | public ConnectionPoolDataSource createConnectionPoolDataSource(Properties props) throws SQLException {
if (props == null) props = new Properties();
ConnectionPoolDataSource dataSource = newConnectionPoolDataSource();
setBeanProperties(dataSource, props);
return dataSource;
} | java | public ConnectionPoolDataSource createConnectionPoolDataSource(Properties props) throws SQLException {
if (props == null) props = new Properties();
ConnectionPoolDataSource dataSource = newConnectionPoolDataSource();
setBeanProperties(dataSource, props);
return dataSource;
} | [
"public",
"ConnectionPoolDataSource",
"createConnectionPoolDataSource",
"(",
"Properties",
"props",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"props",
"==",
"null",
")",
"props",
"=",
"new",
"Properties",
"(",
")",
";",
"ConnectionPoolDataSource",
"dataSource",
... | Create a ConnectionPoolDataSource object.
@param props The properties that define the ConnectionPoolDataSource implementation to create and how the
ConnectionPoolDataSource is configured
@return The configured ConnectionPoolDataSource
@throws SQLException If the data source cannot be created | [
"Create",
"a",
"ConnectionPoolDataSource",
"object",
"."
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jdbc-drivers/abstract-jdbc-driver/src/main/java/org/wisdom/jdbc/driver/helpers/AbstractDataSourceFactory.java#L80-L85 | train |
wisdom-framework/wisdom-jdbc | wisdom-jdbc-drivers/abstract-jdbc-driver/src/main/java/org/wisdom/jdbc/driver/helpers/AbstractDataSourceFactory.java | AbstractDataSourceFactory.createXADataSource | public XADataSource createXADataSource(Properties props) throws SQLException {
if (props == null) props = new Properties();
XADataSource dataSource = newXADataSource();
setBeanProperties(dataSource, props);
return dataSource;
} | java | public XADataSource createXADataSource(Properties props) throws SQLException {
if (props == null) props = new Properties();
XADataSource dataSource = newXADataSource();
setBeanProperties(dataSource, props);
return dataSource;
} | [
"public",
"XADataSource",
"createXADataSource",
"(",
"Properties",
"props",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"props",
"==",
"null",
")",
"props",
"=",
"new",
"Properties",
"(",
")",
";",
"XADataSource",
"dataSource",
"=",
"newXADataSource",
"(",
... | Creates an XADataSource object.
@param props The properties that define the XADataSource implementation to create and how the XADataSource is
configured
@return The configured XADataSource
@throws SQLException If the data source cannot be created | [
"Creates",
"an",
"XADataSource",
"object",
"."
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jdbc-drivers/abstract-jdbc-driver/src/main/java/org/wisdom/jdbc/driver/helpers/AbstractDataSourceFactory.java#L95-L100 | train |
wisdom-framework/wisdom-jdbc | wisdom-jdbc-drivers/abstract-jdbc-driver/src/main/java/org/wisdom/jdbc/driver/helpers/AbstractDataSourceFactory.java | AbstractDataSourceFactory.createDriver | public Driver createDriver(Properties props) throws SQLException {
Driver driver = newJdbcDriver();
setBeanProperties(driver, props);
return driver;
} | java | public Driver createDriver(Properties props) throws SQLException {
Driver driver = newJdbcDriver();
setBeanProperties(driver, props);
return driver;
} | [
"public",
"Driver",
"createDriver",
"(",
"Properties",
"props",
")",
"throws",
"SQLException",
"{",
"Driver",
"driver",
"=",
"newJdbcDriver",
"(",
")",
";",
"setBeanProperties",
"(",
"driver",
",",
"props",
")",
";",
"return",
"driver",
";",
"}"
] | Creates a new JDBC Driver instance.
@param props The properties used to configure the Driver. {@literal null} indicates no properties. If the
property cannot be set on the Driver being created then an SQLException must be thrown.
@return A configured java.sql.Driver.
@throws SQLException If the driver instance cannot be created | [
"Creates",
"a",
"new",
"JDBC",
"Driver",
"instance",
"."
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jdbc-drivers/abstract-jdbc-driver/src/main/java/org/wisdom/jdbc/driver/helpers/AbstractDataSourceFactory.java#L110-L114 | train |
wisdom-framework/wisdom-jdbc | wisdom-jdbc-drivers/abstract-jdbc-driver/src/main/java/org/wisdom/jdbc/driver/helpers/AbstractDataSourceFactory.java | AbstractDataSourceFactory.setBeanProperties | static void setBeanProperties(Object object, Properties props)
throws SQLException {
if (props != null) {
Enumeration<?> enumeration = props.keys();
while (enumeration.hasMoreElements()) {
String name = (String) enumeration.nextElement();
setProperty(object, name, props.getProperty(name));
}
}
} | java | static void setBeanProperties(Object object, Properties props)
throws SQLException {
if (props != null) {
Enumeration<?> enumeration = props.keys();
while (enumeration.hasMoreElements()) {
String name = (String) enumeration.nextElement();
setProperty(object, name, props.getProperty(name));
}
}
} | [
"static",
"void",
"setBeanProperties",
"(",
"Object",
"object",
",",
"Properties",
"props",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"props",
"!=",
"null",
")",
"{",
"Enumeration",
"<",
"?",
">",
"enumeration",
"=",
"props",
".",
"keys",
"(",
")",
... | Sets the given properties on the target object.
@param object the object on which the properties need to be set
@param props the properties
@throws SQLException if a property cannot be set. | [
"Sets",
"the",
"given",
"properties",
"on",
"the",
"target",
"object",
"."
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jdbc-drivers/abstract-jdbc-driver/src/main/java/org/wisdom/jdbc/driver/helpers/AbstractDataSourceFactory.java#L123-L133 | train |
wisdom-framework/wisdom-jdbc | wisdom-jpa-manager/src/main/java/org/wisdom/framework/osgi/QuotedTokenizer.java | QuotedTokenizer.nextToken | public String nextToken(String separators) {
separator = 0;
if (peek != null) {
String tmp = peek;
peek = null;
return tmp;
}
if (index == string.length()) {
return null;
}
StringBuilder sb = new StringBuilder();
boolean hadstring = false; // means no further trimming
boolean validspace = false; // means include spaces
while (index < string.length()) {
char c = string.charAt(index++);
if (Character.isWhitespace(c)) {
if (index == string.length()) {
break;
}
if (validspace) {
sb.append(c);
}
continue;
}
if (separators.indexOf(c) >= 0) {
if (returnTokens) {
peek = Character.toString(c);
} else {
separator = c;
}
break;
}
switch (c) {
case '"':
case '\'':
hadstring = true;
quotedString(sb, c);
// skip remaining space
validspace = false;
break;
default:
sb.append(c);
validspace = true;
}
}
String result = sb.toString();
if (!hadstring) {
result = result.trim();
}
if (result.length() == 0 && index == string.length()) {
return null;
}
return result;
} | java | public String nextToken(String separators) {
separator = 0;
if (peek != null) {
String tmp = peek;
peek = null;
return tmp;
}
if (index == string.length()) {
return null;
}
StringBuilder sb = new StringBuilder();
boolean hadstring = false; // means no further trimming
boolean validspace = false; // means include spaces
while (index < string.length()) {
char c = string.charAt(index++);
if (Character.isWhitespace(c)) {
if (index == string.length()) {
break;
}
if (validspace) {
sb.append(c);
}
continue;
}
if (separators.indexOf(c) >= 0) {
if (returnTokens) {
peek = Character.toString(c);
} else {
separator = c;
}
break;
}
switch (c) {
case '"':
case '\'':
hadstring = true;
quotedString(sb, c);
// skip remaining space
validspace = false;
break;
default:
sb.append(c);
validspace = true;
}
}
String result = sb.toString();
if (!hadstring) {
result = result.trim();
}
if (result.length() == 0 && index == string.length()) {
return null;
}
return result;
} | [
"public",
"String",
"nextToken",
"(",
"String",
"separators",
")",
"{",
"separator",
"=",
"0",
";",
"if",
"(",
"peek",
"!=",
"null",
")",
"{",
"String",
"tmp",
"=",
"peek",
";",
"peek",
"=",
"null",
";",
"return",
"tmp",
";",
"}",
"if",
"(",
"index... | Retrieve next token.
@param separators the separators
@return the next token. | [
"Retrieve",
"next",
"token",
"."
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jpa-manager/src/main/java/org/wisdom/framework/osgi/QuotedTokenizer.java#L67-L131 | train |
wisdom-framework/wisdom-jdbc | wisdom-jpa-manager/src/main/java/org/wisdom/framework/jpa/TransactionalEntityManager.java | TransactionalEntityManager.getEM | private EntityManager getEM() throws IllegalStateException {
if (!open) {
throw new IllegalStateException("The JPA bridge has closed");
}
try {
// Do we already have one on this thread?
EntityManager em = perThreadEntityManager.get();
if (em != null) {
return em;
}
// Nope, so we need to check if there actually is a transaction
final Transaction transaction = transactionManager.getTransaction();
if (transaction == null) {
throw new TransactionRequiredException("Cannot create an EM since no transaction active");
}
em = entityManagerFactory.createEntityManager();
try {
// Register a callback at the end of the transaction
transaction.registerSynchronization(new Synchronization() {
@Override
public void beforeCompletion() {
if (!open) {
throw new IllegalStateException(
"The Transaction Entity Manager was closed in the mean time");
}
}
@Override
public void afterCompletion(int arg0) {
EntityManager em = perThreadEntityManager.get();
perThreadEntityManager.set(null);
em.close();
}
});
} catch (Exception e) {
em.close();
throw new IllegalStateException("Registering synchronization to close EM", e);
}
// Make it available for later calls on this thread
perThreadEntityManager.set(em);
// And make sure it joins the current transaction.
em.joinTransaction();
return em;
} catch (Exception e) {
throw new IllegalStateException("Error while retrieving entity manager", e);
}
} | java | private EntityManager getEM() throws IllegalStateException {
if (!open) {
throw new IllegalStateException("The JPA bridge has closed");
}
try {
// Do we already have one on this thread?
EntityManager em = perThreadEntityManager.get();
if (em != null) {
return em;
}
// Nope, so we need to check if there actually is a transaction
final Transaction transaction = transactionManager.getTransaction();
if (transaction == null) {
throw new TransactionRequiredException("Cannot create an EM since no transaction active");
}
em = entityManagerFactory.createEntityManager();
try {
// Register a callback at the end of the transaction
transaction.registerSynchronization(new Synchronization() {
@Override
public void beforeCompletion() {
if (!open) {
throw new IllegalStateException(
"The Transaction Entity Manager was closed in the mean time");
}
}
@Override
public void afterCompletion(int arg0) {
EntityManager em = perThreadEntityManager.get();
perThreadEntityManager.set(null);
em.close();
}
});
} catch (Exception e) {
em.close();
throw new IllegalStateException("Registering synchronization to close EM", e);
}
// Make it available for later calls on this thread
perThreadEntityManager.set(em);
// And make sure it joins the current transaction.
em.joinTransaction();
return em;
} catch (Exception e) {
throw new IllegalStateException("Error while retrieving entity manager", e);
}
} | [
"private",
"EntityManager",
"getEM",
"(",
")",
"throws",
"IllegalStateException",
"{",
"if",
"(",
"!",
"open",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"The JPA bridge has closed\"",
")",
";",
"}",
"try",
"{",
"// Do we already have one on this thread... | The delegated methods call this method to get the delegate. This method
verifies if we're still open, if there already is an Entity Manager for
this thread and otherwise creates it and enlists it for auto close at the
current transaction.
@return an Entity Manager | [
"The",
"delegated",
"methods",
"call",
"this",
"method",
"to",
"get",
"the",
"delegate",
".",
"This",
"method",
"verifies",
"if",
"we",
"re",
"still",
"open",
"if",
"there",
"already",
"is",
"an",
"Entity",
"Manager",
"for",
"this",
"thread",
"and",
"other... | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jpa-manager/src/main/java/org/wisdom/framework/jpa/TransactionalEntityManager.java#L64-L122 | train |
KayLerch/alexa-skills-kit-tellask-java | src/main/java/io/klerch/alexa/tellask/model/wrapper/AlexaSpeechletResponse.java | AlexaSpeechletResponse.getOutputSpeech | @Override
public OutputSpeech getOutputSpeech() {
if (outputSpeech != null) {
return outputSpeech;
}
final String utterance;
try {
utterance = yamlReader.getRandomUtterance(output).orElseThrow(IOException::new);
LOG.debug("Random utterance read out from YAML file: " + utterance);
} catch (IOException e) {
LOG.error("Error while generating response utterance.", e);
return null;
}
final String utteranceSsml = resolveSlotsInUtterance(utterance);
final SsmlOutputSpeech ssmlOutputSpeech = new SsmlOutputSpeech();
ssmlOutputSpeech.setSsml(utteranceSsml);
return ssmlOutputSpeech;
} | java | @Override
public OutputSpeech getOutputSpeech() {
if (outputSpeech != null) {
return outputSpeech;
}
final String utterance;
try {
utterance = yamlReader.getRandomUtterance(output).orElseThrow(IOException::new);
LOG.debug("Random utterance read out from YAML file: " + utterance);
} catch (IOException e) {
LOG.error("Error while generating response utterance.", e);
return null;
}
final String utteranceSsml = resolveSlotsInUtterance(utterance);
final SsmlOutputSpeech ssmlOutputSpeech = new SsmlOutputSpeech();
ssmlOutputSpeech.setSsml(utteranceSsml);
return ssmlOutputSpeech;
} | [
"@",
"Override",
"public",
"OutputSpeech",
"getOutputSpeech",
"(",
")",
"{",
"if",
"(",
"outputSpeech",
"!=",
"null",
")",
"{",
"return",
"outputSpeech",
";",
"}",
"final",
"String",
"utterance",
";",
"try",
"{",
"utterance",
"=",
"yamlReader",
".",
"getRand... | Gets the generated output speech.
@return the generated output speech. | [
"Gets",
"the",
"generated",
"output",
"speech",
"."
] | 2c19028e775c2512dd4649d12962c0b48bf7f2bc | https://github.com/KayLerch/alexa-skills-kit-tellask-java/blob/2c19028e775c2512dd4649d12962c0b48bf7f2bc/src/main/java/io/klerch/alexa/tellask/model/wrapper/AlexaSpeechletResponse.java#L94-L115 | train |
KayLerch/alexa-skills-kit-tellask-java | src/main/java/io/klerch/alexa/tellask/model/wrapper/AlexaSpeechletResponse.java | AlexaSpeechletResponse.getReprompt | @Override
public Reprompt getReprompt() {
if (reprompt != null || !output.shouldReprompt()) {
return reprompt;
}
final String repromptSpeech = yamlReader.getRandomReprompt(output).orElse(null);
if (repromptSpeech != null) {
final String utteranceSsml = resolveSlotsInUtterance(repromptSpeech);
final SsmlOutputSpeech ssmlOutputSpeech = new SsmlOutputSpeech();
ssmlOutputSpeech.setSsml(utteranceSsml);
final Reprompt reprompt2 = new Reprompt();
reprompt2.setOutputSpeech(ssmlOutputSpeech);
return reprompt2;
}
return null;
} | java | @Override
public Reprompt getReprompt() {
if (reprompt != null || !output.shouldReprompt()) {
return reprompt;
}
final String repromptSpeech = yamlReader.getRandomReprompt(output).orElse(null);
if (repromptSpeech != null) {
final String utteranceSsml = resolveSlotsInUtterance(repromptSpeech);
final SsmlOutputSpeech ssmlOutputSpeech = new SsmlOutputSpeech();
ssmlOutputSpeech.setSsml(utteranceSsml);
final Reprompt reprompt2 = new Reprompt();
reprompt2.setOutputSpeech(ssmlOutputSpeech);
return reprompt2;
}
return null;
} | [
"@",
"Override",
"public",
"Reprompt",
"getReprompt",
"(",
")",
"{",
"if",
"(",
"reprompt",
"!=",
"null",
"||",
"!",
"output",
".",
"shouldReprompt",
"(",
")",
")",
"{",
"return",
"reprompt",
";",
"}",
"final",
"String",
"repromptSpeech",
"=",
"yamlReader"... | Gets the generated reprompt.
@return the generated reprompt | [
"Gets",
"the",
"generated",
"reprompt",
"."
] | 2c19028e775c2512dd4649d12962c0b48bf7f2bc | https://github.com/KayLerch/alexa-skills-kit-tellask-java/blob/2c19028e775c2512dd4649d12962c0b48bf7f2bc/src/main/java/io/klerch/alexa/tellask/model/wrapper/AlexaSpeechletResponse.java#L121-L138 | train |
wisdom-framework/wisdom-jdbc | wisdom-jpa-manager/src/main/java/org/wisdom/framework/transaction/impl/PropagationManager.java | PropagationManager.getActiveTransaction | private Transaction getActiveTransaction() throws SystemException {
Transaction tx = manager.getTransaction();
if (tx != null && tx.getStatus() != Status.STATUS_NO_TRANSACTION) {
return tx;
} else {
return null;
}
} | java | private Transaction getActiveTransaction() throws SystemException {
Transaction tx = manager.getTransaction();
if (tx != null && tx.getStatus() != Status.STATUS_NO_TRANSACTION) {
return tx;
} else {
return null;
}
} | [
"private",
"Transaction",
"getActiveTransaction",
"(",
")",
"throws",
"SystemException",
"{",
"Transaction",
"tx",
"=",
"manager",
".",
"getTransaction",
"(",
")",
";",
"if",
"(",
"tx",
"!=",
"null",
"&&",
"tx",
".",
"getStatus",
"(",
")",
"!=",
"Status",
... | Checks whether or not we have an active transaction. If so, returns it.
@return the activate transaction, {@code null} if none.
@throws SystemException thrown by the transaction manager to indicate that it has encountered an
unexpected error condition that prevents future transaction services from
proceeding. | [
"Checks",
"whether",
"or",
"not",
"we",
"have",
"an",
"active",
"transaction",
".",
"If",
"so",
"returns",
"it",
"."
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jpa-manager/src/main/java/org/wisdom/framework/transaction/impl/PropagationManager.java#L60-L67 | train |
wisdom-framework/wisdom-jdbc | wisdom-jpa-manager/src/main/java/org/wisdom/framework/transaction/impl/PropagationManager.java | PropagationManager.onEntry | public void onEntry(Propagation propagation, int timeout, String interceptionId) throws SystemException,
NotSupportedException, RollbackException {
Transaction transaction = getActiveTransaction();
switch (propagation) {
case REQUIRES:
// Are we already in a transaction?
if (transaction == null) {
// No, create one
if (timeout > 0) {
manager.setTransactionTimeout(timeout);
}
manager.begin();
Transaction tx = getActiveTransaction();
tx.registerSynchronization(this);
owned.add(tx);
} else {
// Add the transaction to the transaction list
transactions.add(transaction);
}
break;
case MANDATORY:
if (transaction == null) {
// Error
throw new IllegalStateException("The " + interceptionId + " must be called inside a " +
"JTA transaction");
} else {
if (transactions.add(transaction)) {
transaction.registerSynchronization(this);
}
}
break;
case SUPPORTED:
// if transaction != null, register the callback, else do nothing
if (transaction != null) {
if (transactions.add(transaction)) {
transaction.registerSynchronization(this);
}
}
// Else do nothing.
break;
case NOT_SUPPORTED:
if (transaction != null) {
// Suspend the current transaction.
suspended.put(Thread.currentThread(), transaction);
manager.suspend();
}
break;
case NEVER:
if (transaction != null) {
throw new IllegalStateException("The " + interceptionId + " must never be called inside a transaction");
}
break;
case REQUIRES_NEW:
if (transaction == null) {
// No current transaction, Just creates a new one
if (timeout > 0) {
manager.setTransactionTimeout(timeout);
}
manager.begin();
Transaction tx = getActiveTransaction();
owned.add(tx);
} else {
// suspend the current transaction
suspended.put(Thread.currentThread(), manager.suspend());
if (timeout > 0) {
manager.setTransactionTimeout(timeout);
}
manager.begin();
owned.add(manager.getTransaction());
}
break;
default:
throw new UnsupportedOperationException("Unknown or unsupported propagation policy for " + interceptionId + " :" +
propagation);
}
} | java | public void onEntry(Propagation propagation, int timeout, String interceptionId) throws SystemException,
NotSupportedException, RollbackException {
Transaction transaction = getActiveTransaction();
switch (propagation) {
case REQUIRES:
// Are we already in a transaction?
if (transaction == null) {
// No, create one
if (timeout > 0) {
manager.setTransactionTimeout(timeout);
}
manager.begin();
Transaction tx = getActiveTransaction();
tx.registerSynchronization(this);
owned.add(tx);
} else {
// Add the transaction to the transaction list
transactions.add(transaction);
}
break;
case MANDATORY:
if (transaction == null) {
// Error
throw new IllegalStateException("The " + interceptionId + " must be called inside a " +
"JTA transaction");
} else {
if (transactions.add(transaction)) {
transaction.registerSynchronization(this);
}
}
break;
case SUPPORTED:
// if transaction != null, register the callback, else do nothing
if (transaction != null) {
if (transactions.add(transaction)) {
transaction.registerSynchronization(this);
}
}
// Else do nothing.
break;
case NOT_SUPPORTED:
if (transaction != null) {
// Suspend the current transaction.
suspended.put(Thread.currentThread(), transaction);
manager.suspend();
}
break;
case NEVER:
if (transaction != null) {
throw new IllegalStateException("The " + interceptionId + " must never be called inside a transaction");
}
break;
case REQUIRES_NEW:
if (transaction == null) {
// No current transaction, Just creates a new one
if (timeout > 0) {
manager.setTransactionTimeout(timeout);
}
manager.begin();
Transaction tx = getActiveTransaction();
owned.add(tx);
} else {
// suspend the current transaction
suspended.put(Thread.currentThread(), manager.suspend());
if (timeout > 0) {
manager.setTransactionTimeout(timeout);
}
manager.begin();
owned.add(manager.getTransaction());
}
break;
default:
throw new UnsupportedOperationException("Unknown or unsupported propagation policy for " + interceptionId + " :" +
propagation);
}
} | [
"public",
"void",
"onEntry",
"(",
"Propagation",
"propagation",
",",
"int",
"timeout",
",",
"String",
"interceptionId",
")",
"throws",
"SystemException",
",",
"NotSupportedException",
",",
"RollbackException",
"{",
"Transaction",
"transaction",
"=",
"getActiveTransactio... | Enters a transactional bloc.
@param propagation the propagation strategy
@param timeout the transaction timeout
@param interceptionId an identifier for the interception, used for logging.
@throws SystemException thrown by the transaction manager to indicate that it has encountered an
unexpected error condition that prevents future transaction services from
proceeding.
@throws NotSupportedException indicates that the request cannot be executed because the operation is not a
supported feature.
@throws RollbackException thrown when the transaction has been marked for rollback only or the transaction
has been rolled back instead of committed. | [
"Enters",
"a",
"transactional",
"bloc",
"."
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jpa-manager/src/main/java/org/wisdom/framework/transaction/impl/PropagationManager.java#L83-L161 | train |
wisdom-framework/wisdom-jdbc | wisdom-jpa-manager/src/main/java/org/wisdom/framework/transaction/impl/PropagationManager.java | PropagationManager.onExit | public void onExit(Propagation propagation, String interceptionId,
TransactionCallback callback) throws HeuristicRollbackException, HeuristicMixedException, SystemException,
InvalidTransactionException {
Transaction current = getActiveTransaction();
if (callback == null) {
callback = new TransactionCallback() {
@Override
public void transactionCommitted(Transaction transaction) {
// Do nothing
}
@Override
public void transactionRolledBack(Transaction transaction) {
// Do nothing
}
};
}
switch (propagation) {
case REQUIRES:
// Are we the owner of the transaction?
if (owned.contains(current)) { // Owner.
try {
current.commit(); // Commit the transaction
owned.remove(current);
callback.transactionCommitted(current);
} catch (RollbackException e) {
owned.remove(current);
e.printStackTrace();
callback.transactionRolledBack(current);
}
} // Else wait for commit.
break;
case MANDATORY:
// We are never the owner, so just exits the transaction.
break;
case SUPPORTED:
// Do nothing.
break;
case NOT_SUPPORTED:
// We may have suspended a transaction if one, resume it
// If we have another transaction and we have suspended a transaction,
// throw an IllegalStateException because it's impossible to resume
// the suspended transaction. If we didn't suspend a transaction, accept the new transaction (user
// responsibility)
List<Transaction> susp = suspended.get(Thread.currentThread());
if (current != null && !susp.isEmpty()) {
throw new IllegalStateException("Error while handling " + interceptionId + " : you cannot start a" +
" transaction after having suspended one. We would not be able to resume the suspended " +
"transaction");
} else if (current == null && !susp.isEmpty()) {
manager.resume(susp.remove(susp.size() - 1));
}
break;
case NEVER:
// Do nothing.
break;
case REQUIRES_NEW:
// We're necessary the owner.
try {
current.commit(); // Commit the transaction
owned.remove(current);
callback.transactionCommitted(current);
List<Transaction> suspendedTransactions = suspended.get(Thread.currentThread());
if (suspendedTransactions != null && !suspendedTransactions.isEmpty()) {
// suspend the completed transaction.
Transaction trans = suspendedTransactions.get(suspendedTransactions.size() - 1);
manager.suspend();
suspendedTransactions.remove(trans);
manager.resume(trans);
}
} catch (RollbackException e) { // The transaction was rolledback rather than committed
owned.remove(current);
callback.transactionRolledBack(current);
List<Transaction> suspendedTransactions = suspended.get(Thread.currentThread());
if (suspendedTransactions != null && !suspendedTransactions.isEmpty()) {
// suspend the transaction.
Transaction trans = suspendedTransactions.get(suspendedTransactions.size() - 1);
manager.suspend();
suspendedTransactions.remove(trans);
manager.resume(trans);
}
}
break;
default:
throw new UnsupportedOperationException("Unknown or unsupported propagation policy for " + interceptionId + " :" +
propagation);
}
} | java | public void onExit(Propagation propagation, String interceptionId,
TransactionCallback callback) throws HeuristicRollbackException, HeuristicMixedException, SystemException,
InvalidTransactionException {
Transaction current = getActiveTransaction();
if (callback == null) {
callback = new TransactionCallback() {
@Override
public void transactionCommitted(Transaction transaction) {
// Do nothing
}
@Override
public void transactionRolledBack(Transaction transaction) {
// Do nothing
}
};
}
switch (propagation) {
case REQUIRES:
// Are we the owner of the transaction?
if (owned.contains(current)) { // Owner.
try {
current.commit(); // Commit the transaction
owned.remove(current);
callback.transactionCommitted(current);
} catch (RollbackException e) {
owned.remove(current);
e.printStackTrace();
callback.transactionRolledBack(current);
}
} // Else wait for commit.
break;
case MANDATORY:
// We are never the owner, so just exits the transaction.
break;
case SUPPORTED:
// Do nothing.
break;
case NOT_SUPPORTED:
// We may have suspended a transaction if one, resume it
// If we have another transaction and we have suspended a transaction,
// throw an IllegalStateException because it's impossible to resume
// the suspended transaction. If we didn't suspend a transaction, accept the new transaction (user
// responsibility)
List<Transaction> susp = suspended.get(Thread.currentThread());
if (current != null && !susp.isEmpty()) {
throw new IllegalStateException("Error while handling " + interceptionId + " : you cannot start a" +
" transaction after having suspended one. We would not be able to resume the suspended " +
"transaction");
} else if (current == null && !susp.isEmpty()) {
manager.resume(susp.remove(susp.size() - 1));
}
break;
case NEVER:
// Do nothing.
break;
case REQUIRES_NEW:
// We're necessary the owner.
try {
current.commit(); // Commit the transaction
owned.remove(current);
callback.transactionCommitted(current);
List<Transaction> suspendedTransactions = suspended.get(Thread.currentThread());
if (suspendedTransactions != null && !suspendedTransactions.isEmpty()) {
// suspend the completed transaction.
Transaction trans = suspendedTransactions.get(suspendedTransactions.size() - 1);
manager.suspend();
suspendedTransactions.remove(trans);
manager.resume(trans);
}
} catch (RollbackException e) { // The transaction was rolledback rather than committed
owned.remove(current);
callback.transactionRolledBack(current);
List<Transaction> suspendedTransactions = suspended.get(Thread.currentThread());
if (suspendedTransactions != null && !suspendedTransactions.isEmpty()) {
// suspend the transaction.
Transaction trans = suspendedTransactions.get(suspendedTransactions.size() - 1);
manager.suspend();
suspendedTransactions.remove(trans);
manager.resume(trans);
}
}
break;
default:
throw new UnsupportedOperationException("Unknown or unsupported propagation policy for " + interceptionId + " :" +
propagation);
}
} | [
"public",
"void",
"onExit",
"(",
"Propagation",
"propagation",
",",
"String",
"interceptionId",
",",
"TransactionCallback",
"callback",
")",
"throws",
"HeuristicRollbackException",
",",
"HeuristicMixedException",
",",
"SystemException",
",",
"InvalidTransactionException",
"... | Leaves a transactional bloc. This method decides what do to with the current transaction. This includes
committing or resuming a transaction.
@param propagation the propagation strategy
@param interceptionId an identifier for the interception, used for logging.
@param callback the transaction callback
@throws HeuristicRollbackException thrown by the commit operation to report that a heuristic decision was
made and that all relevant updates have been rolled back.
@throws HeuristicMixedException report that a heuristic decision was made and that some relevant updates have
been committed and others have been rolled back
@throws SystemException thrown by the transaction manager to indicate that it has encountered an
unexpected error condition that prevents future transaction services from
proceeding.
@throws InvalidTransactionException the current transaction is invalid | [
"Leaves",
"a",
"transactional",
"bloc",
".",
"This",
"method",
"decides",
"what",
"do",
"to",
"with",
"the",
"current",
"transaction",
".",
"This",
"includes",
"committing",
"or",
"resuming",
"a",
"transaction",
"."
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jpa-manager/src/main/java/org/wisdom/framework/transaction/impl/PropagationManager.java#L179-L269 | train |
wisdom-framework/wisdom-jdbc | wisdom-jpa-manager/src/main/java/org/wisdom/framework/transaction/impl/PropagationManager.java | PropagationManager.onError | public void onError(Exception e, Propagation propagation, Class<? extends Exception>[] noRollbackFor,
Class<? extends Exception>[] rollbackFor, String interceptionId, TransactionCallback callback) throws SystemException, HeuristicRollbackException, HeuristicMixedException, InvalidTransactionException {
Transaction current = getActiveTransaction();
if (current != null) {
// We have a transaction.
// Check whether or not the transaction needs to be marked as rollback only.
if (!Arrays.asList(noRollbackFor).contains(e.getClass())) {
if (Arrays.asList(rollbackFor).contains(e.getClass()) || rollbackFor.length == 0) {
current.setRollbackOnly();
}
}
onExit(propagation, interceptionId, callback);
}
} | java | public void onError(Exception e, Propagation propagation, Class<? extends Exception>[] noRollbackFor,
Class<? extends Exception>[] rollbackFor, String interceptionId, TransactionCallback callback) throws SystemException, HeuristicRollbackException, HeuristicMixedException, InvalidTransactionException {
Transaction current = getActiveTransaction();
if (current != null) {
// We have a transaction.
// Check whether or not the transaction needs to be marked as rollback only.
if (!Arrays.asList(noRollbackFor).contains(e.getClass())) {
if (Arrays.asList(rollbackFor).contains(e.getClass()) || rollbackFor.length == 0) {
current.setRollbackOnly();
}
}
onExit(propagation, interceptionId, callback);
}
} | [
"public",
"void",
"onError",
"(",
"Exception",
"e",
",",
"Propagation",
"propagation",
",",
"Class",
"<",
"?",
"extends",
"Exception",
">",
"[",
"]",
"noRollbackFor",
",",
"Class",
"<",
"?",
"extends",
"Exception",
">",
"[",
"]",
"rollbackFor",
",",
"Strin... | A transactional bloc has thrown an exception. This method decides what needs to be done in that case.
@param e the exception
@param propagation the propagation strategy
@param noRollbackFor the set of exceptions that does not make the current transaction to rollback
@param rollbackFor the set of exceptions that makes the current transaction to rollback
@param interceptionId an identifier for the interception, used for logging.
@param callback the transaction callback
@throws SystemException thrown by the transaction manager to indicate that it has encountered an
unexpected error condition that prevents future transaction services from
proceeding.
@throws HeuristicRollbackException thrown by the commit operation to report that a heuristic decision was made
and that all relevant updates have been rolled back.
@throws HeuristicMixedException thrown to report that a heuristic decision was made and that some relevant
updates have been committed and others have been rolled back.
@throws InvalidTransactionException the request carried an invalid transaction context. | [
"A",
"transactional",
"bloc",
"has",
"thrown",
"an",
"exception",
".",
"This",
"method",
"decides",
"what",
"needs",
"to",
"be",
"done",
"in",
"that",
"case",
"."
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jpa-manager/src/main/java/org/wisdom/framework/transaction/impl/PropagationManager.java#L307-L320 | train |
KayLerch/alexa-skills-kit-tellask-java | src/main/java/io/klerch/alexa/tellask/util/factory/AlexaSpeechletFactory.java | AlexaSpeechletFactory.createSpeechletFromRequest | public static <T extends AlexaSpeechlet> T createSpeechletFromRequest(final byte[] serializedSpeechletRequest, final Class<T> speechletClass, final UtteranceReader utteranceReader) throws IOException {
final ObjectMapper mapper = new ObjectMapper();
final JsonNode parser = mapper.readTree(serializedSpeechletRequest);
final String locale = Optional.of(parser.path("request"))
.filter(node -> !node.isMissingNode())
.map(node -> node.path("locale"))
.filter(node -> !node.isMissingNode())
.map(JsonNode::textValue)
.orElse(DEFAULT_LOCALE);
try {
return speechletClass.getConstructor(String.class, UtteranceReader.class)
.newInstance(locale, utteranceReader);
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
throw new IOException("Could not create Speechlet from speechlet request", e);
}
} | java | public static <T extends AlexaSpeechlet> T createSpeechletFromRequest(final byte[] serializedSpeechletRequest, final Class<T> speechletClass, final UtteranceReader utteranceReader) throws IOException {
final ObjectMapper mapper = new ObjectMapper();
final JsonNode parser = mapper.readTree(serializedSpeechletRequest);
final String locale = Optional.of(parser.path("request"))
.filter(node -> !node.isMissingNode())
.map(node -> node.path("locale"))
.filter(node -> !node.isMissingNode())
.map(JsonNode::textValue)
.orElse(DEFAULT_LOCALE);
try {
return speechletClass.getConstructor(String.class, UtteranceReader.class)
.newInstance(locale, utteranceReader);
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
throw new IOException("Could not create Speechlet from speechlet request", e);
}
} | [
"public",
"static",
"<",
"T",
"extends",
"AlexaSpeechlet",
">",
"T",
"createSpeechletFromRequest",
"(",
"final",
"byte",
"[",
"]",
"serializedSpeechletRequest",
",",
"final",
"Class",
"<",
"T",
">",
"speechletClass",
",",
"final",
"UtteranceReader",
"utteranceReader... | Creates an AlexaSpeechlet from bytes of a speechlet request. It will extract the
locale from the request and uses it for creating a new instance of AlexaSpeechlet
@param serializedSpeechletRequest bytes of a speechlet request
@param speechletClass the class of your AlexaSpeechlet to instantiate
@param utteranceReader the reader AlexaSpeechlet should use when reading out utterances
@param <T> must extend AlexaSpeechlet
@return new instance of AlexaSpeechlet
@throws IOException thrown when something went wrong | [
"Creates",
"an",
"AlexaSpeechlet",
"from",
"bytes",
"of",
"a",
"speechlet",
"request",
".",
"It",
"will",
"extract",
"the",
"locale",
"from",
"the",
"request",
"and",
"uses",
"it",
"for",
"creating",
"a",
"new",
"instance",
"of",
"AlexaSpeechlet"
] | 2c19028e775c2512dd4649d12962c0b48bf7f2bc | https://github.com/KayLerch/alexa-skills-kit-tellask-java/blob/2c19028e775c2512dd4649d12962c0b48bf7f2bc/src/main/java/io/klerch/alexa/tellask/util/factory/AlexaSpeechletFactory.java#L37-L54 | train |
nmdp-bioinformatics/genotype-list | gl-client/src/main/java/org/nmdp/gl/client/GlstringBuilder.java | GlstringBuilder.build | public String build() {
if (locus == null && tree.isEmpty()) {
throw new IllegalStateException("must call locus(String) or allele(String) at least once");
}
if (tree.isEmpty()) {
return locus;
}
String glstring = tree.toString();
char last = glstring.charAt(glstring.length() - 1);
if (operators.matches(last)) {
throw new IllegalStateException("last element of a glstring must not be an operator, was " + last);
}
return glstring;
} | java | public String build() {
if (locus == null && tree.isEmpty()) {
throw new IllegalStateException("must call locus(String) or allele(String) at least once");
}
if (tree.isEmpty()) {
return locus;
}
String glstring = tree.toString();
char last = glstring.charAt(glstring.length() - 1);
if (operators.matches(last)) {
throw new IllegalStateException("last element of a glstring must not be an operator, was " + last);
}
return glstring;
} | [
"public",
"String",
"build",
"(",
")",
"{",
"if",
"(",
"locus",
"==",
"null",
"&&",
"tree",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"must call locus(String) or allele(String) at least once\"",
")",
";",
"}",
"if",
"(... | Build and return a new GL String configured from the properties of this GL String builder.
@return a new GL String configured from the properties of this GL String builder
@throws IllegalStateException if {@link #locus(String)} or {@link #allele(String)} has not been called at least once
@throws IllegalStateException if the last call was an operator ({@link #allelicAmbiguity()}, {@link #inPhase()},
{@link #plus()}, {@link #genotypicAmbiguity()}, and {@link #locus(String)}) | [
"Build",
"and",
"return",
"a",
"new",
"GL",
"String",
"configured",
"from",
"the",
"properties",
"of",
"this",
"GL",
"String",
"builder",
"."
] | 03b2579552cb9f680a62ffaaecdca9c2a5d12ee4 | https://github.com/nmdp-bioinformatics/genotype-list/blob/03b2579552cb9f680a62ffaaecdca9c2a5d12ee4/gl-client/src/main/java/org/nmdp/gl/client/GlstringBuilder.java#L222-L235 | train |
dimaki/refuel | src/main/java/de/dimaki/refuel/appcast/boundary/AppcastManager.java | AppcastManager.download | public Path download(Appcast appcast, Path targetDir) throws IOException, Exception {
Path downloaded = null;
Enclosure enclosure = appcast.getLatestEnclosure();
if (enclosure != null) {
String url = enclosure.getUrl();
if (url != null && !url.isEmpty()) {
URL enclosureUrl = new URL(url);
String targetName = url.substring( url.lastIndexOf('/')+1, url.length() );
long length = enclosure.getLength();
File tmpFile = null;
ReadableByteChannel rbc = null;
FileOutputStream fos = null;
try {
tmpFile = File.createTempFile("ac-", ".part");
rbc = Channels.newChannel(enclosureUrl.openStream());
fos = new FileOutputStream(tmpFile);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
// Verify if file is ok
// Check size
if (length > 0) {
long size = Files.size(tmpFile.toPath());
if (length != size) {
throw new Exception("Downloaded file has wrong size! Expected: " + length + " -- Actual: " + size);
}
}
// Check MD5/DSA Signature
String md5 = enclosure.getMd5();
if (md5 != null) {
MessageDigest md = MessageDigest.getInstance("MD5");
md.reset();
byte[] bytes = new byte[2048];
int numBytes;
try (FileInputStream is = new FileInputStream(tmpFile)) {
while ((numBytes = is.read(bytes)) != -1) {
md.update(bytes, 0, numBytes);
}
}
String hash = toHex(md.digest());
if (!md5.equalsIgnoreCase(hash)) {
throw new Exception("Downloaded file has wrong MD5 hash! Expected: " + md5 + " -- Actual: " + hash);
}
}
// Copy file to target dir
downloaded = Files.copy(tmpFile.toPath(), targetDir.resolve(targetName), StandardCopyOption.REPLACE_EXISTING);
} finally {
try { if (fos != null) fos.close(); } catch (IOException e) { /* ignore */ }
try { if (rbc != null) rbc.close(); } catch (IOException e) { /* ignore */ }
if (tmpFile != null) {
Files.deleteIfExists(tmpFile.toPath());
}
}
}
}
return downloaded;
} | java | public Path download(Appcast appcast, Path targetDir) throws IOException, Exception {
Path downloaded = null;
Enclosure enclosure = appcast.getLatestEnclosure();
if (enclosure != null) {
String url = enclosure.getUrl();
if (url != null && !url.isEmpty()) {
URL enclosureUrl = new URL(url);
String targetName = url.substring( url.lastIndexOf('/')+1, url.length() );
long length = enclosure.getLength();
File tmpFile = null;
ReadableByteChannel rbc = null;
FileOutputStream fos = null;
try {
tmpFile = File.createTempFile("ac-", ".part");
rbc = Channels.newChannel(enclosureUrl.openStream());
fos = new FileOutputStream(tmpFile);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
// Verify if file is ok
// Check size
if (length > 0) {
long size = Files.size(tmpFile.toPath());
if (length != size) {
throw new Exception("Downloaded file has wrong size! Expected: " + length + " -- Actual: " + size);
}
}
// Check MD5/DSA Signature
String md5 = enclosure.getMd5();
if (md5 != null) {
MessageDigest md = MessageDigest.getInstance("MD5");
md.reset();
byte[] bytes = new byte[2048];
int numBytes;
try (FileInputStream is = new FileInputStream(tmpFile)) {
while ((numBytes = is.read(bytes)) != -1) {
md.update(bytes, 0, numBytes);
}
}
String hash = toHex(md.digest());
if (!md5.equalsIgnoreCase(hash)) {
throw new Exception("Downloaded file has wrong MD5 hash! Expected: " + md5 + " -- Actual: " + hash);
}
}
// Copy file to target dir
downloaded = Files.copy(tmpFile.toPath(), targetDir.resolve(targetName), StandardCopyOption.REPLACE_EXISTING);
} finally {
try { if (fos != null) fos.close(); } catch (IOException e) { /* ignore */ }
try { if (rbc != null) rbc.close(); } catch (IOException e) { /* ignore */ }
if (tmpFile != null) {
Files.deleteIfExists(tmpFile.toPath());
}
}
}
}
return downloaded;
} | [
"public",
"Path",
"download",
"(",
"Appcast",
"appcast",
",",
"Path",
"targetDir",
")",
"throws",
"IOException",
",",
"Exception",
"{",
"Path",
"downloaded",
"=",
"null",
";",
"Enclosure",
"enclosure",
"=",
"appcast",
".",
"getLatestEnclosure",
"(",
")",
";",
... | Download the file from the given URL to the specified target
@param appcast The appcast content
@param targetDir The target download dir (update directory)
@return Path to the downloaded update file
@throws IOException in case of an error | [
"Download",
"the",
"file",
"from",
"the",
"given",
"URL",
"to",
"the",
"specified",
"target"
] | 8024ac34f52b33de291d859c3b12fc237783f873 | https://github.com/dimaki/refuel/blob/8024ac34f52b33de291d859c3b12fc237783f873/src/main/java/de/dimaki/refuel/appcast/boundary/AppcastManager.java#L197-L256 | train |
KayLerch/alexa-skills-kit-tellask-java | src/main/java/io/klerch/alexa/tellask/util/resource/YamlReader.java | YamlReader.flatten | private Stream<Object> flatten(final Object o) {
if (o instanceof Map<?, ?>) {
return ((Map<?, ?>) o).values().stream().flatMap(this::flatten);
}
return Stream.of(o);
} | java | private Stream<Object> flatten(final Object o) {
if (o instanceof Map<?, ?>) {
return ((Map<?, ?>) o).values().stream().flatMap(this::flatten);
}
return Stream.of(o);
} | [
"private",
"Stream",
"<",
"Object",
">",
"flatten",
"(",
"final",
"Object",
"o",
")",
"{",
"if",
"(",
"o",
"instanceof",
"Map",
"<",
"?",
",",
"?",
">",
")",
"{",
"return",
"(",
"(",
"Map",
"<",
"?",
",",
"?",
">",
")",
"o",
")",
".",
"values... | Recursively go along yaml nodes beneath the given one to flatten string values
@param o YAML node point of start
@return flattened values beneath given YAML node | [
"Recursively",
"go",
"along",
"yaml",
"nodes",
"beneath",
"the",
"given",
"one",
"to",
"flatten",
"string",
"values"
] | 2c19028e775c2512dd4649d12962c0b48bf7f2bc | https://github.com/KayLerch/alexa-skills-kit-tellask-java/blob/2c19028e775c2512dd4649d12962c0b48bf7f2bc/src/main/java/io/klerch/alexa/tellask/util/resource/YamlReader.java#L136-L141 | train |
wisdom-framework/wisdom-jdbc | wisdom-openjpa-enhancer-plugin/src/main/java/org/wisdom/openjpa/enhancer/OpenJPAEnhancerMojo.java | OpenJPAEnhancerMojo.findEntityClassFiles | protected List<File> findEntityClassFiles() throws MojoExecutionException {
try {
return FileUtils.getFiles(classes, includes, excludes);
} catch (IOException e) {
throw new MojoExecutionException("Error while scanning for '" + includes + "' in " + "'"
+ classes.getAbsolutePath() + "'.", e);
}
} | java | protected List<File> findEntityClassFiles() throws MojoExecutionException {
try {
return FileUtils.getFiles(classes, includes, excludes);
} catch (IOException e) {
throw new MojoExecutionException("Error while scanning for '" + includes + "' in " + "'"
+ classes.getAbsolutePath() + "'.", e);
}
} | [
"protected",
"List",
"<",
"File",
">",
"findEntityClassFiles",
"(",
")",
"throws",
"MojoExecutionException",
"{",
"try",
"{",
"return",
"FileUtils",
".",
"getFiles",
"(",
"classes",
",",
"includes",
",",
"excludes",
")",
";",
"}",
"catch",
"(",
"IOException",
... | Locates and returns a list of class files found under specified class
directory.
@return list of class files.
@throws MojoExecutionException if there was an error scanning class file
resources. | [
"Locates",
"and",
"returns",
"a",
"list",
"of",
"class",
"files",
"found",
"under",
"specified",
"class",
"directory",
"."
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-openjpa-enhancer-plugin/src/main/java/org/wisdom/openjpa/enhancer/OpenJPAEnhancerMojo.java#L351-L358 | train |
wisdom-framework/wisdom-jdbc | wisdom-openjpa-enhancer-plugin/src/main/java/org/wisdom/openjpa/enhancer/OpenJPAEnhancerMojo.java | OpenJPAEnhancerMojo.getOptions | protected Options getOptions() throws MojoExecutionException {
File persistence = ensurePersistenceXml();
Options opts = new Options();
if (toolProperties != null) {
opts.putAll(toolProperties);
}
opts.put(OPTION_PROPERTIES_FILE, persistence.getAbsolutePath());
if (connectionDriverName != null) {
opts.put(OPTION_CONNECTION_DRIVER_NAME, connectionDriverName);
}
if (connectionProperties != null) {
opts.put(OPTION_CONNECTION_PROPERTIES, connectionProperties);
}
// put the standard options into the list also
opts.put(OPTION_ADD_DEFAULT_CONSTRUCTOR, Boolean.toString(addDefaultConstructor));
opts.put(OPTION_ENFORCE_PROPERTY_RESTRICTION, Boolean.toString(enforcePropertyRestrictions));
opts.put(OPTION_USE_TEMP_CLASSLOADER, Boolean.toString(tmpClassLoader));
return opts;
} | java | protected Options getOptions() throws MojoExecutionException {
File persistence = ensurePersistenceXml();
Options opts = new Options();
if (toolProperties != null) {
opts.putAll(toolProperties);
}
opts.put(OPTION_PROPERTIES_FILE, persistence.getAbsolutePath());
if (connectionDriverName != null) {
opts.put(OPTION_CONNECTION_DRIVER_NAME, connectionDriverName);
}
if (connectionProperties != null) {
opts.put(OPTION_CONNECTION_PROPERTIES, connectionProperties);
}
// put the standard options into the list also
opts.put(OPTION_ADD_DEFAULT_CONSTRUCTOR, Boolean.toString(addDefaultConstructor));
opts.put(OPTION_ENFORCE_PROPERTY_RESTRICTION, Boolean.toString(enforcePropertyRestrictions));
opts.put(OPTION_USE_TEMP_CLASSLOADER, Boolean.toString(tmpClassLoader));
return opts;
} | [
"protected",
"Options",
"getOptions",
"(",
")",
"throws",
"MojoExecutionException",
"{",
"File",
"persistence",
"=",
"ensurePersistenceXml",
"(",
")",
";",
"Options",
"opts",
"=",
"new",
"Options",
"(",
")",
";",
"if",
"(",
"toolProperties",
"!=",
"null",
")",... | Get the options for the OpenJPA enhancer tool.
@return populated Options | [
"Get",
"the",
"options",
"for",
"the",
"OpenJPA",
"enhancer",
"tool",
"."
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-openjpa-enhancer-plugin/src/main/java/org/wisdom/openjpa/enhancer/OpenJPAEnhancerMojo.java#L380-L403 | train |
wisdom-framework/wisdom-jdbc | wisdom-openjpa-enhancer-plugin/src/main/java/org/wisdom/openjpa/enhancer/OpenJPAEnhancerMojo.java | OpenJPAEnhancerMojo.enhance | private void enhance(List<File> files) throws MojoExecutionException {
Options opts = getOptions();
// list of input files
String[] args = getFilePaths(files);
boolean ok;
final ClassLoader original = Thread.currentThread().getContextClassLoader();
try {
if (!tmpClassLoader) {
extendRealmClasspath();
}
ok = PCEnhancer.run(args, opts);
} finally {
// We may have change the TCCL, restore the original one
Thread.currentThread().setContextClassLoader(original);
}
if (!ok) {
throw new MojoExecutionException("The OpenJPA Enhancer tool detected an error, check log");
}
} | java | private void enhance(List<File> files) throws MojoExecutionException {
Options opts = getOptions();
// list of input files
String[] args = getFilePaths(files);
boolean ok;
final ClassLoader original = Thread.currentThread().getContextClassLoader();
try {
if (!tmpClassLoader) {
extendRealmClasspath();
}
ok = PCEnhancer.run(args, opts);
} finally {
// We may have change the TCCL, restore the original one
Thread.currentThread().setContextClassLoader(original);
}
if (!ok) {
throw new MojoExecutionException("The OpenJPA Enhancer tool detected an error, check log");
}
} | [
"private",
"void",
"enhance",
"(",
"List",
"<",
"File",
">",
"files",
")",
"throws",
"MojoExecutionException",
"{",
"Options",
"opts",
"=",
"getOptions",
"(",
")",
";",
"// list of input files",
"String",
"[",
"]",
"args",
"=",
"getFilePaths",
"(",
"files",
... | Processes a list of class file resources that are to be enhanced.
@param files class file resources to enhance.
@throws MojoExecutionException if the enhancer encountered a failure | [
"Processes",
"a",
"list",
"of",
"class",
"file",
"resources",
"that",
"are",
"to",
"be",
"enhanced",
"."
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-openjpa-enhancer-plugin/src/main/java/org/wisdom/openjpa/enhancer/OpenJPAEnhancerMojo.java#L411-L434 | train |
viltgroup/minium | minium-webelements/src/main/java/minium/web/internal/actions/DefaultOnUnhandledAlertInteractionListener.java | DefaultOnUnhandledAlertInteractionListener.handleAlert | protected void handleAlert(Alert alert) {
if (LOGGEER.isDebugEnabled()) {
LOGGEER.debug("Accepting alert box with message: {}", alert.getText());
}
alert.accept();
} | java | protected void handleAlert(Alert alert) {
if (LOGGEER.isDebugEnabled()) {
LOGGEER.debug("Accepting alert box with message: {}", alert.getText());
}
alert.accept();
} | [
"protected",
"void",
"handleAlert",
"(",
"Alert",
"alert",
")",
"{",
"if",
"(",
"LOGGEER",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOGGEER",
".",
"debug",
"(",
"\"Accepting alert box with message: {}\"",
",",
"alert",
".",
"getText",
"(",
")",
")",
";",
... | by default, we accept the alert | [
"by",
"default",
"we",
"accept",
"the",
"alert"
] | f512fdd966ed4034d3ed53518eae7ad993562ab1 | https://github.com/viltgroup/minium/blob/f512fdd966ed4034d3ed53518eae7ad993562ab1/minium-webelements/src/main/java/minium/web/internal/actions/DefaultOnUnhandledAlertInteractionListener.java#L50-L55 | train |
dimaki/refuel | src/main/java/de/dimaki/refuel/Bootstrap.java | Bootstrap.update | public static Path update(Path applicationFile, Path updateDir, boolean removeUpdateFiles) throws IOException {
Path newApplicationJar = null;
// Extract the application name from the application file
String applicationName = applicationFile.getFileName().toString();
// Strip the extension
applicationName = applicationName.substring(0, applicationName.lastIndexOf("."));
ArrayList<Path> updateFiles = new ArrayList<>();
try (DirectoryStream<Path> stream = Files.newDirectoryStream(updateDir, applicationName + "*.{jar,JAR,war,WAR,rar,RAR,ear,EAR}")) {
for (Path entry : stream) {
updateFiles.add(entry);
}
} catch (DirectoryIteratorException ex) {
// I/O error encounted during the iteration, the cause is an IOException
throw ex.getCause();
}
if (!updateFiles.isEmpty()) {
Path updateFile = updateFiles.get(0);
newApplicationJar = Files.copy(updateFile, applicationFile, StandardCopyOption.REPLACE_EXISTING);
if (removeUpdateFiles) {
Files.delete(updateFile);
}
}
return newApplicationJar;
} | java | public static Path update(Path applicationFile, Path updateDir, boolean removeUpdateFiles) throws IOException {
Path newApplicationJar = null;
// Extract the application name from the application file
String applicationName = applicationFile.getFileName().toString();
// Strip the extension
applicationName = applicationName.substring(0, applicationName.lastIndexOf("."));
ArrayList<Path> updateFiles = new ArrayList<>();
try (DirectoryStream<Path> stream = Files.newDirectoryStream(updateDir, applicationName + "*.{jar,JAR,war,WAR,rar,RAR,ear,EAR}")) {
for (Path entry : stream) {
updateFiles.add(entry);
}
} catch (DirectoryIteratorException ex) {
// I/O error encounted during the iteration, the cause is an IOException
throw ex.getCause();
}
if (!updateFiles.isEmpty()) {
Path updateFile = updateFiles.get(0);
newApplicationJar = Files.copy(updateFile, applicationFile, StandardCopyOption.REPLACE_EXISTING);
if (removeUpdateFiles) {
Files.delete(updateFile);
}
}
return newApplicationJar;
} | [
"public",
"static",
"Path",
"update",
"(",
"Path",
"applicationFile",
",",
"Path",
"updateDir",
",",
"boolean",
"removeUpdateFiles",
")",
"throws",
"IOException",
"{",
"Path",
"newApplicationJar",
"=",
"null",
";",
"// Extract the application name from the application fil... | Update the application file with the content from the update directory.
@param applicationFile The application file to be updated
@param updateDir The update directory holding the new file versions
@param removeUpdateFiles If true, the updated files are deleted from the update directory
@return The path to the newly updated application file, or null if there was no update performed
@throws IOException In case of an error | [
"Update",
"the",
"application",
"file",
"with",
"the",
"content",
"from",
"the",
"update",
"directory",
"."
] | 8024ac34f52b33de291d859c3b12fc237783f873 | https://github.com/dimaki/refuel/blob/8024ac34f52b33de291d859c3b12fc237783f873/src/main/java/de/dimaki/refuel/Bootstrap.java#L48-L74 | train |
viltgroup/minium | minium-webelements/src/main/java/minium/web/internal/actions/AbstractWebInteraction.java | AbstractWebInteraction.getFirstElement | protected WebElement getFirstElement(Elements elems) {
DocumentWebElement documentWebElement = Iterables.getFirst(elems.as(InternalWebElements.class).wrappedNativeElements(), null);
return documentWebElement == null ? null : documentWebElement.getWrappedWebElement();
} | java | protected WebElement getFirstElement(Elements elems) {
DocumentWebElement documentWebElement = Iterables.getFirst(elems.as(InternalWebElements.class).wrappedNativeElements(), null);
return documentWebElement == null ? null : documentWebElement.getWrappedWebElement();
} | [
"protected",
"WebElement",
"getFirstElement",
"(",
"Elements",
"elems",
")",
"{",
"DocumentWebElement",
"documentWebElement",
"=",
"Iterables",
".",
"getFirst",
"(",
"elems",
".",
"as",
"(",
"InternalWebElements",
".",
"class",
")",
".",
"wrappedNativeElements",
"("... | Gets the first element.
@param elems the elems
@return the first element | [
"Gets",
"the",
"first",
"element",
"."
] | f512fdd966ed4034d3ed53518eae7ad993562ab1 | https://github.com/viltgroup/minium/blob/f512fdd966ed4034d3ed53518eae7ad993562ab1/minium-webelements/src/main/java/minium/web/internal/actions/AbstractWebInteraction.java#L48-L51 | train |
wisdom-framework/wisdom-jdbc | wisdom-jpa-manager/src/main/java/org/wisdom/framework/jpa/crud/AbstractJTACrud.java | AbstractJTACrud.transaction | @Override
public <R> FluentTransaction<R>.Intermediate transaction(Callable<R> callable) {
return FluentTransaction.transaction(getTransactionManager()).with(callable);
} | java | @Override
public <R> FluentTransaction<R>.Intermediate transaction(Callable<R> callable) {
return FluentTransaction.transaction(getTransactionManager()).with(callable);
} | [
"@",
"Override",
"public",
"<",
"R",
">",
"FluentTransaction",
"<",
"R",
">",
".",
"Intermediate",
"transaction",
"(",
"Callable",
"<",
"R",
">",
"callable",
")",
"{",
"return",
"FluentTransaction",
".",
"transaction",
"(",
"getTransactionManager",
"(",
")",
... | Create a FluentTransaction, with the given transaction block.
@param <R> the return type of the transaction block
@param callable, The transaction block to be executed by the returned FluentTransaction
@return a new FluentTransaction with a transaction block already defined.
@throws java.lang.UnsupportedOperationException if transactions are not supported. | [
"Create",
"a",
"FluentTransaction",
"with",
"the",
"given",
"transaction",
"block",
"."
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jpa-manager/src/main/java/org/wisdom/framework/jpa/crud/AbstractJTACrud.java#L142-L145 | train |
wisdom-framework/wisdom-jdbc | wisdom-jpa-manager/src/main/java/org/wisdom/framework/jpa/crud/AbstractJTACrud.java | AbstractJTACrud.findOne | @Override
public T findOne(final I id) {
return inTransaction(new Callable<T>() {
@Override
public T call() throws Exception {
return entityManager.find(entity, id);
}
});
} | java | @Override
public T findOne(final I id) {
return inTransaction(new Callable<T>() {
@Override
public T call() throws Exception {
return entityManager.find(entity, id);
}
});
} | [
"@",
"Override",
"public",
"T",
"findOne",
"(",
"final",
"I",
"id",
")",
"{",
"return",
"inTransaction",
"(",
"new",
"Callable",
"<",
"T",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"T",
"call",
"(",
")",
"throws",
"Exception",
"{",
"return",
"en... | Retrieves an entity by its id.
@param id the id, must not be null
@return the entity instance, {@literal null} if there are no entities matching the given id. | [
"Retrieves",
"an",
"entity",
"by",
"its",
"id",
"."
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jpa-manager/src/main/java/org/wisdom/framework/jpa/crud/AbstractJTACrud.java#L199-L207 | train |
wisdom-framework/wisdom-jdbc | wisdom-jpa-manager/src/main/java/org/wisdom/framework/jpa/crud/AbstractJTACrud.java | AbstractJTACrud.findAll | @Override
public Iterable<T> findAll() {
return inTransaction(new Callable<Iterable<T>>() {
@Override
public Iterable<T> call() throws Exception {
CriteriaQuery<T> cq = entityManager.getCriteriaBuilder().createQuery(entity);
Root<T> pet = cq.from(entity);
cq.select(pet);
return entityManager.createQuery(cq).getResultList();
}
});
} | java | @Override
public Iterable<T> findAll() {
return inTransaction(new Callable<Iterable<T>>() {
@Override
public Iterable<T> call() throws Exception {
CriteriaQuery<T> cq = entityManager.getCriteriaBuilder().createQuery(entity);
Root<T> pet = cq.from(entity);
cq.select(pet);
return entityManager.createQuery(cq).getResultList();
}
});
} | [
"@",
"Override",
"public",
"Iterable",
"<",
"T",
">",
"findAll",
"(",
")",
"{",
"return",
"inTransaction",
"(",
"new",
"Callable",
"<",
"Iterable",
"<",
"T",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Iterable",
"<",
"T",
">",
"call",
"(",
... | Returns all instances of the entity.
@return the instances, empty if none. | [
"Returns",
"all",
"instances",
"of",
"the",
"entity",
"."
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jpa-manager/src/main/java/org/wisdom/framework/jpa/crud/AbstractJTACrud.java#L215-L226 | train |
wisdom-framework/wisdom-jdbc | wisdom-jpa-manager/src/main/java/org/wisdom/framework/jpa/crud/AbstractJTACrud.java | AbstractJTACrud.findOne | @Override
public T findOne(EntityFilter<T> filter) {
for (T object : findAll()) {
if (filter.accept(object)) {
return object;
}
}
return null;
} | java | @Override
public T findOne(EntityFilter<T> filter) {
for (T object : findAll()) {
if (filter.accept(object)) {
return object;
}
}
return null;
} | [
"@",
"Override",
"public",
"T",
"findOne",
"(",
"EntityFilter",
"<",
"T",
">",
"filter",
")",
"{",
"for",
"(",
"T",
"object",
":",
"findAll",
"(",
")",
")",
"{",
"if",
"(",
"filter",
".",
"accept",
"(",
"object",
")",
")",
"{",
"return",
"object",
... | Retrieves the entity matching the given filter. If several entities matches, the first is returned.
@param filter the filter
@return the first matching instance, {@literal null} if none | [
"Retrieves",
"the",
"entity",
"matching",
"the",
"given",
"filter",
".",
"If",
"several",
"entities",
"matches",
"the",
"first",
"is",
"returned",
"."
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jpa-manager/src/main/java/org/wisdom/framework/jpa/crud/AbstractJTACrud.java#L234-L242 | train |
wisdom-framework/wisdom-jdbc | wisdom-jpa-manager/src/main/java/org/wisdom/framework/jpa/crud/AbstractJTACrud.java | AbstractJTACrud.findAll | @Override
public Iterable<T> findAll(Iterable<I> ids) {
List<T> results = new ArrayList<>();
for (I id : ids) {
T t = findOne(id);
if (t != null) {
results.add(t);
}
}
return results;
} | java | @Override
public Iterable<T> findAll(Iterable<I> ids) {
List<T> results = new ArrayList<>();
for (I id : ids) {
T t = findOne(id);
if (t != null) {
results.add(t);
}
}
return results;
} | [
"@",
"Override",
"public",
"Iterable",
"<",
"T",
">",
"findAll",
"(",
"Iterable",
"<",
"I",
">",
"ids",
")",
"{",
"List",
"<",
"T",
">",
"results",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"I",
"id",
":",
"ids",
")",
"{",
"T",
... | Returns all instances of the type with the given IDs.
@param ids the ids.
@return the instances, empty if none. | [
"Returns",
"all",
"instances",
"of",
"the",
"type",
"with",
"the",
"given",
"IDs",
"."
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jpa-manager/src/main/java/org/wisdom/framework/jpa/crud/AbstractJTACrud.java#L250-L260 | train |
wisdom-framework/wisdom-jdbc | wisdom-jpa-manager/src/main/java/org/wisdom/framework/jpa/crud/AbstractJTACrud.java | AbstractJTACrud.findAll | @Override
public Iterable<T> findAll(EntityFilter<T> filter) {
List<T> results = new ArrayList<>();
for (T object : findAll()) {
if (filter.accept(object)) {
results.add(object);
}
}
return results;
} | java | @Override
public Iterable<T> findAll(EntityFilter<T> filter) {
List<T> results = new ArrayList<>();
for (T object : findAll()) {
if (filter.accept(object)) {
results.add(object);
}
}
return results;
} | [
"@",
"Override",
"public",
"Iterable",
"<",
"T",
">",
"findAll",
"(",
"EntityFilter",
"<",
"T",
">",
"filter",
")",
"{",
"List",
"<",
"T",
">",
"results",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"T",
"object",
":",
"findAll",
"(",... | Retrieves the entities matching the given filter.
Be aware that the implementation may load all stored entities in memory to retrieve the right set of entities.
@param filter the filter
@return the matching instances, empty if none. | [
"Retrieves",
"the",
"entities",
"matching",
"the",
"given",
"filter",
".",
"Be",
"aware",
"that",
"the",
"implementation",
"may",
"load",
"all",
"stored",
"entities",
"in",
"memory",
"to",
"retrieve",
"the",
"right",
"set",
"of",
"entities",
"."
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jpa-manager/src/main/java/org/wisdom/framework/jpa/crud/AbstractJTACrud.java#L269-L278 | train |
wisdom-framework/wisdom-jdbc | wisdom-jpa-manager/src/main/java/org/wisdom/framework/jpa/crud/AbstractJTACrud.java | AbstractJTACrud.delete | @Override
public T delete(final T t) {
return inTransaction(
new Callable<T>() {
@Override
public T call() throws Exception {
T attached = getAttached(t);
if (attached != null) {
entityManager.remove(attached);
}
return t;
}
}
);
} | java | @Override
public T delete(final T t) {
return inTransaction(
new Callable<T>() {
@Override
public T call() throws Exception {
T attached = getAttached(t);
if (attached != null) {
entityManager.remove(attached);
}
return t;
}
}
);
} | [
"@",
"Override",
"public",
"T",
"delete",
"(",
"final",
"T",
"t",
")",
"{",
"return",
"inTransaction",
"(",
"new",
"Callable",
"<",
"T",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"T",
"call",
"(",
")",
"throws",
"Exception",
"{",
"T",
"attached"... | Deletes the given entity instance. The instance is removed from the persistent layer.
@param t the instance
@return the entity instance, may be the same as the parameter t but can also be different | [
"Deletes",
"the",
"given",
"entity",
"instance",
".",
"The",
"instance",
"is",
"removed",
"from",
"the",
"persistent",
"layer",
"."
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jpa-manager/src/main/java/org/wisdom/framework/jpa/crud/AbstractJTACrud.java#L286-L300 | train |
wisdom-framework/wisdom-jdbc | wisdom-jpa-manager/src/main/java/org/wisdom/framework/jpa/crud/AbstractJTACrud.java | AbstractJTACrud.getAttached | @SuppressWarnings("unchecked")
private T getAttached(T object) {
if (entityManager.contains(object)) {
return object;
} else {
return findOne((I) entityManager.getEntityManagerFactory()
.getPersistenceUnitUtil().getIdentifier(object));
}
} | java | @SuppressWarnings("unchecked")
private T getAttached(T object) {
if (entityManager.contains(object)) {
return object;
} else {
return findOne((I) entityManager.getEntityManagerFactory()
.getPersistenceUnitUtil().getIdentifier(object));
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"T",
"getAttached",
"(",
"T",
"object",
")",
"{",
"if",
"(",
"entityManager",
".",
"contains",
"(",
"object",
")",
")",
"{",
"return",
"object",
";",
"}",
"else",
"{",
"return",
"findOne",
"(... | Gets the 'managed' version of the given entity instance.
@param object the entity
@return the managed version, it can be the given object is the instance is not detached. If we can't find the
'managed' version of the object, return {@code null}. | [
"Gets",
"the",
"managed",
"version",
"of",
"the",
"given",
"entity",
"instance",
"."
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jpa-manager/src/main/java/org/wisdom/framework/jpa/crud/AbstractJTACrud.java#L333-L341 | train |
wisdom-framework/wisdom-jdbc | wisdom-jpa-manager/src/main/java/org/wisdom/framework/jpa/crud/AbstractJTACrud.java | AbstractJTACrud.delete | @Override
public Iterable<T> delete(final Iterable<T> entities) {
return inTransaction(new Callable<Iterable<T>>() {
@Override
public Iterable<T> call() throws Exception {
for (T object : entities) {
T attached = getAttached(object);
if (attached != null) {
entityManager.remove(attached);
}
}
return entities;
}
});
} | java | @Override
public Iterable<T> delete(final Iterable<T> entities) {
return inTransaction(new Callable<Iterable<T>>() {
@Override
public Iterable<T> call() throws Exception {
for (T object : entities) {
T attached = getAttached(object);
if (attached != null) {
entityManager.remove(attached);
}
}
return entities;
}
});
} | [
"@",
"Override",
"public",
"Iterable",
"<",
"T",
">",
"delete",
"(",
"final",
"Iterable",
"<",
"T",
">",
"entities",
")",
"{",
"return",
"inTransaction",
"(",
"new",
"Callable",
"<",
"Iterable",
"<",
"T",
">",
">",
"(",
")",
"{",
"@",
"Override",
"pu... | Deletes the given entity instances. The instances are removed from the persistent layer.
@param entities the entities to remove from the persistent layer
@return the set of entity instances | [
"Deletes",
"the",
"given",
"entity",
"instances",
".",
"The",
"instances",
"are",
"removed",
"from",
"the",
"persistent",
"layer",
"."
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jpa-manager/src/main/java/org/wisdom/framework/jpa/crud/AbstractJTACrud.java#L349-L363 | train |
wisdom-framework/wisdom-jdbc | wisdom-jpa-manager/src/main/java/org/wisdom/framework/jpa/crud/AbstractJTACrud.java | AbstractJTACrud.save | @Override
public Iterable<T> save(final Iterable<T> entities) {
return inTransaction(new Callable<Iterable<T>>() {
@Override
public Iterable<T> call() throws Exception {
for (T object : entities) {
entityManager.persist(object);
}
return entities;
}
});
} | java | @Override
public Iterable<T> save(final Iterable<T> entities) {
return inTransaction(new Callable<Iterable<T>>() {
@Override
public Iterable<T> call() throws Exception {
for (T object : entities) {
entityManager.persist(object);
}
return entities;
}
});
} | [
"@",
"Override",
"public",
"Iterable",
"<",
"T",
">",
"save",
"(",
"final",
"Iterable",
"<",
"T",
">",
"entities",
")",
"{",
"return",
"inTransaction",
"(",
"new",
"Callable",
"<",
"Iterable",
"<",
"T",
">",
">",
"(",
")",
"{",
"@",
"Override",
"publ... | Saves all given entities. Use the returned instances for further operations as the operation might have
changed the entity instances completely.
@param entities the entities to save, must not contains {@literal null} values
@return the saved entities | [
"Saves",
"all",
"given",
"entities",
".",
"Use",
"the",
"returned",
"instances",
"for",
"further",
"operations",
"as",
"the",
"operation",
"might",
"have",
"changed",
"the",
"entity",
"instances",
"completely",
"."
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jpa-manager/src/main/java/org/wisdom/framework/jpa/crud/AbstractJTACrud.java#L420-L431 | train |
wisdom-framework/wisdom-jdbc | wisdom-jpa-manager/src/main/java/org/wisdom/framework/jpa/PersistentBundle.java | PersistentBundle.createUnitInstance | private ComponentInstance createUnitInstance(Persistence.PersistenceUnit unit) throws MissingHandlerException,
UnacceptableConfiguration, ConfigurationException {
LOGGER.info("Creating persistence unit instance for unit {}", unit.getName());
Dictionary<String, Object> configuration = new Hashtable<>();
configuration.put("bundle", this);
configuration.put("unit", unit);
Dictionary<String, String> filters = new Hashtable<>();
if (!Strings.isNullOrEmpty(unit.getJtaDataSource())) {
filters.put("jta-ds", createDataSourceFilter(unit.getJtaDataSource()));
filters.put("ds", createDataSourceFilter(unit.getJtaDataSource()));
}
if (! Strings.isNullOrEmpty(unit.getNonJtaDataSource())) {
filters.put("ds", createDataSourceFilter(unit.getNonJtaDataSource()));
if (filters.get("jta-ds") == null) {
filters.put("jta-ds", createDataSourceFilter(unit.getNonJtaDataSource()));
}
}
configuration.put("requires.filters", filters);
LOGGER.info("Creating persistence unit instance for unit {} : {}", unit.getName(), configuration);
return factory.createComponentInstance(configuration);
} | java | private ComponentInstance createUnitInstance(Persistence.PersistenceUnit unit) throws MissingHandlerException,
UnacceptableConfiguration, ConfigurationException {
LOGGER.info("Creating persistence unit instance for unit {}", unit.getName());
Dictionary<String, Object> configuration = new Hashtable<>();
configuration.put("bundle", this);
configuration.put("unit", unit);
Dictionary<String, String> filters = new Hashtable<>();
if (!Strings.isNullOrEmpty(unit.getJtaDataSource())) {
filters.put("jta-ds", createDataSourceFilter(unit.getJtaDataSource()));
filters.put("ds", createDataSourceFilter(unit.getJtaDataSource()));
}
if (! Strings.isNullOrEmpty(unit.getNonJtaDataSource())) {
filters.put("ds", createDataSourceFilter(unit.getNonJtaDataSource()));
if (filters.get("jta-ds") == null) {
filters.put("jta-ds", createDataSourceFilter(unit.getNonJtaDataSource()));
}
}
configuration.put("requires.filters", filters);
LOGGER.info("Creating persistence unit instance for unit {} : {}", unit.getName(), configuration);
return factory.createComponentInstance(configuration);
} | [
"private",
"ComponentInstance",
"createUnitInstance",
"(",
"Persistence",
".",
"PersistenceUnit",
"unit",
")",
"throws",
"MissingHandlerException",
",",
"UnacceptableConfiguration",
",",
"ConfigurationException",
"{",
"LOGGER",
".",
"info",
"(",
"\"Creating persistence unit i... | Creates the component instance for the given unit.
This function computes the filters to retrieve the data sources. If a data source is not set in inject a
filter that will never match.
@param unit the persistence unit
@return the created instance
@throws MissingHandlerException the instance cannot be created because of a missing handler
@throws UnacceptableConfiguration the configuration if invalid.
@throws ConfigurationException the configuration is rejected. | [
"Creates",
"the",
"component",
"instance",
"for",
"the",
"given",
"unit",
".",
"This",
"function",
"computes",
"the",
"filters",
"to",
"retrieve",
"the",
"data",
"sources",
".",
"If",
"a",
"data",
"source",
"is",
"not",
"set",
"in",
"inject",
"a",
"filter"... | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jpa-manager/src/main/java/org/wisdom/framework/jpa/PersistentBundle.java#L96-L116 | train |
KayLerch/alexa-skills-kit-tellask-java | src/main/java/io/klerch/alexa/tellask/model/AlexaInput.java | AlexaInput.hasSlot | public boolean hasSlot(final String slotName) {
return intentRequest != null && intentRequest.getIntent().getSlots().containsKey(slotName);
} | java | public boolean hasSlot(final String slotName) {
return intentRequest != null && intentRequest.getIntent().getSlots().containsKey(slotName);
} | [
"public",
"boolean",
"hasSlot",
"(",
"final",
"String",
"slotName",
")",
"{",
"return",
"intentRequest",
"!=",
"null",
"&&",
"intentRequest",
".",
"getIntent",
"(",
")",
".",
"getSlots",
"(",
")",
".",
"containsKey",
"(",
"slotName",
")",
";",
"}"
] | Checks if a slot is contained in the intent request. This is no guarantee that the slot
value is not null.
@param slotName name of the slot to look after
@return True, if the slot exists in the intent request | [
"Checks",
"if",
"a",
"slot",
"is",
"contained",
"in",
"the",
"intent",
"request",
".",
"This",
"is",
"no",
"guarantee",
"that",
"the",
"slot",
"value",
"is",
"not",
"null",
"."
] | 2c19028e775c2512dd4649d12962c0b48bf7f2bc | https://github.com/KayLerch/alexa-skills-kit-tellask-java/blob/2c19028e775c2512dd4649d12962c0b48bf7f2bc/src/main/java/io/klerch/alexa/tellask/model/AlexaInput.java#L113-L115 | train |
KayLerch/alexa-skills-kit-tellask-java | src/main/java/io/klerch/alexa/tellask/model/AlexaInput.java | AlexaInput.hasSlotIsEqual | public boolean hasSlotIsEqual(final String slotName, final String value) {
final String slotValue = getSlotValue(slotName);
return (slotValue != null && slotValue.equals(value)) ||
slotValue == value;
} | java | public boolean hasSlotIsEqual(final String slotName, final String value) {
final String slotValue = getSlotValue(slotName);
return (slotValue != null && slotValue.equals(value)) ||
slotValue == value;
} | [
"public",
"boolean",
"hasSlotIsEqual",
"(",
"final",
"String",
"slotName",
",",
"final",
"String",
"value",
")",
"{",
"final",
"String",
"slotValue",
"=",
"getSlotValue",
"(",
"slotName",
")",
";",
"return",
"(",
"slotValue",
"!=",
"null",
"&&",
"slotValue",
... | Checks if a slot is contained in the intent request and also got the value provided.
@param slotName name of the slot to look after
@param value the value
@return True, if slot with slotName has a value equal to the given value | [
"Checks",
"if",
"a",
"slot",
"is",
"contained",
"in",
"the",
"intent",
"request",
"and",
"also",
"got",
"the",
"value",
"provided",
"."
] | 2c19028e775c2512dd4649d12962c0b48bf7f2bc | https://github.com/KayLerch/alexa-skills-kit-tellask-java/blob/2c19028e775c2512dd4649d12962c0b48bf7f2bc/src/main/java/io/klerch/alexa/tellask/model/AlexaInput.java#L123-L127 | train |
KayLerch/alexa-skills-kit-tellask-java | src/main/java/io/klerch/alexa/tellask/model/AlexaInput.java | AlexaInput.hasSlotIsDoubleMetaphoneEqual | public boolean hasSlotIsDoubleMetaphoneEqual(final String slotName, final String value) {
final String slotValue = getSlotValue(slotName);
return hasSlotNotBlank(slotName) && value != null &&
new DoubleMetaphone().isDoubleMetaphoneEqual(slotValue, value);
} | java | public boolean hasSlotIsDoubleMetaphoneEqual(final String slotName, final String value) {
final String slotValue = getSlotValue(slotName);
return hasSlotNotBlank(slotName) && value != null &&
new DoubleMetaphone().isDoubleMetaphoneEqual(slotValue, value);
} | [
"public",
"boolean",
"hasSlotIsDoubleMetaphoneEqual",
"(",
"final",
"String",
"slotName",
",",
"final",
"String",
"value",
")",
"{",
"final",
"String",
"slotValue",
"=",
"getSlotValue",
"(",
"slotName",
")",
";",
"return",
"hasSlotNotBlank",
"(",
"slotName",
")",
... | Checks if a slot is contained in the intent request and has a value which is a
phonetic sibling of the string given to this method. Double metaphone algorithm
is optimized for English language and in this case is used to match slot value with
value given to this method.
@param slotName name of the slot to look after
@param value the value
@return True, if slot value and given value are phonetically equal with Double metaphone algorithm | [
"Checks",
"if",
"a",
"slot",
"is",
"contained",
"in",
"the",
"intent",
"request",
"and",
"has",
"a",
"value",
"which",
"is",
"a",
"phonetic",
"sibling",
"of",
"the",
"string",
"given",
"to",
"this",
"method",
".",
"Double",
"metaphone",
"algorithm",
"is",
... | 2c19028e775c2512dd4649d12962c0b48bf7f2bc | https://github.com/KayLerch/alexa-skills-kit-tellask-java/blob/2c19028e775c2512dd4649d12962c0b48bf7f2bc/src/main/java/io/klerch/alexa/tellask/model/AlexaInput.java#L138-L142 | train |
KayLerch/alexa-skills-kit-tellask-java | src/main/java/io/klerch/alexa/tellask/model/AlexaInput.java | AlexaInput.hasSlotIsCologneEqual | public boolean hasSlotIsCologneEqual(final String slotName, final String value) {
final String slotValue = getSlotValue(slotName);
return hasSlotNotBlank(slotName) && value != null &&
new ColognePhonetic().isEncodeEqual(slotValue, value);
} | java | public boolean hasSlotIsCologneEqual(final String slotName, final String value) {
final String slotValue = getSlotValue(slotName);
return hasSlotNotBlank(slotName) && value != null &&
new ColognePhonetic().isEncodeEqual(slotValue, value);
} | [
"public",
"boolean",
"hasSlotIsCologneEqual",
"(",
"final",
"String",
"slotName",
",",
"final",
"String",
"value",
")",
"{",
"final",
"String",
"slotValue",
"=",
"getSlotValue",
"(",
"slotName",
")",
";",
"return",
"hasSlotNotBlank",
"(",
"slotName",
")",
"&&",
... | Checks if a slot is contained in the intent request and has a value which is a
phonetic sibling of the string given to this method. Cologne phonetic algorithm
is optimized for German language and in this case is used to match slot value with
value given to this method.
@param slotName name of the slot to look after
@param value the value
@return True, if slot value and given value are phonetically equal with Cologne phonetic algorithm | [
"Checks",
"if",
"a",
"slot",
"is",
"contained",
"in",
"the",
"intent",
"request",
"and",
"has",
"a",
"value",
"which",
"is",
"a",
"phonetic",
"sibling",
"of",
"the",
"string",
"given",
"to",
"this",
"method",
".",
"Cologne",
"phonetic",
"algorithm",
"is",
... | 2c19028e775c2512dd4649d12962c0b48bf7f2bc | https://github.com/KayLerch/alexa-skills-kit-tellask-java/blob/2c19028e775c2512dd4649d12962c0b48bf7f2bc/src/main/java/io/klerch/alexa/tellask/model/AlexaInput.java#L153-L157 | train |
KayLerch/alexa-skills-kit-tellask-java | src/main/java/io/klerch/alexa/tellask/model/AlexaInput.java | AlexaInput.hasSlotIsPhoneticallyEqual | public boolean hasSlotIsPhoneticallyEqual(final String slotName, final String value) {
return getLocale().equals("de-DE") ? hasSlotIsCologneEqual(slotName, value) :
hasSlotIsDoubleMetaphoneEqual(slotName, value);
} | java | public boolean hasSlotIsPhoneticallyEqual(final String slotName, final String value) {
return getLocale().equals("de-DE") ? hasSlotIsCologneEqual(slotName, value) :
hasSlotIsDoubleMetaphoneEqual(slotName, value);
} | [
"public",
"boolean",
"hasSlotIsPhoneticallyEqual",
"(",
"final",
"String",
"slotName",
",",
"final",
"String",
"value",
")",
"{",
"return",
"getLocale",
"(",
")",
".",
"equals",
"(",
"\"de-DE\"",
")",
"?",
"hasSlotIsCologneEqual",
"(",
"slotName",
",",
"value",
... | Checks if a slot is contained in the intent request and has a value which is a
phonetic sibling of the string given to this method. This method picks the correct
algorithm depending on the locale coming in with the speechlet request. For example the
German locale compares the slot value and the given value with the Cologne phonetic
algorithm whereas english locales result in this method using the Double Metaphone algorithm.
@param slotName name of the slot to look after
@param value the value
@return True, if slot value and given value are phonetically equal | [
"Checks",
"if",
"a",
"slot",
"is",
"contained",
"in",
"the",
"intent",
"request",
"and",
"has",
"a",
"value",
"which",
"is",
"a",
"phonetic",
"sibling",
"of",
"the",
"string",
"given",
"to",
"this",
"method",
".",
"This",
"method",
"picks",
"the",
"corre... | 2c19028e775c2512dd4649d12962c0b48bf7f2bc | https://github.com/KayLerch/alexa-skills-kit-tellask-java/blob/2c19028e775c2512dd4649d12962c0b48bf7f2bc/src/main/java/io/klerch/alexa/tellask/model/AlexaInput.java#L169-L172 | train |
KayLerch/alexa-skills-kit-tellask-java | src/main/java/io/klerch/alexa/tellask/model/AlexaInput.java | AlexaInput.hasSlotNotBlank | public boolean hasSlotNotBlank(final String slotName) {
return hasSlot(slotName) && StringUtils.isNotBlank(intentRequest.getIntent().getSlot(slotName).getValue());
} | java | public boolean hasSlotNotBlank(final String slotName) {
return hasSlot(slotName) && StringUtils.isNotBlank(intentRequest.getIntent().getSlot(slotName).getValue());
} | [
"public",
"boolean",
"hasSlotNotBlank",
"(",
"final",
"String",
"slotName",
")",
"{",
"return",
"hasSlot",
"(",
"slotName",
")",
"&&",
"StringUtils",
".",
"isNotBlank",
"(",
"intentRequest",
".",
"getIntent",
"(",
")",
".",
"getSlot",
"(",
"slotName",
")",
"... | Checks if a slot is contained in the intent request and its value is not blank.
@param slotName name of the slot to look after
@return True, if the slot exists in the intent request and is not blank. | [
"Checks",
"if",
"a",
"slot",
"is",
"contained",
"in",
"the",
"intent",
"request",
"and",
"its",
"value",
"is",
"not",
"blank",
"."
] | 2c19028e775c2512dd4649d12962c0b48bf7f2bc | https://github.com/KayLerch/alexa-skills-kit-tellask-java/blob/2c19028e775c2512dd4649d12962c0b48bf7f2bc/src/main/java/io/klerch/alexa/tellask/model/AlexaInput.java#L179-L181 | train |
KayLerch/alexa-skills-kit-tellask-java | src/main/java/io/klerch/alexa/tellask/model/AlexaInput.java | AlexaInput.hasSlotIsNumber | public boolean hasSlotIsNumber(final String slotName) {
return hasSlot(slotName) && NumberUtils.isNumber(intentRequest.getIntent().getSlot(slotName).getValue());
} | java | public boolean hasSlotIsNumber(final String slotName) {
return hasSlot(slotName) && NumberUtils.isNumber(intentRequest.getIntent().getSlot(slotName).getValue());
} | [
"public",
"boolean",
"hasSlotIsNumber",
"(",
"final",
"String",
"slotName",
")",
"{",
"return",
"hasSlot",
"(",
"slotName",
")",
"&&",
"NumberUtils",
".",
"isNumber",
"(",
"intentRequest",
".",
"getIntent",
"(",
")",
".",
"getSlot",
"(",
"slotName",
")",
"."... | Checks if a slot is contained in the intent request and its value is a number.
@param slotName name of the slot to look after
@return True, if the slot exists in the intent request and is a number. | [
"Checks",
"if",
"a",
"slot",
"is",
"contained",
"in",
"the",
"intent",
"request",
"and",
"its",
"value",
"is",
"a",
"number",
"."
] | 2c19028e775c2512dd4649d12962c0b48bf7f2bc | https://github.com/KayLerch/alexa-skills-kit-tellask-java/blob/2c19028e775c2512dd4649d12962c0b48bf7f2bc/src/main/java/io/klerch/alexa/tellask/model/AlexaInput.java#L188-L190 | train |
KayLerch/alexa-skills-kit-tellask-java | src/main/java/io/klerch/alexa/tellask/model/AlexaInput.java | AlexaInput.getSlotValue | public String getSlotValue(final String slotName) {
return hasSlot(slotName) ? intentRequest.getIntent().getSlot(slotName).getValue() : null;
} | java | public String getSlotValue(final String slotName) {
return hasSlot(slotName) ? intentRequest.getIntent().getSlot(slotName).getValue() : null;
} | [
"public",
"String",
"getSlotValue",
"(",
"final",
"String",
"slotName",
")",
"{",
"return",
"hasSlot",
"(",
"slotName",
")",
"?",
"intentRequest",
".",
"getIntent",
"(",
")",
".",
"getSlot",
"(",
"slotName",
")",
".",
"getValue",
"(",
")",
":",
"null",
"... | Gets the slot value as a string in case slot exists otherwise null
@param slotName name of the slot to look after
@return slot value as a string in case slot exists otherwise null | [
"Gets",
"the",
"slot",
"value",
"as",
"a",
"string",
"in",
"case",
"slot",
"exists",
"otherwise",
"null"
] | 2c19028e775c2512dd4649d12962c0b48bf7f2bc | https://github.com/KayLerch/alexa-skills-kit-tellask-java/blob/2c19028e775c2512dd4649d12962c0b48bf7f2bc/src/main/java/io/klerch/alexa/tellask/model/AlexaInput.java#L207-L209 | train |
KayLerch/alexa-skills-kit-tellask-java | src/main/java/io/klerch/alexa/tellask/model/wrapper/AlexaRequestStreamHandler.java | AlexaRequestStreamHandler.getSpeechlet | public Class<? extends AlexaSpeechlet> getSpeechlet() {
final AlexaApplication app = this.getClass().getAnnotation(AlexaApplication.class);
return app != null ? app.speechlet() : AlexaSpeechlet.class;
} | java | public Class<? extends AlexaSpeechlet> getSpeechlet() {
final AlexaApplication app = this.getClass().getAnnotation(AlexaApplication.class);
return app != null ? app.speechlet() : AlexaSpeechlet.class;
} | [
"public",
"Class",
"<",
"?",
"extends",
"AlexaSpeechlet",
">",
"getSpeechlet",
"(",
")",
"{",
"final",
"AlexaApplication",
"app",
"=",
"this",
".",
"getClass",
"(",
")",
".",
"getAnnotation",
"(",
"AlexaApplication",
".",
"class",
")",
";",
"return",
"app",
... | Provides the speechlet used to handle the request.
@return speechlet used to handle the request. | [
"Provides",
"the",
"speechlet",
"used",
"to",
"handle",
"the",
"request",
"."
] | 2c19028e775c2512dd4649d12962c0b48bf7f2bc | https://github.com/KayLerch/alexa-skills-kit-tellask-java/blob/2c19028e775c2512dd4649d12962c0b48bf7f2bc/src/main/java/io/klerch/alexa/tellask/model/wrapper/AlexaRequestStreamHandler.java#L69-L72 | train |
KayLerch/alexa-skills-kit-tellask-java | src/main/java/io/klerch/alexa/tellask/model/wrapper/AlexaRequestStreamHandler.java | AlexaRequestStreamHandler.handleRequest | @Override
public void handleRequest(final InputStream input, final OutputStream output, final Context context) throws IOException {
byte[] serializedSpeechletRequest = IOUtils.toByteArray(input);
final AlexaSpeechlet speechlet = AlexaSpeechletFactory.createSpeechletFromRequest(serializedSpeechletRequest, getSpeechlet(), getUtteranceReader());
final SpeechletRequestHandler handler = getRequestStreamHandler();
try {
byte[] outputBytes = handler.handleSpeechletCall(speechlet, serializedSpeechletRequest);
output.write(outputBytes);
} catch (SpeechletRequestHandlerException | SpeechletException e) {
// wrap actual exception in expected IOException
throw new IOException(e);
}
} | java | @Override
public void handleRequest(final InputStream input, final OutputStream output, final Context context) throws IOException {
byte[] serializedSpeechletRequest = IOUtils.toByteArray(input);
final AlexaSpeechlet speechlet = AlexaSpeechletFactory.createSpeechletFromRequest(serializedSpeechletRequest, getSpeechlet(), getUtteranceReader());
final SpeechletRequestHandler handler = getRequestStreamHandler();
try {
byte[] outputBytes = handler.handleSpeechletCall(speechlet, serializedSpeechletRequest);
output.write(outputBytes);
} catch (SpeechletRequestHandlerException | SpeechletException e) {
// wrap actual exception in expected IOException
throw new IOException(e);
}
} | [
"@",
"Override",
"public",
"void",
"handleRequest",
"(",
"final",
"InputStream",
"input",
",",
"final",
"OutputStream",
"output",
",",
"final",
"Context",
"context",
")",
"throws",
"IOException",
"{",
"byte",
"[",
"]",
"serializedSpeechletRequest",
"=",
"IOUtils",... | The handler method is called on a Lambda execution.
@param input the input stream containing the Lambda request payload
@param output the output stream containing the Lambda response payload
@param context a context for a Lambda execution.
@throws IOException exception is thrown on invalid request payload or on a provided speechlet
handler having no public constructor taking a String containing the locale | [
"The",
"handler",
"method",
"is",
"called",
"on",
"a",
"Lambda",
"execution",
"."
] | 2c19028e775c2512dd4649d12962c0b48bf7f2bc | https://github.com/KayLerch/alexa-skills-kit-tellask-java/blob/2c19028e775c2512dd4649d12962c0b48bf7f2bc/src/main/java/io/klerch/alexa/tellask/model/wrapper/AlexaRequestStreamHandler.java#L82-L94 | train |
KayLerch/alexa-skills-kit-tellask-java | src/main/java/io/klerch/alexa/tellask/model/wrapper/AlexaRequestStreamHandler.java | AlexaRequestStreamHandler.getRequestStreamHandler | private SpeechletRequestHandler getRequestStreamHandler() {
final Set<String> supportedApplicationIds = getSupportedApplicationIds();
// at least one supported application-id need to be provided
Validate.notEmpty(supportedApplicationIds, "Must provide supported application-id either with overriding the getter or using AlexaApplication-annotation in " + this.getClass().getSimpleName());
return new SpeechletRequestHandler(
Collections.singletonList(
new ApplicationIdSpeechletRequestVerifier(supportedApplicationIds)),
Arrays.asList(
new ResponseSizeSpeechletResponseVerifier(),
new OutputSpeechSpeechletResponseVerifier(),
new CardSpeechletResponseVerifier()));
} | java | private SpeechletRequestHandler getRequestStreamHandler() {
final Set<String> supportedApplicationIds = getSupportedApplicationIds();
// at least one supported application-id need to be provided
Validate.notEmpty(supportedApplicationIds, "Must provide supported application-id either with overriding the getter or using AlexaApplication-annotation in " + this.getClass().getSimpleName());
return new SpeechletRequestHandler(
Collections.singletonList(
new ApplicationIdSpeechletRequestVerifier(supportedApplicationIds)),
Arrays.asList(
new ResponseSizeSpeechletResponseVerifier(),
new OutputSpeechSpeechletResponseVerifier(),
new CardSpeechletResponseVerifier()));
} | [
"private",
"SpeechletRequestHandler",
"getRequestStreamHandler",
"(",
")",
"{",
"final",
"Set",
"<",
"String",
">",
"supportedApplicationIds",
"=",
"getSupportedApplicationIds",
"(",
")",
";",
"// at least one supported application-id need to be provided",
"Validate",
".",
"n... | Constructs the stream handler giving it all the provided information.
@return stream handler | [
"Constructs",
"the",
"stream",
"handler",
"giving",
"it",
"all",
"the",
"provided",
"information",
"."
] | 2c19028e775c2512dd4649d12962c0b48bf7f2bc | https://github.com/KayLerch/alexa-skills-kit-tellask-java/blob/2c19028e775c2512dd4649d12962c0b48bf7f2bc/src/main/java/io/klerch/alexa/tellask/model/wrapper/AlexaRequestStreamHandler.java#L100-L112 | train |
nmdp-bioinformatics/genotype-list | gl-client-local/src/main/java/org/nmdp/gl/client/local/LocalGlClient.java | LocalGlClient.create | public static GlClient create() {
Injector injector = Guice.createInjector(getLocalModules());
return injector.getInstance(GlClient.class);
} | java | public static GlClient create() {
Injector injector = Guice.createInjector(getLocalModules());
return injector.getInstance(GlClient.class);
} | [
"public",
"static",
"GlClient",
"create",
"(",
")",
"{",
"Injector",
"injector",
"=",
"Guice",
".",
"createInjector",
"(",
"getLocalModules",
"(",
")",
")",
";",
"return",
"injector",
".",
"getInstance",
"(",
"GlClient",
".",
"class",
")",
";",
"}"
] | Create and return a new instance of LocalGlClient configured with the default nomenclature.
@return a new instance of LocalGlClient configured with the default nomenclature | [
"Create",
"and",
"return",
"a",
"new",
"instance",
"of",
"LocalGlClient",
"configured",
"with",
"the",
"default",
"nomenclature",
"."
] | 03b2579552cb9f680a62ffaaecdca9c2a5d12ee4 | https://github.com/nmdp-bioinformatics/genotype-list/blob/03b2579552cb9f680a62ffaaecdca9c2a5d12ee4/gl-client-local/src/main/java/org/nmdp/gl/client/local/LocalGlClient.java#L194-L197 | train |
nmdp-bioinformatics/genotype-list | gl-client-local/src/main/java/org/nmdp/gl/client/local/LocalGlClient.java | LocalGlClient.createStrict | public static GlClient createStrict(final Class<? extends Nomenclature> nomenclatureClass) throws IOException {
checkNotNull(nomenclatureClass);
Injector injector = Guice.createInjector(getLocalStrictModules(nomenclatureClass));
Nomenclature nomenclature = injector.getInstance(Nomenclature.class);
nomenclature.load();
return injector.getInstance(GlClient.class);
} | java | public static GlClient createStrict(final Class<? extends Nomenclature> nomenclatureClass) throws IOException {
checkNotNull(nomenclatureClass);
Injector injector = Guice.createInjector(getLocalStrictModules(nomenclatureClass));
Nomenclature nomenclature = injector.getInstance(Nomenclature.class);
nomenclature.load();
return injector.getInstance(GlClient.class);
} | [
"public",
"static",
"GlClient",
"createStrict",
"(",
"final",
"Class",
"<",
"?",
"extends",
"Nomenclature",
">",
"nomenclatureClass",
")",
"throws",
"IOException",
"{",
"checkNotNull",
"(",
"nomenclatureClass",
")",
";",
"Injector",
"injector",
"=",
"Guice",
".",
... | Create and return a new instance of LocalGlClient configured in strict mode with the specified nomenclature.
@param nomenclatureClass nomenclature class, must not be null
@return a new instance of LocalGlClient configured in strict mode with the specified nomenclature
@throws IOException if an I/O error occurs | [
"Create",
"and",
"return",
"a",
"new",
"instance",
"of",
"LocalGlClient",
"configured",
"in",
"strict",
"mode",
"with",
"the",
"specified",
"nomenclature",
"."
] | 03b2579552cb9f680a62ffaaecdca9c2a5d12ee4 | https://github.com/nmdp-bioinformatics/genotype-list/blob/03b2579552cb9f680a62ffaaecdca9c2a5d12ee4/gl-client-local/src/main/java/org/nmdp/gl/client/local/LocalGlClient.java#L219-L225 | train |
nmdp-bioinformatics/genotype-list | gl-client-local/src/main/java/org/nmdp/gl/client/local/LocalGlClient.java | LocalGlClient.getLocalStrictModules | public static List<AbstractModule> getLocalStrictModules(final Class<? extends Nomenclature> nomenclatureClass) {
checkNotNull(nomenclatureClass);
return ImmutableList.of(new LocalStrictModule(), new CacheModule(), new IdModule(), new AbstractModule() {
@Override
protected void configure() {
bind(Nomenclature.class).to(nomenclatureClass);
}
});
} | java | public static List<AbstractModule> getLocalStrictModules(final Class<? extends Nomenclature> nomenclatureClass) {
checkNotNull(nomenclatureClass);
return ImmutableList.of(new LocalStrictModule(), new CacheModule(), new IdModule(), new AbstractModule() {
@Override
protected void configure() {
bind(Nomenclature.class).to(nomenclatureClass);
}
});
} | [
"public",
"static",
"List",
"<",
"AbstractModule",
">",
"getLocalStrictModules",
"(",
"final",
"Class",
"<",
"?",
"extends",
"Nomenclature",
">",
"nomenclatureClass",
")",
"{",
"checkNotNull",
"(",
"nomenclatureClass",
")",
";",
"return",
"ImmutableList",
".",
"of... | Return the list of modules that configure LocalGlClient in strict mode with the specified nomenclature.
<p>
Note the nomenclature provided by an injector created from these modules must be loaded, e.g.
<pre>
Injector injector = Guice.createInjector(getLocalStrictModules(nomenclatureClass));
Nomenclature nomenclature = injector.getInstance(Nomenclature.class);
nomenclature.load();
</pre>
</p>
@param nomenclatureClass nomenclature class, must ot be null
@return the list of modules that configure LocalGlClient in strict mode with the specified nomenclature | [
"Return",
"the",
"list",
"of",
"modules",
"that",
"configure",
"LocalGlClient",
"in",
"strict",
"mode",
"with",
"the",
"specified",
"nomenclature",
"."
] | 03b2579552cb9f680a62ffaaecdca9c2a5d12ee4 | https://github.com/nmdp-bioinformatics/genotype-list/blob/03b2579552cb9f680a62ffaaecdca9c2a5d12ee4/gl-client-local/src/main/java/org/nmdp/gl/client/local/LocalGlClient.java#L251-L259 | train |
wisdom-framework/wisdom-jdbc | wisdom-jpa-manager/src/main/java/org/wisdom/framework/jpa/crud/JPARepository.java | JPARepository.getCrudServices | @Override
public Collection<Crud<?, ?>> getCrudServices() {
List<Crud<?, ?>> list = new ArrayList<>();
list.addAll(cruds);
return list;
} | java | @Override
public Collection<Crud<?, ?>> getCrudServices() {
List<Crud<?, ?>> list = new ArrayList<>();
list.addAll(cruds);
return list;
} | [
"@",
"Override",
"public",
"Collection",
"<",
"Crud",
"<",
"?",
",",
"?",
">",
">",
"getCrudServices",
"(",
")",
"{",
"List",
"<",
"Crud",
"<",
"?",
",",
"?",
">",
">",
"list",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"list",
".",
"addAll",
... | Gets the list of Crud service managed by the current repository.
@return the list of crud services, empty if none | [
"Gets",
"the",
"list",
"of",
"Crud",
"service",
"managed",
"by",
"the",
"current",
"repository",
"."
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jpa-manager/src/main/java/org/wisdom/framework/jpa/crud/JPARepository.java#L88-L93 | train |
wisdom-framework/wisdom-jdbc | wisdom-jpa-manager/src/main/java/org/wisdom/framework/jpa/crud/JPARepository.java | JPARepository.dispose | public void dispose() {
for (ServiceRegistration registration : registrations) {
registration.unregister();
}
registrations.clear();
for (AbstractJTACrud crud : cruds) {
crud.dispose();
}
} | java | public void dispose() {
for (ServiceRegistration registration : registrations) {
registration.unregister();
}
registrations.clear();
for (AbstractJTACrud crud : cruds) {
crud.dispose();
}
} | [
"public",
"void",
"dispose",
"(",
")",
"{",
"for",
"(",
"ServiceRegistration",
"registration",
":",
"registrations",
")",
"{",
"registration",
".",
"unregister",
"(",
")",
";",
"}",
"registrations",
".",
"clear",
"(",
")",
";",
"for",
"(",
"AbstractJTACrud",... | Stops the repository. It un-registers all crud services. | [
"Stops",
"the",
"repository",
".",
"It",
"un",
"-",
"registers",
"all",
"crud",
"services",
"."
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jpa-manager/src/main/java/org/wisdom/framework/jpa/crud/JPARepository.java#L139-L147 | train |
nmdp-bioinformatics/genotype-list | gl-client/src/main/java/org/nmdp/gl/client/GlResourceBuilder.java | GlResourceBuilder.reset | public GlResourceBuilder reset() {
alleles.clear();
alleleLists.clear();
haplotypes.clear();
genotypes.clear();
genotypeLists.clear();
locus = null;
allele = null;
alleleList = null;
haplotype = null;
genotype = null;
genotypeList = null;
return this;
} | java | public GlResourceBuilder reset() {
alleles.clear();
alleleLists.clear();
haplotypes.clear();
genotypes.clear();
genotypeLists.clear();
locus = null;
allele = null;
alleleList = null;
haplotype = null;
genotype = null;
genotypeList = null;
return this;
} | [
"public",
"GlResourceBuilder",
"reset",
"(",
")",
"{",
"alleles",
".",
"clear",
"(",
")",
";",
"alleleLists",
".",
"clear",
"(",
")",
";",
"haplotypes",
".",
"clear",
"(",
")",
";",
"genotypes",
".",
"clear",
"(",
")",
";",
"genotypeLists",
".",
"clear... | Return this gl resource builder with its configuration reset.
@return this gl resource builder with its configuration reset | [
"Return",
"this",
"gl",
"resource",
"builder",
"with",
"its",
"configuration",
"reset",
"."
] | 03b2579552cb9f680a62ffaaecdca9c2a5d12ee4 | https://github.com/nmdp-bioinformatics/genotype-list/blob/03b2579552cb9f680a62ffaaecdca9c2a5d12ee4/gl-client/src/main/java/org/nmdp/gl/client/GlResourceBuilder.java#L165-L178 | train |
wisdom-framework/wisdom-jdbc | wisdom-jpa-manager/src/main/java/org/wisdom/framework/jpa/PersistenceUnitComponent.java | PersistenceUnitComponent.start | @Validate
public void start() {
try {
Map<String, Object> map = new HashMap<>();
for (Persistence.PersistenceUnit.Properties.Property p :
persistenceUnitXml.getProperties().getProperty()) {
map.put(p.getName(), p.getValue());
}
if (isOpenJPA()) {
map.put("openjpa.ManagedRuntime",
"invocation(TransactionManagerMethod=org.wisdom.framework.jpa.accessor" +
".TransactionManagerAccessor.get)");
}
// This is not going to work with OpenJPA because the current version of OpenJPA requires an old version
// of javax.validation. The wisdom one is too recent.
map.put("javax.persistence.validation.factory", validator);
Dictionary<String, Object> properties = new Hashtable<>();
properties.put(UNIT_NAME_PROP, persistenceUnitXml.getName());
properties.put(UNIT_VERSION_PROP, sourceBundle.bundle.getVersion());
properties.put(UNIT_PROVIDER_PROP, provider.getClass().getName());
List<String> entities = persistenceUnitXml.getClazz();
properties.put(UNIT_ENTITIES_PROP, entities.toArray(new String[entities.size()]));
properties.put(UNIT_TRANSACTION_PROP, getTransactionType().toString());
// If the unit set the transaction to RESOURCE_LOCAL, no JTA involved.
if (persistenceUnitXml.getTransactionType() ==
org.wisdom.framework.jpa.model.PersistenceUnitTransactionType.RESOURCE_LOCAL) {
entityManagerFactory = provider.createContainerEntityManagerFactory(this, map);
entityManager = entityManagerFactory.createEntityManager();
emfRegistration = bundleContext.registerService(EntityManagerFactory.class, entityManagerFactory, properties);
emRegistration = bundleContext.registerService(EntityManager.class,
entityManager, properties);
repository = new JPARepository(persistenceUnitXml, entityManager,
entityManagerFactory, transactionManager, sourceBundle.bundle.getBundleContext());
} else {
// JTA
entityManagerFactory = provider.createContainerEntityManagerFactory(this, map);
entityManager = new TransactionalEntityManager(transactionManager, entityManagerFactory, this);
emRegistration = bundleContext.registerService(EntityManager.class,
entityManager, properties);
emfRegistration = bundleContext.registerService(EntityManagerFactory.class, entityManagerFactory, properties);
repository = new JPARepository(persistenceUnitXml, entityManager,
entityManagerFactory, transactionManager, sourceBundle.bundle.getBundleContext());
}
} catch (Exception e) {
LOGGER.error("Error while initializing the JPA services for unit {}",
persistenceUnitXml.getName(), e);
}
} | java | @Validate
public void start() {
try {
Map<String, Object> map = new HashMap<>();
for (Persistence.PersistenceUnit.Properties.Property p :
persistenceUnitXml.getProperties().getProperty()) {
map.put(p.getName(), p.getValue());
}
if (isOpenJPA()) {
map.put("openjpa.ManagedRuntime",
"invocation(TransactionManagerMethod=org.wisdom.framework.jpa.accessor" +
".TransactionManagerAccessor.get)");
}
// This is not going to work with OpenJPA because the current version of OpenJPA requires an old version
// of javax.validation. The wisdom one is too recent.
map.put("javax.persistence.validation.factory", validator);
Dictionary<String, Object> properties = new Hashtable<>();
properties.put(UNIT_NAME_PROP, persistenceUnitXml.getName());
properties.put(UNIT_VERSION_PROP, sourceBundle.bundle.getVersion());
properties.put(UNIT_PROVIDER_PROP, provider.getClass().getName());
List<String> entities = persistenceUnitXml.getClazz();
properties.put(UNIT_ENTITIES_PROP, entities.toArray(new String[entities.size()]));
properties.put(UNIT_TRANSACTION_PROP, getTransactionType().toString());
// If the unit set the transaction to RESOURCE_LOCAL, no JTA involved.
if (persistenceUnitXml.getTransactionType() ==
org.wisdom.framework.jpa.model.PersistenceUnitTransactionType.RESOURCE_LOCAL) {
entityManagerFactory = provider.createContainerEntityManagerFactory(this, map);
entityManager = entityManagerFactory.createEntityManager();
emfRegistration = bundleContext.registerService(EntityManagerFactory.class, entityManagerFactory, properties);
emRegistration = bundleContext.registerService(EntityManager.class,
entityManager, properties);
repository = new JPARepository(persistenceUnitXml, entityManager,
entityManagerFactory, transactionManager, sourceBundle.bundle.getBundleContext());
} else {
// JTA
entityManagerFactory = provider.createContainerEntityManagerFactory(this, map);
entityManager = new TransactionalEntityManager(transactionManager, entityManagerFactory, this);
emRegistration = bundleContext.registerService(EntityManager.class,
entityManager, properties);
emfRegistration = bundleContext.registerService(EntityManagerFactory.class, entityManagerFactory, properties);
repository = new JPARepository(persistenceUnitXml, entityManager,
entityManagerFactory, transactionManager, sourceBundle.bundle.getBundleContext());
}
} catch (Exception e) {
LOGGER.error("Error while initializing the JPA services for unit {}",
persistenceUnitXml.getName(), e);
}
} | [
"@",
"Validate",
"public",
"void",
"start",
"(",
")",
"{",
"try",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"map",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"Persistence",
".",
"PersistenceUnit",
".",
"Properties",
".",
"Property",
... | Starts the unit. It creates the entity manager factory and entity manager, as well as the repository and crud
services. | [
"Starts",
"the",
"unit",
".",
"It",
"creates",
"the",
"entity",
"manager",
"factory",
"and",
"entity",
"manager",
"as",
"well",
"as",
"the",
"repository",
"and",
"crud",
"services",
"."
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jpa-manager/src/main/java/org/wisdom/framework/jpa/PersistenceUnitComponent.java#L171-L227 | train |
wisdom-framework/wisdom-jdbc | wisdom-jpa-manager/src/main/java/org/wisdom/framework/jpa/PersistenceUnitComponent.java | PersistenceUnitComponent.getNewTempClassLoader | @Override
public ClassLoader getNewTempClassLoader() {
return new ClassLoader(getClassLoader()) { //NOSONAR
/**
* Searches for the .class file and define it using the current class loader.
* @param className the class name
* @return the class object
* @throws ClassNotFoundException if the class cannot be found
*/
@Override
protected Class findClass(String className) throws ClassNotFoundException {
// Use path of class, then get the resource
String path = className.replace('.', '/').concat(".class");
URL resource = getParent().getResource(path);
if (resource == null) {
throw new ClassNotFoundException(className + " as resource " + path + " in " + getParent());
}
try {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
IOUtils.copy(resource.openStream(), bout);
byte[] buffer = bout.toByteArray();
return defineClass(className, buffer, 0, buffer.length);
} catch (Exception e) {
throw new ClassNotFoundException(className + " as resource" + path + " in " + getParent(), e);
}
}
/**
* Finds a resource in the bundle.
* @param resource the resource
* @return the url of the resource from the bundle, {@code null} if not found.
*/
@Override
protected URL findResource(String resource) {
return getParent().getResource(resource);
}
/**
* Finds resources in the bundle.
* @param resource the resource
* @return the url of the resources from the bundle, empty if not found.
*/
@Override
protected Enumeration<URL> findResources(String resource) throws IOException {
return getParent().getResources(resource);
}
};
} | java | @Override
public ClassLoader getNewTempClassLoader() {
return new ClassLoader(getClassLoader()) { //NOSONAR
/**
* Searches for the .class file and define it using the current class loader.
* @param className the class name
* @return the class object
* @throws ClassNotFoundException if the class cannot be found
*/
@Override
protected Class findClass(String className) throws ClassNotFoundException {
// Use path of class, then get the resource
String path = className.replace('.', '/').concat(".class");
URL resource = getParent().getResource(path);
if (resource == null) {
throw new ClassNotFoundException(className + " as resource " + path + " in " + getParent());
}
try {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
IOUtils.copy(resource.openStream(), bout);
byte[] buffer = bout.toByteArray();
return defineClass(className, buffer, 0, buffer.length);
} catch (Exception e) {
throw new ClassNotFoundException(className + " as resource" + path + " in " + getParent(), e);
}
}
/**
* Finds a resource in the bundle.
* @param resource the resource
* @return the url of the resource from the bundle, {@code null} if not found.
*/
@Override
protected URL findResource(String resource) {
return getParent().getResource(resource);
}
/**
* Finds resources in the bundle.
* @param resource the resource
* @return the url of the resources from the bundle, empty if not found.
*/
@Override
protected Enumeration<URL> findResources(String resource) throws IOException {
return getParent().getResources(resource);
}
};
} | [
"@",
"Override",
"public",
"ClassLoader",
"getNewTempClassLoader",
"(",
")",
"{",
"return",
"new",
"ClassLoader",
"(",
"getClassLoader",
"(",
")",
")",
"{",
"//NOSONAR",
"/**\n * Searches for the .class file and define it using the current class loader.\n ... | In this method we just create a simple temporary class loader. This class
loader uses the bundle's class loader as parent but defines the classes
in this class loader. This has the implicit assumption that the temp
class loader is used BEFORE any bundle's classes are loaded since a class
loader does parent delegation first. Sigh, guess it works most of the
time. There is however, no good alternative though in OSGi we could
actually refresh the bundle.
@see javax.persistence.spi.PersistenceUnitInfo#getNewTempClassLoader() | [
"In",
"this",
"method",
"we",
"just",
"create",
"a",
"simple",
"temporary",
"class",
"loader",
".",
"This",
"class",
"loader",
"uses",
"the",
"bundle",
"s",
"class",
"loader",
"as",
"parent",
"but",
"defines",
"the",
"classes",
"in",
"this",
"class",
"load... | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jpa-manager/src/main/java/org/wisdom/framework/jpa/PersistenceUnitComponent.java#L314-L365 | train |
wisdom-framework/wisdom-jdbc | wisdom-jpa-manager/src/main/java/org/wisdom/framework/transaction/impl/XidFactoryImpl.java | XidFactoryImpl.createXid | public Xid createXid() {
byte[] globalId = baseId.clone();
long id;
synchronized (this) {
id = count++;
}
insertLong(id, globalId, 0);
return new XidImpl(globalId);
} | java | public Xid createXid() {
byte[] globalId = baseId.clone();
long id;
synchronized (this) {
id = count++;
}
insertLong(id, globalId, 0);
return new XidImpl(globalId);
} | [
"public",
"Xid",
"createXid",
"(",
")",
"{",
"byte",
"[",
"]",
"globalId",
"=",
"baseId",
".",
"clone",
"(",
")",
";",
"long",
"id",
";",
"synchronized",
"(",
"this",
")",
"{",
"id",
"=",
"count",
"++",
";",
"}",
"insertLong",
"(",
"id",
",",
"gl... | Creates the Xid.
@return the new Xid | [
"Creates",
"the",
"Xid",
"."
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jpa-manager/src/main/java/org/wisdom/framework/transaction/impl/XidFactoryImpl.java#L54-L62 | train |
wisdom-framework/wisdom-jdbc | wisdom-jpa-manager/src/main/java/org/wisdom/framework/transaction/impl/XidFactoryImpl.java | XidFactoryImpl.createBranch | public Xid createBranch(Xid globalId, int branch) {
byte[] branchId = baseId.clone();
branchId[0] = (byte) branch;
branchId[1] = (byte) (branch >>> 8);
branchId[2] = (byte) (branch >>> 16);
branchId[3] = (byte) (branch >>> 24);
insertLong(start, branchId, 4);
return new XidImpl(globalId, branchId);
} | java | public Xid createBranch(Xid globalId, int branch) {
byte[] branchId = baseId.clone();
branchId[0] = (byte) branch;
branchId[1] = (byte) (branch >>> 8);
branchId[2] = (byte) (branch >>> 16);
branchId[3] = (byte) (branch >>> 24);
insertLong(start, branchId, 4);
return new XidImpl(globalId, branchId);
} | [
"public",
"Xid",
"createBranch",
"(",
"Xid",
"globalId",
",",
"int",
"branch",
")",
"{",
"byte",
"[",
"]",
"branchId",
"=",
"baseId",
".",
"clone",
"(",
")",
";",
"branchId",
"[",
"0",
"]",
"=",
"(",
"byte",
")",
"branch",
";",
"branchId",
"[",
"1"... | Create a branch Xid.
@param globalId the global Xid
@param branch the branch number
@return the new Xid. | [
"Create",
"a",
"branch",
"Xid",
"."
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jpa-manager/src/main/java/org/wisdom/framework/transaction/impl/XidFactoryImpl.java#L70-L78 | train |
wisdom-framework/wisdom-jdbc | wisdom-jpa-manager/src/main/java/org/wisdom/framework/transaction/impl/XidFactoryImpl.java | XidFactoryImpl.matchesGlobalId | public boolean matchesGlobalId(byte[] globalTransactionId) {
if (globalTransactionId.length != Xid.MAXGTRIDSIZE) {
return false;
}
for (int i = 8; i < globalTransactionId.length; i++) {
if (globalTransactionId[i] != baseId[i]) {
return false;
}
}
// for recovery, only match old transactions
long id = extractLong(globalTransactionId, 0);
return (id < start);
} | java | public boolean matchesGlobalId(byte[] globalTransactionId) {
if (globalTransactionId.length != Xid.MAXGTRIDSIZE) {
return false;
}
for (int i = 8; i < globalTransactionId.length; i++) {
if (globalTransactionId[i] != baseId[i]) {
return false;
}
}
// for recovery, only match old transactions
long id = extractLong(globalTransactionId, 0);
return (id < start);
} | [
"public",
"boolean",
"matchesGlobalId",
"(",
"byte",
"[",
"]",
"globalTransactionId",
")",
"{",
"if",
"(",
"globalTransactionId",
".",
"length",
"!=",
"Xid",
".",
"MAXGTRIDSIZE",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"8",
";... | Checks whether or not the given byte array matches the global id.
@param globalTransactionId the global transaction id
@return true if it matches | [
"Checks",
"whether",
"or",
"not",
"the",
"given",
"byte",
"array",
"matches",
"the",
"global",
"id",
"."
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jpa-manager/src/main/java/org/wisdom/framework/transaction/impl/XidFactoryImpl.java#L85-L97 | train |
wisdom-framework/wisdom-jdbc | wisdom-jpa-manager/src/main/java/org/wisdom/framework/transaction/impl/XidFactoryImpl.java | XidFactoryImpl.matchesBranchId | public boolean matchesBranchId(byte[] branchQualifier) {
if (branchQualifier.length != Xid.MAXBQUALSIZE) {
return false;
}
long id = extractLong(branchQualifier, 4);
if (id >= start) {
// newly created branch, not recoverable
return false;
}
for (int i = 12; i < branchQualifier.length; i++) {
if (branchQualifier[i] != baseId[i]) {
return false;
}
}
return true;
} | java | public boolean matchesBranchId(byte[] branchQualifier) {
if (branchQualifier.length != Xid.MAXBQUALSIZE) {
return false;
}
long id = extractLong(branchQualifier, 4);
if (id >= start) {
// newly created branch, not recoverable
return false;
}
for (int i = 12; i < branchQualifier.length; i++) {
if (branchQualifier[i] != baseId[i]) {
return false;
}
}
return true;
} | [
"public",
"boolean",
"matchesBranchId",
"(",
"byte",
"[",
"]",
"branchQualifier",
")",
"{",
"if",
"(",
"branchQualifier",
".",
"length",
"!=",
"Xid",
".",
"MAXBQUALSIZE",
")",
"{",
"return",
"false",
";",
"}",
"long",
"id",
"=",
"extractLong",
"(",
"branch... | Checks whether or not the given byte array matches the branch id.
@param branchQualifier the branch qualifier
@return true if it matches | [
"Checks",
"whether",
"or",
"not",
"the",
"given",
"byte",
"array",
"matches",
"the",
"branch",
"id",
"."
] | 931f5acf0b2bcb0a8f3b683d60d326caafd09a72 | https://github.com/wisdom-framework/wisdom-jdbc/blob/931f5acf0b2bcb0a8f3b683d60d326caafd09a72/wisdom-jpa-manager/src/main/java/org/wisdom/framework/transaction/impl/XidFactoryImpl.java#L104-L120 | train |
naver/android-utilset | UtilSet/src/com/navercorp/utilset/ui/ActivityUtils.java | ActivityUtils.isPackageInstalled | public static boolean isPackageInstalled(Context context, String packageName) {
try {
context.getPackageManager().getApplicationInfo(packageName, 0);
return true;
} catch (Exception e) {
return false;
}
} | java | public static boolean isPackageInstalled(Context context, String packageName) {
try {
context.getPackageManager().getApplicationInfo(packageName, 0);
return true;
} catch (Exception e) {
return false;
}
} | [
"public",
"static",
"boolean",
"isPackageInstalled",
"(",
"Context",
"context",
",",
"String",
"packageName",
")",
"{",
"try",
"{",
"context",
".",
"getPackageManager",
"(",
")",
".",
"getApplicationInfo",
"(",
"packageName",
",",
"0",
")",
";",
"return",
"tru... | Checks if a package is installed.
@param context Context to be used to verify the existence of the package.
@param packageName Package name to be searched.
@return true if the package is discovered; false otherwise | [
"Checks",
"if",
"a",
"package",
"is",
"installed",
"."
] | 4af5f821466bc5bec4ea221ca6d87e0ac9b87e0b | https://github.com/naver/android-utilset/blob/4af5f821466bc5bec4ea221ca6d87e0ac9b87e0b/UtilSet/src/com/navercorp/utilset/ui/ActivityUtils.java#L26-L33 | train |
naver/android-utilset | UtilSet/src/com/navercorp/utilset/ui/ActivityUtils.java | ActivityUtils.getBaseActivityClassName | public static String getBaseActivityClassName(Context context) {
ComponentName activity = getBaseActivity(context);
if (activity == null) {
return null;
}
return activity.getClassName();
} | java | public static String getBaseActivityClassName(Context context) {
ComponentName activity = getBaseActivity(context);
if (activity == null) {
return null;
}
return activity.getClassName();
} | [
"public",
"static",
"String",
"getBaseActivityClassName",
"(",
"Context",
"context",
")",
"{",
"ComponentName",
"activity",
"=",
"getBaseActivity",
"(",
"context",
")",
";",
"if",
"(",
"activity",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
... | Returns Class name of base activity
@param context Context to provide activity information
@return String representing class name of base activity | [
"Returns",
"Class",
"name",
"of",
"base",
"activity"
] | 4af5f821466bc5bec4ea221ca6d87e0ac9b87e0b | https://github.com/naver/android-utilset/blob/4af5f821466bc5bec4ea221ca6d87e0ac9b87e0b/UtilSet/src/com/navercorp/utilset/ui/ActivityUtils.java#L53-L59 | train |
naver/android-utilset | UtilSet/src/com/navercorp/utilset/ui/ActivityUtils.java | ActivityUtils.getTopActivityPackageName | public static String getTopActivityPackageName(Context context) {
ComponentName activity = getTopActivity(context);
if (activity == null) {
return null;
}
return activity.getPackageName();
} | java | public static String getTopActivityPackageName(Context context) {
ComponentName activity = getTopActivity(context);
if (activity == null) {
return null;
}
return activity.getPackageName();
} | [
"public",
"static",
"String",
"getTopActivityPackageName",
"(",
"Context",
"context",
")",
"{",
"ComponentName",
"activity",
"=",
"getTopActivity",
"(",
"context",
")",
";",
"if",
"(",
"activity",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
... | Returns Package name of top activity
@param context Context to provide activity information
@return String representing package name of top activity | [
"Returns",
"Package",
"name",
"of",
"top",
"activity"
] | 4af5f821466bc5bec4ea221ca6d87e0ac9b87e0b | https://github.com/naver/android-utilset/blob/4af5f821466bc5bec4ea221ca6d87e0ac9b87e0b/UtilSet/src/com/navercorp/utilset/ui/ActivityUtils.java#L66-L72 | train |
naver/android-utilset | UtilSet/src/com/navercorp/utilset/ui/ActivityUtils.java | ActivityUtils.getTopActivityClassName | public static String getTopActivityClassName(Context context) {
ComponentName activity = getTopActivity(context);
if (activity == null) {
return null;
}
return activity.getClassName();
} | java | public static String getTopActivityClassName(Context context) {
ComponentName activity = getTopActivity(context);
if (activity == null) {
return null;
}
return activity.getClassName();
} | [
"public",
"static",
"String",
"getTopActivityClassName",
"(",
"Context",
"context",
")",
"{",
"ComponentName",
"activity",
"=",
"getTopActivity",
"(",
"context",
")",
";",
"if",
"(",
"activity",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"... | Returns Class name of top activity
@param context Context to provide activity information
@return String representing class name of top activity | [
"Returns",
"Class",
"name",
"of",
"top",
"activity"
] | 4af5f821466bc5bec4ea221ca6d87e0ac9b87e0b | https://github.com/naver/android-utilset/blob/4af5f821466bc5bec4ea221ca6d87e0ac9b87e0b/UtilSet/src/com/navercorp/utilset/ui/ActivityUtils.java#L79-L85 | train |
naver/android-utilset | UtilSet/src/com/navercorp/utilset/ui/ActivityUtils.java | ActivityUtils.isTopApplication | public static boolean isTopApplication(Context context) {
ComponentName activity = getTopActivity(context);
if (activity == null) {
return false;
}
return activity.getPackageName().equals(context.getApplicationInfo().packageName);
} | java | public static boolean isTopApplication(Context context) {
ComponentName activity = getTopActivity(context);
if (activity == null) {
return false;
}
return activity.getPackageName().equals(context.getApplicationInfo().packageName);
} | [
"public",
"static",
"boolean",
"isTopApplication",
"(",
"Context",
"context",
")",
"{",
"ComponentName",
"activity",
"=",
"getTopActivity",
"(",
"context",
")",
";",
"if",
"(",
"activity",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"return",
"activ... | Determines if this application is top activity
@param context Context to be examined
@return true if this application is a top activity; false otherwise | [
"Determines",
"if",
"this",
"application",
"is",
"top",
"activity"
] | 4af5f821466bc5bec4ea221ca6d87e0ac9b87e0b | https://github.com/naver/android-utilset/blob/4af5f821466bc5bec4ea221ca6d87e0ac9b87e0b/UtilSet/src/com/navercorp/utilset/ui/ActivityUtils.java#L94-L100 | train |
naver/android-utilset | UtilSet/src/com/navercorp/utilset/ui/ActivityUtils.java | ActivityUtils.isContextForeground | public static boolean isContextForeground(Context context) {
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
List<RunningAppProcessInfo> appProcesses = activityManager.getRunningAppProcesses();
int pid = getPid();
for (RunningAppProcessInfo appProcess : appProcesses) {
if (appProcess.pid == pid) {
return appProcess.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND;
}
}
return false;
} | java | public static boolean isContextForeground(Context context) {
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
List<RunningAppProcessInfo> appProcesses = activityManager.getRunningAppProcesses();
int pid = getPid();
for (RunningAppProcessInfo appProcess : appProcesses) {
if (appProcess.pid == pid) {
return appProcess.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND;
}
}
return false;
} | [
"public",
"static",
"boolean",
"isContextForeground",
"(",
"Context",
"context",
")",
"{",
"ActivityManager",
"activityManager",
"=",
"(",
"ActivityManager",
")",
"context",
".",
"getSystemService",
"(",
"Context",
".",
"ACTIVITY_SERVICE",
")",
";",
"List",
"<",
"... | Checks if this application is foreground
@param context Context to be examined
@return true if this application is running on the top; false otherwise | [
"Checks",
"if",
"this",
"application",
"is",
"foreground"
] | 4af5f821466bc5bec4ea221ca6d87e0ac9b87e0b | https://github.com/naver/android-utilset/blob/4af5f821466bc5bec4ea221ca6d87e0ac9b87e0b/UtilSet/src/com/navercorp/utilset/ui/ActivityUtils.java#L109-L120 | train |
naver/android-utilset | UtilSet/src/com/navercorp/utilset/device/DeviceTypeDetector.java | DeviceTypeDetector.getDeviceType | public DeviceType getDeviceType(Context activityContext) {
// Verifies if the Generalized Size of the device is XLARGE to be
// considered a Tablet
boolean xlarge = ((activityContext.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == SCREENLAYOUT_SIZE_XLARGE);
// If XLarge, checks if the Generalized Density is at least MDPI
// (160dpi)
if (xlarge) {
DisplayMetrics metrics = new DisplayMetrics();
Activity activity = (Activity)activityContext;
activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
// MDPI=160, DEFAULT=160, DENSITY_HIGH=240, DENSITY_MEDIUM=160,
// DENSITY_TV=213, DENSITY_XHIGH=320
if (metrics.densityDpi == DisplayMetrics.DENSITY_DEFAULT
|| metrics.densityDpi == DisplayMetrics.DENSITY_HIGH
|| metrics.densityDpi == DisplayMetrics.DENSITY_MEDIUM
|| metrics.densityDpi == DENSITY_TV
|| metrics.densityDpi == DENSITY_XHIGH) {
// this is a tablet!
return DeviceType.Tablet;
}
}
// this is not a tablet!
return DeviceType.Handset;
} | java | public DeviceType getDeviceType(Context activityContext) {
// Verifies if the Generalized Size of the device is XLARGE to be
// considered a Tablet
boolean xlarge = ((activityContext.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == SCREENLAYOUT_SIZE_XLARGE);
// If XLarge, checks if the Generalized Density is at least MDPI
// (160dpi)
if (xlarge) {
DisplayMetrics metrics = new DisplayMetrics();
Activity activity = (Activity)activityContext;
activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
// MDPI=160, DEFAULT=160, DENSITY_HIGH=240, DENSITY_MEDIUM=160,
// DENSITY_TV=213, DENSITY_XHIGH=320
if (metrics.densityDpi == DisplayMetrics.DENSITY_DEFAULT
|| metrics.densityDpi == DisplayMetrics.DENSITY_HIGH
|| metrics.densityDpi == DisplayMetrics.DENSITY_MEDIUM
|| metrics.densityDpi == DENSITY_TV
|| metrics.densityDpi == DENSITY_XHIGH) {
// this is a tablet!
return DeviceType.Tablet;
}
}
// this is not a tablet!
return DeviceType.Handset;
} | [
"public",
"DeviceType",
"getDeviceType",
"(",
"Context",
"activityContext",
")",
"{",
"// Verifies if the Generalized Size of the device is XLARGE to be",
"// considered a Tablet",
"boolean",
"xlarge",
"=",
"(",
"(",
"activityContext",
".",
"getResources",
"(",
")",
".",
"g... | Checks if the device is a tablet or a phone
@param activityContext The Activity Context.
@return Returns true if the device is a Tablet | [
"Checks",
"if",
"the",
"device",
"is",
"a",
"tablet",
"or",
"a",
"phone"
] | 4af5f821466bc5bec4ea221ca6d87e0ac9b87e0b | https://github.com/naver/android-utilset/blob/4af5f821466bc5bec4ea221ca6d87e0ac9b87e0b/UtilSet/src/com/navercorp/utilset/device/DeviceTypeDetector.java#L25-L52 | train |
naver/android-utilset | UtilSet/src/com/navercorp/utilset/audio/VolumeUtils.java | VolumeUtils.getCurrentVolume | public static int getCurrentVolume(Context context) {
AudioManager mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
return mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
} | java | public static int getCurrentVolume(Context context) {
AudioManager mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
return mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
} | [
"public",
"static",
"int",
"getCurrentVolume",
"(",
"Context",
"context",
")",
"{",
"AudioManager",
"mAudioManager",
"=",
"(",
"AudioManager",
")",
"context",
".",
"getSystemService",
"(",
"Context",
".",
"AUDIO_SERVICE",
")",
";",
"return",
"mAudioManager",
".",
... | Returns current media volume
@param context
@return current volume | [
"Returns",
"current",
"media",
"volume"
] | 4af5f821466bc5bec4ea221ca6d87e0ac9b87e0b | https://github.com/naver/android-utilset/blob/4af5f821466bc5bec4ea221ca6d87e0ac9b87e0b/UtilSet/src/com/navercorp/utilset/audio/VolumeUtils.java#L20-L23 | train |
naver/android-utilset | UtilSet/src/com/navercorp/utilset/audio/VolumeUtils.java | VolumeUtils.getMaximumVolume | public static int getMaximumVolume(Context context) {
return ((AudioManager) context.getSystemService(Context.AUDIO_SERVICE)).getStreamMaxVolume(AudioManager.STREAM_MUSIC);
} | java | public static int getMaximumVolume(Context context) {
return ((AudioManager) context.getSystemService(Context.AUDIO_SERVICE)).getStreamMaxVolume(AudioManager.STREAM_MUSIC);
} | [
"public",
"static",
"int",
"getMaximumVolume",
"(",
"Context",
"context",
")",
"{",
"return",
"(",
"(",
"AudioManager",
")",
"context",
".",
"getSystemService",
"(",
"Context",
".",
"AUDIO_SERVICE",
")",
")",
".",
"getStreamMaxVolume",
"(",
"AudioManager",
".",
... | Returns maximum volume the media volume can have
@param context Context
@return Maximum volume | [
"Returns",
"maximum",
"volume",
"the",
"media",
"volume",
"can",
"have"
] | 4af5f821466bc5bec4ea221ca6d87e0ac9b87e0b | https://github.com/naver/android-utilset/blob/4af5f821466bc5bec4ea221ca6d87e0ac9b87e0b/UtilSet/src/com/navercorp/utilset/audio/VolumeUtils.java#L90-L92 | train |
naver/android-utilset | UtilSet/src/com/navercorp/utilset/network/NetworkMonitor.java | NetworkMonitor.registerConnectivityReceiver | private void registerConnectivityReceiver() {
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
context.registerReceiver(connectivityReceiver, intentFilter);
} | java | private void registerConnectivityReceiver() {
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
context.registerReceiver(connectivityReceiver, intentFilter);
} | [
"private",
"void",
"registerConnectivityReceiver",
"(",
")",
"{",
"IntentFilter",
"intentFilter",
"=",
"new",
"IntentFilter",
"(",
")",
";",
"intentFilter",
".",
"addAction",
"(",
"ConnectivityManager",
".",
"CONNECTIVITY_ACTION",
")",
";",
"context",
".",
"register... | Registers receiver to be notified of broadcast event when network
connection changes | [
"Registers",
"receiver",
"to",
"be",
"notified",
"of",
"broadcast",
"event",
"when",
"network",
"connection",
"changes"
] | 4af5f821466bc5bec4ea221ca6d87e0ac9b87e0b | https://github.com/naver/android-utilset/blob/4af5f821466bc5bec4ea221ca6d87e0ac9b87e0b/UtilSet/src/com/navercorp/utilset/network/NetworkMonitor.java#L246-L250 | train |
naver/android-utilset | UtilSet/src/com/navercorp/utilset/network/NetworkMonitor.java | NetworkMonitor.isWifiFake | public boolean isWifiFake(String ipAddress, int port) {
SocketChannel socketChannel = null;
try {
socketChannel = SocketChannel.open();
socketChannel.connect(new InetSocketAddress(ipAddress, port));
} catch (IOException e) {
Log.d(TAG, "Current Wifi is stupid!!! by IOException");
return true;
} catch (UnresolvedAddressException e) {
Log.d(TAG, "Current Wifi is stupid!!! by InetSocketAddress");
return true;
} finally {
if (socketChannel != null)
try {
socketChannel.close();
} catch (IOException e) {
Log.d(TAG, "Error occured while closing SocketChannel");
}
}
return false;
} | java | public boolean isWifiFake(String ipAddress, int port) {
SocketChannel socketChannel = null;
try {
socketChannel = SocketChannel.open();
socketChannel.connect(new InetSocketAddress(ipAddress, port));
} catch (IOException e) {
Log.d(TAG, "Current Wifi is stupid!!! by IOException");
return true;
} catch (UnresolvedAddressException e) {
Log.d(TAG, "Current Wifi is stupid!!! by InetSocketAddress");
return true;
} finally {
if (socketChannel != null)
try {
socketChannel.close();
} catch (IOException e) {
Log.d(TAG, "Error occured while closing SocketChannel");
}
}
return false;
} | [
"public",
"boolean",
"isWifiFake",
"(",
"String",
"ipAddress",
",",
"int",
"port",
")",
"{",
"SocketChannel",
"socketChannel",
"=",
"null",
";",
"try",
"{",
"socketChannel",
"=",
"SocketChannel",
".",
"open",
"(",
")",
";",
"socketChannel",
".",
"connect",
"... | Checks if currently connected Access Point is either rogue or incapable
of routing packet
@param ipAddress
Any valid IP addresses will work to check if the device is
connected to properly working AP
@param port
Port number bound with ipAddress parameter
@return true if currently connected AP is not working normally; false
otherwise | [
"Checks",
"if",
"currently",
"connected",
"Access",
"Point",
"is",
"either",
"rogue",
"or",
"incapable",
"of",
"routing",
"packet"
] | 4af5f821466bc5bec4ea221ca6d87e0ac9b87e0b | https://github.com/naver/android-utilset/blob/4af5f821466bc5bec4ea221ca6d87e0ac9b87e0b/UtilSet/src/com/navercorp/utilset/network/NetworkMonitor.java#L756-L776 | train |
hayribakici/infiniteviewpager | infiniteviewpager/src/com/thehayro/view/InfinitePagerAdapter.java | InfinitePagerAdapter.instantiateItem | @Override
public final Object instantiateItem(final ViewGroup container, final int position) {
if (Constants.DEBUG) {
Log.i("InfiniteViewPager", String.format("instantiating position %s", position));
}
final PageModel<T> model = createPageModel(position);
mPageModels[position] = model;
container.addView(model.getParentView());
return model;
} | java | @Override
public final Object instantiateItem(final ViewGroup container, final int position) {
if (Constants.DEBUG) {
Log.i("InfiniteViewPager", String.format("instantiating position %s", position));
}
final PageModel<T> model = createPageModel(position);
mPageModels[position] = model;
container.addView(model.getParentView());
return model;
} | [
"@",
"Override",
"public",
"final",
"Object",
"instantiateItem",
"(",
"final",
"ViewGroup",
"container",
",",
"final",
"int",
"position",
")",
"{",
"if",
"(",
"Constants",
".",
"DEBUG",
")",
"{",
"Log",
".",
"i",
"(",
"\"InfiniteViewPager\"",
",",
"String",
... | This method is only called, when this pagerAdapter is initialized. | [
"This",
"method",
"is",
"only",
"called",
"when",
"this",
"pagerAdapter",
"is",
"initialized",
"."
] | cb3ca2a3833bbb3aeef02b9693787987b970bb89 | https://github.com/hayribakici/infiniteviewpager/blob/cb3ca2a3833bbb3aeef02b9693787987b970bb89/infiniteviewpager/src/com/thehayro/view/InfinitePagerAdapter.java#L63-L72 | train |
hayribakici/infiniteviewpager | infiniteviewpager/src/com/thehayro/view/InfinitePagerAdapter.java | InfinitePagerAdapter.printPageModels | private void printPageModels(final String tag) {
for (int i = 0; i < PAGE_COUNT; i++) {
printPageModel(tag, mPageModels[i], i);
}
} | java | private void printPageModels(final String tag) {
for (int i = 0; i < PAGE_COUNT; i++) {
printPageModel(tag, mPageModels[i], i);
}
} | [
"private",
"void",
"printPageModels",
"(",
"final",
"String",
"tag",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"PAGE_COUNT",
";",
"i",
"++",
")",
"{",
"printPageModel",
"(",
"tag",
",",
"mPageModels",
"[",
"i",
"]",
",",
"i",
")",
... | Debug related methods | [
"Debug",
"related",
"methods"
] | cb3ca2a3833bbb3aeef02b9693787987b970bb89 | https://github.com/hayribakici/infiniteviewpager/blob/cb3ca2a3833bbb3aeef02b9693787987b970bb89/infiniteviewpager/src/com/thehayro/view/InfinitePagerAdapter.java#L239-L243 | train |
davidmoten/grumpy | grumpy-core/src/main/java/com/github/davidmoten/grumpy/core/Position.java | Position.predict | public final Position predict(double distanceKm, double courseDegrees) {
assertWithMsg(alt == 0.0, "Predictions only valid for Earth's surface");
double dr = distanceKm / EARTH_RADIUS_KM;
double latR = toRadians(lat);
double lonR = toRadians(lon);
double courseR = toRadians(courseDegrees);
double lat2Radians = asin(sin(latR) * cos(dr) + cos(latR) * sin(dr) * cos(courseR));
double lon2Radians = atan2(sin(courseR) * sin(dr) * cos(latR), cos(dr) - sin(latR)
* sin(lat2Radians));
double lon3Radians = mod(lonR + lon2Radians + PI, 2 * PI) - PI;
return new Position(FastMath.toDegrees(lat2Radians), FastMath.toDegrees(lon3Radians));
} | java | public final Position predict(double distanceKm, double courseDegrees) {
assertWithMsg(alt == 0.0, "Predictions only valid for Earth's surface");
double dr = distanceKm / EARTH_RADIUS_KM;
double latR = toRadians(lat);
double lonR = toRadians(lon);
double courseR = toRadians(courseDegrees);
double lat2Radians = asin(sin(latR) * cos(dr) + cos(latR) * sin(dr) * cos(courseR));
double lon2Radians = atan2(sin(courseR) * sin(dr) * cos(latR), cos(dr) - sin(latR)
* sin(lat2Radians));
double lon3Radians = mod(lonR + lon2Radians + PI, 2 * PI) - PI;
return new Position(FastMath.toDegrees(lat2Radians), FastMath.toDegrees(lon3Radians));
} | [
"public",
"final",
"Position",
"predict",
"(",
"double",
"distanceKm",
",",
"double",
"courseDegrees",
")",
"{",
"assertWithMsg",
"(",
"alt",
"==",
"0.0",
",",
"\"Predictions only valid for Earth's surface\"",
")",
";",
"double",
"dr",
"=",
"distanceKm",
"/",
"EAR... | Predicts position travelling along a great circle arc based on the
Haversine formula.
From http://www.movable-type.co.uk/scripts/latlong.html
@param distanceKm
@param courseDegrees
@return | [
"Predicts",
"position",
"travelling",
"along",
"a",
"great",
"circle",
"arc",
"based",
"on",
"the",
"Haversine",
"formula",
"."
] | f2d03e6b9771f15425fb3f76314837efc08c1233 | https://github.com/davidmoten/grumpy/blob/f2d03e6b9771f15425fb3f76314837efc08c1233/grumpy-core/src/main/java/com/github/davidmoten/grumpy/core/Position.java#L104-L115 | train |
davidmoten/grumpy | grumpy-core/src/main/java/com/github/davidmoten/grumpy/core/Position.java | Position.getBearingDegrees | public final double getBearingDegrees(Position position) {
double lat1 = toRadians(lat);
double lat2 = toRadians(position.lat);
double lon1 = toRadians(lon);
double lon2 = toRadians(position.lon);
double dLon = lon2 - lon1;
double sinDLon = sin(dLon);
double cosLat2 = cos(lat2);
double y = sinDLon * cosLat2;
double x = cos(lat1) * sin(lat2) - sin(lat1) * cosLat2 * cos(dLon);
double course = FastMath.toDegrees(atan2(y, x));
if (course < 0)
course += 360;
return course;
} | java | public final double getBearingDegrees(Position position) {
double lat1 = toRadians(lat);
double lat2 = toRadians(position.lat);
double lon1 = toRadians(lon);
double lon2 = toRadians(position.lon);
double dLon = lon2 - lon1;
double sinDLon = sin(dLon);
double cosLat2 = cos(lat2);
double y = sinDLon * cosLat2;
double x = cos(lat1) * sin(lat2) - sin(lat1) * cosLat2 * cos(dLon);
double course = FastMath.toDegrees(atan2(y, x));
if (course < 0)
course += 360;
return course;
} | [
"public",
"final",
"double",
"getBearingDegrees",
"(",
"Position",
"position",
")",
"{",
"double",
"lat1",
"=",
"toRadians",
"(",
"lat",
")",
";",
"double",
"lat2",
"=",
"toRadians",
"(",
"position",
".",
"lat",
")",
";",
"double",
"lon1",
"=",
"toRadians"... | Returns a great circle bearing in degrees in the range 0 to 360.
@param position
@return | [
"Returns",
"a",
"great",
"circle",
"bearing",
"in",
"degrees",
"in",
"the",
"range",
"0",
"to",
"360",
"."
] | f2d03e6b9771f15425fb3f76314837efc08c1233 | https://github.com/davidmoten/grumpy/blob/f2d03e6b9771f15425fb3f76314837efc08c1233/grumpy-core/src/main/java/com/github/davidmoten/grumpy/core/Position.java#L290-L304 | train |
davidmoten/grumpy | grumpy-core/src/main/java/com/github/davidmoten/grumpy/core/Position.java | Position.getBearingDifferenceDegrees | public static double getBearingDifferenceDegrees(double bearing1, double bearing2) {
if (bearing1 < 0)
bearing1 += 360;
if (bearing2 > 180)
bearing2 -= 360;
double result = bearing1 - bearing2;
if (result > 180)
result -= 360;
return result;
} | java | public static double getBearingDifferenceDegrees(double bearing1, double bearing2) {
if (bearing1 < 0)
bearing1 += 360;
if (bearing2 > 180)
bearing2 -= 360;
double result = bearing1 - bearing2;
if (result > 180)
result -= 360;
return result;
} | [
"public",
"static",
"double",
"getBearingDifferenceDegrees",
"(",
"double",
"bearing1",
",",
"double",
"bearing2",
")",
"{",
"if",
"(",
"bearing1",
"<",
"0",
")",
"bearing1",
"+=",
"360",
";",
"if",
"(",
"bearing2",
">",
"180",
")",
"bearing2",
"-=",
"360"... | returns difference in degrees in the range -180 to 180
@param bearing1
degrees between -360 and 360
@param bearing2
degrees between -360 and 360
@return | [
"returns",
"difference",
"in",
"degrees",
"in",
"the",
"range",
"-",
"180",
"to",
"180"
] | f2d03e6b9771f15425fb3f76314837efc08c1233 | https://github.com/davidmoten/grumpy/blob/f2d03e6b9771f15425fb3f76314837efc08c1233/grumpy-core/src/main/java/com/github/davidmoten/grumpy/core/Position.java#L315-L324 | train |
davidmoten/grumpy | grumpy-core/src/main/java/com/github/davidmoten/grumpy/core/Position.java | Position.getPositionAlongPath | public final Position getPositionAlongPath(Position position, double proportion) {
if (proportion >= 0 && proportion <= 1) {
// Get bearing degrees for course
double courseDegrees = this.getBearingDegrees(position);
// Get distance from position arg and this objects location
double distanceKm = this.getDistanceToKm(position);
// Predict the position for a proportion of the course
// where this object is the start position and the arg
// is the destination position.
Position retPosition = this.predict(proportion * distanceKm, courseDegrees);
return retPosition;
} else
throw new RuntimeException("Proportion must be between 0 and 1 inclusive");
} | java | public final Position getPositionAlongPath(Position position, double proportion) {
if (proportion >= 0 && proportion <= 1) {
// Get bearing degrees for course
double courseDegrees = this.getBearingDegrees(position);
// Get distance from position arg and this objects location
double distanceKm = this.getDistanceToKm(position);
// Predict the position for a proportion of the course
// where this object is the start position and the arg
// is the destination position.
Position retPosition = this.predict(proportion * distanceKm, courseDegrees);
return retPosition;
} else
throw new RuntimeException("Proportion must be between 0 and 1 inclusive");
} | [
"public",
"final",
"Position",
"getPositionAlongPath",
"(",
"Position",
"position",
",",
"double",
"proportion",
")",
"{",
"if",
"(",
"proportion",
">=",
"0",
"&&",
"proportion",
"<=",
"1",
")",
"{",
"// Get bearing degrees for course",
"double",
"courseDegrees",
... | Returns a position along a path according to the proportion value
@param position
@param proportion
is between 0 and 1 inclusive
@return | [
"Returns",
"a",
"position",
"along",
"a",
"path",
"according",
"to",
"the",
"proportion",
"value"
] | f2d03e6b9771f15425fb3f76314837efc08c1233 | https://github.com/davidmoten/grumpy/blob/f2d03e6b9771f15425fb3f76314837efc08c1233/grumpy-core/src/main/java/com/github/davidmoten/grumpy/core/Position.java#L387-L405 | train |
davidmoten/grumpy | grumpy-core/src/main/java/com/github/davidmoten/grumpy/core/Position.java | Position.longitudeDiff | public static double longitudeDiff(double a, double b) {
a = to180(a);
b = to180(b);
return Math.abs(to180(a - b));
} | java | public static double longitudeDiff(double a, double b) {
a = to180(a);
b = to180(b);
return Math.abs(to180(a - b));
} | [
"public",
"static",
"double",
"longitudeDiff",
"(",
"double",
"a",
",",
"double",
"b",
")",
"{",
"a",
"=",
"to180",
"(",
"a",
")",
";",
"b",
"=",
"to180",
"(",
"b",
")",
";",
"return",
"Math",
".",
"abs",
"(",
"to180",
"(",
"a",
"-",
"b",
")",
... | Returns the difference between two longitude values. The returned value
is always >=0.
@param a
@param b
@return | [
"Returns",
"the",
"difference",
"between",
"two",
"longitude",
"values",
".",
"The",
"returned",
"value",
"is",
"always",
">",
"=",
"0",
"."
] | f2d03e6b9771f15425fb3f76314837efc08c1233 | https://github.com/davidmoten/grumpy/blob/f2d03e6b9771f15425fb3f76314837efc08c1233/grumpy-core/src/main/java/com/github/davidmoten/grumpy/core/Position.java#L568-L572 | train |
davidmoten/grumpy | grumpy-core/src/main/java/com/github/davidmoten/grumpy/core/Position.java | Position.to180 | public static double to180(double d) {
if (d < 0)
return -to180(abs(d));
else {
if (d > 180) {
long n = round(floor((d + 180) / 360.0));
return d - n * 360;
} else
return d;
}
} | java | public static double to180(double d) {
if (d < 0)
return -to180(abs(d));
else {
if (d > 180) {
long n = round(floor((d + 180) / 360.0));
return d - n * 360;
} else
return d;
}
} | [
"public",
"static",
"double",
"to180",
"(",
"double",
"d",
")",
"{",
"if",
"(",
"d",
"<",
"0",
")",
"return",
"-",
"to180",
"(",
"abs",
"(",
"d",
")",
")",
";",
"else",
"{",
"if",
"(",
"d",
">",
"180",
")",
"{",
"long",
"n",
"=",
"round",
"... | Converts an angle in degrees to range -180< x <= 180.
@param d
@return | [
"Converts",
"an",
"angle",
"in",
"degrees",
"to",
"range",
"-",
"180<",
"x",
"<",
"=",
"180",
"."
] | f2d03e6b9771f15425fb3f76314837efc08c1233 | https://github.com/davidmoten/grumpy/blob/f2d03e6b9771f15425fb3f76314837efc08c1233/grumpy-core/src/main/java/com/github/davidmoten/grumpy/core/Position.java#L580-L590 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.