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
sequence | docstring
stringlengths 3
16k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 105
339
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
mgormley/optimize | src/main/java/edu/jhu/hlt/optimize/function/SampleFunction.java | SampleFunction.convertBatch | private int[] convertBatch(int[] batch) {
int[] conv = new int[batch.length];
for (int i=0; i<batch.length; i++) {
conv[i] = sample[batch[i]];
}
return conv;
} | java | private int[] convertBatch(int[] batch) {
int[] conv = new int[batch.length];
for (int i=0; i<batch.length; i++) {
conv[i] = sample[batch[i]];
}
return conv;
} | [
"private",
"int",
"[",
"]",
"convertBatch",
"(",
"int",
"[",
"]",
"batch",
")",
"{",
"int",
"[",
"]",
"conv",
"=",
"new",
"int",
"[",
"batch",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"batch",
".",
"length",
";",
"i",
"++",
")",
"{",
"conv",
"[",
"i",
"]",
"=",
"sample",
"[",
"batch",
"[",
"i",
"]",
"]",
";",
"}",
"return",
"conv",
";",
"}"
] | Converts a batch indexing into the sample, to a batch indexing into the
original function.
@param batch The batch indexing into the sample.
@return A new batch indexing into the original function, containing only
the indices from the sample. | [
"Converts",
"a",
"batch",
"indexing",
"into",
"the",
"sample",
"to",
"a",
"batch",
"indexing",
"into",
"the",
"original",
"function",
"."
] | 3d1b93260b99febb8a5ecd9e8543c223e151a8d3 | https://github.com/mgormley/optimize/blob/3d1b93260b99febb8a5ecd9e8543c223e151a8d3/src/main/java/edu/jhu/hlt/optimize/function/SampleFunction.java#L37-L43 | train |
Canadensys/canadensys-core | src/main/java/net/canadensys/utils/ListUtils.java | ListUtils.containsAtLeastOneNonBlank | public static boolean containsAtLeastOneNonBlank(List<String> list){
for(String str : list){
if(StringUtils.isNotBlank(str)){
return true;
}
}
return false;
} | java | public static boolean containsAtLeastOneNonBlank(List<String> list){
for(String str : list){
if(StringUtils.isNotBlank(str)){
return true;
}
}
return false;
} | [
"public",
"static",
"boolean",
"containsAtLeastOneNonBlank",
"(",
"List",
"<",
"String",
">",
"list",
")",
"{",
"for",
"(",
"String",
"str",
":",
"list",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isNotBlank",
"(",
"str",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Check that a list allowing null and empty item contains at least one element that is
not blank.
@param list can't be null
@return | [
"Check",
"that",
"a",
"list",
"allowing",
"null",
"and",
"empty",
"item",
"contains",
"at",
"least",
"one",
"element",
"that",
"is",
"not",
"blank",
"."
] | 5e13569f7c0f4cdc7080da72643ff61123ad76fd | https://github.com/Canadensys/canadensys-core/blob/5e13569f7c0f4cdc7080da72643ff61123ad76fd/src/main/java/net/canadensys/utils/ListUtils.java#L21-L28 | train |
Canadensys/canadensys-core | src/main/java/net/canadensys/utils/ListUtils.java | ListUtils.toIntegerList | public static List<Integer> toIntegerList(List<String> strList, boolean failOnException){
List<Integer> intList = new ArrayList<Integer>();
for(String str : strList){
try{
intList.add(Integer.parseInt(str));
}
catch(NumberFormatException nfe){
if(failOnException){
return null;
}
else{
intList.add(null);
}
}
}
return intList;
} | java | public static List<Integer> toIntegerList(List<String> strList, boolean failOnException){
List<Integer> intList = new ArrayList<Integer>();
for(String str : strList){
try{
intList.add(Integer.parseInt(str));
}
catch(NumberFormatException nfe){
if(failOnException){
return null;
}
else{
intList.add(null);
}
}
}
return intList;
} | [
"public",
"static",
"List",
"<",
"Integer",
">",
"toIntegerList",
"(",
"List",
"<",
"String",
">",
"strList",
",",
"boolean",
"failOnException",
")",
"{",
"List",
"<",
"Integer",
">",
"intList",
"=",
"new",
"ArrayList",
"<",
"Integer",
">",
"(",
")",
";",
"for",
"(",
"String",
"str",
":",
"strList",
")",
"{",
"try",
"{",
"intList",
".",
"add",
"(",
"Integer",
".",
"parseInt",
"(",
"str",
")",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"nfe",
")",
"{",
"if",
"(",
"failOnException",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"intList",
".",
"add",
"(",
"null",
")",
";",
"}",
"}",
"}",
"return",
"intList",
";",
"}"
] | Parse a list of String into a list of Integer.
If one element can not be parsed, the behavior depends on the value of failOnException.
@param strList can't be null
@param failOnException if an element can not be parsed should we return null or add a null element to the list.
@return list of all String parsed as Integer or null if failOnException | [
"Parse",
"a",
"list",
"of",
"String",
"into",
"a",
"list",
"of",
"Integer",
".",
"If",
"one",
"element",
"can",
"not",
"be",
"parsed",
"the",
"behavior",
"depends",
"on",
"the",
"value",
"of",
"failOnException",
"."
] | 5e13569f7c0f4cdc7080da72643ff61123ad76fd | https://github.com/Canadensys/canadensys-core/blob/5e13569f7c0f4cdc7080da72643ff61123ad76fd/src/main/java/net/canadensys/utils/ListUtils.java#L37-L53 | train |
mgormley/optimize | src/main/java/edu/jhu/hlt/util/math/Vectors.java | Vectors.add | public static void add(double[] array1, double[] array2) {
assert (array1.length == array2.length);
for (int i=0; i<array1.length; i++) {
array1[i] += array2[i];
}
} | java | public static void add(double[] array1, double[] array2) {
assert (array1.length == array2.length);
for (int i=0; i<array1.length; i++) {
array1[i] += array2[i];
}
} | [
"public",
"static",
"void",
"add",
"(",
"double",
"[",
"]",
"array1",
",",
"double",
"[",
"]",
"array2",
")",
"{",
"assert",
"(",
"array1",
".",
"length",
"==",
"array2",
".",
"length",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"array1",
".",
"length",
";",
"i",
"++",
")",
"{",
"array1",
"[",
"i",
"]",
"+=",
"array2",
"[",
"i",
"]",
";",
"}",
"}"
] | Each element of the second array is added to each element of the first. | [
"Each",
"element",
"of",
"the",
"second",
"array",
"is",
"added",
"to",
"each",
"element",
"of",
"the",
"first",
"."
] | 3d1b93260b99febb8a5ecd9e8543c223e151a8d3 | https://github.com/mgormley/optimize/blob/3d1b93260b99febb8a5ecd9e8543c223e151a8d3/src/main/java/edu/jhu/hlt/util/math/Vectors.java#L233-L238 | train |
Canadensys/canadensys-core | src/main/java/net/canadensys/utils/ArrayUtils.java | ArrayUtils.containsOnlyNull | public static boolean containsOnlyNull(Object... values){
for(Object o : values){
if(o!= null){
return false;
}
}
return true;
} | java | public static boolean containsOnlyNull(Object... values){
for(Object o : values){
if(o!= null){
return false;
}
}
return true;
} | [
"public",
"static",
"boolean",
"containsOnlyNull",
"(",
"Object",
"...",
"values",
")",
"{",
"for",
"(",
"Object",
"o",
":",
"values",
")",
"{",
"if",
"(",
"o",
"!=",
"null",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Check that an array only contains null elements.
@param values, can't be null
@return | [
"Check",
"that",
"an",
"array",
"only",
"contains",
"null",
"elements",
"."
] | 5e13569f7c0f4cdc7080da72643ff61123ad76fd | https://github.com/Canadensys/canadensys-core/blob/5e13569f7c0f4cdc7080da72643ff61123ad76fd/src/main/java/net/canadensys/utils/ArrayUtils.java#L17-L24 | train |
Canadensys/canadensys-core | src/main/java/net/canadensys/utils/ArrayUtils.java | ArrayUtils.containsOnlyNotNull | public static boolean containsOnlyNotNull(Object... values){
for(Object o : values){
if(o== null){
return false;
}
}
return true;
} | java | public static boolean containsOnlyNotNull(Object... values){
for(Object o : values){
if(o== null){
return false;
}
}
return true;
} | [
"public",
"static",
"boolean",
"containsOnlyNotNull",
"(",
"Object",
"...",
"values",
")",
"{",
"for",
"(",
"Object",
"o",
":",
"values",
")",
"{",
"if",
"(",
"o",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Check that an array only contains elements that are not null.
@param values, can't be null
@return | [
"Check",
"that",
"an",
"array",
"only",
"contains",
"elements",
"that",
"are",
"not",
"null",
"."
] | 5e13569f7c0f4cdc7080da72643ff61123ad76fd | https://github.com/Canadensys/canadensys-core/blob/5e13569f7c0f4cdc7080da72643ff61123ad76fd/src/main/java/net/canadensys/utils/ArrayUtils.java#L31-L38 | train |
matiwinnetou/spring-soy-view | spring-soy-view-ajax-compiler/src/main/java/pl/matisoft/soy/ajax/SoyAjaxController.java | SoyAjaxController.compile | @RequestMapping(value="/soy/compileJs", method=GET)
public ResponseEntity<String> compile(@RequestParam(required = false, value="hash", defaultValue = "") final String hash,
@RequestParam(required = true, value = "file") final String[] templateFileNames,
@RequestParam(required = false, value = "locale") String locale,
@RequestParam(required = false, value = "disableProcessors", defaultValue = "false") String disableProcessors,
final HttpServletRequest request) throws IOException {
return compileJs(templateFileNames, hash, new Boolean(disableProcessors).booleanValue(), request, locale);
} | java | @RequestMapping(value="/soy/compileJs", method=GET)
public ResponseEntity<String> compile(@RequestParam(required = false, value="hash", defaultValue = "") final String hash,
@RequestParam(required = true, value = "file") final String[] templateFileNames,
@RequestParam(required = false, value = "locale") String locale,
@RequestParam(required = false, value = "disableProcessors", defaultValue = "false") String disableProcessors,
final HttpServletRequest request) throws IOException {
return compileJs(templateFileNames, hash, new Boolean(disableProcessors).booleanValue(), request, locale);
} | [
"@",
"RequestMapping",
"(",
"value",
"=",
"\"/soy/compileJs\"",
",",
"method",
"=",
"GET",
")",
"public",
"ResponseEntity",
"<",
"String",
">",
"compile",
"(",
"@",
"RequestParam",
"(",
"required",
"=",
"false",
",",
"value",
"=",
"\"hash\"",
",",
"defaultValue",
"=",
"\"\"",
")",
"final",
"String",
"hash",
",",
"@",
"RequestParam",
"(",
"required",
"=",
"true",
",",
"value",
"=",
"\"file\"",
")",
"final",
"String",
"[",
"]",
"templateFileNames",
",",
"@",
"RequestParam",
"(",
"required",
"=",
"false",
",",
"value",
"=",
"\"locale\"",
")",
"String",
"locale",
",",
"@",
"RequestParam",
"(",
"required",
"=",
"false",
",",
"value",
"=",
"\"disableProcessors\"",
",",
"defaultValue",
"=",
"\"false\"",
")",
"String",
"disableProcessors",
",",
"final",
"HttpServletRequest",
"request",
")",
"throws",
"IOException",
"{",
"return",
"compileJs",
"(",
"templateFileNames",
",",
"hash",
",",
"new",
"Boolean",
"(",
"disableProcessors",
")",
".",
"booleanValue",
"(",
")",
",",
"request",
",",
"locale",
")",
";",
"}"
] | An endpoint to compile an array of soy templates to JavaScript.
This endpoint is a preferred way of compiling soy templates to JavaScript but it requires a user to compose a url
on their own or using a helper class TemplateUrlComposer, which calculates checksum of a file and puts this in url
so that whenever a file changes, after a deployment a JavaScript, url changes and a new hash is appended to url, which enforces
getting of new compiles JavaScript resource.
Invocation of this url may throw two types of http exceptions:
1. notFound - usually when a TemplateResolver cannot find a template with an associated name
2. error - usually when there is a permission error and a user is not allowed to compile a template into a JavaScript
@param hash - some unique number that should be used when we are caching this resource in a browser and we use http cache headers
@param templateFileNames - an array of template names, e.g. client-words,server-time, which may or may not contain extension
currently three modes are supported - soy extension, js extension and no extension, which is preferred
@param disableProcessors - whether the controller should run registered outputProcessors after the compilation is complete.
@param request - HttpServletRequest
@param locale - locale
@return response entity, which wraps a compiled soy to JavaScript files.
@throws IOException - io error | [
"An",
"endpoint",
"to",
"compile",
"an",
"array",
"of",
"soy",
"templates",
"to",
"JavaScript",
"."
] | a27c1b2bc76b074a2753ddd7b0c7f685c883d1d1 | https://github.com/matiwinnetou/spring-soy-view/blob/a27c1b2bc76b074a2753ddd7b0c7f685c883d1d1/spring-soy-view-ajax-compiler/src/main/java/pl/matisoft/soy/ajax/SoyAjaxController.java#L156-L163 | train |
mgormley/optimize | src/main/java/edu/jhu/hlt/optimize/BatchSampler.java | BatchSampler.sampleBatchWithReplacement | public int[] sampleBatchWithReplacement() {
// Sample the indices with replacement.
int[] batch = new int[batchSize];
for (int i=0; i<batch.length; i++) {
batch[i] = Prng.nextInt(numExamples);
}
return batch;
} | java | public int[] sampleBatchWithReplacement() {
// Sample the indices with replacement.
int[] batch = new int[batchSize];
for (int i=0; i<batch.length; i++) {
batch[i] = Prng.nextInt(numExamples);
}
return batch;
} | [
"public",
"int",
"[",
"]",
"sampleBatchWithReplacement",
"(",
")",
"{",
"// Sample the indices with replacement.",
"int",
"[",
"]",
"batch",
"=",
"new",
"int",
"[",
"batchSize",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"batch",
".",
"length",
";",
"i",
"++",
")",
"{",
"batch",
"[",
"i",
"]",
"=",
"Prng",
".",
"nextInt",
"(",
"numExamples",
")",
";",
"}",
"return",
"batch",
";",
"}"
] | Samples a batch of indices in the range [0, numExamples) with replacement. | [
"Samples",
"a",
"batch",
"of",
"indices",
"in",
"the",
"range",
"[",
"0",
"numExamples",
")",
"with",
"replacement",
"."
] | 3d1b93260b99febb8a5ecd9e8543c223e151a8d3 | https://github.com/mgormley/optimize/blob/3d1b93260b99febb8a5ecd9e8543c223e151a8d3/src/main/java/edu/jhu/hlt/optimize/BatchSampler.java#L56-L63 | train |
mgormley/optimize | src/main/java/edu/jhu/hlt/optimize/BatchSampler.java | BatchSampler.sampleBatchWithoutReplacement | public int[] sampleBatchWithoutReplacement() {
int[] batch = new int[batchSize];
for (int i=0; i<batch.length; i++) {
if (cur == indices.length) {
cur = 0;
}
if (cur == 0) {
IntArrays.shuffle(indices);
}
batch[i] = indices[cur++];
}
return batch;
} | java | public int[] sampleBatchWithoutReplacement() {
int[] batch = new int[batchSize];
for (int i=0; i<batch.length; i++) {
if (cur == indices.length) {
cur = 0;
}
if (cur == 0) {
IntArrays.shuffle(indices);
}
batch[i] = indices[cur++];
}
return batch;
} | [
"public",
"int",
"[",
"]",
"sampleBatchWithoutReplacement",
"(",
")",
"{",
"int",
"[",
"]",
"batch",
"=",
"new",
"int",
"[",
"batchSize",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"batch",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"cur",
"==",
"indices",
".",
"length",
")",
"{",
"cur",
"=",
"0",
";",
"}",
"if",
"(",
"cur",
"==",
"0",
")",
"{",
"IntArrays",
".",
"shuffle",
"(",
"indices",
")",
";",
"}",
"batch",
"[",
"i",
"]",
"=",
"indices",
"[",
"cur",
"++",
"]",
";",
"}",
"return",
"batch",
";",
"}"
] | Samples a batch of indices in the range [0, numExamples) without replacement. | [
"Samples",
"a",
"batch",
"of",
"indices",
"in",
"the",
"range",
"[",
"0",
"numExamples",
")",
"without",
"replacement",
"."
] | 3d1b93260b99febb8a5ecd9e8543c223e151a8d3 | https://github.com/mgormley/optimize/blob/3d1b93260b99febb8a5ecd9e8543c223e151a8d3/src/main/java/edu/jhu/hlt/optimize/BatchSampler.java#L66-L78 | train |
tractionsoftware/gwt-traction | src/main/java/com/tractionsoftware/gwt/user/client/ui/TractionDialogBox.java | TractionDialogBox.adjustGlassSize | public void adjustGlassSize() {
if (isGlassEnabled()) {
ResizeHandler handler = getGlassResizer();
if (handler != null) handler.onResize(null);
}
} | java | public void adjustGlassSize() {
if (isGlassEnabled()) {
ResizeHandler handler = getGlassResizer();
if (handler != null) handler.onResize(null);
}
} | [
"public",
"void",
"adjustGlassSize",
"(",
")",
"{",
"if",
"(",
"isGlassEnabled",
"(",
")",
")",
"{",
"ResizeHandler",
"handler",
"=",
"getGlassResizer",
"(",
")",
";",
"if",
"(",
"handler",
"!=",
"null",
")",
"handler",
".",
"onResize",
"(",
"null",
")",
";",
"}",
"}"
] | This can be called to adjust the size of the dialog glass. It
is implemented using JSNI to bypass the "private" keyword on
the glassResizer. | [
"This",
"can",
"be",
"called",
"to",
"adjust",
"the",
"size",
"of",
"the",
"dialog",
"glass",
".",
"It",
"is",
"implemented",
"using",
"JSNI",
"to",
"bypass",
"the",
"private",
"keyword",
"on",
"the",
"glassResizer",
"."
] | efc1423c619439763fb064b777b7235e9ce414a3 | https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/ui/TractionDialogBox.java#L201-L206 | train |
mgormley/optimize | src/main/java/edu/jhu/hlt/optimize/function/Bounds.java | Bounds.getSymmetricBounds | public static Bounds getSymmetricBounds(int dim, double l, double u) {
double [] L = new double[dim];
double [] U = new double[dim];
for(int i=0; i<dim; i++) {
L[i] = l;
U[i] = u;
}
return new Bounds(L, U);
} | java | public static Bounds getSymmetricBounds(int dim, double l, double u) {
double [] L = new double[dim];
double [] U = new double[dim];
for(int i=0; i<dim; i++) {
L[i] = l;
U[i] = u;
}
return new Bounds(L, U);
} | [
"public",
"static",
"Bounds",
"getSymmetricBounds",
"(",
"int",
"dim",
",",
"double",
"l",
",",
"double",
"u",
")",
"{",
"double",
"[",
"]",
"L",
"=",
"new",
"double",
"[",
"dim",
"]",
";",
"double",
"[",
"]",
"U",
"=",
"new",
"double",
"[",
"dim",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"dim",
";",
"i",
"++",
")",
"{",
"L",
"[",
"i",
"]",
"=",
"l",
";",
"U",
"[",
"i",
"]",
"=",
"u",
";",
"}",
"return",
"new",
"Bounds",
"(",
"L",
",",
"U",
")",
";",
"}"
] | Gets bounds which are identical for all dimensions.
@param dim The number of dimensions.
@param l The value of all lower bounds.
@param u The value of all upper bounds.
@return The new bounds. | [
"Gets",
"bounds",
"which",
"are",
"identical",
"for",
"all",
"dimensions",
"."
] | 3d1b93260b99febb8a5ecd9e8543c223e151a8d3 | https://github.com/mgormley/optimize/blob/3d1b93260b99febb8a5ecd9e8543c223e151a8d3/src/main/java/edu/jhu/hlt/optimize/function/Bounds.java#L67-L75 | train |
httpcache4j/httpcache4j | httpcache4j-api/src/main/java/org/codehaus/httpcache4j/Tag.java | Tag.parse | public static Optional<Tag> parse(final String httpTag) {
Tag result = null;
boolean weak = false;
String internal = httpTag;
if (internal.startsWith("W/")) {
weak = true;
internal = internal.substring(2);
}
if (internal.startsWith("\"") && internal.endsWith("\"")) {
result = new Tag(
internal.substring(1, internal.length() - 1), weak);
}
else if (internal.equals("*")) {
result = new Tag("*", weak);
}
return Optional.ofNullable(result);
} | java | public static Optional<Tag> parse(final String httpTag) {
Tag result = null;
boolean weak = false;
String internal = httpTag;
if (internal.startsWith("W/")) {
weak = true;
internal = internal.substring(2);
}
if (internal.startsWith("\"") && internal.endsWith("\"")) {
result = new Tag(
internal.substring(1, internal.length() - 1), weak);
}
else if (internal.equals("*")) {
result = new Tag("*", weak);
}
return Optional.ofNullable(result);
} | [
"public",
"static",
"Optional",
"<",
"Tag",
">",
"parse",
"(",
"final",
"String",
"httpTag",
")",
"{",
"Tag",
"result",
"=",
"null",
";",
"boolean",
"weak",
"=",
"false",
";",
"String",
"internal",
"=",
"httpTag",
";",
"if",
"(",
"internal",
".",
"startsWith",
"(",
"\"W/\"",
")",
")",
"{",
"weak",
"=",
"true",
";",
"internal",
"=",
"internal",
".",
"substring",
"(",
"2",
")",
";",
"}",
"if",
"(",
"internal",
".",
"startsWith",
"(",
"\"\\\"\"",
")",
"&&",
"internal",
".",
"endsWith",
"(",
"\"\\\"\"",
")",
")",
"{",
"result",
"=",
"new",
"Tag",
"(",
"internal",
".",
"substring",
"(",
"1",
",",
"internal",
".",
"length",
"(",
")",
"-",
"1",
")",
",",
"weak",
")",
";",
"}",
"else",
"if",
"(",
"internal",
".",
"equals",
"(",
"\"*\"",
")",
")",
"{",
"result",
"=",
"new",
"Tag",
"(",
"\"*\"",
",",
"weak",
")",
";",
"}",
"return",
"Optional",
".",
"ofNullable",
"(",
"result",
")",
";",
"}"
] | Parses a tag formatted as defined by the HTTP standard.
@param httpTag The HTTP tag string; if it starts with 'W/' the tag will be
marked as weak and the data following the 'W/' used as the tag;
otherwise it should be surrounded with quotes (e.g.,
"sometag").
@return A new tag instance.
@see <a
href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.11">HTTP
Entity Tags</a> | [
"Parses",
"a",
"tag",
"formatted",
"as",
"defined",
"by",
"the",
"HTTP",
"standard",
"."
] | 9c07ebd63cd104a99eb9e771f760f14efa4fe0f6 | https://github.com/httpcache4j/httpcache4j/blob/9c07ebd63cd104a99eb9e771f760f14efa4fe0f6/httpcache4j-api/src/main/java/org/codehaus/httpcache4j/Tag.java#L58-L77 | train |
httpcache4j/httpcache4j | httpcache4j-api/src/main/java/org/codehaus/httpcache4j/Tag.java | Tag.format | public String format() {
if (getName().equals("*")) {
return "*";
}
else {
StringBuilder sb = new StringBuilder();
if (isWeak()) {
sb.append("W/");
}
return sb.append('"').append(getName()).append('"').toString();
}
} | java | public String format() {
if (getName().equals("*")) {
return "*";
}
else {
StringBuilder sb = new StringBuilder();
if (isWeak()) {
sb.append("W/");
}
return sb.append('"').append(getName()).append('"').toString();
}
} | [
"public",
"String",
"format",
"(",
")",
"{",
"if",
"(",
"getName",
"(",
")",
".",
"equals",
"(",
"\"*\"",
")",
")",
"{",
"return",
"\"*\"",
";",
"}",
"else",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"isWeak",
"(",
")",
")",
"{",
"sb",
".",
"append",
"(",
"\"W/\"",
")",
";",
"}",
"return",
"sb",
".",
"append",
"(",
"'",
"'",
")",
".",
"append",
"(",
"getName",
"(",
")",
")",
".",
"append",
"(",
"'",
"'",
")",
".",
"toString",
"(",
")",
";",
"}",
"}"
] | Returns tag formatted as an HTTP tag string.
@return The formatted HTTP tag string.
@see <a
href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.11">HTTP
Entity Tags</a> | [
"Returns",
"tag",
"formatted",
"as",
"an",
"HTTP",
"tag",
"string",
"."
] | 9c07ebd63cd104a99eb9e771f760f14efa4fe0f6 | https://github.com/httpcache4j/httpcache4j/blob/9c07ebd63cd104a99eb9e771f760f14efa4fe0f6/httpcache4j-api/src/main/java/org/codehaus/httpcache4j/Tag.java#L151-L162 | train |
Canadensys/canadensys-core | src/main/java/net/canadensys/bundle/UTF8PropertyResourceBundle.java | UTF8PropertyResourceBundle.getBundle | public static PropertyResourceBundle getBundle(String baseName, Locale locale) throws UnsupportedEncodingException, IOException{
InputStream is = UTF8PropertyResourceBundle.class.getResourceAsStream("/"+baseName + "_"+locale.toString()+PROPERTIES_EXT);
if(is != null){
return new PropertyResourceBundle(new InputStreamReader(is, "UTF-8"));
}
return null;
} | java | public static PropertyResourceBundle getBundle(String baseName, Locale locale) throws UnsupportedEncodingException, IOException{
InputStream is = UTF8PropertyResourceBundle.class.getResourceAsStream("/"+baseName + "_"+locale.toString()+PROPERTIES_EXT);
if(is != null){
return new PropertyResourceBundle(new InputStreamReader(is, "UTF-8"));
}
return null;
} | [
"public",
"static",
"PropertyResourceBundle",
"getBundle",
"(",
"String",
"baseName",
",",
"Locale",
"locale",
")",
"throws",
"UnsupportedEncodingException",
",",
"IOException",
"{",
"InputStream",
"is",
"=",
"UTF8PropertyResourceBundle",
".",
"class",
".",
"getResourceAsStream",
"(",
"\"/\"",
"+",
"baseName",
"+",
"\"_\"",
"+",
"locale",
".",
"toString",
"(",
")",
"+",
"PROPERTIES_EXT",
")",
";",
"if",
"(",
"is",
"!=",
"null",
")",
"{",
"return",
"new",
"PropertyResourceBundle",
"(",
"new",
"InputStreamReader",
"(",
"is",
",",
"\"UTF-8\"",
")",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Get a PropertyResourceBundle able to read an UTF-8 properties file.
@param baseName
@param locale
@return new ResourceBundle or null if no bundle can be found.
@throws UnsupportedEncodingException
@throws IOException | [
"Get",
"a",
"PropertyResourceBundle",
"able",
"to",
"read",
"an",
"UTF",
"-",
"8",
"properties",
"file",
"."
] | 5e13569f7c0f4cdc7080da72643ff61123ad76fd | https://github.com/Canadensys/canadensys-core/blob/5e13569f7c0f4cdc7080da72643ff61123ad76fd/src/main/java/net/canadensys/bundle/UTF8PropertyResourceBundle.java#L26-L32 | train |
mgormley/optimize | src/main/java/edu/jhu/hlt/optimize/SGD.java | SGD.minimize | @Override
public boolean minimize(DifferentiableBatchFunction function, IntDoubleVector point) {
return minimize(function, point, null);
} | java | @Override
public boolean minimize(DifferentiableBatchFunction function, IntDoubleVector point) {
return minimize(function, point, null);
} | [
"@",
"Override",
"public",
"boolean",
"minimize",
"(",
"DifferentiableBatchFunction",
"function",
",",
"IntDoubleVector",
"point",
")",
"{",
"return",
"minimize",
"(",
"function",
",",
"point",
",",
"null",
")",
";",
"}"
] | Minimize the function starting at the given initial point. | [
"Minimize",
"the",
"function",
"starting",
"at",
"the",
"given",
"initial",
"point",
"."
] | 3d1b93260b99febb8a5ecd9e8543c223e151a8d3 | https://github.com/mgormley/optimize/blob/3d1b93260b99febb8a5ecd9e8543c223e151a8d3/src/main/java/edu/jhu/hlt/optimize/SGD.java#L87-L90 | train |
cchabanois/transmorph | src/main/java/net/entropysoft/transmorph/converters/beans/AbstractSimpleBeanConverter.java | AbstractSimpleBeanConverter.convertElement | @SuppressWarnings("unchecked")
public <T> T convertElement(ConversionContext context, Object source,
TypeReference<T> destinationType) throws ConverterException {
return (T) elementConverter.convert(context, source, destinationType);
} | java | @SuppressWarnings("unchecked")
public <T> T convertElement(ConversionContext context, Object source,
TypeReference<T> destinationType) throws ConverterException {
return (T) elementConverter.convert(context, source, destinationType);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"T",
">",
"T",
"convertElement",
"(",
"ConversionContext",
"context",
",",
"Object",
"source",
",",
"TypeReference",
"<",
"T",
">",
"destinationType",
")",
"throws",
"ConverterException",
"{",
"return",
"(",
"T",
")",
"elementConverter",
".",
"convert",
"(",
"context",
",",
"source",
",",
"destinationType",
")",
";",
"}"
] | Convert element to another object given a parameterized type signature
@param context
@param destinationType
the destination type
@param source
the source object
@return the converted object
@throws ConverterException
if conversion failed | [
"Convert",
"element",
"to",
"another",
"object",
"given",
"a",
"parameterized",
"type",
"signature"
] | 118550f30b9680a84eab7496bd8b04118740dcec | https://github.com/cchabanois/transmorph/blob/118550f30b9680a84eab7496bd8b04118740dcec/src/main/java/net/entropysoft/transmorph/converters/beans/AbstractSimpleBeanConverter.java#L78-L82 | train |
httpcache4j/httpcache4j | httpcache4j-api/src/main/java/org/codehaus/httpcache4j/Conditionals.java | Conditionals.addIfMatch | public Conditionals addIfMatch(Tag tag) {
Preconditions.checkArgument(!modifiedSince.isPresent(), String.format(ERROR_MESSAGE, HeaderConstants.IF_MATCH, HeaderConstants.IF_MODIFIED_SINCE));
Preconditions.checkArgument(noneMatch.isEmpty(), String.format(ERROR_MESSAGE, HeaderConstants.IF_MATCH, HeaderConstants.IF_NONE_MATCH));
List<Tag> match = new ArrayList<>(this.match);
if (tag == null) {
tag = Tag.ALL;
}
if (Tag.ALL.equals(tag)) {
match.clear();
}
if (!match.contains(Tag.ALL)) {
if (!match.contains(tag)) {
match.add(tag);
}
}
else {
throw new IllegalArgumentException("Tag ALL already in the list");
}
return new Conditionals(Collections.unmodifiableList(match), empty(), Optional.empty(), unModifiedSince);
} | java | public Conditionals addIfMatch(Tag tag) {
Preconditions.checkArgument(!modifiedSince.isPresent(), String.format(ERROR_MESSAGE, HeaderConstants.IF_MATCH, HeaderConstants.IF_MODIFIED_SINCE));
Preconditions.checkArgument(noneMatch.isEmpty(), String.format(ERROR_MESSAGE, HeaderConstants.IF_MATCH, HeaderConstants.IF_NONE_MATCH));
List<Tag> match = new ArrayList<>(this.match);
if (tag == null) {
tag = Tag.ALL;
}
if (Tag.ALL.equals(tag)) {
match.clear();
}
if (!match.contains(Tag.ALL)) {
if (!match.contains(tag)) {
match.add(tag);
}
}
else {
throw new IllegalArgumentException("Tag ALL already in the list");
}
return new Conditionals(Collections.unmodifiableList(match), empty(), Optional.empty(), unModifiedSince);
} | [
"public",
"Conditionals",
"addIfMatch",
"(",
"Tag",
"tag",
")",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"!",
"modifiedSince",
".",
"isPresent",
"(",
")",
",",
"String",
".",
"format",
"(",
"ERROR_MESSAGE",
",",
"HeaderConstants",
".",
"IF_MATCH",
",",
"HeaderConstants",
".",
"IF_MODIFIED_SINCE",
")",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"noneMatch",
".",
"isEmpty",
"(",
")",
",",
"String",
".",
"format",
"(",
"ERROR_MESSAGE",
",",
"HeaderConstants",
".",
"IF_MATCH",
",",
"HeaderConstants",
".",
"IF_NONE_MATCH",
")",
")",
";",
"List",
"<",
"Tag",
">",
"match",
"=",
"new",
"ArrayList",
"<>",
"(",
"this",
".",
"match",
")",
";",
"if",
"(",
"tag",
"==",
"null",
")",
"{",
"tag",
"=",
"Tag",
".",
"ALL",
";",
"}",
"if",
"(",
"Tag",
".",
"ALL",
".",
"equals",
"(",
"tag",
")",
")",
"{",
"match",
".",
"clear",
"(",
")",
";",
"}",
"if",
"(",
"!",
"match",
".",
"contains",
"(",
"Tag",
".",
"ALL",
")",
")",
"{",
"if",
"(",
"!",
"match",
".",
"contains",
"(",
"tag",
")",
")",
"{",
"match",
".",
"add",
"(",
"tag",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Tag ALL already in the list\"",
")",
";",
"}",
"return",
"new",
"Conditionals",
"(",
"Collections",
".",
"unmodifiableList",
"(",
"match",
")",
",",
"empty",
"(",
")",
",",
"Optional",
".",
"empty",
"(",
")",
",",
"unModifiedSince",
")",
";",
"}"
] | Adds tags to the If-Match header.
@param tag the tag to add, may be null. This means the same as adding {@link Tag#ALL}
@throws IllegalArgumentException if ALL is supplied more than once, or you add a null tag more than once.
@return a new Conditionals object with the If-Match tag added. | [
"Adds",
"tags",
"to",
"the",
"If",
"-",
"Match",
"header",
"."
] | 9c07ebd63cd104a99eb9e771f760f14efa4fe0f6 | https://github.com/httpcache4j/httpcache4j/blob/9c07ebd63cd104a99eb9e771f760f14efa4fe0f6/httpcache4j-api/src/main/java/org/codehaus/httpcache4j/Conditionals.java#L90-L110 | train |
httpcache4j/httpcache4j | httpcache4j-api/src/main/java/org/codehaus/httpcache4j/Conditionals.java | Conditionals.ifModifiedSince | public Conditionals ifModifiedSince(LocalDateTime time) {
Preconditions.checkArgument(match.isEmpty(), String.format(ERROR_MESSAGE, HeaderConstants.IF_MODIFIED_SINCE, HeaderConstants.IF_MATCH));
Preconditions.checkArgument(!unModifiedSince.isPresent(), String.format(ERROR_MESSAGE, HeaderConstants.IF_MODIFIED_SINCE, HeaderConstants.IF_UNMODIFIED_SINCE));
time = time.withNano(0);
return new Conditionals(empty(), noneMatch, Optional.of(time), Optional.empty());
} | java | public Conditionals ifModifiedSince(LocalDateTime time) {
Preconditions.checkArgument(match.isEmpty(), String.format(ERROR_MESSAGE, HeaderConstants.IF_MODIFIED_SINCE, HeaderConstants.IF_MATCH));
Preconditions.checkArgument(!unModifiedSince.isPresent(), String.format(ERROR_MESSAGE, HeaderConstants.IF_MODIFIED_SINCE, HeaderConstants.IF_UNMODIFIED_SINCE));
time = time.withNano(0);
return new Conditionals(empty(), noneMatch, Optional.of(time), Optional.empty());
} | [
"public",
"Conditionals",
"ifModifiedSince",
"(",
"LocalDateTime",
"time",
")",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"match",
".",
"isEmpty",
"(",
")",
",",
"String",
".",
"format",
"(",
"ERROR_MESSAGE",
",",
"HeaderConstants",
".",
"IF_MODIFIED_SINCE",
",",
"HeaderConstants",
".",
"IF_MATCH",
")",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"!",
"unModifiedSince",
".",
"isPresent",
"(",
")",
",",
"String",
".",
"format",
"(",
"ERROR_MESSAGE",
",",
"HeaderConstants",
".",
"IF_MODIFIED_SINCE",
",",
"HeaderConstants",
".",
"IF_UNMODIFIED_SINCE",
")",
")",
";",
"time",
"=",
"time",
".",
"withNano",
"(",
"0",
")",
";",
"return",
"new",
"Conditionals",
"(",
"empty",
"(",
")",
",",
"noneMatch",
",",
"Optional",
".",
"of",
"(",
"time",
")",
",",
"Optional",
".",
"empty",
"(",
")",
")",
";",
"}"
] | You should use the server's time here. Otherwise you might get unexpected results.
The typical use case is:
<pre>
HTTPResponse response = ....
HTTPRequest request = createRequest();
request = request.conditionals(new Conditionals().ifModifiedSince(response.getLastModified());
</pre>
@param time the time to check.
@return the conditionals with the If-Modified-Since date set. | [
"You",
"should",
"use",
"the",
"server",
"s",
"time",
"here",
".",
"Otherwise",
"you",
"might",
"get",
"unexpected",
"results",
"."
] | 9c07ebd63cd104a99eb9e771f760f14efa4fe0f6 | https://github.com/httpcache4j/httpcache4j/blob/9c07ebd63cd104a99eb9e771f760f14efa4fe0f6/httpcache4j-api/src/main/java/org/codehaus/httpcache4j/Conditionals.java#L160-L165 | train |
httpcache4j/httpcache4j | httpcache4j-api/src/main/java/org/codehaus/httpcache4j/Conditionals.java | Conditionals.toHeaders | public Headers toHeaders() {
Headers headers = new Headers();
if (!getMatch().isEmpty()) {
headers = headers.add(new Header(HeaderConstants.IF_MATCH, buildTagHeaderValue(getMatch())));
}
if (!getNoneMatch().isEmpty()) {
headers = headers.add(new Header(HeaderConstants.IF_NONE_MATCH, buildTagHeaderValue(getNoneMatch())));
}
if (modifiedSince.isPresent()) {
headers = headers.set(HeaderUtils.toHttpDate(HeaderConstants.IF_MODIFIED_SINCE, modifiedSince.get()));
}
if (unModifiedSince.isPresent()) {
headers = headers.set(HeaderUtils.toHttpDate(HeaderConstants.IF_UNMODIFIED_SINCE, unModifiedSince.get()));
}
return headers;
} | java | public Headers toHeaders() {
Headers headers = new Headers();
if (!getMatch().isEmpty()) {
headers = headers.add(new Header(HeaderConstants.IF_MATCH, buildTagHeaderValue(getMatch())));
}
if (!getNoneMatch().isEmpty()) {
headers = headers.add(new Header(HeaderConstants.IF_NONE_MATCH, buildTagHeaderValue(getNoneMatch())));
}
if (modifiedSince.isPresent()) {
headers = headers.set(HeaderUtils.toHttpDate(HeaderConstants.IF_MODIFIED_SINCE, modifiedSince.get()));
}
if (unModifiedSince.isPresent()) {
headers = headers.set(HeaderUtils.toHttpDate(HeaderConstants.IF_UNMODIFIED_SINCE, unModifiedSince.get()));
}
return headers;
} | [
"public",
"Headers",
"toHeaders",
"(",
")",
"{",
"Headers",
"headers",
"=",
"new",
"Headers",
"(",
")",
";",
"if",
"(",
"!",
"getMatch",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"headers",
"=",
"headers",
".",
"add",
"(",
"new",
"Header",
"(",
"HeaderConstants",
".",
"IF_MATCH",
",",
"buildTagHeaderValue",
"(",
"getMatch",
"(",
")",
")",
")",
")",
";",
"}",
"if",
"(",
"!",
"getNoneMatch",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"headers",
"=",
"headers",
".",
"add",
"(",
"new",
"Header",
"(",
"HeaderConstants",
".",
"IF_NONE_MATCH",
",",
"buildTagHeaderValue",
"(",
"getNoneMatch",
"(",
")",
")",
")",
")",
";",
"}",
"if",
"(",
"modifiedSince",
".",
"isPresent",
"(",
")",
")",
"{",
"headers",
"=",
"headers",
".",
"set",
"(",
"HeaderUtils",
".",
"toHttpDate",
"(",
"HeaderConstants",
".",
"IF_MODIFIED_SINCE",
",",
"modifiedSince",
".",
"get",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"unModifiedSince",
".",
"isPresent",
"(",
")",
")",
"{",
"headers",
"=",
"headers",
".",
"set",
"(",
"HeaderUtils",
".",
"toHttpDate",
"(",
"HeaderConstants",
".",
"IF_UNMODIFIED_SINCE",
",",
"unModifiedSince",
".",
"get",
"(",
")",
")",
")",
";",
"}",
"return",
"headers",
";",
"}"
] | Converts the Conditionals into real headers.
@return real headers. | [
"Converts",
"the",
"Conditionals",
"into",
"real",
"headers",
"."
] | 9c07ebd63cd104a99eb9e771f760f14efa4fe0f6 | https://github.com/httpcache4j/httpcache4j/blob/9c07ebd63cd104a99eb9e771f760f14efa4fe0f6/httpcache4j-api/src/main/java/org/codehaus/httpcache4j/Conditionals.java#L216-L232 | train |
jbossws/jbossws-spi | src/main/java/org/jboss/wsf/spi/metadata/webservices/WebserviceDescriptionMetaData.java | WebserviceDescriptionMetaData.getPortComponentQNames | public Collection<QName> getPortComponentQNames()
{
//TODO:Check if there is just one QName that drives all portcomponents
//or each port component can have a distinct QName (namespace/prefix)
//Maintain uniqueness of the QName
Map<String, QName> map = new HashMap<String, QName>();
for (PortComponentMetaData pcm : portComponents)
{
QName qname = pcm.getWsdlPort();
map.put(qname.getPrefix(), qname);
}
return map.values();
} | java | public Collection<QName> getPortComponentQNames()
{
//TODO:Check if there is just one QName that drives all portcomponents
//or each port component can have a distinct QName (namespace/prefix)
//Maintain uniqueness of the QName
Map<String, QName> map = new HashMap<String, QName>();
for (PortComponentMetaData pcm : portComponents)
{
QName qname = pcm.getWsdlPort();
map.put(qname.getPrefix(), qname);
}
return map.values();
} | [
"public",
"Collection",
"<",
"QName",
">",
"getPortComponentQNames",
"(",
")",
"{",
"//TODO:Check if there is just one QName that drives all portcomponents",
"//or each port component can have a distinct QName (namespace/prefix)",
"//Maintain uniqueness of the QName",
"Map",
"<",
"String",
",",
"QName",
">",
"map",
"=",
"new",
"HashMap",
"<",
"String",
",",
"QName",
">",
"(",
")",
";",
"for",
"(",
"PortComponentMetaData",
"pcm",
":",
"portComponents",
")",
"{",
"QName",
"qname",
"=",
"pcm",
".",
"getWsdlPort",
"(",
")",
";",
"map",
".",
"put",
"(",
"qname",
".",
"getPrefix",
"(",
")",
",",
"qname",
")",
";",
"}",
"return",
"map",
".",
"values",
"(",
")",
";",
"}"
] | Get the QNames of the port components to be declared
in the namespaces
@return collection of QNames | [
"Get",
"the",
"QNames",
"of",
"the",
"port",
"components",
"to",
"be",
"declared",
"in",
"the",
"namespaces"
] | 845e66c18679ce3aaf76f849822110b4650a9d78 | https://github.com/jbossws/jbossws-spi/blob/845e66c18679ce3aaf76f849822110b4650a9d78/src/main/java/org/jboss/wsf/spi/metadata/webservices/WebserviceDescriptionMetaData.java#L102-L114 | train |
jbossws/jbossws-spi | src/main/java/org/jboss/wsf/spi/metadata/webservices/WebserviceDescriptionMetaData.java | WebserviceDescriptionMetaData.getPortComponentByWsdlPort | public PortComponentMetaData getPortComponentByWsdlPort(String name)
{
ArrayList<String> pcNames = new ArrayList<String>();
for (PortComponentMetaData pc : portComponents)
{
String wsdlPortName = pc.getWsdlPort().getLocalPart();
if (wsdlPortName.equals(name))
return pc;
pcNames.add(wsdlPortName);
}
Loggers.METADATA_LOGGER.cannotGetPortComponentName(name, pcNames);
return null;
} | java | public PortComponentMetaData getPortComponentByWsdlPort(String name)
{
ArrayList<String> pcNames = new ArrayList<String>();
for (PortComponentMetaData pc : portComponents)
{
String wsdlPortName = pc.getWsdlPort().getLocalPart();
if (wsdlPortName.equals(name))
return pc;
pcNames.add(wsdlPortName);
}
Loggers.METADATA_LOGGER.cannotGetPortComponentName(name, pcNames);
return null;
} | [
"public",
"PortComponentMetaData",
"getPortComponentByWsdlPort",
"(",
"String",
"name",
")",
"{",
"ArrayList",
"<",
"String",
">",
"pcNames",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"PortComponentMetaData",
"pc",
":",
"portComponents",
")",
"{",
"String",
"wsdlPortName",
"=",
"pc",
".",
"getWsdlPort",
"(",
")",
".",
"getLocalPart",
"(",
")",
";",
"if",
"(",
"wsdlPortName",
".",
"equals",
"(",
"name",
")",
")",
"return",
"pc",
";",
"pcNames",
".",
"add",
"(",
"wsdlPortName",
")",
";",
"}",
"Loggers",
".",
"METADATA_LOGGER",
".",
"cannotGetPortComponentName",
"(",
"name",
",",
"pcNames",
")",
";",
"return",
"null",
";",
"}"
] | Lookup a PortComponentMetaData by wsdl-port local part
@param name - the wsdl-port local part
@return PortComponentMetaData if found, null otherwise | [
"Lookup",
"a",
"PortComponentMetaData",
"by",
"wsdl",
"-",
"port",
"local",
"part"
] | 845e66c18679ce3aaf76f849822110b4650a9d78 | https://github.com/jbossws/jbossws-spi/blob/845e66c18679ce3aaf76f849822110b4650a9d78/src/main/java/org/jboss/wsf/spi/metadata/webservices/WebserviceDescriptionMetaData.java#L122-L136 | train |
tractionsoftware/gwt-traction | src/main/java/com/tractionsoftware/gwt/user/client/util/Geometry.java | Geometry.setBounds | public static final void setBounds(UIObject o, Rect bounds) {
setPosition(o, bounds);
setSize(o, bounds);
} | java | public static final void setBounds(UIObject o, Rect bounds) {
setPosition(o, bounds);
setSize(o, bounds);
} | [
"public",
"static",
"final",
"void",
"setBounds",
"(",
"UIObject",
"o",
",",
"Rect",
"bounds",
")",
"{",
"setPosition",
"(",
"o",
",",
"bounds",
")",
";",
"setSize",
"(",
"o",
",",
"bounds",
")",
";",
"}"
] | Sets the bounds of a UIObject, moving and sizing to match the
bounds specified. Currently used for the itemhover and useful
for other absolutely positioned elements. | [
"Sets",
"the",
"bounds",
"of",
"a",
"UIObject",
"moving",
"and",
"sizing",
"to",
"match",
"the",
"bounds",
"specified",
".",
"Currently",
"used",
"for",
"the",
"itemhover",
"and",
"useful",
"for",
"other",
"absolutely",
"positioned",
"elements",
"."
] | efc1423c619439763fb064b777b7235e9ce414a3 | https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/util/Geometry.java#L89-L92 | train |
tractionsoftware/gwt-traction | src/main/java/com/tractionsoftware/gwt/user/client/util/Geometry.java | Geometry.setPosition | public static final void setPosition(UIObject o, Rect pos) {
Style style = o.getElement().getStyle();
style.setPropertyPx("left", pos.x);
style.setPropertyPx("top", pos.y);
} | java | public static final void setPosition(UIObject o, Rect pos) {
Style style = o.getElement().getStyle();
style.setPropertyPx("left", pos.x);
style.setPropertyPx("top", pos.y);
} | [
"public",
"static",
"final",
"void",
"setPosition",
"(",
"UIObject",
"o",
",",
"Rect",
"pos",
")",
"{",
"Style",
"style",
"=",
"o",
".",
"getElement",
"(",
")",
".",
"getStyle",
"(",
")",
";",
"style",
".",
"setPropertyPx",
"(",
"\"left\"",
",",
"pos",
".",
"x",
")",
";",
"style",
".",
"setPropertyPx",
"(",
"\"top\"",
",",
"pos",
".",
"y",
")",
";",
"}"
] | Sets the position of a UIObject | [
"Sets",
"the",
"position",
"of",
"a",
"UIObject"
] | efc1423c619439763fb064b777b7235e9ce414a3 | https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/util/Geometry.java#L97-L101 | train |
tractionsoftware/gwt-traction | src/main/java/com/tractionsoftware/gwt/user/client/util/Geometry.java | Geometry.setSize | public static final void setSize(UIObject o, Rect size) {
o.setPixelSize(size.w, size.h);
} | java | public static final void setSize(UIObject o, Rect size) {
o.setPixelSize(size.w, size.h);
} | [
"public",
"static",
"final",
"void",
"setSize",
"(",
"UIObject",
"o",
",",
"Rect",
"size",
")",
"{",
"o",
".",
"setPixelSize",
"(",
"size",
".",
"w",
",",
"size",
".",
"h",
")",
";",
"}"
] | Sets the size of a UIObject | [
"Sets",
"the",
"size",
"of",
"a",
"UIObject"
] | efc1423c619439763fb064b777b7235e9ce414a3 | https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/util/Geometry.java#L106-L109 | train |
tractionsoftware/gwt-traction | src/main/java/com/tractionsoftware/gwt/user/client/util/Geometry.java | Geometry.isInside | public static final boolean isInside(int x, int y, Rect box) {
return (box.x < x && x < box.x + box.w && box.y < y && y < box.y + box.h);
} | java | public static final boolean isInside(int x, int y, Rect box) {
return (box.x < x && x < box.x + box.w && box.y < y && y < box.y + box.h);
} | [
"public",
"static",
"final",
"boolean",
"isInside",
"(",
"int",
"x",
",",
"int",
"y",
",",
"Rect",
"box",
")",
"{",
"return",
"(",
"box",
".",
"x",
"<",
"x",
"&&",
"x",
"<",
"box",
".",
"x",
"+",
"box",
".",
"w",
"&&",
"box",
".",
"y",
"<",
"y",
"&&",
"y",
"<",
"box",
".",
"y",
"+",
"box",
".",
"h",
")",
";",
"}"
] | Determines if a point is inside a box. | [
"Determines",
"if",
"a",
"point",
"is",
"inside",
"a",
"box",
"."
] | efc1423c619439763fb064b777b7235e9ce414a3 | https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/util/Geometry.java#L114-L116 | train |
tractionsoftware/gwt-traction | src/main/java/com/tractionsoftware/gwt/user/client/util/Geometry.java | Geometry.isMouseInside | public static final boolean isMouseInside(NativeEvent event, Element element) {
return isInside(event.getClientX() + Window.getScrollLeft(), event.getClientY() + Window.getScrollTop(), getBounds(element));
} | java | public static final boolean isMouseInside(NativeEvent event, Element element) {
return isInside(event.getClientX() + Window.getScrollLeft(), event.getClientY() + Window.getScrollTop(), getBounds(element));
} | [
"public",
"static",
"final",
"boolean",
"isMouseInside",
"(",
"NativeEvent",
"event",
",",
"Element",
"element",
")",
"{",
"return",
"isInside",
"(",
"event",
".",
"getClientX",
"(",
")",
"+",
"Window",
".",
"getScrollLeft",
"(",
")",
",",
"event",
".",
"getClientY",
"(",
")",
"+",
"Window",
".",
"getScrollTop",
"(",
")",
",",
"getBounds",
"(",
"element",
")",
")",
";",
"}"
] | Determines if a mouse event is inside a box. | [
"Determines",
"if",
"a",
"mouse",
"event",
"is",
"inside",
"a",
"box",
"."
] | efc1423c619439763fb064b777b7235e9ce414a3 | https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/util/Geometry.java#L121-L123 | train |
tractionsoftware/gwt-traction | src/main/java/com/tractionsoftware/gwt/user/client/util/Geometry.java | Geometry.getViewportBounds | public static final Rect getViewportBounds() {
return new Rect(Window.getScrollLeft(), Window.getScrollTop(), Window.getClientWidth(), Window.getClientHeight());
} | java | public static final Rect getViewportBounds() {
return new Rect(Window.getScrollLeft(), Window.getScrollTop(), Window.getClientWidth(), Window.getClientHeight());
} | [
"public",
"static",
"final",
"Rect",
"getViewportBounds",
"(",
")",
"{",
"return",
"new",
"Rect",
"(",
"Window",
".",
"getScrollLeft",
"(",
")",
",",
"Window",
".",
"getScrollTop",
"(",
")",
",",
"Window",
".",
"getClientWidth",
"(",
")",
",",
"Window",
".",
"getClientHeight",
"(",
")",
")",
";",
"}"
] | This takes into account scrolling and will be in absolute
coordinates where the top left corner of the page is 0,0 but
the viewport may be scrolled to something else. | [
"This",
"takes",
"into",
"account",
"scrolling",
"and",
"will",
"be",
"in",
"absolute",
"coordinates",
"where",
"the",
"top",
"left",
"corner",
"of",
"the",
"page",
"is",
"0",
"0",
"but",
"the",
"viewport",
"may",
"be",
"scrolled",
"to",
"something",
"else",
"."
] | efc1423c619439763fb064b777b7235e9ce414a3 | https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/util/Geometry.java#L130-L132 | train |
tractionsoftware/gwt-traction | src/main/java/com/tractionsoftware/gwt/user/client/ui/UTCDateBox.java | UTCDateBox.utc2date | public static final Date utc2date(Long time) {
// don't accept negative values
if (time == null || time < 0) return null;
// add the timezone offset
time += timezoneOffsetMillis(new Date(time));
return new Date(time);
} | java | public static final Date utc2date(Long time) {
// don't accept negative values
if (time == null || time < 0) return null;
// add the timezone offset
time += timezoneOffsetMillis(new Date(time));
return new Date(time);
} | [
"public",
"static",
"final",
"Date",
"utc2date",
"(",
"Long",
"time",
")",
"{",
"// don't accept negative values",
"if",
"(",
"time",
"==",
"null",
"||",
"time",
"<",
"0",
")",
"return",
"null",
";",
"// add the timezone offset",
"time",
"+=",
"timezoneOffsetMillis",
"(",
"new",
"Date",
"(",
"time",
")",
")",
";",
"return",
"new",
"Date",
"(",
"time",
")",
";",
"}"
] | Converts a time in UTC to a gwt Date object which is in the timezone of
the current browser.
@return The Date corresponding to the time, adjusted for the timezone of
the current browser. null if the specified time is null or
represents a negative number. | [
"Converts",
"a",
"time",
"in",
"UTC",
"to",
"a",
"gwt",
"Date",
"object",
"which",
"is",
"in",
"the",
"timezone",
"of",
"the",
"current",
"browser",
"."
] | efc1423c619439763fb064b777b7235e9ce414a3 | https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/ui/UTCDateBox.java#L206-L215 | train |
tractionsoftware/gwt-traction | src/main/java/com/tractionsoftware/gwt/user/client/ui/UTCDateBox.java | UTCDateBox.date2utc | public static final Long date2utc(Date date) {
// use null for a null date
if (date == null) return null;
long time = date.getTime();
// remove the timezone offset
time -= timezoneOffsetMillis(date);
return time;
} | java | public static final Long date2utc(Date date) {
// use null for a null date
if (date == null) return null;
long time = date.getTime();
// remove the timezone offset
time -= timezoneOffsetMillis(date);
return time;
} | [
"public",
"static",
"final",
"Long",
"date2utc",
"(",
"Date",
"date",
")",
"{",
"// use null for a null date",
"if",
"(",
"date",
"==",
"null",
")",
"return",
"null",
";",
"long",
"time",
"=",
"date",
".",
"getTime",
"(",
")",
";",
"// remove the timezone offset ",
"time",
"-=",
"timezoneOffsetMillis",
"(",
"date",
")",
";",
"return",
"time",
";",
"}"
] | Converts a gwt Date in the timezone of the current browser to a time in
UTC.
@return A Long corresponding to the number of milliseconds since January
1, 1970, 00:00:00 GMT or null if the specified Date is null. | [
"Converts",
"a",
"gwt",
"Date",
"in",
"the",
"timezone",
"of",
"the",
"current",
"browser",
"to",
"a",
"time",
"in",
"UTC",
"."
] | efc1423c619439763fb064b777b7235e9ce414a3 | https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/ui/UTCDateBox.java#L224-L235 | train |
cchabanois/transmorph | src/main/java/net/entropysoft/transmorph/signature/TypeSignatureFactory.java | TypeSignatureFactory.getTypeSignature | public static FullTypeSignature getTypeSignature(String typeSignatureString,
boolean useInternalFormFullyQualifiedName) {
String key;
if (!useInternalFormFullyQualifiedName) {
key = typeSignatureString.replace('.', '/')
.replace('$', '.');
} else {
key = typeSignatureString;
}
// we always use the internal form as a key for cache
FullTypeSignature typeSignature = typeSignatureCache
.get(key);
if (typeSignature == null) {
ClassFileTypeSignatureParser typeSignatureParser = new ClassFileTypeSignatureParser(
typeSignatureString);
typeSignatureParser.setUseInternalFormFullyQualifiedName(useInternalFormFullyQualifiedName);
typeSignature = typeSignatureParser.parseTypeSignature();
typeSignatureCache.put(typeSignatureString, typeSignature);
}
return typeSignature;
} | java | public static FullTypeSignature getTypeSignature(String typeSignatureString,
boolean useInternalFormFullyQualifiedName) {
String key;
if (!useInternalFormFullyQualifiedName) {
key = typeSignatureString.replace('.', '/')
.replace('$', '.');
} else {
key = typeSignatureString;
}
// we always use the internal form as a key for cache
FullTypeSignature typeSignature = typeSignatureCache
.get(key);
if (typeSignature == null) {
ClassFileTypeSignatureParser typeSignatureParser = new ClassFileTypeSignatureParser(
typeSignatureString);
typeSignatureParser.setUseInternalFormFullyQualifiedName(useInternalFormFullyQualifiedName);
typeSignature = typeSignatureParser.parseTypeSignature();
typeSignatureCache.put(typeSignatureString, typeSignature);
}
return typeSignature;
} | [
"public",
"static",
"FullTypeSignature",
"getTypeSignature",
"(",
"String",
"typeSignatureString",
",",
"boolean",
"useInternalFormFullyQualifiedName",
")",
"{",
"String",
"key",
";",
"if",
"(",
"!",
"useInternalFormFullyQualifiedName",
")",
"{",
"key",
"=",
"typeSignatureString",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
";",
"}",
"else",
"{",
"key",
"=",
"typeSignatureString",
";",
"}",
"// we always use the internal form as a key for cache",
"FullTypeSignature",
"typeSignature",
"=",
"typeSignatureCache",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"typeSignature",
"==",
"null",
")",
"{",
"ClassFileTypeSignatureParser",
"typeSignatureParser",
"=",
"new",
"ClassFileTypeSignatureParser",
"(",
"typeSignatureString",
")",
";",
"typeSignatureParser",
".",
"setUseInternalFormFullyQualifiedName",
"(",
"useInternalFormFullyQualifiedName",
")",
";",
"typeSignature",
"=",
"typeSignatureParser",
".",
"parseTypeSignature",
"(",
")",
";",
"typeSignatureCache",
".",
"put",
"(",
"typeSignatureString",
",",
"typeSignature",
")",
";",
"}",
"return",
"typeSignature",
";",
"}"
] | get TypeSignature given the signature
@param typeSignature
@param useInternalFormFullyQualifiedName
if true, fqn in parameterizedTypeSignature must be in the form
'java/lang/Thread'. If false fqn must be of the form
'java.lang.Thread'
@return | [
"get",
"TypeSignature",
"given",
"the",
"signature"
] | 118550f30b9680a84eab7496bd8b04118740dcec | https://github.com/cchabanois/transmorph/blob/118550f30b9680a84eab7496bd8b04118740dcec/src/main/java/net/entropysoft/transmorph/signature/TypeSignatureFactory.java#L57-L78 | train |
cchabanois/transmorph | src/main/java/net/entropysoft/transmorph/signature/TypeSignatureFactory.java | TypeSignatureFactory.getTypeSignature | public static FullTypeSignature getTypeSignature(Class<?> clazz, Class<?>[] typeArgs) {
ClassTypeSignature rawClassTypeSignature = (ClassTypeSignature) javaTypeToTypeSignature
.getTypeSignature(clazz);
TypeArgSignature[] typeArgSignatures = new TypeArgSignature[typeArgs.length];
for (int i = 0; i < typeArgs.length; i++) {
typeArgSignatures[i] = new TypeArgSignature(
TypeArgSignature.NO_WILDCARD,
(FieldTypeSignature) javaTypeToTypeSignature
.getTypeSignature(typeArgs[i]));
}
ClassTypeSignature classTypeSignature = new ClassTypeSignature(
rawClassTypeSignature.getBinaryName(), typeArgSignatures,
rawClassTypeSignature.getOwnerTypeSignature());
return classTypeSignature;
} | java | public static FullTypeSignature getTypeSignature(Class<?> clazz, Class<?>[] typeArgs) {
ClassTypeSignature rawClassTypeSignature = (ClassTypeSignature) javaTypeToTypeSignature
.getTypeSignature(clazz);
TypeArgSignature[] typeArgSignatures = new TypeArgSignature[typeArgs.length];
for (int i = 0; i < typeArgs.length; i++) {
typeArgSignatures[i] = new TypeArgSignature(
TypeArgSignature.NO_WILDCARD,
(FieldTypeSignature) javaTypeToTypeSignature
.getTypeSignature(typeArgs[i]));
}
ClassTypeSignature classTypeSignature = new ClassTypeSignature(
rawClassTypeSignature.getBinaryName(), typeArgSignatures,
rawClassTypeSignature.getOwnerTypeSignature());
return classTypeSignature;
} | [
"public",
"static",
"FullTypeSignature",
"getTypeSignature",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"Class",
"<",
"?",
">",
"[",
"]",
"typeArgs",
")",
"{",
"ClassTypeSignature",
"rawClassTypeSignature",
"=",
"(",
"ClassTypeSignature",
")",
"javaTypeToTypeSignature",
".",
"getTypeSignature",
"(",
"clazz",
")",
";",
"TypeArgSignature",
"[",
"]",
"typeArgSignatures",
"=",
"new",
"TypeArgSignature",
"[",
"typeArgs",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"typeArgs",
".",
"length",
";",
"i",
"++",
")",
"{",
"typeArgSignatures",
"[",
"i",
"]",
"=",
"new",
"TypeArgSignature",
"(",
"TypeArgSignature",
".",
"NO_WILDCARD",
",",
"(",
"FieldTypeSignature",
")",
"javaTypeToTypeSignature",
".",
"getTypeSignature",
"(",
"typeArgs",
"[",
"i",
"]",
")",
")",
";",
"}",
"ClassTypeSignature",
"classTypeSignature",
"=",
"new",
"ClassTypeSignature",
"(",
"rawClassTypeSignature",
".",
"getBinaryName",
"(",
")",
",",
"typeArgSignatures",
",",
"rawClassTypeSignature",
".",
"getOwnerTypeSignature",
"(",
")",
")",
";",
"return",
"classTypeSignature",
";",
"}"
] | get the TypeSignature corresponding to given class with given type
arguments
@param clazz
@param typeArgs
@return | [
"get",
"the",
"TypeSignature",
"corresponding",
"to",
"given",
"class",
"with",
"given",
"type",
"arguments"
] | 118550f30b9680a84eab7496bd8b04118740dcec | https://github.com/cchabanois/transmorph/blob/118550f30b9680a84eab7496bd8b04118740dcec/src/main/java/net/entropysoft/transmorph/signature/TypeSignatureFactory.java#L112-L127 | train |
resource4j/resource4j | core/src/main/java/com/github/resource4j/values/ResourceStrings.java | ResourceStrings.ofNullable | public static OptionalString ofNullable(ResourceKey key, String value) {
return new GenericOptionalString(RUNTIME_SOURCE, key, value);
} | java | public static OptionalString ofNullable(ResourceKey key, String value) {
return new GenericOptionalString(RUNTIME_SOURCE, key, value);
} | [
"public",
"static",
"OptionalString",
"ofNullable",
"(",
"ResourceKey",
"key",
",",
"String",
"value",
")",
"{",
"return",
"new",
"GenericOptionalString",
"(",
"RUNTIME_SOURCE",
",",
"key",
",",
"value",
")",
";",
"}"
] | Returns new instance of OptionalString with given key and value
@param key key of the returned OptionalString
@param value wrapped string
@return given object wrapped in OptionalString with given key | [
"Returns",
"new",
"instance",
"of",
"OptionalString",
"with",
"given",
"key",
"and",
"value"
] | 6100443b9a78edc8a5867e1e075f7ee12e6698ca | https://github.com/resource4j/resource4j/blob/6100443b9a78edc8a5867e1e075f7ee12e6698ca/core/src/main/java/com/github/resource4j/values/ResourceStrings.java#L41-L43 | train |
openEHR/adl2-core | adl2core-parser/src/main/java/org/openehr/adl/parser/AdlDeserializer.java | AdlDeserializer.parse | public Archetype parse(String adl) {
try {
return parse(new StringReader(adl));
} catch (IOException e) {
// StringReader should never throw an IOException
throw new AssertionError(e);
}
} | java | public Archetype parse(String adl) {
try {
return parse(new StringReader(adl));
} catch (IOException e) {
// StringReader should never throw an IOException
throw new AssertionError(e);
}
} | [
"public",
"Archetype",
"parse",
"(",
"String",
"adl",
")",
"{",
"try",
"{",
"return",
"parse",
"(",
"new",
"StringReader",
"(",
"adl",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"// StringReader should never throw an IOException",
"throw",
"new",
"AssertionError",
"(",
"e",
")",
";",
"}",
"}"
] | Parses an adl source into a differential archetype.
@param adl contents of an adl source file
@return parsed archetype
@throws org.openehr.adl.parser.AdlParserException if an error occurred while parsing | [
"Parses",
"an",
"adl",
"source",
"into",
"a",
"differential",
"archetype",
"."
] | dd5c1c0fe7ef5e43fbfaf6a0389990ba5380e22c | https://github.com/openEHR/adl2-core/blob/dd5c1c0fe7ef5e43fbfaf6a0389990ba5380e22c/adl2core-parser/src/main/java/org/openehr/adl/parser/AdlDeserializer.java#L52-L59 | train |
taimos/dvalin | interconnect/model/src/main/java/de/taimos/dvalin/interconnect/model/service/DaemonScanner.java | DaemonScanner.object2Array | @SuppressWarnings({"unchecked", "unused"})
public static <T> T[] object2Array(final Class<T> clazz, final Object obj) {
return (T[]) obj;
} | java | @SuppressWarnings({"unchecked", "unused"})
public static <T> T[] object2Array(final Class<T> clazz, final Object obj) {
return (T[]) obj;
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unchecked\"",
",",
"\"unused\"",
"}",
")",
"public",
"static",
"<",
"T",
">",
"T",
"[",
"]",
"object2Array",
"(",
"final",
"Class",
"<",
"T",
">",
"clazz",
",",
"final",
"Object",
"obj",
")",
"{",
"return",
"(",
"T",
"[",
"]",
")",
"obj",
";",
"}"
] | We try to convert an Object to an Array and this is not easy in Java so we need a little bit of nasty magic.
@param <T> Type of elements
@param clazz Clazz of the Objct elements
@param obj Object
@return Array | [
"We",
"try",
"to",
"convert",
"an",
"Object",
"to",
"an",
"Array",
"and",
"this",
"is",
"not",
"easy",
"in",
"Java",
"so",
"we",
"need",
"a",
"little",
"bit",
"of",
"nasty",
"magic",
"."
] | ff8f1bf594e43d7e8ca8de0b4da9f923b66a1a47 | https://github.com/taimos/dvalin/blob/ff8f1bf594e43d7e8ca8de0b4da9f923b66a1a47/interconnect/model/src/main/java/de/taimos/dvalin/interconnect/model/service/DaemonScanner.java#L271-L274 | train |
transloadit/java-sdk | src/main/java/com/transloadit/sdk/async/AsyncAssembly.java | AsyncAssembly.pauseUpload | public void pauseUpload() throws LocalOperationException {
if (state == State.UPLOADING) {
setState(State.PAUSED);
executor.hardStop();
} else {
throw new LocalOperationException("Attempt to pause upload while assembly is not uploading");
}
} | java | public void pauseUpload() throws LocalOperationException {
if (state == State.UPLOADING) {
setState(State.PAUSED);
executor.hardStop();
} else {
throw new LocalOperationException("Attempt to pause upload while assembly is not uploading");
}
} | [
"public",
"void",
"pauseUpload",
"(",
")",
"throws",
"LocalOperationException",
"{",
"if",
"(",
"state",
"==",
"State",
".",
"UPLOADING",
")",
"{",
"setState",
"(",
"State",
".",
"PAUSED",
")",
";",
"executor",
".",
"hardStop",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"LocalOperationException",
"(",
"\"Attempt to pause upload while assembly is not uploading\"",
")",
";",
"}",
"}"
] | Pauses the file upload. This is a blocking function that would try to wait till the assembly file uploads
have actually been paused if possible.
@throws LocalOperationException if the method is called while no upload is going on. | [
"Pauses",
"the",
"file",
"upload",
".",
"This",
"is",
"a",
"blocking",
"function",
"that",
"would",
"try",
"to",
"wait",
"till",
"the",
"assembly",
"file",
"uploads",
"have",
"actually",
"been",
"paused",
"if",
"possible",
"."
] | 9326c540a66f77b3d907d0b2c05bff1145ca14f7 | https://github.com/transloadit/java-sdk/blob/9326c540a66f77b3d907d0b2c05bff1145ca14f7/src/main/java/com/transloadit/sdk/async/AsyncAssembly.java#L68-L75 | train |
transloadit/java-sdk | src/main/java/com/transloadit/sdk/async/AsyncAssembly.java | AsyncAssembly.watchStatus | protected AssemblyResponse watchStatus() throws LocalOperationException, RequestException {
AssemblyResponse response;
do {
response = getClient().getAssemblyByUrl(url);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new LocalOperationException(e);
}
} while (!response.isFinished());
setState(State.FINISHED);
return response;
} | java | protected AssemblyResponse watchStatus() throws LocalOperationException, RequestException {
AssemblyResponse response;
do {
response = getClient().getAssemblyByUrl(url);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new LocalOperationException(e);
}
} while (!response.isFinished());
setState(State.FINISHED);
return response;
} | [
"protected",
"AssemblyResponse",
"watchStatus",
"(",
")",
"throws",
"LocalOperationException",
",",
"RequestException",
"{",
"AssemblyResponse",
"response",
";",
"do",
"{",
"response",
"=",
"getClient",
"(",
")",
".",
"getAssemblyByUrl",
"(",
"url",
")",
";",
"try",
"{",
"Thread",
".",
"sleep",
"(",
"1000",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"throw",
"new",
"LocalOperationException",
"(",
"e",
")",
";",
"}",
"}",
"while",
"(",
"!",
"response",
".",
"isFinished",
"(",
")",
")",
";",
"setState",
"(",
"State",
".",
"FINISHED",
")",
";",
"return",
"response",
";",
"}"
] | Runs intermediate check on the Assembly status until it is finished executing,
then returns it as a response.
@return {@link AssemblyResponse}
@throws LocalOperationException if something goes wrong while running non-http operations.
@throws RequestException if request to Transloadit server fails. | [
"Runs",
"intermediate",
"check",
"on",
"the",
"Assembly",
"status",
"until",
"it",
"is",
"finished",
"executing",
"then",
"returns",
"it",
"as",
"a",
"response",
"."
] | 9326c540a66f77b3d907d0b2c05bff1145ca14f7 | https://github.com/transloadit/java-sdk/blob/9326c540a66f77b3d907d0b2c05bff1145ca14f7/src/main/java/com/transloadit/sdk/async/AsyncAssembly.java#L123-L136 | train |
transloadit/java-sdk | src/main/java/com/transloadit/sdk/async/AsyncAssembly.java | AsyncAssembly.getTotalUploadSize | private long getTotalUploadSize() throws IOException {
long size = 0;
for (Map.Entry<String, File> entry : files.entrySet()) {
size += entry.getValue().length();
}
for (Map.Entry<String, InputStream> entry : fileStreams.entrySet()) {
size += entry.getValue().available();
}
return size;
} | java | private long getTotalUploadSize() throws IOException {
long size = 0;
for (Map.Entry<String, File> entry : files.entrySet()) {
size += entry.getValue().length();
}
for (Map.Entry<String, InputStream> entry : fileStreams.entrySet()) {
size += entry.getValue().available();
}
return size;
} | [
"private",
"long",
"getTotalUploadSize",
"(",
")",
"throws",
"IOException",
"{",
"long",
"size",
"=",
"0",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"File",
">",
"entry",
":",
"files",
".",
"entrySet",
"(",
")",
")",
"{",
"size",
"+=",
"entry",
".",
"getValue",
"(",
")",
".",
"length",
"(",
")",
";",
"}",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"InputStream",
">",
"entry",
":",
"fileStreams",
".",
"entrySet",
"(",
")",
")",
"{",
"size",
"+=",
"entry",
".",
"getValue",
"(",
")",
".",
"available",
"(",
")",
";",
"}",
"return",
"size",
";",
"}"
] | used for upload progress | [
"used",
"for",
"upload",
"progress"
] | 9326c540a66f77b3d907d0b2c05bff1145ca14f7 | https://github.com/transloadit/java-sdk/blob/9326c540a66f77b3d907d0b2c05bff1145ca14f7/src/main/java/com/transloadit/sdk/async/AsyncAssembly.java#L252-L262 | train |
taimos/dvalin | interconnect/model/src/main/java/de/taimos/dvalin/interconnect/model/InterconnectMapper.java | InterconnectMapper.fromJson | public static <T extends InterconnectObject> T fromJson(String data, Class<T> clazz) throws IOException {
return InterconnectMapper.mapper.readValue(data, clazz);
} | java | public static <T extends InterconnectObject> T fromJson(String data, Class<T> clazz) throws IOException {
return InterconnectMapper.mapper.readValue(data, clazz);
} | [
"public",
"static",
"<",
"T",
"extends",
"InterconnectObject",
">",
"T",
"fromJson",
"(",
"String",
"data",
",",
"Class",
"<",
"T",
">",
"clazz",
")",
"throws",
"IOException",
"{",
"return",
"InterconnectMapper",
".",
"mapper",
".",
"readValue",
"(",
"data",
",",
"clazz",
")",
";",
"}"
] | Creates an object from the given JSON data.
@param data the JSON data
@param clazz the class object for the content of the JSON data
@param <T> the type of the class object extending {@link InterconnectObject}
@return the object contained in the given JSON data
@throws JsonParseException if a the JSON data could not be parsed
@throws JsonMappingException if the mapping of the JSON data to the IVO failed
@throws IOException if an I/O related problem occurred | [
"Creates",
"an",
"object",
"from",
"the",
"given",
"JSON",
"data",
"."
] | ff8f1bf594e43d7e8ca8de0b4da9f923b66a1a47 | https://github.com/taimos/dvalin/blob/ff8f1bf594e43d7e8ca8de0b4da9f923b66a1a47/interconnect/model/src/main/java/de/taimos/dvalin/interconnect/model/InterconnectMapper.java#L77-L79 | train |
transloadit/java-sdk | src/main/java/com/transloadit/sdk/Template.java | Template.save | public Response save() throws RequestException, LocalOperationException {
Map<String, Object> templateData = new HashMap<String, Object>();
templateData.put("name", name);
options.put("steps", steps.toMap());
templateData.put("template", options);
Request request = new Request(transloadit);
return new Response(request.post("/templates", templateData));
} | java | public Response save() throws RequestException, LocalOperationException {
Map<String, Object> templateData = new HashMap<String, Object>();
templateData.put("name", name);
options.put("steps", steps.toMap());
templateData.put("template", options);
Request request = new Request(transloadit);
return new Response(request.post("/templates", templateData));
} | [
"public",
"Response",
"save",
"(",
")",
"throws",
"RequestException",
",",
"LocalOperationException",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"templateData",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"templateData",
".",
"put",
"(",
"\"name\"",
",",
"name",
")",
";",
"options",
".",
"put",
"(",
"\"steps\"",
",",
"steps",
".",
"toMap",
"(",
")",
")",
";",
"templateData",
".",
"put",
"(",
"\"template\"",
",",
"options",
")",
";",
"Request",
"request",
"=",
"new",
"Request",
"(",
"transloadit",
")",
";",
"return",
"new",
"Response",
"(",
"request",
".",
"post",
"(",
"\"/templates\"",
",",
"templateData",
")",
")",
";",
"}"
] | Submits the configured template to Transloadit.
@return {@link Response}
@throws RequestException if request to transloadit server fails.
@throws LocalOperationException if something goes wrong while running non-http operations. | [
"Submits",
"the",
"configured",
"template",
"to",
"Transloadit",
"."
] | 9326c540a66f77b3d907d0b2c05bff1145ca14f7 | https://github.com/transloadit/java-sdk/blob/9326c540a66f77b3d907d0b2c05bff1145ca14f7/src/main/java/com/transloadit/sdk/Template.java#L62-L71 | train |
wcm-io/wcm-io-sling | commons/src/main/java/io/wcm/sling/commons/caservice/impl/ServiceInfo.java | ServiceInfo.matches | public boolean matches(String resourcePath) {
if (!valid) {
return false;
}
if (resourcePath == null) {
return acceptsContextPathEmpty;
}
if (contextPathRegex != null && !contextPathRegex.matcher(resourcePath).matches()) {
return false;
}
if (contextPathBlacklistRegex != null && contextPathBlacklistRegex.matcher(resourcePath).matches()) {
return false;
}
return true;
} | java | public boolean matches(String resourcePath) {
if (!valid) {
return false;
}
if (resourcePath == null) {
return acceptsContextPathEmpty;
}
if (contextPathRegex != null && !contextPathRegex.matcher(resourcePath).matches()) {
return false;
}
if (contextPathBlacklistRegex != null && contextPathBlacklistRegex.matcher(resourcePath).matches()) {
return false;
}
return true;
} | [
"public",
"boolean",
"matches",
"(",
"String",
"resourcePath",
")",
"{",
"if",
"(",
"!",
"valid",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"resourcePath",
"==",
"null",
")",
"{",
"return",
"acceptsContextPathEmpty",
";",
"}",
"if",
"(",
"contextPathRegex",
"!=",
"null",
"&&",
"!",
"contextPathRegex",
".",
"matcher",
"(",
"resourcePath",
")",
".",
"matches",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"contextPathBlacklistRegex",
"!=",
"null",
"&&",
"contextPathBlacklistRegex",
".",
"matcher",
"(",
"resourcePath",
")",
".",
"matches",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Checks if this service implementation accepts the given resource path.
@param resourcePath Resource path
@return true if the implementation matches and the configuration is not invalid. | [
"Checks",
"if",
"this",
"service",
"implementation",
"accepts",
"the",
"given",
"resource",
"path",
"."
] | 90adbe432469378794b5695c72e9cdfa2b7d36f1 | https://github.com/wcm-io/wcm-io-sling/blob/90adbe432469378794b5695c72e9cdfa2b7d36f1/commons/src/main/java/io/wcm/sling/commons/caservice/impl/ServiceInfo.java#L148-L162 | train |
cenobites/struts2-json-plugin | src/main/java/es/cenobit/struts2/json/JsonService.java | JsonService.getClassLoader | private ClassLoaderInterface getClassLoader() {
Map<String, Object> application = ActionContext.getContext().getApplication();
if (application != null) {
return (ClassLoaderInterface) application.get(ClassLoaderInterface.CLASS_LOADER_INTERFACE);
}
return null;
} | java | private ClassLoaderInterface getClassLoader() {
Map<String, Object> application = ActionContext.getContext().getApplication();
if (application != null) {
return (ClassLoaderInterface) application.get(ClassLoaderInterface.CLASS_LOADER_INTERFACE);
}
return null;
} | [
"private",
"ClassLoaderInterface",
"getClassLoader",
"(",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"application",
"=",
"ActionContext",
".",
"getContext",
"(",
")",
".",
"getApplication",
"(",
")",
";",
"if",
"(",
"application",
"!=",
"null",
")",
"{",
"return",
"(",
"ClassLoaderInterface",
")",
"application",
".",
"get",
"(",
"ClassLoaderInterface",
".",
"CLASS_LOADER_INTERFACE",
")",
";",
"}",
"return",
"null",
";",
"}"
] | this class loader interface can be used by other plugins to lookup
resources from the bundles. A temporary class loader interface is set
during other configuration loading as well
@return ClassLoaderInterface (BundleClassLoaderInterface) | [
"this",
"class",
"loader",
"interface",
"can",
"be",
"used",
"by",
"other",
"plugins",
"to",
"lookup",
"resources",
"from",
"the",
"bundles",
".",
"A",
"temporary",
"class",
"loader",
"interface",
"is",
"set",
"during",
"other",
"configuration",
"loading",
"as",
"well"
] | 00f948942d85b6f696d46672332ff7b3942ecb1b | https://github.com/cenobites/struts2-json-plugin/blob/00f948942d85b6f696d46672332ff7b3942ecb1b/src/main/java/es/cenobit/struts2/json/JsonService.java#L105-L111 | train |
wcm-io/wcm-io-sling | commons/src/main/java/io/wcm/sling/commons/request/QueryStringBuilder.java | QueryStringBuilder.build | public @Nullable String build() {
StringBuilder queryString = new StringBuilder();
for (NameValuePair param : params) {
if (queryString.length() > 0) {
queryString.append(PARAM_SEPARATOR);
}
queryString.append(Escape.urlEncode(param.getName()));
queryString.append(VALUE_SEPARATOR);
queryString.append(Escape.urlEncode(param.getValue()));
}
if (queryString.length() > 0) {
return queryString.toString();
}
else {
return null;
}
} | java | public @Nullable String build() {
StringBuilder queryString = new StringBuilder();
for (NameValuePair param : params) {
if (queryString.length() > 0) {
queryString.append(PARAM_SEPARATOR);
}
queryString.append(Escape.urlEncode(param.getName()));
queryString.append(VALUE_SEPARATOR);
queryString.append(Escape.urlEncode(param.getValue()));
}
if (queryString.length() > 0) {
return queryString.toString();
}
else {
return null;
}
} | [
"public",
"@",
"Nullable",
"String",
"build",
"(",
")",
"{",
"StringBuilder",
"queryString",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"NameValuePair",
"param",
":",
"params",
")",
"{",
"if",
"(",
"queryString",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"queryString",
".",
"append",
"(",
"PARAM_SEPARATOR",
")",
";",
"}",
"queryString",
".",
"append",
"(",
"Escape",
".",
"urlEncode",
"(",
"param",
".",
"getName",
"(",
")",
")",
")",
";",
"queryString",
".",
"append",
"(",
"VALUE_SEPARATOR",
")",
";",
"queryString",
".",
"append",
"(",
"Escape",
".",
"urlEncode",
"(",
"param",
".",
"getValue",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"queryString",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"return",
"queryString",
".",
"toString",
"(",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | Build query string.
@return Query string or null if query string contains no parameters at all. | [
"Build",
"query",
"string",
"."
] | 90adbe432469378794b5695c72e9cdfa2b7d36f1 | https://github.com/wcm-io/wcm-io-sling/blob/90adbe432469378794b5695c72e9cdfa2b7d36f1/commons/src/main/java/io/wcm/sling/commons/request/QueryStringBuilder.java#L89-L107 | train |
transloadit/java-sdk | src/main/java/com/transloadit/sdk/Transloadit.java | Transloadit.cancelAssembly | public AssemblyResponse cancelAssembly(String url)
throws RequestException, LocalOperationException {
Request request = new Request(this);
return new AssemblyResponse(request.delete(url, new HashMap<String, Object>()));
} | java | public AssemblyResponse cancelAssembly(String url)
throws RequestException, LocalOperationException {
Request request = new Request(this);
return new AssemblyResponse(request.delete(url, new HashMap<String, Object>()));
} | [
"public",
"AssemblyResponse",
"cancelAssembly",
"(",
"String",
"url",
")",
"throws",
"RequestException",
",",
"LocalOperationException",
"{",
"Request",
"request",
"=",
"new",
"Request",
"(",
"this",
")",
";",
"return",
"new",
"AssemblyResponse",
"(",
"request",
".",
"delete",
"(",
"url",
",",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
")",
")",
";",
"}"
] | cancels a running assembly.
@param url full url of the Assembly.
@return {@link AssemblyResponse}
@throws RequestException if request to transloadit server fails.
@throws LocalOperationException if something goes wrong while running non-http operations. | [
"cancels",
"a",
"running",
"assembly",
"."
] | 9326c540a66f77b3d907d0b2c05bff1145ca14f7 | https://github.com/transloadit/java-sdk/blob/9326c540a66f77b3d907d0b2c05bff1145ca14f7/src/main/java/com/transloadit/sdk/Transloadit.java#L152-L156 | train |
transloadit/java-sdk | src/main/java/com/transloadit/sdk/Transloadit.java | Transloadit.getTemplate | public Response getTemplate(String id) throws RequestException, LocalOperationException {
Request request = new Request(this);
return new Response(request.get("/templates/" + id));
} | java | public Response getTemplate(String id) throws RequestException, LocalOperationException {
Request request = new Request(this);
return new Response(request.get("/templates/" + id));
} | [
"public",
"Response",
"getTemplate",
"(",
"String",
"id",
")",
"throws",
"RequestException",
",",
"LocalOperationException",
"{",
"Request",
"request",
"=",
"new",
"Request",
"(",
"this",
")",
";",
"return",
"new",
"Response",
"(",
"request",
".",
"get",
"(",
"\"/templates/\"",
"+",
"id",
")",
")",
";",
"}"
] | Returns a single template.
@param id id of the template to retrieve.
@return {@link Response}
@throws RequestException if request to transloadit server fails.
@throws LocalOperationException if something goes wrong while running non-http operations. | [
"Returns",
"a",
"single",
"template",
"."
] | 9326c540a66f77b3d907d0b2c05bff1145ca14f7 | https://github.com/transloadit/java-sdk/blob/9326c540a66f77b3d907d0b2c05bff1145ca14f7/src/main/java/com/transloadit/sdk/Transloadit.java#L195-L198 | train |
transloadit/java-sdk | src/main/java/com/transloadit/sdk/Transloadit.java | Transloadit.updateTemplate | public Response updateTemplate(String id, Map<String, Object> options)
throws RequestException, LocalOperationException {
Request request = new Request(this);
return new Response(request.put("/templates/" + id, options));
} | java | public Response updateTemplate(String id, Map<String, Object> options)
throws RequestException, LocalOperationException {
Request request = new Request(this);
return new Response(request.put("/templates/" + id, options));
} | [
"public",
"Response",
"updateTemplate",
"(",
"String",
"id",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"options",
")",
"throws",
"RequestException",
",",
"LocalOperationException",
"{",
"Request",
"request",
"=",
"new",
"Request",
"(",
"this",
")",
";",
"return",
"new",
"Response",
"(",
"request",
".",
"put",
"(",
"\"/templates/\"",
"+",
"id",
",",
"options",
")",
")",
";",
"}"
] | Updates the template with the specified id.
@param id id of the template to update
@param options a Map of options to update/add.
@return {@link Response}
@throws RequestException if request to transloadit server fails.
@throws LocalOperationException if something goes wrong while running non-http operations. | [
"Updates",
"the",
"template",
"with",
"the",
"specified",
"id",
"."
] | 9326c540a66f77b3d907d0b2c05bff1145ca14f7 | https://github.com/transloadit/java-sdk/blob/9326c540a66f77b3d907d0b2c05bff1145ca14f7/src/main/java/com/transloadit/sdk/Transloadit.java#L210-L214 | train |
transloadit/java-sdk | src/main/java/com/transloadit/sdk/Transloadit.java | Transloadit.deleteTemplate | public Response deleteTemplate(String id)
throws RequestException, LocalOperationException {
Request request = new Request(this);
return new Response(request.delete("/templates/" + id, new HashMap<String, Object>()));
} | java | public Response deleteTemplate(String id)
throws RequestException, LocalOperationException {
Request request = new Request(this);
return new Response(request.delete("/templates/" + id, new HashMap<String, Object>()));
} | [
"public",
"Response",
"deleteTemplate",
"(",
"String",
"id",
")",
"throws",
"RequestException",
",",
"LocalOperationException",
"{",
"Request",
"request",
"=",
"new",
"Request",
"(",
"this",
")",
";",
"return",
"new",
"Response",
"(",
"request",
".",
"delete",
"(",
"\"/templates/\"",
"+",
"id",
",",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
")",
")",
";",
"}"
] | Deletes a template.
@param id id of the template to delete.
@return {@link Response}
@throws RequestException if request to transloadit server fails.
@throws LocalOperationException if something goes wrong while running non-http operations. | [
"Deletes",
"a",
"template",
"."
] | 9326c540a66f77b3d907d0b2c05bff1145ca14f7 | https://github.com/transloadit/java-sdk/blob/9326c540a66f77b3d907d0b2c05bff1145ca14f7/src/main/java/com/transloadit/sdk/Transloadit.java#L225-L229 | train |
transloadit/java-sdk | src/main/java/com/transloadit/sdk/Transloadit.java | Transloadit.listTemplates | public ListResponse listTemplates(Map<String, Object> options)
throws RequestException, LocalOperationException {
Request request = new Request(this);
return new ListResponse(request.get("/templates", options));
} | java | public ListResponse listTemplates(Map<String, Object> options)
throws RequestException, LocalOperationException {
Request request = new Request(this);
return new ListResponse(request.get("/templates", options));
} | [
"public",
"ListResponse",
"listTemplates",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"options",
")",
"throws",
"RequestException",
",",
"LocalOperationException",
"{",
"Request",
"request",
"=",
"new",
"Request",
"(",
"this",
")",
";",
"return",
"new",
"ListResponse",
"(",
"request",
".",
"get",
"(",
"\"/templates\"",
",",
"options",
")",
")",
";",
"}"
] | Returns a list of all templates under the user account
@param options {@link Map} extra options to send along with the request.
@return {@link ListResponse}
@throws RequestException if request to transloadit server fails.
@throws LocalOperationException if something goes wrong while running non-http operations. | [
"Returns",
"a",
"list",
"of",
"all",
"templates",
"under",
"the",
"user",
"account"
] | 9326c540a66f77b3d907d0b2c05bff1145ca14f7 | https://github.com/transloadit/java-sdk/blob/9326c540a66f77b3d907d0b2c05bff1145ca14f7/src/main/java/com/transloadit/sdk/Transloadit.java#L240-L244 | train |
transloadit/java-sdk | src/main/java/com/transloadit/sdk/Transloadit.java | Transloadit.getBill | public Response getBill(int month, int year)
throws RequestException, LocalOperationException {
Request request = new Request(this);
return new Response(request.get("/bill/" + year + String.format("-%02d", month)));
} | java | public Response getBill(int month, int year)
throws RequestException, LocalOperationException {
Request request = new Request(this);
return new Response(request.get("/bill/" + year + String.format("-%02d", month)));
} | [
"public",
"Response",
"getBill",
"(",
"int",
"month",
",",
"int",
"year",
")",
"throws",
"RequestException",
",",
"LocalOperationException",
"{",
"Request",
"request",
"=",
"new",
"Request",
"(",
"this",
")",
";",
"return",
"new",
"Response",
"(",
"request",
".",
"get",
"(",
"\"/bill/\"",
"+",
"year",
"+",
"String",
".",
"format",
"(",
"\"-%02d\"",
",",
"month",
")",
")",
")",
";",
"}"
] | Returns the bill for the month specified.
@param month for which bill to retrieve.
@param year for which bill to retrieve.
@return {@link Response}
@throws RequestException if request to transloadit server fails.
@throws LocalOperationException if something goes wrong while running non-http operations. | [
"Returns",
"the",
"bill",
"for",
"the",
"month",
"specified",
"."
] | 9326c540a66f77b3d907d0b2c05bff1145ca14f7 | https://github.com/transloadit/java-sdk/blob/9326c540a66f77b3d907d0b2c05bff1145ca14f7/src/main/java/com/transloadit/sdk/Transloadit.java#L269-L273 | train |
resource4j/resource4j | converters/src/main/java/com/github/resource4j/converters/TypeConverter.java | TypeConverter.convert | @SuppressWarnings("unchecked")
public static <T> T convert(Object fromValue, Class<T> toType) throws TypeCastException {
return convert(fromValue, toType, (String) null);
} | java | @SuppressWarnings("unchecked")
public static <T> T convert(Object fromValue, Class<T> toType) throws TypeCastException {
return convert(fromValue, toType, (String) null);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"T",
">",
"T",
"convert",
"(",
"Object",
"fromValue",
",",
"Class",
"<",
"T",
">",
"toType",
")",
"throws",
"TypeCastException",
"{",
"return",
"convert",
"(",
"fromValue",
",",
"toType",
",",
"(",
"String",
")",
"null",
")",
";",
"}"
] | Convert given value to given target
@param fromValue
the value to convert
@param toType
target target
@param <T>
target of the result
@return the value converted to given target
@throws TypeCastException
if conversion was not possible | [
"Convert",
"given",
"value",
"to",
"given",
"target"
] | 6100443b9a78edc8a5867e1e075f7ee12e6698ca | https://github.com/resource4j/resource4j/blob/6100443b9a78edc8a5867e1e075f7ee12e6698ca/converters/src/main/java/com/github/resource4j/converters/TypeConverter.java#L122-L125 | train |
taimos/dvalin | jaxrs-jwtauth/src/main/java/de/taimos/dvalin/jaxrs/security/jwt/JWTAuth.java | JWTAuth.verifyToken | public SignedJWT verifyToken(String jwtString) throws ParseException {
try {
SignedJWT jwt = SignedJWT.parse(jwtString);
if (jwt.verify(new MACVerifier(this.jwtSharedSecret))) {
return jwt;
}
return null;
} catch (JOSEException e) {
throw new RuntimeException("Error verifying JSON Web Token", e);
}
} | java | public SignedJWT verifyToken(String jwtString) throws ParseException {
try {
SignedJWT jwt = SignedJWT.parse(jwtString);
if (jwt.verify(new MACVerifier(this.jwtSharedSecret))) {
return jwt;
}
return null;
} catch (JOSEException e) {
throw new RuntimeException("Error verifying JSON Web Token", e);
}
} | [
"public",
"SignedJWT",
"verifyToken",
"(",
"String",
"jwtString",
")",
"throws",
"ParseException",
"{",
"try",
"{",
"SignedJWT",
"jwt",
"=",
"SignedJWT",
".",
"parse",
"(",
"jwtString",
")",
";",
"if",
"(",
"jwt",
".",
"verify",
"(",
"new",
"MACVerifier",
"(",
"this",
".",
"jwtSharedSecret",
")",
")",
")",
"{",
"return",
"jwt",
";",
"}",
"return",
"null",
";",
"}",
"catch",
"(",
"JOSEException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Error verifying JSON Web Token\"",
",",
"e",
")",
";",
"}",
"}"
] | Check the given JWT
@param jwtString the JSON Web Token
@return the parsed and verified token or null if token is invalid
@throws ParseException if the token cannot be parsed | [
"Check",
"the",
"given",
"JWT"
] | ff8f1bf594e43d7e8ca8de0b4da9f923b66a1a47 | https://github.com/taimos/dvalin/blob/ff8f1bf594e43d7e8ca8de0b4da9f923b66a1a47/jaxrs-jwtauth/src/main/java/de/taimos/dvalin/jaxrs/security/jwt/JWTAuth.java#L97-L107 | train |
wcm-io/wcm-io-sling | commons/src/main/java/io/wcm/sling/commons/osgi/RankedServices.java | RankedServices.bind | public void bind(T service, Map<String, Object> props) {
synchronized (serviceMap) {
serviceMap.put(ServiceUtil.getComparableForServiceRanking(props), service);
updateSortedServices();
}
} | java | public void bind(T service, Map<String, Object> props) {
synchronized (serviceMap) {
serviceMap.put(ServiceUtil.getComparableForServiceRanking(props), service);
updateSortedServices();
}
} | [
"public",
"void",
"bind",
"(",
"T",
"service",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"props",
")",
"{",
"synchronized",
"(",
"serviceMap",
")",
"{",
"serviceMap",
".",
"put",
"(",
"ServiceUtil",
".",
"getComparableForServiceRanking",
"(",
"props",
")",
",",
"service",
")",
";",
"updateSortedServices",
"(",
")",
";",
"}",
"}"
] | Handle bind service event.
@param service Service instance
@param props Service reference properties | [
"Handle",
"bind",
"service",
"event",
"."
] | 90adbe432469378794b5695c72e9cdfa2b7d36f1 | https://github.com/wcm-io/wcm-io-sling/blob/90adbe432469378794b5695c72e9cdfa2b7d36f1/commons/src/main/java/io/wcm/sling/commons/osgi/RankedServices.java#L69-L74 | train |
wcm-io/wcm-io-sling | commons/src/main/java/io/wcm/sling/commons/osgi/RankedServices.java | RankedServices.unbind | public void unbind(T service, Map<String, Object> props) {
synchronized (serviceMap) {
serviceMap.remove(ServiceUtil.getComparableForServiceRanking(props));
updateSortedServices();
}
} | java | public void unbind(T service, Map<String, Object> props) {
synchronized (serviceMap) {
serviceMap.remove(ServiceUtil.getComparableForServiceRanking(props));
updateSortedServices();
}
} | [
"public",
"void",
"unbind",
"(",
"T",
"service",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"props",
")",
"{",
"synchronized",
"(",
"serviceMap",
")",
"{",
"serviceMap",
".",
"remove",
"(",
"ServiceUtil",
".",
"getComparableForServiceRanking",
"(",
"props",
")",
")",
";",
"updateSortedServices",
"(",
")",
";",
"}",
"}"
] | Handle unbind service event.
@param service Service instance
@param props Service reference properties | [
"Handle",
"unbind",
"service",
"event",
"."
] | 90adbe432469378794b5695c72e9cdfa2b7d36f1 | https://github.com/wcm-io/wcm-io-sling/blob/90adbe432469378794b5695c72e9cdfa2b7d36f1/commons/src/main/java/io/wcm/sling/commons/osgi/RankedServices.java#L81-L86 | train |
wcm-io/wcm-io-sling | commons/src/main/java/io/wcm/sling/commons/osgi/RankedServices.java | RankedServices.updateSortedServices | private void updateSortedServices() {
List<T> copiedList = new ArrayList<T>(serviceMap.values());
sortedServices = Collections.unmodifiableList(copiedList);
if (changeListener != null) {
changeListener.changed();
}
} | java | private void updateSortedServices() {
List<T> copiedList = new ArrayList<T>(serviceMap.values());
sortedServices = Collections.unmodifiableList(copiedList);
if (changeListener != null) {
changeListener.changed();
}
} | [
"private",
"void",
"updateSortedServices",
"(",
")",
"{",
"List",
"<",
"T",
">",
"copiedList",
"=",
"new",
"ArrayList",
"<",
"T",
">",
"(",
"serviceMap",
".",
"values",
"(",
")",
")",
";",
"sortedServices",
"=",
"Collections",
".",
"unmodifiableList",
"(",
"copiedList",
")",
";",
"if",
"(",
"changeListener",
"!=",
"null",
")",
"{",
"changeListener",
".",
"changed",
"(",
")",
";",
"}",
"}"
] | Update list of sorted services by copying it from the array and making it unmodifiable. | [
"Update",
"list",
"of",
"sorted",
"services",
"by",
"copying",
"it",
"from",
"the",
"array",
"and",
"making",
"it",
"unmodifiable",
"."
] | 90adbe432469378794b5695c72e9cdfa2b7d36f1 | https://github.com/wcm-io/wcm-io-sling/blob/90adbe432469378794b5695c72e9cdfa2b7d36f1/commons/src/main/java/io/wcm/sling/commons/osgi/RankedServices.java#L91-L97 | train |
resource4j/resource4j | integration/extras/src/main/java/com/github/resource4j/extras/json/JacksonParser.java | JacksonParser.json | public static <T> JacksonParser<T> json(Class<T> contentType) {
return new JacksonParser<>(null, contentType);
} | java | public static <T> JacksonParser<T> json(Class<T> contentType) {
return new JacksonParser<>(null, contentType);
} | [
"public",
"static",
"<",
"T",
">",
"JacksonParser",
"<",
"T",
">",
"json",
"(",
"Class",
"<",
"T",
">",
"contentType",
")",
"{",
"return",
"new",
"JacksonParser",
"<>",
"(",
"null",
",",
"contentType",
")",
";",
"}"
] | Creates typed parser
@param contentType class of parsed object
@param <T> type of parsed object
@return parser of objects of given type | [
"Creates",
"typed",
"parser"
] | 6100443b9a78edc8a5867e1e075f7ee12e6698ca | https://github.com/resource4j/resource4j/blob/6100443b9a78edc8a5867e1e075f7ee12e6698ca/integration/extras/src/main/java/com/github/resource4j/extras/json/JacksonParser.java#L35-L37 | train |
transloadit/java-sdk | src/main/java/com/transloadit/sdk/Steps.java | Steps.addStep | public void addStep(String name, String robot, Map<String, Object> options) {
all.put(name, new Step(name, robot, options));
} | java | public void addStep(String name, String robot, Map<String, Object> options) {
all.put(name, new Step(name, robot, options));
} | [
"public",
"void",
"addStep",
"(",
"String",
"name",
",",
"String",
"robot",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"options",
")",
"{",
"all",
".",
"put",
"(",
"name",
",",
"new",
"Step",
"(",
"name",
",",
"robot",
",",
"options",
")",
")",
";",
"}"
] | Adds a new step to the list of steps.
@param name Name of the step to add.
@param robot The name of the robot ot use with the step.
@param options extra options required for the step. | [
"Adds",
"a",
"new",
"step",
"to",
"the",
"list",
"of",
"steps",
"."
] | 9326c540a66f77b3d907d0b2c05bff1145ca14f7 | https://github.com/transloadit/java-sdk/blob/9326c540a66f77b3d907d0b2c05bff1145ca14f7/src/main/java/com/transloadit/sdk/Steps.java#L54-L56 | train |
heneke/thymeleaf-extras-togglz | src/main/java/com/github/heneke/thymeleaf/togglz/processor/AbstractFeatureAttrProcessor.java | AbstractFeatureAttrProcessor.determineFeatureState | protected boolean determineFeatureState(final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue, boolean defaultState) {
final IStandardExpressionParser expressionParser = StandardExpressions.getExpressionParser(context.getConfiguration());
final IStandardExpression expression = expressionParser.parseExpression(context, attributeValue);
final Object value = expression.execute(context);
if (value != null) {
return isFeatureActive(value.toString());
}
else {
return defaultState;
}
} | java | protected boolean determineFeatureState(final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue, boolean defaultState) {
final IStandardExpressionParser expressionParser = StandardExpressions.getExpressionParser(context.getConfiguration());
final IStandardExpression expression = expressionParser.parseExpression(context, attributeValue);
final Object value = expression.execute(context);
if (value != null) {
return isFeatureActive(value.toString());
}
else {
return defaultState;
}
} | [
"protected",
"boolean",
"determineFeatureState",
"(",
"final",
"ITemplateContext",
"context",
",",
"final",
"IProcessableElementTag",
"tag",
",",
"final",
"AttributeName",
"attributeName",
",",
"final",
"String",
"attributeValue",
",",
"boolean",
"defaultState",
")",
"{",
"final",
"IStandardExpressionParser",
"expressionParser",
"=",
"StandardExpressions",
".",
"getExpressionParser",
"(",
"context",
".",
"getConfiguration",
"(",
")",
")",
";",
"final",
"IStandardExpression",
"expression",
"=",
"expressionParser",
".",
"parseExpression",
"(",
"context",
",",
"attributeValue",
")",
";",
"final",
"Object",
"value",
"=",
"expression",
".",
"execute",
"(",
"context",
")",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"return",
"isFeatureActive",
"(",
"value",
".",
"toString",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"defaultState",
";",
"}",
"}"
] | Determines the feature state
@param context the template context
@param tag the tag
@param attributeName the attribute name
@param attributeValue the attribute value
@param defaultState the default state if the expression evaluates to null
@return the feature state | [
"Determines",
"the",
"feature",
"state"
] | 768984cd373c7220c35557799e79ddbc5d7f9cf2 | https://github.com/heneke/thymeleaf-extras-togglz/blob/768984cd373c7220c35557799e79ddbc5d7f9cf2/src/main/java/com/github/heneke/thymeleaf/togglz/processor/AbstractFeatureAttrProcessor.java#L53-L63 | train |
cenobites/struts2-json-plugin | src/main/java/es/cenobit/struts2/json/ClasspathConfigurationProvider.java | ClasspathConfigurationProvider.init | public void init(Configuration configuration) {
if (devMode && reload && !listeningToDispatcher) {
// this is the only way I found to be able to get added to to
// ConfigurationProvider list
// listening to events in Dispatcher
listeningToDispatcher = true;
Dispatcher.addDispatcherListener(this);
}
} | java | public void init(Configuration configuration) {
if (devMode && reload && !listeningToDispatcher) {
// this is the only way I found to be able to get added to to
// ConfigurationProvider list
// listening to events in Dispatcher
listeningToDispatcher = true;
Dispatcher.addDispatcherListener(this);
}
} | [
"public",
"void",
"init",
"(",
"Configuration",
"configuration",
")",
"{",
"if",
"(",
"devMode",
"&&",
"reload",
"&&",
"!",
"listeningToDispatcher",
")",
"{",
"// this is the only way I found to be able to get added to to",
"// ConfigurationProvider list",
"// listening to events in Dispatcher",
"listeningToDispatcher",
"=",
"true",
";",
"Dispatcher",
".",
"addDispatcherListener",
"(",
"this",
")",
";",
"}",
"}"
] | Not used. | [
"Not",
"used",
"."
] | 00f948942d85b6f696d46672332ff7b3942ecb1b | https://github.com/cenobites/struts2-json-plugin/blob/00f948942d85b6f696d46672332ff7b3942ecb1b/src/main/java/es/cenobit/struts2/json/ClasspathConfigurationProvider.java#L71-L79 | train |
transloadit/java-sdk | src/main/java/com/transloadit/sdk/Assembly.java | Assembly.addFile | public void addFile(File file) {
String name = "file";
files.put(normalizeDuplicateName(name), file);
} | java | public void addFile(File file) {
String name = "file";
files.put(normalizeDuplicateName(name), file);
} | [
"public",
"void",
"addFile",
"(",
"File",
"file",
")",
"{",
"String",
"name",
"=",
"\"file\"",
";",
"files",
".",
"put",
"(",
"normalizeDuplicateName",
"(",
"name",
")",
",",
"file",
")",
";",
"}"
] | Adds a file to your assembly but automatically generates the field name of the file.
@param file {@link File} the file to be uploaded. | [
"Adds",
"a",
"file",
"to",
"your",
"assembly",
"but",
"automatically",
"generates",
"the",
"field",
"name",
"of",
"the",
"file",
"."
] | 9326c540a66f77b3d907d0b2c05bff1145ca14f7 | https://github.com/transloadit/java-sdk/blob/9326c540a66f77b3d907d0b2c05bff1145ca14f7/src/main/java/com/transloadit/sdk/Assembly.java#L71-L74 | train |
transloadit/java-sdk | src/main/java/com/transloadit/sdk/Assembly.java | Assembly.addFile | public void addFile(InputStream inputStream) {
String name = "file";
fileStreams.put(normalizeDuplicateName(name), inputStream);
} | java | public void addFile(InputStream inputStream) {
String name = "file";
fileStreams.put(normalizeDuplicateName(name), inputStream);
} | [
"public",
"void",
"addFile",
"(",
"InputStream",
"inputStream",
")",
"{",
"String",
"name",
"=",
"\"file\"",
";",
"fileStreams",
".",
"put",
"(",
"normalizeDuplicateName",
"(",
"name",
")",
",",
"inputStream",
")",
";",
"}"
] | Adds a file to your assembly but automatically genarates the name of the file.
@param inputStream {@link InputStream} the file to be uploaded. | [
"Adds",
"a",
"file",
"to",
"your",
"assembly",
"but",
"automatically",
"genarates",
"the",
"name",
"of",
"the",
"file",
"."
] | 9326c540a66f77b3d907d0b2c05bff1145ca14f7 | https://github.com/transloadit/java-sdk/blob/9326c540a66f77b3d907d0b2c05bff1145ca14f7/src/main/java/com/transloadit/sdk/Assembly.java#L97-L100 | train |
transloadit/java-sdk | src/main/java/com/transloadit/sdk/Assembly.java | Assembly.removeFile | public void removeFile(String name) {
if(files.containsKey(name)) {
files.remove(name);
}
if(fileStreams.containsKey(name)) {
fileStreams.remove(name);
}
} | java | public void removeFile(String name) {
if(files.containsKey(name)) {
files.remove(name);
}
if(fileStreams.containsKey(name)) {
fileStreams.remove(name);
}
} | [
"public",
"void",
"removeFile",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"files",
".",
"containsKey",
"(",
"name",
")",
")",
"{",
"files",
".",
"remove",
"(",
"name",
")",
";",
"}",
"if",
"(",
"fileStreams",
".",
"containsKey",
"(",
"name",
")",
")",
"{",
"fileStreams",
".",
"remove",
"(",
"name",
")",
";",
"}",
"}"
] | Removes file from your assembly.
@param name field name of the file to remove. | [
"Removes",
"file",
"from",
"your",
"assembly",
"."
] | 9326c540a66f77b3d907d0b2c05bff1145ca14f7 | https://github.com/transloadit/java-sdk/blob/9326c540a66f77b3d907d0b2c05bff1145ca14f7/src/main/java/com/transloadit/sdk/Assembly.java#L107-L115 | train |
transloadit/java-sdk | src/main/java/com/transloadit/sdk/Assembly.java | Assembly.save | public AssemblyResponse save(boolean isResumable)
throws RequestException, LocalOperationException {
Request request = new Request(getClient());
options.put("steps", steps.toMap());
// only do tus uploads if files will be uploaded
if (isResumable && getFilesCount() > 0) {
Map<String, String> tusOptions = new HashMap<String, String>();
tusOptions.put("tus_num_expected_upload_files", Integer.toString(getFilesCount()));
AssemblyResponse response = new AssemblyResponse(
request.post("/assemblies", options, tusOptions, null, null), true);
// check if the assembly returned an error
if (response.hasError()) {
throw new RequestException("Request to Assembly failed: " + response.json().getString("error"));
}
try {
handleTusUpload(response);
} catch (IOException e) {
throw new LocalOperationException(e);
} catch (ProtocolException e) {
throw new RequestException(e);
}
return response;
} else {
return new AssemblyResponse(request.post("/assemblies", options, null, files, fileStreams));
}
} | java | public AssemblyResponse save(boolean isResumable)
throws RequestException, LocalOperationException {
Request request = new Request(getClient());
options.put("steps", steps.toMap());
// only do tus uploads if files will be uploaded
if (isResumable && getFilesCount() > 0) {
Map<String, String> tusOptions = new HashMap<String, String>();
tusOptions.put("tus_num_expected_upload_files", Integer.toString(getFilesCount()));
AssemblyResponse response = new AssemblyResponse(
request.post("/assemblies", options, tusOptions, null, null), true);
// check if the assembly returned an error
if (response.hasError()) {
throw new RequestException("Request to Assembly failed: " + response.json().getString("error"));
}
try {
handleTusUpload(response);
} catch (IOException e) {
throw new LocalOperationException(e);
} catch (ProtocolException e) {
throw new RequestException(e);
}
return response;
} else {
return new AssemblyResponse(request.post("/assemblies", options, null, files, fileStreams));
}
} | [
"public",
"AssemblyResponse",
"save",
"(",
"boolean",
"isResumable",
")",
"throws",
"RequestException",
",",
"LocalOperationException",
"{",
"Request",
"request",
"=",
"new",
"Request",
"(",
"getClient",
"(",
")",
")",
";",
"options",
".",
"put",
"(",
"\"steps\"",
",",
"steps",
".",
"toMap",
"(",
")",
")",
";",
"// only do tus uploads if files will be uploaded",
"if",
"(",
"isResumable",
"&&",
"getFilesCount",
"(",
")",
">",
"0",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"tusOptions",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"tusOptions",
".",
"put",
"(",
"\"tus_num_expected_upload_files\"",
",",
"Integer",
".",
"toString",
"(",
"getFilesCount",
"(",
")",
")",
")",
";",
"AssemblyResponse",
"response",
"=",
"new",
"AssemblyResponse",
"(",
"request",
".",
"post",
"(",
"\"/assemblies\"",
",",
"options",
",",
"tusOptions",
",",
"null",
",",
"null",
")",
",",
"true",
")",
";",
"// check if the assembly returned an error",
"if",
"(",
"response",
".",
"hasError",
"(",
")",
")",
"{",
"throw",
"new",
"RequestException",
"(",
"\"Request to Assembly failed: \"",
"+",
"response",
".",
"json",
"(",
")",
".",
"getString",
"(",
"\"error\"",
")",
")",
";",
"}",
"try",
"{",
"handleTusUpload",
"(",
"response",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"LocalOperationException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"ProtocolException",
"e",
")",
"{",
"throw",
"new",
"RequestException",
"(",
"e",
")",
";",
"}",
"return",
"response",
";",
"}",
"else",
"{",
"return",
"new",
"AssemblyResponse",
"(",
"request",
".",
"post",
"(",
"\"/assemblies\"",
",",
"options",
",",
"null",
",",
"files",
",",
"fileStreams",
")",
")",
";",
"}",
"}"
] | Submits the configured assembly to Transloadit for processing.
@param isResumable boolean value that tells the assembly whether or not to use tus.
@return {@link AssemblyResponse} the response received from the Transloadit server.
@throws RequestException if request to Transloadit server fails.
@throws LocalOperationException if something goes wrong while running non-http operations. | [
"Submits",
"the",
"configured",
"assembly",
"to",
"Transloadit",
"for",
"processing",
"."
] | 9326c540a66f77b3d907d0b2c05bff1145ca14f7 | https://github.com/transloadit/java-sdk/blob/9326c540a66f77b3d907d0b2c05bff1145ca14f7/src/main/java/com/transloadit/sdk/Assembly.java#L155-L184 | train |
transloadit/java-sdk | src/main/java/com/transloadit/sdk/Assembly.java | Assembly.processTusFiles | protected void processTusFiles(String assemblyUrl) throws IOException, ProtocolException {
tusClient.setUploadCreationURL(new URL(getClient().getHostUrl() + "/resumable/files/"));
tusClient.enableResuming(tusURLStore);
for (Map.Entry<String, File> entry : files.entrySet()) {
processTusFile(entry.getValue(), entry.getKey(), assemblyUrl);
}
for (Map.Entry<String, InputStream> entry : fileStreams.entrySet()) {
processTusFile(entry.getValue(), entry.getKey(), assemblyUrl);
}
} | java | protected void processTusFiles(String assemblyUrl) throws IOException, ProtocolException {
tusClient.setUploadCreationURL(new URL(getClient().getHostUrl() + "/resumable/files/"));
tusClient.enableResuming(tusURLStore);
for (Map.Entry<String, File> entry : files.entrySet()) {
processTusFile(entry.getValue(), entry.getKey(), assemblyUrl);
}
for (Map.Entry<String, InputStream> entry : fileStreams.entrySet()) {
processTusFile(entry.getValue(), entry.getKey(), assemblyUrl);
}
} | [
"protected",
"void",
"processTusFiles",
"(",
"String",
"assemblyUrl",
")",
"throws",
"IOException",
",",
"ProtocolException",
"{",
"tusClient",
".",
"setUploadCreationURL",
"(",
"new",
"URL",
"(",
"getClient",
"(",
")",
".",
"getHostUrl",
"(",
")",
"+",
"\"/resumable/files/\"",
")",
")",
";",
"tusClient",
".",
"enableResuming",
"(",
"tusURLStore",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"File",
">",
"entry",
":",
"files",
".",
"entrySet",
"(",
")",
")",
"{",
"processTusFile",
"(",
"entry",
".",
"getValue",
"(",
")",
",",
"entry",
".",
"getKey",
"(",
")",
",",
"assemblyUrl",
")",
";",
"}",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"InputStream",
">",
"entry",
":",
"fileStreams",
".",
"entrySet",
"(",
")",
")",
"{",
"processTusFile",
"(",
"entry",
".",
"getValue",
"(",
")",
",",
"entry",
".",
"getKey",
"(",
")",
",",
"assemblyUrl",
")",
";",
"}",
"}"
] | Prepares all files added for tus uploads.
@param assemblyUrl the assembly url affiliated with the tus upload.
@throws IOException when there's a failure with file retrieval.
@throws ProtocolException when there's a failure with tus upload. | [
"Prepares",
"all",
"files",
"added",
"for",
"tus",
"uploads",
"."
] | 9326c540a66f77b3d907d0b2c05bff1145ca14f7 | https://github.com/transloadit/java-sdk/blob/9326c540a66f77b3d907d0b2c05bff1145ca14f7/src/main/java/com/transloadit/sdk/Assembly.java#L209-L220 | train |
openEHR/adl2-core | adl2core-common/src/main/java/org/openehr/adl/util/AdlUtils.java | AdlUtils.makeClone | @SuppressWarnings("unchecked")
public static <T extends Serializable> T makeClone(T from) {
return (T) SerializationUtils.clone(from);
} | java | @SuppressWarnings("unchecked")
public static <T extends Serializable> T makeClone(T from) {
return (T) SerializationUtils.clone(from);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"T",
"extends",
"Serializable",
">",
"T",
"makeClone",
"(",
"T",
"from",
")",
"{",
"return",
"(",
"T",
")",
"SerializationUtils",
".",
"clone",
"(",
"from",
")",
";",
"}"
] | Creates a clone using java serialization
@param from Object to be cloned
@param <T> type of the cloned object
@return Clone of the object | [
"Creates",
"a",
"clone",
"using",
"java",
"serialization"
] | dd5c1c0fe7ef5e43fbfaf6a0389990ba5380e22c | https://github.com/openEHR/adl2-core/blob/dd5c1c0fe7ef5e43fbfaf6a0389990ba5380e22c/adl2core-common/src/main/java/org/openehr/adl/util/AdlUtils.java#L96-L99 | train |
jcuda/jcudnn | JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java | JCudnn.checkResult | private static int checkResult(int result)
{
if (exceptionsEnabled && result !=
cudnnStatus.CUDNN_STATUS_SUCCESS)
{
throw new CudaException(cudnnStatus.stringFor(result));
}
return result;
} | java | private static int checkResult(int result)
{
if (exceptionsEnabled && result !=
cudnnStatus.CUDNN_STATUS_SUCCESS)
{
throw new CudaException(cudnnStatus.stringFor(result));
}
return result;
} | [
"private",
"static",
"int",
"checkResult",
"(",
"int",
"result",
")",
"{",
"if",
"(",
"exceptionsEnabled",
"&&",
"result",
"!=",
"cudnnStatus",
".",
"CUDNN_STATUS_SUCCESS",
")",
"{",
"throw",
"new",
"CudaException",
"(",
"cudnnStatus",
".",
"stringFor",
"(",
"result",
")",
")",
";",
"}",
"return",
"result",
";",
"}"
] | If the given result is not cudnnStatus.CUDNN_STATUS_SUCCESS
and exceptions have been enabled, this method will throw a
CudaException with an error message that corresponds to the
given result code. Otherwise, the given result is simply
returned.
@param result The result to check
@return The result that was given as the parameter
@throws CudaException If exceptions have been enabled and
the given result code is not cudnnStatus.CUDNN_STATUS_SUCCESS | [
"If",
"the",
"given",
"result",
"is",
"not",
"cudnnStatus",
".",
"CUDNN_STATUS_SUCCESS",
"and",
"exceptions",
"have",
"been",
"enabled",
"this",
"method",
"will",
"throw",
"a",
"CudaException",
"with",
"an",
"error",
"message",
"that",
"corresponds",
"to",
"the",
"given",
"result",
"code",
".",
"Otherwise",
"the",
"given",
"result",
"is",
"simply",
"returned",
"."
] | ce71f2fc02817cecace51a80e6db5f0c7f10cffc | https://github.com/jcuda/jcudnn/blob/ce71f2fc02817cecace51a80e6db5f0c7f10cffc/JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java#L134-L142 | train |
jcuda/jcudnn | JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java | JCudnn.cudnnSetTensor4dDescriptorEx | public static int cudnnSetTensor4dDescriptorEx(
cudnnTensorDescriptor tensorDesc,
int dataType, /** image data type */
int n, /** number of inputs (batch size) */
int c, /** number of input feature maps */
int h, /** height of input section */
int w, /** width of input section */
int nStride,
int cStride,
int hStride,
int wStride)
{
return checkResult(cudnnSetTensor4dDescriptorExNative(tensorDesc, dataType, n, c, h, w, nStride, cStride, hStride, wStride));
} | java | public static int cudnnSetTensor4dDescriptorEx(
cudnnTensorDescriptor tensorDesc,
int dataType, /** image data type */
int n, /** number of inputs (batch size) */
int c, /** number of input feature maps */
int h, /** height of input section */
int w, /** width of input section */
int nStride,
int cStride,
int hStride,
int wStride)
{
return checkResult(cudnnSetTensor4dDescriptorExNative(tensorDesc, dataType, n, c, h, w, nStride, cStride, hStride, wStride));
} | [
"public",
"static",
"int",
"cudnnSetTensor4dDescriptorEx",
"(",
"cudnnTensorDescriptor",
"tensorDesc",
",",
"int",
"dataType",
",",
"/** image data type */",
"int",
"n",
",",
"/** number of inputs (batch size) */",
"int",
"c",
",",
"/** number of input feature maps */",
"int",
"h",
",",
"/** height of input section */",
"int",
"w",
",",
"/** width of input section */",
"int",
"nStride",
",",
"int",
"cStride",
",",
"int",
"hStride",
",",
"int",
"wStride",
")",
"{",
"return",
"checkResult",
"(",
"cudnnSetTensor4dDescriptorExNative",
"(",
"tensorDesc",
",",
"dataType",
",",
"n",
",",
"c",
",",
"h",
",",
"w",
",",
"nStride",
",",
"cStride",
",",
"hStride",
",",
"wStride",
")",
")",
";",
"}"
] | width of input section | [
"width",
"of",
"input",
"section"
] | ce71f2fc02817cecace51a80e6db5f0c7f10cffc | https://github.com/jcuda/jcudnn/blob/ce71f2fc02817cecace51a80e6db5f0c7f10cffc/JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java#L285-L298 | train |
jcuda/jcudnn | JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java | JCudnn.cudnnOpTensor | public static int cudnnOpTensor(
cudnnHandle handle,
cudnnOpTensorDescriptor opTensorDesc,
Pointer alpha1,
cudnnTensorDescriptor aDesc,
Pointer A,
Pointer alpha2,
cudnnTensorDescriptor bDesc,
Pointer B,
Pointer beta,
cudnnTensorDescriptor cDesc,
Pointer C)
{
return checkResult(cudnnOpTensorNative(handle, opTensorDesc, alpha1, aDesc, A, alpha2, bDesc, B, beta, cDesc, C));
} | java | public static int cudnnOpTensor(
cudnnHandle handle,
cudnnOpTensorDescriptor opTensorDesc,
Pointer alpha1,
cudnnTensorDescriptor aDesc,
Pointer A,
Pointer alpha2,
cudnnTensorDescriptor bDesc,
Pointer B,
Pointer beta,
cudnnTensorDescriptor cDesc,
Pointer C)
{
return checkResult(cudnnOpTensorNative(handle, opTensorDesc, alpha1, aDesc, A, alpha2, bDesc, B, beta, cDesc, C));
} | [
"public",
"static",
"int",
"cudnnOpTensor",
"(",
"cudnnHandle",
"handle",
",",
"cudnnOpTensorDescriptor",
"opTensorDesc",
",",
"Pointer",
"alpha1",
",",
"cudnnTensorDescriptor",
"aDesc",
",",
"Pointer",
"A",
",",
"Pointer",
"alpha2",
",",
"cudnnTensorDescriptor",
"bDesc",
",",
"Pointer",
"B",
",",
"Pointer",
"beta",
",",
"cudnnTensorDescriptor",
"cDesc",
",",
"Pointer",
"C",
")",
"{",
"return",
"checkResult",
"(",
"cudnnOpTensorNative",
"(",
"handle",
",",
"opTensorDesc",
",",
"alpha1",
",",
"aDesc",
",",
"A",
",",
"alpha2",
",",
"bDesc",
",",
"B",
",",
"beta",
",",
"cDesc",
",",
"C",
")",
")",
";",
"}"
] | B tensor is ignored for CUDNN_OP_TENSOR_SQRT, CUDNN_OP_TENSOR_NOT. | [
"B",
"tensor",
"is",
"ignored",
"for",
"CUDNN_OP_TENSOR_SQRT",
"CUDNN_OP_TENSOR_NOT",
"."
] | ce71f2fc02817cecace51a80e6db5f0c7f10cffc | https://github.com/jcuda/jcudnn/blob/ce71f2fc02817cecace51a80e6db5f0c7f10cffc/JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java#L532-L546 | train |
jcuda/jcudnn | JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java | JCudnn.cudnnGetReductionIndicesSize | public static int cudnnGetReductionIndicesSize(
cudnnHandle handle,
cudnnReduceTensorDescriptor reduceTensorDesc,
cudnnTensorDescriptor aDesc,
cudnnTensorDescriptor cDesc,
long[] sizeInBytes)
{
return checkResult(cudnnGetReductionIndicesSizeNative(handle, reduceTensorDesc, aDesc, cDesc, sizeInBytes));
} | java | public static int cudnnGetReductionIndicesSize(
cudnnHandle handle,
cudnnReduceTensorDescriptor reduceTensorDesc,
cudnnTensorDescriptor aDesc,
cudnnTensorDescriptor cDesc,
long[] sizeInBytes)
{
return checkResult(cudnnGetReductionIndicesSizeNative(handle, reduceTensorDesc, aDesc, cDesc, sizeInBytes));
} | [
"public",
"static",
"int",
"cudnnGetReductionIndicesSize",
"(",
"cudnnHandle",
"handle",
",",
"cudnnReduceTensorDescriptor",
"reduceTensorDesc",
",",
"cudnnTensorDescriptor",
"aDesc",
",",
"cudnnTensorDescriptor",
"cDesc",
",",
"long",
"[",
"]",
"sizeInBytes",
")",
"{",
"return",
"checkResult",
"(",
"cudnnGetReductionIndicesSizeNative",
"(",
"handle",
",",
"reduceTensorDesc",
",",
"aDesc",
",",
"cDesc",
",",
"sizeInBytes",
")",
")",
";",
"}"
] | Helper function to return the minimum size of the index space to be passed to the reduction given the input and
output tensors | [
"Helper",
"function",
"to",
"return",
"the",
"minimum",
"size",
"of",
"the",
"index",
"space",
"to",
"be",
"passed",
"to",
"the",
"reduction",
"given",
"the",
"input",
"and",
"output",
"tensors"
] | ce71f2fc02817cecace51a80e6db5f0c7f10cffc | https://github.com/jcuda/jcudnn/blob/ce71f2fc02817cecace51a80e6db5f0c7f10cffc/JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java#L619-L627 | train |
jcuda/jcudnn | JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java | JCudnn.cudnnGetReductionWorkspaceSize | public static int cudnnGetReductionWorkspaceSize(
cudnnHandle handle,
cudnnReduceTensorDescriptor reduceTensorDesc,
cudnnTensorDescriptor aDesc,
cudnnTensorDescriptor cDesc,
long[] sizeInBytes)
{
return checkResult(cudnnGetReductionWorkspaceSizeNative(handle, reduceTensorDesc, aDesc, cDesc, sizeInBytes));
} | java | public static int cudnnGetReductionWorkspaceSize(
cudnnHandle handle,
cudnnReduceTensorDescriptor reduceTensorDesc,
cudnnTensorDescriptor aDesc,
cudnnTensorDescriptor cDesc,
long[] sizeInBytes)
{
return checkResult(cudnnGetReductionWorkspaceSizeNative(handle, reduceTensorDesc, aDesc, cDesc, sizeInBytes));
} | [
"public",
"static",
"int",
"cudnnGetReductionWorkspaceSize",
"(",
"cudnnHandle",
"handle",
",",
"cudnnReduceTensorDescriptor",
"reduceTensorDesc",
",",
"cudnnTensorDescriptor",
"aDesc",
",",
"cudnnTensorDescriptor",
"cDesc",
",",
"long",
"[",
"]",
"sizeInBytes",
")",
"{",
"return",
"checkResult",
"(",
"cudnnGetReductionWorkspaceSizeNative",
"(",
"handle",
",",
"reduceTensorDesc",
",",
"aDesc",
",",
"cDesc",
",",
"sizeInBytes",
")",
")",
";",
"}"
] | Helper function to return the minimum size of the workspace to be passed to the reduction given the input and output
tensors | [
"Helper",
"function",
"to",
"return",
"the",
"minimum",
"size",
"of",
"the",
"workspace",
"to",
"be",
"passed",
"to",
"the",
"reduction",
"given",
"the",
"input",
"and",
"output",
"tensors"
] | ce71f2fc02817cecace51a80e6db5f0c7f10cffc | https://github.com/jcuda/jcudnn/blob/ce71f2fc02817cecace51a80e6db5f0c7f10cffc/JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java#L638-L646 | train |
jcuda/jcudnn | JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java | JCudnn.cudnnReduceTensor | public static int cudnnReduceTensor(
cudnnHandle handle,
cudnnReduceTensorDescriptor reduceTensorDesc,
Pointer indices,
long indicesSizeInBytes,
Pointer workspace,
long workspaceSizeInBytes,
Pointer alpha,
cudnnTensorDescriptor aDesc,
Pointer A,
Pointer beta,
cudnnTensorDescriptor cDesc,
Pointer C)
{
return checkResult(cudnnReduceTensorNative(handle, reduceTensorDesc, indices, indicesSizeInBytes, workspace, workspaceSizeInBytes, alpha, aDesc, A, beta, cDesc, C));
} | java | public static int cudnnReduceTensor(
cudnnHandle handle,
cudnnReduceTensorDescriptor reduceTensorDesc,
Pointer indices,
long indicesSizeInBytes,
Pointer workspace,
long workspaceSizeInBytes,
Pointer alpha,
cudnnTensorDescriptor aDesc,
Pointer A,
Pointer beta,
cudnnTensorDescriptor cDesc,
Pointer C)
{
return checkResult(cudnnReduceTensorNative(handle, reduceTensorDesc, indices, indicesSizeInBytes, workspace, workspaceSizeInBytes, alpha, aDesc, A, beta, cDesc, C));
} | [
"public",
"static",
"int",
"cudnnReduceTensor",
"(",
"cudnnHandle",
"handle",
",",
"cudnnReduceTensorDescriptor",
"reduceTensorDesc",
",",
"Pointer",
"indices",
",",
"long",
"indicesSizeInBytes",
",",
"Pointer",
"workspace",
",",
"long",
"workspaceSizeInBytes",
",",
"Pointer",
"alpha",
",",
"cudnnTensorDescriptor",
"aDesc",
",",
"Pointer",
"A",
",",
"Pointer",
"beta",
",",
"cudnnTensorDescriptor",
"cDesc",
",",
"Pointer",
"C",
")",
"{",
"return",
"checkResult",
"(",
"cudnnReduceTensorNative",
"(",
"handle",
",",
"reduceTensorDesc",
",",
"indices",
",",
"indicesSizeInBytes",
",",
"workspace",
",",
"workspaceSizeInBytes",
",",
"alpha",
",",
"aDesc",
",",
"A",
",",
"beta",
",",
"cDesc",
",",
"C",
")",
")",
";",
"}"
] | The indices space is ignored for reduce ops other than min or max. | [
"The",
"indices",
"space",
"is",
"ignored",
"for",
"reduce",
"ops",
"other",
"than",
"min",
"or",
"max",
"."
] | ce71f2fc02817cecace51a80e6db5f0c7f10cffc | https://github.com/jcuda/jcudnn/blob/ce71f2fc02817cecace51a80e6db5f0c7f10cffc/JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java#L658-L673 | train |
jcuda/jcudnn | JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java | JCudnn.cudnnGetConvolutionNdDescriptor | public static int cudnnGetConvolutionNdDescriptor(
cudnnConvolutionDescriptor convDesc,
int arrayLengthRequested,
int[] arrayLength,
int[] padA,
int[] strideA,
int[] dilationA,
int[] mode,
int[] computeType)/** convolution data type */
{
return checkResult(cudnnGetConvolutionNdDescriptorNative(convDesc, arrayLengthRequested, arrayLength, padA, strideA, dilationA, mode, computeType));
} | java | public static int cudnnGetConvolutionNdDescriptor(
cudnnConvolutionDescriptor convDesc,
int arrayLengthRequested,
int[] arrayLength,
int[] padA,
int[] strideA,
int[] dilationA,
int[] mode,
int[] computeType)/** convolution data type */
{
return checkResult(cudnnGetConvolutionNdDescriptorNative(convDesc, arrayLengthRequested, arrayLength, padA, strideA, dilationA, mode, computeType));
} | [
"public",
"static",
"int",
"cudnnGetConvolutionNdDescriptor",
"(",
"cudnnConvolutionDescriptor",
"convDesc",
",",
"int",
"arrayLengthRequested",
",",
"int",
"[",
"]",
"arrayLength",
",",
"int",
"[",
"]",
"padA",
",",
"int",
"[",
"]",
"strideA",
",",
"int",
"[",
"]",
"dilationA",
",",
"int",
"[",
"]",
"mode",
",",
"int",
"[",
"]",
"computeType",
")",
"/** convolution data type */",
"{",
"return",
"checkResult",
"(",
"cudnnGetConvolutionNdDescriptorNative",
"(",
"convDesc",
",",
"arrayLengthRequested",
",",
"arrayLength",
",",
"padA",
",",
"strideA",
",",
"dilationA",
",",
"mode",
",",
"computeType",
")",
")",
";",
"}"
] | convolution data type | [
"convolution",
"data",
"type"
] | ce71f2fc02817cecace51a80e6db5f0c7f10cffc | https://github.com/jcuda/jcudnn/blob/ce71f2fc02817cecace51a80e6db5f0c7f10cffc/JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java#L965-L976 | train |
jcuda/jcudnn | JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java | JCudnn.cudnnConvolutionForward | public static int cudnnConvolutionForward(
cudnnHandle handle,
Pointer alpha,
cudnnTensorDescriptor xDesc,
Pointer x,
cudnnFilterDescriptor wDesc,
Pointer w,
cudnnConvolutionDescriptor convDesc,
int algo,
Pointer workSpace,
long workSpaceSizeInBytes,
Pointer beta,
cudnnTensorDescriptor yDesc,
Pointer y)
{
return checkResult(cudnnConvolutionForwardNative(handle, alpha, xDesc, x, wDesc, w, convDesc, algo, workSpace, workSpaceSizeInBytes, beta, yDesc, y));
} | java | public static int cudnnConvolutionForward(
cudnnHandle handle,
Pointer alpha,
cudnnTensorDescriptor xDesc,
Pointer x,
cudnnFilterDescriptor wDesc,
Pointer w,
cudnnConvolutionDescriptor convDesc,
int algo,
Pointer workSpace,
long workSpaceSizeInBytes,
Pointer beta,
cudnnTensorDescriptor yDesc,
Pointer y)
{
return checkResult(cudnnConvolutionForwardNative(handle, alpha, xDesc, x, wDesc, w, convDesc, algo, workSpace, workSpaceSizeInBytes, beta, yDesc, y));
} | [
"public",
"static",
"int",
"cudnnConvolutionForward",
"(",
"cudnnHandle",
"handle",
",",
"Pointer",
"alpha",
",",
"cudnnTensorDescriptor",
"xDesc",
",",
"Pointer",
"x",
",",
"cudnnFilterDescriptor",
"wDesc",
",",
"Pointer",
"w",
",",
"cudnnConvolutionDescriptor",
"convDesc",
",",
"int",
"algo",
",",
"Pointer",
"workSpace",
",",
"long",
"workSpaceSizeInBytes",
",",
"Pointer",
"beta",
",",
"cudnnTensorDescriptor",
"yDesc",
",",
"Pointer",
"y",
")",
"{",
"return",
"checkResult",
"(",
"cudnnConvolutionForwardNative",
"(",
"handle",
",",
"alpha",
",",
"xDesc",
",",
"x",
",",
"wDesc",
",",
"w",
",",
"convDesc",
",",
"algo",
",",
"workSpace",
",",
"workSpaceSizeInBytes",
",",
"beta",
",",
"yDesc",
",",
"y",
")",
")",
";",
"}"
] | Function to perform the forward pass for batch convolution | [
"Function",
"to",
"perform",
"the",
"forward",
"pass",
"for",
"batch",
"convolution"
] | ce71f2fc02817cecace51a80e6db5f0c7f10cffc | https://github.com/jcuda/jcudnn/blob/ce71f2fc02817cecace51a80e6db5f0c7f10cffc/JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java#L1156-L1172 | train |
jcuda/jcudnn | JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java | JCudnn.cudnnConvolutionBackwardBias | public static int cudnnConvolutionBackwardBias(
cudnnHandle handle,
Pointer alpha,
cudnnTensorDescriptor dyDesc,
Pointer dy,
Pointer beta,
cudnnTensorDescriptor dbDesc,
Pointer db)
{
return checkResult(cudnnConvolutionBackwardBiasNative(handle, alpha, dyDesc, dy, beta, dbDesc, db));
} | java | public static int cudnnConvolutionBackwardBias(
cudnnHandle handle,
Pointer alpha,
cudnnTensorDescriptor dyDesc,
Pointer dy,
Pointer beta,
cudnnTensorDescriptor dbDesc,
Pointer db)
{
return checkResult(cudnnConvolutionBackwardBiasNative(handle, alpha, dyDesc, dy, beta, dbDesc, db));
} | [
"public",
"static",
"int",
"cudnnConvolutionBackwardBias",
"(",
"cudnnHandle",
"handle",
",",
"Pointer",
"alpha",
",",
"cudnnTensorDescriptor",
"dyDesc",
",",
"Pointer",
"dy",
",",
"Pointer",
"beta",
",",
"cudnnTensorDescriptor",
"dbDesc",
",",
"Pointer",
"db",
")",
"{",
"return",
"checkResult",
"(",
"cudnnConvolutionBackwardBiasNative",
"(",
"handle",
",",
"alpha",
",",
"dyDesc",
",",
"dy",
",",
"beta",
",",
"dbDesc",
",",
"db",
")",
")",
";",
"}"
] | Function to compute the bias gradient for batch convolution | [
"Function",
"to",
"compute",
"the",
"bias",
"gradient",
"for",
"batch",
"convolution"
] | ce71f2fc02817cecace51a80e6db5f0c7f10cffc | https://github.com/jcuda/jcudnn/blob/ce71f2fc02817cecace51a80e6db5f0c7f10cffc/JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java#L1234-L1244 | train |
jcuda/jcudnn | JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java | JCudnn.cudnnSoftmaxForward | public static int cudnnSoftmaxForward(
cudnnHandle handle,
int algo,
int mode,
Pointer alpha,
cudnnTensorDescriptor xDesc,
Pointer x,
Pointer beta,
cudnnTensorDescriptor yDesc,
Pointer y)
{
return checkResult(cudnnSoftmaxForwardNative(handle, algo, mode, alpha, xDesc, x, beta, yDesc, y));
} | java | public static int cudnnSoftmaxForward(
cudnnHandle handle,
int algo,
int mode,
Pointer alpha,
cudnnTensorDescriptor xDesc,
Pointer x,
Pointer beta,
cudnnTensorDescriptor yDesc,
Pointer y)
{
return checkResult(cudnnSoftmaxForwardNative(handle, algo, mode, alpha, xDesc, x, beta, yDesc, y));
} | [
"public",
"static",
"int",
"cudnnSoftmaxForward",
"(",
"cudnnHandle",
"handle",
",",
"int",
"algo",
",",
"int",
"mode",
",",
"Pointer",
"alpha",
",",
"cudnnTensorDescriptor",
"xDesc",
",",
"Pointer",
"x",
",",
"Pointer",
"beta",
",",
"cudnnTensorDescriptor",
"yDesc",
",",
"Pointer",
"y",
")",
"{",
"return",
"checkResult",
"(",
"cudnnSoftmaxForwardNative",
"(",
"handle",
",",
"algo",
",",
"mode",
",",
"alpha",
",",
"xDesc",
",",
"x",
",",
"beta",
",",
"yDesc",
",",
"y",
")",
")",
";",
"}"
] | Function to perform forward softmax | [
"Function",
"to",
"perform",
"forward",
"softmax"
] | ce71f2fc02817cecace51a80e6db5f0c7f10cffc | https://github.com/jcuda/jcudnn/blob/ce71f2fc02817cecace51a80e6db5f0c7f10cffc/JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java#L1615-L1627 | train |
jcuda/jcudnn | JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java | JCudnn.cudnnSoftmaxBackward | public static int cudnnSoftmaxBackward(
cudnnHandle handle,
int algo,
int mode,
Pointer alpha,
cudnnTensorDescriptor yDesc,
Pointer y,
cudnnTensorDescriptor dyDesc,
Pointer dy,
Pointer beta,
cudnnTensorDescriptor dxDesc,
Pointer dx)
{
return checkResult(cudnnSoftmaxBackwardNative(handle, algo, mode, alpha, yDesc, y, dyDesc, dy, beta, dxDesc, dx));
} | java | public static int cudnnSoftmaxBackward(
cudnnHandle handle,
int algo,
int mode,
Pointer alpha,
cudnnTensorDescriptor yDesc,
Pointer y,
cudnnTensorDescriptor dyDesc,
Pointer dy,
Pointer beta,
cudnnTensorDescriptor dxDesc,
Pointer dx)
{
return checkResult(cudnnSoftmaxBackwardNative(handle, algo, mode, alpha, yDesc, y, dyDesc, dy, beta, dxDesc, dx));
} | [
"public",
"static",
"int",
"cudnnSoftmaxBackward",
"(",
"cudnnHandle",
"handle",
",",
"int",
"algo",
",",
"int",
"mode",
",",
"Pointer",
"alpha",
",",
"cudnnTensorDescriptor",
"yDesc",
",",
"Pointer",
"y",
",",
"cudnnTensorDescriptor",
"dyDesc",
",",
"Pointer",
"dy",
",",
"Pointer",
"beta",
",",
"cudnnTensorDescriptor",
"dxDesc",
",",
"Pointer",
"dx",
")",
"{",
"return",
"checkResult",
"(",
"cudnnSoftmaxBackwardNative",
"(",
"handle",
",",
"algo",
",",
"mode",
",",
"alpha",
",",
"yDesc",
",",
"y",
",",
"dyDesc",
",",
"dy",
",",
"beta",
",",
"dxDesc",
",",
"dx",
")",
")",
";",
"}"
] | Function to perform backward softmax | [
"Function",
"to",
"perform",
"backward",
"softmax"
] | ce71f2fc02817cecace51a80e6db5f0c7f10cffc | https://github.com/jcuda/jcudnn/blob/ce71f2fc02817cecace51a80e6db5f0c7f10cffc/JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java#L1641-L1655 | train |
jcuda/jcudnn | JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java | JCudnn.cudnnPoolingForward | public static int cudnnPoolingForward(
cudnnHandle handle,
cudnnPoolingDescriptor poolingDesc,
Pointer alpha,
cudnnTensorDescriptor xDesc,
Pointer x,
Pointer beta,
cudnnTensorDescriptor yDesc,
Pointer y)
{
return checkResult(cudnnPoolingForwardNative(handle, poolingDesc, alpha, xDesc, x, beta, yDesc, y));
} | java | public static int cudnnPoolingForward(
cudnnHandle handle,
cudnnPoolingDescriptor poolingDesc,
Pointer alpha,
cudnnTensorDescriptor xDesc,
Pointer x,
Pointer beta,
cudnnTensorDescriptor yDesc,
Pointer y)
{
return checkResult(cudnnPoolingForwardNative(handle, poolingDesc, alpha, xDesc, x, beta, yDesc, y));
} | [
"public",
"static",
"int",
"cudnnPoolingForward",
"(",
"cudnnHandle",
"handle",
",",
"cudnnPoolingDescriptor",
"poolingDesc",
",",
"Pointer",
"alpha",
",",
"cudnnTensorDescriptor",
"xDesc",
",",
"Pointer",
"x",
",",
"Pointer",
"beta",
",",
"cudnnTensorDescriptor",
"yDesc",
",",
"Pointer",
"y",
")",
"{",
"return",
"checkResult",
"(",
"cudnnPoolingForwardNative",
"(",
"handle",
",",
"poolingDesc",
",",
"alpha",
",",
"xDesc",
",",
"x",
",",
"beta",
",",
"yDesc",
",",
"y",
")",
")",
";",
"}"
] | Function to perform forward pooling | [
"Function",
"to",
"perform",
"forward",
"pooling"
] | ce71f2fc02817cecace51a80e6db5f0c7f10cffc | https://github.com/jcuda/jcudnn/blob/ce71f2fc02817cecace51a80e6db5f0c7f10cffc/JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java#L1820-L1831 | train |
jcuda/jcudnn | JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java | JCudnn.cudnnPoolingBackward | public static int cudnnPoolingBackward(
cudnnHandle handle,
cudnnPoolingDescriptor poolingDesc,
Pointer alpha,
cudnnTensorDescriptor yDesc,
Pointer y,
cudnnTensorDescriptor dyDesc,
Pointer dy,
cudnnTensorDescriptor xDesc,
Pointer x,
Pointer beta,
cudnnTensorDescriptor dxDesc,
Pointer dx)
{
return checkResult(cudnnPoolingBackwardNative(handle, poolingDesc, alpha, yDesc, y, dyDesc, dy, xDesc, x, beta, dxDesc, dx));
} | java | public static int cudnnPoolingBackward(
cudnnHandle handle,
cudnnPoolingDescriptor poolingDesc,
Pointer alpha,
cudnnTensorDescriptor yDesc,
Pointer y,
cudnnTensorDescriptor dyDesc,
Pointer dy,
cudnnTensorDescriptor xDesc,
Pointer x,
Pointer beta,
cudnnTensorDescriptor dxDesc,
Pointer dx)
{
return checkResult(cudnnPoolingBackwardNative(handle, poolingDesc, alpha, yDesc, y, dyDesc, dy, xDesc, x, beta, dxDesc, dx));
} | [
"public",
"static",
"int",
"cudnnPoolingBackward",
"(",
"cudnnHandle",
"handle",
",",
"cudnnPoolingDescriptor",
"poolingDesc",
",",
"Pointer",
"alpha",
",",
"cudnnTensorDescriptor",
"yDesc",
",",
"Pointer",
"y",
",",
"cudnnTensorDescriptor",
"dyDesc",
",",
"Pointer",
"dy",
",",
"cudnnTensorDescriptor",
"xDesc",
",",
"Pointer",
"x",
",",
"Pointer",
"beta",
",",
"cudnnTensorDescriptor",
"dxDesc",
",",
"Pointer",
"dx",
")",
"{",
"return",
"checkResult",
"(",
"cudnnPoolingBackwardNative",
"(",
"handle",
",",
"poolingDesc",
",",
"alpha",
",",
"yDesc",
",",
"y",
",",
"dyDesc",
",",
"dy",
",",
"xDesc",
",",
"x",
",",
"beta",
",",
"dxDesc",
",",
"dx",
")",
")",
";",
"}"
] | Function to perform backward pooling | [
"Function",
"to",
"perform",
"backward",
"pooling"
] | ce71f2fc02817cecace51a80e6db5f0c7f10cffc | https://github.com/jcuda/jcudnn/blob/ce71f2fc02817cecace51a80e6db5f0c7f10cffc/JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java#L1844-L1859 | train |
jcuda/jcudnn | JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java | JCudnn.cudnnGetActivationDescriptor | public static int cudnnGetActivationDescriptor(
cudnnActivationDescriptor activationDesc,
int[] mode,
int[] reluNanOpt,
double[] coef)/** ceiling for clipped RELU, alpha for ELU */
{
return checkResult(cudnnGetActivationDescriptorNative(activationDesc, mode, reluNanOpt, coef));
} | java | public static int cudnnGetActivationDescriptor(
cudnnActivationDescriptor activationDesc,
int[] mode,
int[] reluNanOpt,
double[] coef)/** ceiling for clipped RELU, alpha for ELU */
{
return checkResult(cudnnGetActivationDescriptorNative(activationDesc, mode, reluNanOpt, coef));
} | [
"public",
"static",
"int",
"cudnnGetActivationDescriptor",
"(",
"cudnnActivationDescriptor",
"activationDesc",
",",
"int",
"[",
"]",
"mode",
",",
"int",
"[",
"]",
"reluNanOpt",
",",
"double",
"[",
"]",
"coef",
")",
"/** ceiling for clipped RELU, alpha for ELU */",
"{",
"return",
"checkResult",
"(",
"cudnnGetActivationDescriptorNative",
"(",
"activationDesc",
",",
"mode",
",",
"reluNanOpt",
",",
"coef",
")",
")",
";",
"}"
] | ceiling for clipped RELU, alpha for ELU | [
"ceiling",
"for",
"clipped",
"RELU",
"alpha",
"for",
"ELU"
] | ce71f2fc02817cecace51a80e6db5f0c7f10cffc | https://github.com/jcuda/jcudnn/blob/ce71f2fc02817cecace51a80e6db5f0c7f10cffc/JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java#L1900-L1907 | train |
jcuda/jcudnn | JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java | JCudnn.cudnnActivationForward | public static int cudnnActivationForward(
cudnnHandle handle,
cudnnActivationDescriptor activationDesc,
Pointer alpha,
cudnnTensorDescriptor xDesc,
Pointer x,
Pointer beta,
cudnnTensorDescriptor yDesc,
Pointer y)
{
return checkResult(cudnnActivationForwardNative(handle, activationDesc, alpha, xDesc, x, beta, yDesc, y));
} | java | public static int cudnnActivationForward(
cudnnHandle handle,
cudnnActivationDescriptor activationDesc,
Pointer alpha,
cudnnTensorDescriptor xDesc,
Pointer x,
Pointer beta,
cudnnTensorDescriptor yDesc,
Pointer y)
{
return checkResult(cudnnActivationForwardNative(handle, activationDesc, alpha, xDesc, x, beta, yDesc, y));
} | [
"public",
"static",
"int",
"cudnnActivationForward",
"(",
"cudnnHandle",
"handle",
",",
"cudnnActivationDescriptor",
"activationDesc",
",",
"Pointer",
"alpha",
",",
"cudnnTensorDescriptor",
"xDesc",
",",
"Pointer",
"x",
",",
"Pointer",
"beta",
",",
"cudnnTensorDescriptor",
"yDesc",
",",
"Pointer",
"y",
")",
"{",
"return",
"checkResult",
"(",
"cudnnActivationForwardNative",
"(",
"handle",
",",
"activationDesc",
",",
"alpha",
",",
"xDesc",
",",
"x",
",",
"beta",
",",
"yDesc",
",",
"y",
")",
")",
";",
"}"
] | Function to perform forward activation | [
"Function",
"to",
"perform",
"forward",
"activation"
] | ce71f2fc02817cecace51a80e6db5f0c7f10cffc | https://github.com/jcuda/jcudnn/blob/ce71f2fc02817cecace51a80e6db5f0c7f10cffc/JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java#L1925-L1936 | train |
jcuda/jcudnn | JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java | JCudnn.cudnnActivationBackward | public static int cudnnActivationBackward(
cudnnHandle handle,
cudnnActivationDescriptor activationDesc,
Pointer alpha,
cudnnTensorDescriptor yDesc,
Pointer y,
cudnnTensorDescriptor dyDesc,
Pointer dy,
cudnnTensorDescriptor xDesc,
Pointer x,
Pointer beta,
cudnnTensorDescriptor dxDesc,
Pointer dx)
{
return checkResult(cudnnActivationBackwardNative(handle, activationDesc, alpha, yDesc, y, dyDesc, dy, xDesc, x, beta, dxDesc, dx));
} | java | public static int cudnnActivationBackward(
cudnnHandle handle,
cudnnActivationDescriptor activationDesc,
Pointer alpha,
cudnnTensorDescriptor yDesc,
Pointer y,
cudnnTensorDescriptor dyDesc,
Pointer dy,
cudnnTensorDescriptor xDesc,
Pointer x,
Pointer beta,
cudnnTensorDescriptor dxDesc,
Pointer dx)
{
return checkResult(cudnnActivationBackwardNative(handle, activationDesc, alpha, yDesc, y, dyDesc, dy, xDesc, x, beta, dxDesc, dx));
} | [
"public",
"static",
"int",
"cudnnActivationBackward",
"(",
"cudnnHandle",
"handle",
",",
"cudnnActivationDescriptor",
"activationDesc",
",",
"Pointer",
"alpha",
",",
"cudnnTensorDescriptor",
"yDesc",
",",
"Pointer",
"y",
",",
"cudnnTensorDescriptor",
"dyDesc",
",",
"Pointer",
"dy",
",",
"cudnnTensorDescriptor",
"xDesc",
",",
"Pointer",
"x",
",",
"Pointer",
"beta",
",",
"cudnnTensorDescriptor",
"dxDesc",
",",
"Pointer",
"dx",
")",
"{",
"return",
"checkResult",
"(",
"cudnnActivationBackwardNative",
"(",
"handle",
",",
"activationDesc",
",",
"alpha",
",",
"yDesc",
",",
"y",
",",
"dyDesc",
",",
"dy",
",",
"xDesc",
",",
"x",
",",
"beta",
",",
"dxDesc",
",",
"dx",
")",
")",
";",
"}"
] | Function to perform backward activation | [
"Function",
"to",
"perform",
"backward",
"activation"
] | ce71f2fc02817cecace51a80e6db5f0c7f10cffc | https://github.com/jcuda/jcudnn/blob/ce71f2fc02817cecace51a80e6db5f0c7f10cffc/JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java#L1949-L1964 | train |
jcuda/jcudnn | JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java | JCudnn.cudnnLRNCrossChannelForward | public static int cudnnLRNCrossChannelForward(
cudnnHandle handle,
cudnnLRNDescriptor normDesc,
int lrnMode,
Pointer alpha,
cudnnTensorDescriptor xDesc,
Pointer x,
Pointer beta,
cudnnTensorDescriptor yDesc,
Pointer y)
{
return checkResult(cudnnLRNCrossChannelForwardNative(handle, normDesc, lrnMode, alpha, xDesc, x, beta, yDesc, y));
} | java | public static int cudnnLRNCrossChannelForward(
cudnnHandle handle,
cudnnLRNDescriptor normDesc,
int lrnMode,
Pointer alpha,
cudnnTensorDescriptor xDesc,
Pointer x,
Pointer beta,
cudnnTensorDescriptor yDesc,
Pointer y)
{
return checkResult(cudnnLRNCrossChannelForwardNative(handle, normDesc, lrnMode, alpha, xDesc, x, beta, yDesc, y));
} | [
"public",
"static",
"int",
"cudnnLRNCrossChannelForward",
"(",
"cudnnHandle",
"handle",
",",
"cudnnLRNDescriptor",
"normDesc",
",",
"int",
"lrnMode",
",",
"Pointer",
"alpha",
",",
"cudnnTensorDescriptor",
"xDesc",
",",
"Pointer",
"x",
",",
"Pointer",
"beta",
",",
"cudnnTensorDescriptor",
"yDesc",
",",
"Pointer",
"y",
")",
"{",
"return",
"checkResult",
"(",
"cudnnLRNCrossChannelForwardNative",
"(",
"handle",
",",
"normDesc",
",",
"lrnMode",
",",
"alpha",
",",
"xDesc",
",",
"x",
",",
"beta",
",",
"yDesc",
",",
"y",
")",
")",
";",
"}"
] | LRN cross-channel forward computation. Double parameters cast to tensor data type | [
"LRN",
"cross",
"-",
"channel",
"forward",
"computation",
".",
"Double",
"parameters",
"cast",
"to",
"tensor",
"data",
"type"
] | ce71f2fc02817cecace51a80e6db5f0c7f10cffc | https://github.com/jcuda/jcudnn/blob/ce71f2fc02817cecace51a80e6db5f0c7f10cffc/JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java#L2054-L2066 | train |
jcuda/jcudnn | JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java | JCudnn.cudnnLRNCrossChannelBackward | public static int cudnnLRNCrossChannelBackward(
cudnnHandle handle,
cudnnLRNDescriptor normDesc,
int lrnMode,
Pointer alpha,
cudnnTensorDescriptor yDesc,
Pointer y,
cudnnTensorDescriptor dyDesc,
Pointer dy,
cudnnTensorDescriptor xDesc,
Pointer x,
Pointer beta,
cudnnTensorDescriptor dxDesc,
Pointer dx)
{
return checkResult(cudnnLRNCrossChannelBackwardNative(handle, normDesc, lrnMode, alpha, yDesc, y, dyDesc, dy, xDesc, x, beta, dxDesc, dx));
} | java | public static int cudnnLRNCrossChannelBackward(
cudnnHandle handle,
cudnnLRNDescriptor normDesc,
int lrnMode,
Pointer alpha,
cudnnTensorDescriptor yDesc,
Pointer y,
cudnnTensorDescriptor dyDesc,
Pointer dy,
cudnnTensorDescriptor xDesc,
Pointer x,
Pointer beta,
cudnnTensorDescriptor dxDesc,
Pointer dx)
{
return checkResult(cudnnLRNCrossChannelBackwardNative(handle, normDesc, lrnMode, alpha, yDesc, y, dyDesc, dy, xDesc, x, beta, dxDesc, dx));
} | [
"public",
"static",
"int",
"cudnnLRNCrossChannelBackward",
"(",
"cudnnHandle",
"handle",
",",
"cudnnLRNDescriptor",
"normDesc",
",",
"int",
"lrnMode",
",",
"Pointer",
"alpha",
",",
"cudnnTensorDescriptor",
"yDesc",
",",
"Pointer",
"y",
",",
"cudnnTensorDescriptor",
"dyDesc",
",",
"Pointer",
"dy",
",",
"cudnnTensorDescriptor",
"xDesc",
",",
"Pointer",
"x",
",",
"Pointer",
"beta",
",",
"cudnnTensorDescriptor",
"dxDesc",
",",
"Pointer",
"dx",
")",
"{",
"return",
"checkResult",
"(",
"cudnnLRNCrossChannelBackwardNative",
"(",
"handle",
",",
"normDesc",
",",
"lrnMode",
",",
"alpha",
",",
"yDesc",
",",
"y",
",",
"dyDesc",
",",
"dy",
",",
"xDesc",
",",
"x",
",",
"beta",
",",
"dxDesc",
",",
"dx",
")",
")",
";",
"}"
] | LRN cross-channel backward computation. Double parameters cast to tensor data type | [
"LRN",
"cross",
"-",
"channel",
"backward",
"computation",
".",
"Double",
"parameters",
"cast",
"to",
"tensor",
"data",
"type"
] | ce71f2fc02817cecace51a80e6db5f0c7f10cffc | https://github.com/jcuda/jcudnn/blob/ce71f2fc02817cecace51a80e6db5f0c7f10cffc/JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java#L2080-L2096 | train |
jcuda/jcudnn | JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java | JCudnn.cudnnBatchNormalizationBackward | public static int cudnnBatchNormalizationBackward(
cudnnHandle handle,
int mode,
Pointer alphaDataDiff,
Pointer betaDataDiff,
Pointer alphaParamDiff,
Pointer betaParamDiff,
cudnnTensorDescriptor xDesc, /** same desc for x, dx, dy */
Pointer x,
cudnnTensorDescriptor dyDesc,
Pointer dy,
cudnnTensorDescriptor dxDesc,
Pointer dx,
/** Shared tensor desc for the 4 tensors below */
cudnnTensorDescriptor dBnScaleBiasDesc,
Pointer bnScale, /** bnBias doesn't affect backpropagation */
/** scale and bias diff are not backpropagated below this layer */
Pointer dBnScaleResult,
Pointer dBnBiasResult,
/** Same epsilon as forward pass */
double epsilon,
/** Optionally cached intermediate results from
forward pass */
Pointer savedMean,
Pointer savedInvVariance)
{
return checkResult(cudnnBatchNormalizationBackwardNative(handle, mode, alphaDataDiff, betaDataDiff, alphaParamDiff, betaParamDiff, xDesc, x, dyDesc, dy, dxDesc, dx, dBnScaleBiasDesc, bnScale, dBnScaleResult, dBnBiasResult, epsilon, savedMean, savedInvVariance));
} | java | public static int cudnnBatchNormalizationBackward(
cudnnHandle handle,
int mode,
Pointer alphaDataDiff,
Pointer betaDataDiff,
Pointer alphaParamDiff,
Pointer betaParamDiff,
cudnnTensorDescriptor xDesc, /** same desc for x, dx, dy */
Pointer x,
cudnnTensorDescriptor dyDesc,
Pointer dy,
cudnnTensorDescriptor dxDesc,
Pointer dx,
/** Shared tensor desc for the 4 tensors below */
cudnnTensorDescriptor dBnScaleBiasDesc,
Pointer bnScale, /** bnBias doesn't affect backpropagation */
/** scale and bias diff are not backpropagated below this layer */
Pointer dBnScaleResult,
Pointer dBnBiasResult,
/** Same epsilon as forward pass */
double epsilon,
/** Optionally cached intermediate results from
forward pass */
Pointer savedMean,
Pointer savedInvVariance)
{
return checkResult(cudnnBatchNormalizationBackwardNative(handle, mode, alphaDataDiff, betaDataDiff, alphaParamDiff, betaParamDiff, xDesc, x, dyDesc, dy, dxDesc, dx, dBnScaleBiasDesc, bnScale, dBnScaleResult, dBnBiasResult, epsilon, savedMean, savedInvVariance));
} | [
"public",
"static",
"int",
"cudnnBatchNormalizationBackward",
"(",
"cudnnHandle",
"handle",
",",
"int",
"mode",
",",
"Pointer",
"alphaDataDiff",
",",
"Pointer",
"betaDataDiff",
",",
"Pointer",
"alphaParamDiff",
",",
"Pointer",
"betaParamDiff",
",",
"cudnnTensorDescriptor",
"xDesc",
",",
"/** same desc for x, dx, dy */",
"Pointer",
"x",
",",
"cudnnTensorDescriptor",
"dyDesc",
",",
"Pointer",
"dy",
",",
"cudnnTensorDescriptor",
"dxDesc",
",",
"Pointer",
"dx",
",",
"/** Shared tensor desc for the 4 tensors below */",
"cudnnTensorDescriptor",
"dBnScaleBiasDesc",
",",
"Pointer",
"bnScale",
",",
"/** bnBias doesn't affect backpropagation */",
"/** scale and bias diff are not backpropagated below this layer */",
"Pointer",
"dBnScaleResult",
",",
"Pointer",
"dBnBiasResult",
",",
"/** Same epsilon as forward pass */",
"double",
"epsilon",
",",
"/** Optionally cached intermediate results from\n forward pass */",
"Pointer",
"savedMean",
",",
"Pointer",
"savedInvVariance",
")",
"{",
"return",
"checkResult",
"(",
"cudnnBatchNormalizationBackwardNative",
"(",
"handle",
",",
"mode",
",",
"alphaDataDiff",
",",
"betaDataDiff",
",",
"alphaParamDiff",
",",
"betaParamDiff",
",",
"xDesc",
",",
"x",
",",
"dyDesc",
",",
"dy",
",",
"dxDesc",
",",
"dx",
",",
"dBnScaleBiasDesc",
",",
"bnScale",
",",
"dBnScaleResult",
",",
"dBnBiasResult",
",",
"epsilon",
",",
"savedMean",
",",
"savedInvVariance",
")",
")",
";",
"}"
] | Performs backward pass of Batch Normalization layer. Returns x gradient,
bnScale gradient and bnBias gradient | [
"Performs",
"backward",
"pass",
"of",
"Batch",
"Normalization",
"layer",
".",
"Returns",
"x",
"gradient",
"bnScale",
"gradient",
"and",
"bnBias",
"gradient"
] | ce71f2fc02817cecace51a80e6db5f0c7f10cffc | https://github.com/jcuda/jcudnn/blob/ce71f2fc02817cecace51a80e6db5f0c7f10cffc/JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java#L2487-L2514 | train |
jcuda/jcudnn | JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java | JCudnn.cudnnRestoreDropoutDescriptor | public static int cudnnRestoreDropoutDescriptor(
cudnnDropoutDescriptor dropoutDesc,
cudnnHandle handle,
float dropout,
Pointer states,
long stateSizeInBytes,
long seed)
{
return checkResult(cudnnRestoreDropoutDescriptorNative(dropoutDesc, handle, dropout, states, stateSizeInBytes, seed));
} | java | public static int cudnnRestoreDropoutDescriptor(
cudnnDropoutDescriptor dropoutDesc,
cudnnHandle handle,
float dropout,
Pointer states,
long stateSizeInBytes,
long seed)
{
return checkResult(cudnnRestoreDropoutDescriptorNative(dropoutDesc, handle, dropout, states, stateSizeInBytes, seed));
} | [
"public",
"static",
"int",
"cudnnRestoreDropoutDescriptor",
"(",
"cudnnDropoutDescriptor",
"dropoutDesc",
",",
"cudnnHandle",
"handle",
",",
"float",
"dropout",
",",
"Pointer",
"states",
",",
"long",
"stateSizeInBytes",
",",
"long",
"seed",
")",
"{",
"return",
"checkResult",
"(",
"cudnnRestoreDropoutDescriptorNative",
"(",
"dropoutDesc",
",",
"handle",
",",
"dropout",
",",
"states",
",",
"stateSizeInBytes",
",",
"seed",
")",
")",
";",
"}"
] | Restores the dropout descriptor to a previously saved-off state | [
"Restores",
"the",
"dropout",
"descriptor",
"to",
"a",
"previously",
"saved",
"-",
"off",
"state"
] | ce71f2fc02817cecace51a80e6db5f0c7f10cffc | https://github.com/jcuda/jcudnn/blob/ce71f2fc02817cecace51a80e6db5f0c7f10cffc/JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java#L2802-L2811 | train |
jcuda/jcudnn | JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java | JCudnn.cudnnCreatePersistentRNNPlan | public static int cudnnCreatePersistentRNNPlan(
cudnnRNNDescriptor rnnDesc,
int minibatch,
int dataType,
cudnnPersistentRNNPlan plan)
{
return checkResult(cudnnCreatePersistentRNNPlanNative(rnnDesc, minibatch, dataType, plan));
} | java | public static int cudnnCreatePersistentRNNPlan(
cudnnRNNDescriptor rnnDesc,
int minibatch,
int dataType,
cudnnPersistentRNNPlan plan)
{
return checkResult(cudnnCreatePersistentRNNPlanNative(rnnDesc, minibatch, dataType, plan));
} | [
"public",
"static",
"int",
"cudnnCreatePersistentRNNPlan",
"(",
"cudnnRNNDescriptor",
"rnnDesc",
",",
"int",
"minibatch",
",",
"int",
"dataType",
",",
"cudnnPersistentRNNPlan",
"plan",
")",
"{",
"return",
"checkResult",
"(",
"cudnnCreatePersistentRNNPlanNative",
"(",
"rnnDesc",
",",
"minibatch",
",",
"dataType",
",",
"plan",
")",
")",
";",
"}"
] | Expensive. Creates the plan for the specific settings. | [
"Expensive",
".",
"Creates",
"the",
"plan",
"for",
"the",
"specific",
"settings",
"."
] | ce71f2fc02817cecace51a80e6db5f0c7f10cffc | https://github.com/jcuda/jcudnn/blob/ce71f2fc02817cecace51a80e6db5f0c7f10cffc/JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java#L3179-L3186 | train |
jcuda/jcudnn | JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java | JCudnn.cudnnGetRNNWorkspaceSize | public static int cudnnGetRNNWorkspaceSize(
cudnnHandle handle,
cudnnRNNDescriptor rnnDesc,
int seqLength,
cudnnTensorDescriptor[] xDesc,
long[] sizeInBytes)
{
return checkResult(cudnnGetRNNWorkspaceSizeNative(handle, rnnDesc, seqLength, xDesc, sizeInBytes));
} | java | public static int cudnnGetRNNWorkspaceSize(
cudnnHandle handle,
cudnnRNNDescriptor rnnDesc,
int seqLength,
cudnnTensorDescriptor[] xDesc,
long[] sizeInBytes)
{
return checkResult(cudnnGetRNNWorkspaceSizeNative(handle, rnnDesc, seqLength, xDesc, sizeInBytes));
} | [
"public",
"static",
"int",
"cudnnGetRNNWorkspaceSize",
"(",
"cudnnHandle",
"handle",
",",
"cudnnRNNDescriptor",
"rnnDesc",
",",
"int",
"seqLength",
",",
"cudnnTensorDescriptor",
"[",
"]",
"xDesc",
",",
"long",
"[",
"]",
"sizeInBytes",
")",
"{",
"return",
"checkResult",
"(",
"cudnnGetRNNWorkspaceSizeNative",
"(",
"handle",
",",
"rnnDesc",
",",
"seqLength",
",",
"xDesc",
",",
"sizeInBytes",
")",
")",
";",
"}"
] | dataType in weight descriptors and input descriptors is used to describe storage | [
"dataType",
"in",
"weight",
"descriptors",
"and",
"input",
"descriptors",
"is",
"used",
"to",
"describe",
"storage"
] | ce71f2fc02817cecace51a80e6db5f0c7f10cffc | https://github.com/jcuda/jcudnn/blob/ce71f2fc02817cecace51a80e6db5f0c7f10cffc/JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java#L3336-L3344 | train |
jcuda/jcudnn | JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java | JCudnn.cudnnCTCLoss | public static int cudnnCTCLoss(
cudnnHandle handle,
cudnnTensorDescriptor probsDesc, /** Tensor descriptor for probabilities, the dimensions are T,N,A (T is the timing steps, N is the
mini batch size, A is the alphabet size) */
Pointer probs, /** probabilities after softmax, in GPU memory */
int[] labels, /** labels, in CPU memory */
int[] labelLengths, /** the length of each label, in CPU memory */
int[] inputLengths, /** the lengths of timing steps in each batch, in CPU memory */
Pointer costs, /** the returned costs of CTC, in GPU memory */
cudnnTensorDescriptor gradientsDesc, /** Tensor descriptor for gradients, the dimensions are T,N,A */
Pointer gradients, /** the returned CTC gradients, in GPU memory, to compute costs only, set it to NULL */
int algo, /** algorithm selected, supported now 0 and 1 */
cudnnCTCLossDescriptor ctcLossDesc,
Pointer workspace, /** pointer to the workspace, in GPU memory */
long workSpaceSizeInBytes)/** the workspace size needed */
{
return checkResult(cudnnCTCLossNative(handle, probsDesc, probs, labels, labelLengths, inputLengths, costs, gradientsDesc, gradients, algo, ctcLossDesc, workspace, workSpaceSizeInBytes));
} | java | public static int cudnnCTCLoss(
cudnnHandle handle,
cudnnTensorDescriptor probsDesc, /** Tensor descriptor for probabilities, the dimensions are T,N,A (T is the timing steps, N is the
mini batch size, A is the alphabet size) */
Pointer probs, /** probabilities after softmax, in GPU memory */
int[] labels, /** labels, in CPU memory */
int[] labelLengths, /** the length of each label, in CPU memory */
int[] inputLengths, /** the lengths of timing steps in each batch, in CPU memory */
Pointer costs, /** the returned costs of CTC, in GPU memory */
cudnnTensorDescriptor gradientsDesc, /** Tensor descriptor for gradients, the dimensions are T,N,A */
Pointer gradients, /** the returned CTC gradients, in GPU memory, to compute costs only, set it to NULL */
int algo, /** algorithm selected, supported now 0 and 1 */
cudnnCTCLossDescriptor ctcLossDesc,
Pointer workspace, /** pointer to the workspace, in GPU memory */
long workSpaceSizeInBytes)/** the workspace size needed */
{
return checkResult(cudnnCTCLossNative(handle, probsDesc, probs, labels, labelLengths, inputLengths, costs, gradientsDesc, gradients, algo, ctcLossDesc, workspace, workSpaceSizeInBytes));
} | [
"public",
"static",
"int",
"cudnnCTCLoss",
"(",
"cudnnHandle",
"handle",
",",
"cudnnTensorDescriptor",
"probsDesc",
",",
"/** Tensor descriptor for probabilities, the dimensions are T,N,A (T is the timing steps, N is the\n mini batch size, A is the alphabet size) */",
"Pointer",
"probs",
",",
"/** probabilities after softmax, in GPU memory */",
"int",
"[",
"]",
"labels",
",",
"/** labels, in CPU memory */",
"int",
"[",
"]",
"labelLengths",
",",
"/** the length of each label, in CPU memory */",
"int",
"[",
"]",
"inputLengths",
",",
"/** the lengths of timing steps in each batch, in CPU memory */",
"Pointer",
"costs",
",",
"/** the returned costs of CTC, in GPU memory */",
"cudnnTensorDescriptor",
"gradientsDesc",
",",
"/** Tensor descriptor for gradients, the dimensions are T,N,A */",
"Pointer",
"gradients",
",",
"/** the returned CTC gradients, in GPU memory, to compute costs only, set it to NULL */",
"int",
"algo",
",",
"/** algorithm selected, supported now 0 and 1 */",
"cudnnCTCLossDescriptor",
"ctcLossDesc",
",",
"Pointer",
"workspace",
",",
"/** pointer to the workspace, in GPU memory */",
"long",
"workSpaceSizeInBytes",
")",
"/** the workspace size needed */",
"{",
"return",
"checkResult",
"(",
"cudnnCTCLossNative",
"(",
"handle",
",",
"probsDesc",
",",
"probs",
",",
"labels",
",",
"labelLengths",
",",
"inputLengths",
",",
"costs",
",",
"gradientsDesc",
",",
"gradients",
",",
"algo",
",",
"ctcLossDesc",
",",
"workspace",
",",
"workSpaceSizeInBytes",
")",
")",
";",
"}"
] | return the ctc costs and gradients, given the probabilities and labels | [
"return",
"the",
"ctc",
"costs",
"and",
"gradients",
"given",
"the",
"probabilities",
"and",
"labels"
] | ce71f2fc02817cecace51a80e6db5f0c7f10cffc | https://github.com/jcuda/jcudnn/blob/ce71f2fc02817cecace51a80e6db5f0c7f10cffc/JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java#L3673-L3690 | train |
jcuda/jcudnn | JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java | JCudnn.cudnnGetCTCLossWorkspaceSize | public static int cudnnGetCTCLossWorkspaceSize(
cudnnHandle handle,
cudnnTensorDescriptor probsDesc, /** Tensor descriptor for probabilities, the dimensions are T,N,A (T is the
timing steps, N is the mini batch size, A is the alphabet size) */
cudnnTensorDescriptor gradientsDesc, /** Tensor descriptor for gradients, the
dimensions are T,N,A. To compute costs
only, set it to NULL */
int[] labels, /** labels, in CPU memory */
int[] labelLengths, /** the length of each label, in CPU memory */
int[] inputLengths, /** the lengths of timing steps in each batch, in CPU memory */
int algo, /** algorithm selected, supported now 0 and 1 */
cudnnCTCLossDescriptor ctcLossDesc,
long[] sizeInBytes)/** pointer to the returned workspace size */
{
return checkResult(cudnnGetCTCLossWorkspaceSizeNative(handle, probsDesc, gradientsDesc, labels, labelLengths, inputLengths, algo, ctcLossDesc, sizeInBytes));
} | java | public static int cudnnGetCTCLossWorkspaceSize(
cudnnHandle handle,
cudnnTensorDescriptor probsDesc, /** Tensor descriptor for probabilities, the dimensions are T,N,A (T is the
timing steps, N is the mini batch size, A is the alphabet size) */
cudnnTensorDescriptor gradientsDesc, /** Tensor descriptor for gradients, the
dimensions are T,N,A. To compute costs
only, set it to NULL */
int[] labels, /** labels, in CPU memory */
int[] labelLengths, /** the length of each label, in CPU memory */
int[] inputLengths, /** the lengths of timing steps in each batch, in CPU memory */
int algo, /** algorithm selected, supported now 0 and 1 */
cudnnCTCLossDescriptor ctcLossDesc,
long[] sizeInBytes)/** pointer to the returned workspace size */
{
return checkResult(cudnnGetCTCLossWorkspaceSizeNative(handle, probsDesc, gradientsDesc, labels, labelLengths, inputLengths, algo, ctcLossDesc, sizeInBytes));
} | [
"public",
"static",
"int",
"cudnnGetCTCLossWorkspaceSize",
"(",
"cudnnHandle",
"handle",
",",
"cudnnTensorDescriptor",
"probsDesc",
",",
"/** Tensor descriptor for probabilities, the dimensions are T,N,A (T is the\n timing steps, N is the mini batch size, A is the alphabet size) */",
"cudnnTensorDescriptor",
"gradientsDesc",
",",
"/** Tensor descriptor for gradients, the\n dimensions are T,N,A. To compute costs\n only, set it to NULL */",
"int",
"[",
"]",
"labels",
",",
"/** labels, in CPU memory */",
"int",
"[",
"]",
"labelLengths",
",",
"/** the length of each label, in CPU memory */",
"int",
"[",
"]",
"inputLengths",
",",
"/** the lengths of timing steps in each batch, in CPU memory */",
"int",
"algo",
",",
"/** algorithm selected, supported now 0 and 1 */",
"cudnnCTCLossDescriptor",
"ctcLossDesc",
",",
"long",
"[",
"]",
"sizeInBytes",
")",
"/** pointer to the returned workspace size */",
"{",
"return",
"checkResult",
"(",
"cudnnGetCTCLossWorkspaceSizeNative",
"(",
"handle",
",",
"probsDesc",
",",
"gradientsDesc",
",",
"labels",
",",
"labelLengths",
",",
"inputLengths",
",",
"algo",
",",
"ctcLossDesc",
",",
"sizeInBytes",
")",
")",
";",
"}"
] | return the workspace size needed for ctc | [
"return",
"the",
"workspace",
"size",
"needed",
"for",
"ctc"
] | ce71f2fc02817cecace51a80e6db5f0c7f10cffc | https://github.com/jcuda/jcudnn/blob/ce71f2fc02817cecace51a80e6db5f0c7f10cffc/JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java#L3709-L3724 | train |
jcuda/jcudnn | JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java | JCudnn.cudnnGetRNNDataDescriptor | public static int cudnnGetRNNDataDescriptor(
cudnnRNNDataDescriptor RNNDataDesc,
int[] dataType,
int[] layout,
int[] maxSeqLength,
int[] batchSize,
int[] vectorSize,
int arrayLengthRequested,
int[] seqLengthArray,
Pointer paddingFill)
{
return checkResult(cudnnGetRNNDataDescriptorNative(RNNDataDesc, dataType, layout, maxSeqLength, batchSize, vectorSize, arrayLengthRequested, seqLengthArray, paddingFill));
} | java | public static int cudnnGetRNNDataDescriptor(
cudnnRNNDataDescriptor RNNDataDesc,
int[] dataType,
int[] layout,
int[] maxSeqLength,
int[] batchSize,
int[] vectorSize,
int arrayLengthRequested,
int[] seqLengthArray,
Pointer paddingFill)
{
return checkResult(cudnnGetRNNDataDescriptorNative(RNNDataDesc, dataType, layout, maxSeqLength, batchSize, vectorSize, arrayLengthRequested, seqLengthArray, paddingFill));
} | [
"public",
"static",
"int",
"cudnnGetRNNDataDescriptor",
"(",
"cudnnRNNDataDescriptor",
"RNNDataDesc",
",",
"int",
"[",
"]",
"dataType",
",",
"int",
"[",
"]",
"layout",
",",
"int",
"[",
"]",
"maxSeqLength",
",",
"int",
"[",
"]",
"batchSize",
",",
"int",
"[",
"]",
"vectorSize",
",",
"int",
"arrayLengthRequested",
",",
"int",
"[",
"]",
"seqLengthArray",
",",
"Pointer",
"paddingFill",
")",
"{",
"return",
"checkResult",
"(",
"cudnnGetRNNDataDescriptorNative",
"(",
"RNNDataDesc",
",",
"dataType",
",",
"layout",
",",
"maxSeqLength",
",",
"batchSize",
",",
"vectorSize",
",",
"arrayLengthRequested",
",",
"seqLengthArray",
",",
"paddingFill",
")",
")",
";",
"}"
] | symbol for filling padding position in output | [
"symbol",
"for",
"filling",
"padding",
"position",
"in",
"output"
] | ce71f2fc02817cecace51a80e6db5f0c7f10cffc | https://github.com/jcuda/jcudnn/blob/ce71f2fc02817cecace51a80e6db5f0c7f10cffc/JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java#L4017-L4029 | train |
resource4j/resource4j | core/src/main/java/com/github/resource4j/values/ResourceValues.java | ResourceValues.ofNullable | public static <T> OptionalValue<T> ofNullable(T value) {
return new GenericOptionalValue<T>(RUNTIME_SOURCE, DEFAULT_KEY, value);
} | java | public static <T> OptionalValue<T> ofNullable(T value) {
return new GenericOptionalValue<T>(RUNTIME_SOURCE, DEFAULT_KEY, value);
} | [
"public",
"static",
"<",
"T",
">",
"OptionalValue",
"<",
"T",
">",
"ofNullable",
"(",
"T",
"value",
")",
"{",
"return",
"new",
"GenericOptionalValue",
"<",
"T",
">",
"(",
"RUNTIME_SOURCE",
",",
"DEFAULT_KEY",
",",
"value",
")",
";",
"}"
] | Returns new instance of OptionalValue with given value
@param value wrapped object
@param <T> type of the wrapped object
@return given object wrapped in OptionalValue | [
"Returns",
"new",
"instance",
"of",
"OptionalValue",
"with",
"given",
"value"
] | 6100443b9a78edc8a5867e1e075f7ee12e6698ca | https://github.com/resource4j/resource4j/blob/6100443b9a78edc8a5867e1e075f7ee12e6698ca/core/src/main/java/com/github/resource4j/values/ResourceValues.java#L33-L35 | train |
resource4j/resource4j | core/src/main/java/com/github/resource4j/values/ResourceValues.java | ResourceValues.ofNullable | public static <T> OptionalValue<T> ofNullable(ResourceKey key, T value) {
return new GenericOptionalValue<T>(RUNTIME_SOURCE, key, value);
} | java | public static <T> OptionalValue<T> ofNullable(ResourceKey key, T value) {
return new GenericOptionalValue<T>(RUNTIME_SOURCE, key, value);
} | [
"public",
"static",
"<",
"T",
">",
"OptionalValue",
"<",
"T",
">",
"ofNullable",
"(",
"ResourceKey",
"key",
",",
"T",
"value",
")",
"{",
"return",
"new",
"GenericOptionalValue",
"<",
"T",
">",
"(",
"RUNTIME_SOURCE",
",",
"key",
",",
"value",
")",
";",
"}"
] | Returns new instance of OptionalValue with given key and value
@param key resource key of the created value
@param value wrapped object
@param <T> type of the wrapped object
@return given object wrapped in OptionalValue with given key | [
"Returns",
"new",
"instance",
"of",
"OptionalValue",
"with",
"given",
"key",
"and",
"value"
] | 6100443b9a78edc8a5867e1e075f7ee12e6698ca | https://github.com/resource4j/resource4j/blob/6100443b9a78edc8a5867e1e075f7ee12e6698ca/core/src/main/java/com/github/resource4j/values/ResourceValues.java#L44-L46 | train |
taimos/dvalin | daemon/src/main/java/de/taimos/daemon/DaemonStarter.java | DaemonStarter.stopService | public static void stopService() {
DaemonStarter.currentPhase.set(LifecyclePhase.STOPPING);
final CountDownLatch cdl = new CountDownLatch(1);
Executors.newSingleThreadExecutor().execute(() -> {
DaemonStarter.getLifecycleListener().stopping();
DaemonStarter.daemon.stop();
cdl.countDown();
});
try {
int timeout = DaemonStarter.lifecycleListener.get().getShutdownTimeoutSeconds();
if (!cdl.await(timeout, TimeUnit.SECONDS)) {
DaemonStarter.rlog.error("Failed to stop gracefully");
DaemonStarter.abortSystem();
}
} catch (InterruptedException e) {
DaemonStarter.rlog.error("Failure awaiting stop", e);
Thread.currentThread().interrupt();
}
} | java | public static void stopService() {
DaemonStarter.currentPhase.set(LifecyclePhase.STOPPING);
final CountDownLatch cdl = new CountDownLatch(1);
Executors.newSingleThreadExecutor().execute(() -> {
DaemonStarter.getLifecycleListener().stopping();
DaemonStarter.daemon.stop();
cdl.countDown();
});
try {
int timeout = DaemonStarter.lifecycleListener.get().getShutdownTimeoutSeconds();
if (!cdl.await(timeout, TimeUnit.SECONDS)) {
DaemonStarter.rlog.error("Failed to stop gracefully");
DaemonStarter.abortSystem();
}
} catch (InterruptedException e) {
DaemonStarter.rlog.error("Failure awaiting stop", e);
Thread.currentThread().interrupt();
}
} | [
"public",
"static",
"void",
"stopService",
"(",
")",
"{",
"DaemonStarter",
".",
"currentPhase",
".",
"set",
"(",
"LifecyclePhase",
".",
"STOPPING",
")",
";",
"final",
"CountDownLatch",
"cdl",
"=",
"new",
"CountDownLatch",
"(",
"1",
")",
";",
"Executors",
".",
"newSingleThreadExecutor",
"(",
")",
".",
"execute",
"(",
"(",
")",
"->",
"{",
"DaemonStarter",
".",
"getLifecycleListener",
"(",
")",
".",
"stopping",
"(",
")",
";",
"DaemonStarter",
".",
"daemon",
".",
"stop",
"(",
")",
";",
"cdl",
".",
"countDown",
"(",
")",
";",
"}",
")",
";",
"try",
"{",
"int",
"timeout",
"=",
"DaemonStarter",
".",
"lifecycleListener",
".",
"get",
"(",
")",
".",
"getShutdownTimeoutSeconds",
"(",
")",
";",
"if",
"(",
"!",
"cdl",
".",
"await",
"(",
"timeout",
",",
"TimeUnit",
".",
"SECONDS",
")",
")",
"{",
"DaemonStarter",
".",
"rlog",
".",
"error",
"(",
"\"Failed to stop gracefully\"",
")",
";",
"DaemonStarter",
".",
"abortSystem",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"DaemonStarter",
".",
"rlog",
".",
"error",
"(",
"\"Failure awaiting stop\"",
",",
"e",
")",
";",
"Thread",
".",
"currentThread",
"(",
")",
".",
"interrupt",
"(",
")",
";",
"}",
"}"
] | Stop the service and end the program | [
"Stop",
"the",
"service",
"and",
"end",
"the",
"program"
] | ff8f1bf594e43d7e8ca8de0b4da9f923b66a1a47 | https://github.com/taimos/dvalin/blob/ff8f1bf594e43d7e8ca8de0b4da9f923b66a1a47/daemon/src/main/java/de/taimos/daemon/DaemonStarter.java#L307-L327 | train |
taimos/dvalin | daemon/src/main/java/de/taimos/daemon/DaemonStarter.java | DaemonStarter.handleSignals | private static void handleSignals() {
if (DaemonStarter.isRunMode()) {
try {
// handle SIGHUP to prevent process to get killed when exiting the tty
Signal.handle(new Signal("HUP"), arg0 -> {
// Nothing to do here
System.out.println("SIG INT");
});
} catch (IllegalArgumentException e) {
System.err.println("Signal HUP not supported");
}
try {
// handle SIGTERM to notify the program to stop
Signal.handle(new Signal("TERM"), arg0 -> {
System.out.println("SIG TERM");
DaemonStarter.stopService();
});
} catch (IllegalArgumentException e) {
System.err.println("Signal TERM not supported");
}
try {
// handle SIGINT to notify the program to stop
Signal.handle(new Signal("INT"), arg0 -> {
System.out.println("SIG INT");
DaemonStarter.stopService();
});
} catch (IllegalArgumentException e) {
System.err.println("Signal INT not supported");
}
try {
// handle SIGUSR2 to notify the life-cycle listener
Signal.handle(new Signal("USR2"), arg0 -> {
System.out.println("SIG USR2");
DaemonStarter.getLifecycleListener().signalUSR2();
});
} catch (IllegalArgumentException e) {
System.err.println("Signal USR2 not supported");
}
}
} | java | private static void handleSignals() {
if (DaemonStarter.isRunMode()) {
try {
// handle SIGHUP to prevent process to get killed when exiting the tty
Signal.handle(new Signal("HUP"), arg0 -> {
// Nothing to do here
System.out.println("SIG INT");
});
} catch (IllegalArgumentException e) {
System.err.println("Signal HUP not supported");
}
try {
// handle SIGTERM to notify the program to stop
Signal.handle(new Signal("TERM"), arg0 -> {
System.out.println("SIG TERM");
DaemonStarter.stopService();
});
} catch (IllegalArgumentException e) {
System.err.println("Signal TERM not supported");
}
try {
// handle SIGINT to notify the program to stop
Signal.handle(new Signal("INT"), arg0 -> {
System.out.println("SIG INT");
DaemonStarter.stopService();
});
} catch (IllegalArgumentException e) {
System.err.println("Signal INT not supported");
}
try {
// handle SIGUSR2 to notify the life-cycle listener
Signal.handle(new Signal("USR2"), arg0 -> {
System.out.println("SIG USR2");
DaemonStarter.getLifecycleListener().signalUSR2();
});
} catch (IllegalArgumentException e) {
System.err.println("Signal USR2 not supported");
}
}
} | [
"private",
"static",
"void",
"handleSignals",
"(",
")",
"{",
"if",
"(",
"DaemonStarter",
".",
"isRunMode",
"(",
")",
")",
"{",
"try",
"{",
"// handle SIGHUP to prevent process to get killed when exiting the tty",
"Signal",
".",
"handle",
"(",
"new",
"Signal",
"(",
"\"HUP\"",
")",
",",
"arg0",
"->",
"{",
"// Nothing to do here",
"System",
".",
"out",
".",
"println",
"(",
"\"SIG INT\"",
")",
";",
"}",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"Signal HUP not supported\"",
")",
";",
"}",
"try",
"{",
"// handle SIGTERM to notify the program to stop",
"Signal",
".",
"handle",
"(",
"new",
"Signal",
"(",
"\"TERM\"",
")",
",",
"arg0",
"->",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"SIG TERM\"",
")",
";",
"DaemonStarter",
".",
"stopService",
"(",
")",
";",
"}",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"Signal TERM not supported\"",
")",
";",
"}",
"try",
"{",
"// handle SIGINT to notify the program to stop",
"Signal",
".",
"handle",
"(",
"new",
"Signal",
"(",
"\"INT\"",
")",
",",
"arg0",
"->",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"SIG INT\"",
")",
";",
"DaemonStarter",
".",
"stopService",
"(",
")",
";",
"}",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"Signal INT not supported\"",
")",
";",
"}",
"try",
"{",
"// handle SIGUSR2 to notify the life-cycle listener",
"Signal",
".",
"handle",
"(",
"new",
"Signal",
"(",
"\"USR2\"",
")",
",",
"arg0",
"->",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"SIG USR2\"",
")",
";",
"DaemonStarter",
".",
"getLifecycleListener",
"(",
")",
".",
"signalUSR2",
"(",
")",
";",
"}",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"Signal USR2 not supported\"",
")",
";",
"}",
"}",
"}"
] | I KNOW WHAT I AM DOING | [
"I",
"KNOW",
"WHAT",
"I",
"AM",
"DOING"
] | ff8f1bf594e43d7e8ca8de0b4da9f923b66a1a47 | https://github.com/taimos/dvalin/blob/ff8f1bf594e43d7e8ca8de0b4da9f923b66a1a47/daemon/src/main/java/de/taimos/daemon/DaemonStarter.java#L330-L372 | train |
taimos/dvalin | daemon/src/main/java/de/taimos/daemon/DaemonStarter.java | DaemonStarter.abortSystem | public static void abortSystem(final Throwable error) {
DaemonStarter.currentPhase.set(LifecyclePhase.ABORTING);
try {
DaemonStarter.getLifecycleListener().aborting();
} catch (Exception e) {
DaemonStarter.rlog.error("Custom abort failed", e);
}
if (error != null) {
DaemonStarter.rlog.error("Unrecoverable error encountered --> Exiting : {}", error.getMessage());
DaemonStarter.getLifecycleListener().exception(LifecyclePhase.ABORTING, error);
} else {
DaemonStarter.rlog.error("Unrecoverable error encountered --> Exiting");
}
// Exit system with failure return code
System.exit(1);
} | java | public static void abortSystem(final Throwable error) {
DaemonStarter.currentPhase.set(LifecyclePhase.ABORTING);
try {
DaemonStarter.getLifecycleListener().aborting();
} catch (Exception e) {
DaemonStarter.rlog.error("Custom abort failed", e);
}
if (error != null) {
DaemonStarter.rlog.error("Unrecoverable error encountered --> Exiting : {}", error.getMessage());
DaemonStarter.getLifecycleListener().exception(LifecyclePhase.ABORTING, error);
} else {
DaemonStarter.rlog.error("Unrecoverable error encountered --> Exiting");
}
// Exit system with failure return code
System.exit(1);
} | [
"public",
"static",
"void",
"abortSystem",
"(",
"final",
"Throwable",
"error",
")",
"{",
"DaemonStarter",
".",
"currentPhase",
".",
"set",
"(",
"LifecyclePhase",
".",
"ABORTING",
")",
";",
"try",
"{",
"DaemonStarter",
".",
"getLifecycleListener",
"(",
")",
".",
"aborting",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"DaemonStarter",
".",
"rlog",
".",
"error",
"(",
"\"Custom abort failed\"",
",",
"e",
")",
";",
"}",
"if",
"(",
"error",
"!=",
"null",
")",
"{",
"DaemonStarter",
".",
"rlog",
".",
"error",
"(",
"\"Unrecoverable error encountered --> Exiting : {}\"",
",",
"error",
".",
"getMessage",
"(",
")",
")",
";",
"DaemonStarter",
".",
"getLifecycleListener",
"(",
")",
".",
"exception",
"(",
"LifecyclePhase",
".",
"ABORTING",
",",
"error",
")",
";",
"}",
"else",
"{",
"DaemonStarter",
".",
"rlog",
".",
"error",
"(",
"\"Unrecoverable error encountered --> Exiting\"",
")",
";",
"}",
"// Exit system with failure return code",
"System",
".",
"exit",
"(",
"1",
")",
";",
"}"
] | Abort the daemon
@param error the error causing the abortion | [
"Abort",
"the",
"daemon"
] | ff8f1bf594e43d7e8ca8de0b4da9f923b66a1a47 | https://github.com/taimos/dvalin/blob/ff8f1bf594e43d7e8ca8de0b4da9f923b66a1a47/daemon/src/main/java/de/taimos/daemon/DaemonStarter.java#L386-L401 | train |
taimos/dvalin | mongodb/src/main/java/de/taimos/dvalin/mongo/MongoDBInit.java | MongoDBInit.initDatabase | @PostConstruct
public void initDatabase() {
MongoDBInit.LOGGER.info("initializing MongoDB");
String dbName = System.getProperty("mongodb.name");
if (dbName == null) {
throw new RuntimeException("Missing database name; Set system property 'mongodb.name'");
}
MongoDatabase db = this.mongo.getDatabase(dbName);
try {
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
Resource[] resources = resolver.getResources("classpath*:mongodb/*.ndjson");
MongoDBInit.LOGGER.info("Scanning for collection data");
for (Resource res : resources) {
String filename = res.getFilename();
String collection = filename.substring(0, filename.length() - 7);
MongoDBInit.LOGGER.info("Found collection file: {}", collection);
MongoCollection<DBObject> dbCollection = db.getCollection(collection, DBObject.class);
try (Scanner scan = new Scanner(res.getInputStream(), "UTF-8")) {
int lines = 0;
while (scan.hasNextLine()) {
String json = scan.nextLine();
Object parse = JSON.parse(json);
if (parse instanceof DBObject) {
DBObject dbObject = (DBObject) parse;
dbCollection.insertOne(dbObject);
} else {
MongoDBInit.LOGGER.error("Invalid object found: {}", parse);
throw new RuntimeException("Invalid object");
}
lines++;
}
MongoDBInit.LOGGER.info("Imported {} objects into collection {}", lines, collection);
}
}
} catch (IOException e) {
throw new RuntimeException("Error importing objects", e);
}
} | java | @PostConstruct
public void initDatabase() {
MongoDBInit.LOGGER.info("initializing MongoDB");
String dbName = System.getProperty("mongodb.name");
if (dbName == null) {
throw new RuntimeException("Missing database name; Set system property 'mongodb.name'");
}
MongoDatabase db = this.mongo.getDatabase(dbName);
try {
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
Resource[] resources = resolver.getResources("classpath*:mongodb/*.ndjson");
MongoDBInit.LOGGER.info("Scanning for collection data");
for (Resource res : resources) {
String filename = res.getFilename();
String collection = filename.substring(0, filename.length() - 7);
MongoDBInit.LOGGER.info("Found collection file: {}", collection);
MongoCollection<DBObject> dbCollection = db.getCollection(collection, DBObject.class);
try (Scanner scan = new Scanner(res.getInputStream(), "UTF-8")) {
int lines = 0;
while (scan.hasNextLine()) {
String json = scan.nextLine();
Object parse = JSON.parse(json);
if (parse instanceof DBObject) {
DBObject dbObject = (DBObject) parse;
dbCollection.insertOne(dbObject);
} else {
MongoDBInit.LOGGER.error("Invalid object found: {}", parse);
throw new RuntimeException("Invalid object");
}
lines++;
}
MongoDBInit.LOGGER.info("Imported {} objects into collection {}", lines, collection);
}
}
} catch (IOException e) {
throw new RuntimeException("Error importing objects", e);
}
} | [
"@",
"PostConstruct",
"public",
"void",
"initDatabase",
"(",
")",
"{",
"MongoDBInit",
".",
"LOGGER",
".",
"info",
"(",
"\"initializing MongoDB\"",
")",
";",
"String",
"dbName",
"=",
"System",
".",
"getProperty",
"(",
"\"mongodb.name\"",
")",
";",
"if",
"(",
"dbName",
"==",
"null",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Missing database name; Set system property 'mongodb.name'\"",
")",
";",
"}",
"MongoDatabase",
"db",
"=",
"this",
".",
"mongo",
".",
"getDatabase",
"(",
"dbName",
")",
";",
"try",
"{",
"PathMatchingResourcePatternResolver",
"resolver",
"=",
"new",
"PathMatchingResourcePatternResolver",
"(",
")",
";",
"Resource",
"[",
"]",
"resources",
"=",
"resolver",
".",
"getResources",
"(",
"\"classpath*:mongodb/*.ndjson\"",
")",
";",
"MongoDBInit",
".",
"LOGGER",
".",
"info",
"(",
"\"Scanning for collection data\"",
")",
";",
"for",
"(",
"Resource",
"res",
":",
"resources",
")",
"{",
"String",
"filename",
"=",
"res",
".",
"getFilename",
"(",
")",
";",
"String",
"collection",
"=",
"filename",
".",
"substring",
"(",
"0",
",",
"filename",
".",
"length",
"(",
")",
"-",
"7",
")",
";",
"MongoDBInit",
".",
"LOGGER",
".",
"info",
"(",
"\"Found collection file: {}\"",
",",
"collection",
")",
";",
"MongoCollection",
"<",
"DBObject",
">",
"dbCollection",
"=",
"db",
".",
"getCollection",
"(",
"collection",
",",
"DBObject",
".",
"class",
")",
";",
"try",
"(",
"Scanner",
"scan",
"=",
"new",
"Scanner",
"(",
"res",
".",
"getInputStream",
"(",
")",
",",
"\"UTF-8\"",
")",
")",
"{",
"int",
"lines",
"=",
"0",
";",
"while",
"(",
"scan",
".",
"hasNextLine",
"(",
")",
")",
"{",
"String",
"json",
"=",
"scan",
".",
"nextLine",
"(",
")",
";",
"Object",
"parse",
"=",
"JSON",
".",
"parse",
"(",
"json",
")",
";",
"if",
"(",
"parse",
"instanceof",
"DBObject",
")",
"{",
"DBObject",
"dbObject",
"=",
"(",
"DBObject",
")",
"parse",
";",
"dbCollection",
".",
"insertOne",
"(",
"dbObject",
")",
";",
"}",
"else",
"{",
"MongoDBInit",
".",
"LOGGER",
".",
"error",
"(",
"\"Invalid object found: {}\"",
",",
"parse",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"\"Invalid object\"",
")",
";",
"}",
"lines",
"++",
";",
"}",
"MongoDBInit",
".",
"LOGGER",
".",
"info",
"(",
"\"Imported {} objects into collection {}\"",
",",
"lines",
",",
"collection",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Error importing objects\"",
",",
"e",
")",
";",
"}",
"}"
] | init database with demo data | [
"init",
"database",
"with",
"demo",
"data"
] | ff8f1bf594e43d7e8ca8de0b4da9f923b66a1a47 | https://github.com/taimos/dvalin/blob/ff8f1bf594e43d7e8ca8de0b4da9f923b66a1a47/mongodb/src/main/java/de/taimos/dvalin/mongo/MongoDBInit.java#L67-L105 | train |
resource4j/resource4j | core/src/main/java/com/github/resource4j/resources/context/ResourceResolutionContext.java | ResourceResolutionContext.with | public static Map<String, Object> with(Object... params) {
Map<String, Object> map = new HashMap<>();
for (int i = 0; i < params.length; i++) {
map.put(String.valueOf(i), params[i]);
}
return map;
} | java | public static Map<String, Object> with(Object... params) {
Map<String, Object> map = new HashMap<>();
for (int i = 0; i < params.length; i++) {
map.put(String.valueOf(i), params[i]);
}
return map;
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"Object",
">",
"with",
"(",
"Object",
"...",
"params",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"map",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"params",
".",
"length",
";",
"i",
"++",
")",
"{",
"map",
".",
"put",
"(",
"String",
".",
"valueOf",
"(",
"i",
")",
",",
"params",
"[",
"i",
"]",
")",
";",
"}",
"return",
"map",
";",
"}"
] | Convenience wrapper for message parameters
@param params
@return | [
"Convenience",
"wrapper",
"for",
"message",
"parameters"
] | 6100443b9a78edc8a5867e1e075f7ee12e6698ca | https://github.com/resource4j/resource4j/blob/6100443b9a78edc8a5867e1e075f7ee12e6698ca/core/src/main/java/com/github/resource4j/resources/context/ResourceResolutionContext.java#L46-L52 | train |
resource4j/resource4j | core/src/main/java/com/github/resource4j/resources/context/ResourceResolutionContext.java | ResourceResolutionContext.context | public static ResourceResolutionContext context(ResourceResolutionComponent[] components,
Map<String, Object> messageParams) {
return new ResourceResolutionContext(components, messageParams);
} | java | public static ResourceResolutionContext context(ResourceResolutionComponent[] components,
Map<String, Object> messageParams) {
return new ResourceResolutionContext(components, messageParams);
} | [
"public",
"static",
"ResourceResolutionContext",
"context",
"(",
"ResourceResolutionComponent",
"[",
"]",
"components",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"messageParams",
")",
"{",
"return",
"new",
"ResourceResolutionContext",
"(",
"components",
",",
"messageParams",
")",
";",
"}"
] | Build resolution context in which message will be discovered and built
@param components resolution components, used to identify message bundle
@param messageParams message parameters will be substituted in message and used in pattern matching
@since 3.1
@return immutable resolution context instance for given parameters | [
"Build",
"resolution",
"context",
"in",
"which",
"message",
"will",
"be",
"discovered",
"and",
"built"
] | 6100443b9a78edc8a5867e1e075f7ee12e6698ca | https://github.com/resource4j/resource4j/blob/6100443b9a78edc8a5867e1e075f7ee12e6698ca/core/src/main/java/com/github/resource4j/resources/context/ResourceResolutionContext.java#L61-L64 | train |
cenobites/struts2-json-plugin | src/main/java/es/cenobit/struts2/json/PackageBasedActionConfigBuilder.java | PackageBasedActionConfigBuilder.setFileProtocols | @Inject("struts.json.action.fileProtocols")
public void setFileProtocols(String fileProtocols) {
if (StringUtils.isNotBlank(fileProtocols)) {
this.fileProtocols = TextParseUtil.commaDelimitedStringToSet(fileProtocols);
}
} | java | @Inject("struts.json.action.fileProtocols")
public void setFileProtocols(String fileProtocols) {
if (StringUtils.isNotBlank(fileProtocols)) {
this.fileProtocols = TextParseUtil.commaDelimitedStringToSet(fileProtocols);
}
} | [
"@",
"Inject",
"(",
"\"struts.json.action.fileProtocols\"",
")",
"public",
"void",
"setFileProtocols",
"(",
"String",
"fileProtocols",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isNotBlank",
"(",
"fileProtocols",
")",
")",
"{",
"this",
".",
"fileProtocols",
"=",
"TextParseUtil",
".",
"commaDelimitedStringToSet",
"(",
"fileProtocols",
")",
";",
"}",
"}"
] | File URLs whose protocol are in these list will be processed as jars
containing classes
@param fileProtocols
Comma separated list of file protocols that will be considered
as jar files and scanned | [
"File",
"URLs",
"whose",
"protocol",
"are",
"in",
"these",
"list",
"will",
"be",
"processed",
"as",
"jars",
"containing",
"classes"
] | 00f948942d85b6f696d46672332ff7b3942ecb1b | https://github.com/cenobites/struts2-json-plugin/blob/00f948942d85b6f696d46672332ff7b3942ecb1b/src/main/java/es/cenobit/struts2/json/PackageBasedActionConfigBuilder.java#L122-L127 | train |
cenobites/struts2-json-plugin | src/main/java/es/cenobit/struts2/json/PackageBasedActionConfigBuilder.java | PackageBasedActionConfigBuilder.cannotInstantiate | protected boolean cannotInstantiate(Class<?> actionClass) {
return actionClass.isAnnotation() || actionClass.isInterface() || actionClass.isEnum()
|| (actionClass.getModifiers() & Modifier.ABSTRACT) != 0 || actionClass.isAnonymousClass();
} | java | protected boolean cannotInstantiate(Class<?> actionClass) {
return actionClass.isAnnotation() || actionClass.isInterface() || actionClass.isEnum()
|| (actionClass.getModifiers() & Modifier.ABSTRACT) != 0 || actionClass.isAnonymousClass();
} | [
"protected",
"boolean",
"cannotInstantiate",
"(",
"Class",
"<",
"?",
">",
"actionClass",
")",
"{",
"return",
"actionClass",
".",
"isAnnotation",
"(",
")",
"||",
"actionClass",
".",
"isInterface",
"(",
")",
"||",
"actionClass",
".",
"isEnum",
"(",
")",
"||",
"(",
"actionClass",
".",
"getModifiers",
"(",
")",
"&",
"Modifier",
".",
"ABSTRACT",
")",
"!=",
"0",
"||",
"actionClass",
".",
"isAnonymousClass",
"(",
")",
";",
"}"
] | Interfaces, enums, annotations, and abstract classes cannot be
instantiated.
@param actionClass
class to check
@return returns true if the class cannot be instantiated or should be
ignored | [
"Interfaces",
"enums",
"annotations",
"and",
"abstract",
"classes",
"cannot",
"be",
"instantiated",
"."
] | 00f948942d85b6f696d46672332ff7b3942ecb1b | https://github.com/cenobites/struts2-json-plugin/blob/00f948942d85b6f696d46672332ff7b3942ecb1b/src/main/java/es/cenobit/struts2/json/PackageBasedActionConfigBuilder.java#L337-L340 | train |
cenobites/struts2-json-plugin | src/main/java/es/cenobit/struts2/json/PackageBasedActionConfigBuilder.java | PackageBasedActionConfigBuilder.checkExcludePackages | protected boolean checkExcludePackages(String classPackageName) {
if (excludePackages != null && excludePackages.length > 0) {
WildcardHelper wildcardHelper = new WildcardHelper();
// we really don't care about the results, just the boolean
Map<String, String> matchMap = new HashMap<String, String>();
for (String packageExclude : excludePackages) {
int[] packagePattern = wildcardHelper.compilePattern(packageExclude);
if (wildcardHelper.match(matchMap, classPackageName, packagePattern)) {
return false;
}
}
}
return true;
} | java | protected boolean checkExcludePackages(String classPackageName) {
if (excludePackages != null && excludePackages.length > 0) {
WildcardHelper wildcardHelper = new WildcardHelper();
// we really don't care about the results, just the boolean
Map<String, String> matchMap = new HashMap<String, String>();
for (String packageExclude : excludePackages) {
int[] packagePattern = wildcardHelper.compilePattern(packageExclude);
if (wildcardHelper.match(matchMap, classPackageName, packagePattern)) {
return false;
}
}
}
return true;
} | [
"protected",
"boolean",
"checkExcludePackages",
"(",
"String",
"classPackageName",
")",
"{",
"if",
"(",
"excludePackages",
"!=",
"null",
"&&",
"excludePackages",
".",
"length",
">",
"0",
")",
"{",
"WildcardHelper",
"wildcardHelper",
"=",
"new",
"WildcardHelper",
"(",
")",
";",
"// we really don't care about the results, just the boolean",
"Map",
"<",
"String",
",",
"String",
">",
"matchMap",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"for",
"(",
"String",
"packageExclude",
":",
"excludePackages",
")",
"{",
"int",
"[",
"]",
"packagePattern",
"=",
"wildcardHelper",
".",
"compilePattern",
"(",
"packageExclude",
")",
";",
"if",
"(",
"wildcardHelper",
".",
"match",
"(",
"matchMap",
",",
"classPackageName",
",",
"packagePattern",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"}",
"return",
"true",
";",
"}"
] | Checks if provided class package is on the exclude list
@param classPackageName
name of class package
@return false if class package is on the {@link #excludePackages} list | [
"Checks",
"if",
"provided",
"class",
"package",
"is",
"on",
"the",
"exclude",
"list"
] | 00f948942d85b6f696d46672332ff7b3942ecb1b | https://github.com/cenobites/struts2-json-plugin/blob/00f948942d85b6f696d46672332ff7b3942ecb1b/src/main/java/es/cenobit/struts2/json/PackageBasedActionConfigBuilder.java#L397-L412 | train |
cenobites/struts2-json-plugin | src/main/java/es/cenobit/struts2/json/PackageBasedActionConfigBuilder.java | PackageBasedActionConfigBuilder.checkActionPackages | protected boolean checkActionPackages(String classPackageName) {
if (actionPackages != null) {
for (String packageName : actionPackages) {
String strictPackageName = packageName + ".";
if (classPackageName.equals(packageName) || classPackageName.startsWith(strictPackageName))
return true;
}
}
return false;
} | java | protected boolean checkActionPackages(String classPackageName) {
if (actionPackages != null) {
for (String packageName : actionPackages) {
String strictPackageName = packageName + ".";
if (classPackageName.equals(packageName) || classPackageName.startsWith(strictPackageName))
return true;
}
}
return false;
} | [
"protected",
"boolean",
"checkActionPackages",
"(",
"String",
"classPackageName",
")",
"{",
"if",
"(",
"actionPackages",
"!=",
"null",
")",
"{",
"for",
"(",
"String",
"packageName",
":",
"actionPackages",
")",
"{",
"String",
"strictPackageName",
"=",
"packageName",
"+",
"\".\"",
";",
"if",
"(",
"classPackageName",
".",
"equals",
"(",
"packageName",
")",
"||",
"classPackageName",
".",
"startsWith",
"(",
"strictPackageName",
")",
")",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Checks if class package match provided list of action packages
@param classPackageName
name of class package
@return true if class package is on the {@link #actionPackages} list | [
"Checks",
"if",
"class",
"package",
"match",
"provided",
"list",
"of",
"action",
"packages"
] | 00f948942d85b6f696d46672332ff7b3942ecb1b | https://github.com/cenobites/struts2-json-plugin/blob/00f948942d85b6f696d46672332ff7b3942ecb1b/src/main/java/es/cenobit/struts2/json/PackageBasedActionConfigBuilder.java#L421-L430 | train |
Subsets and Splits