repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
listlengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
listlengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
lessthanoptimal/BoofCV
|
main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldRegionTracker.java
|
TldRegionTracker.process
|
public boolean process(ImagePyramid<I> image , Rectangle2D_F64 targetRectangle ) {
"""
Creates several tracks inside the target rectangle and compuets their motion
@param image Most recent video image.
@param targetRectangle Location of target in previous frame. Not modified.
@return true if tracking was successful or false if not
"""
boolean success = true;
updateCurrent(image);
// create feature tracks
spawnGrid(targetRectangle);
// track features while computing forward/backward error and NCC error
if( !trackFeature() )
success = false;
// makes the current image into a previous image
setCurrentToPrevious();
return success;
}
|
java
|
public boolean process(ImagePyramid<I> image , Rectangle2D_F64 targetRectangle ) {
boolean success = true;
updateCurrent(image);
// create feature tracks
spawnGrid(targetRectangle);
// track features while computing forward/backward error and NCC error
if( !trackFeature() )
success = false;
// makes the current image into a previous image
setCurrentToPrevious();
return success;
}
|
[
"public",
"boolean",
"process",
"(",
"ImagePyramid",
"<",
"I",
">",
"image",
",",
"Rectangle2D_F64",
"targetRectangle",
")",
"{",
"boolean",
"success",
"=",
"true",
";",
"updateCurrent",
"(",
"image",
")",
";",
"// create feature tracks",
"spawnGrid",
"(",
"targetRectangle",
")",
";",
"// track features while computing forward/backward error and NCC error",
"if",
"(",
"!",
"trackFeature",
"(",
")",
")",
"success",
"=",
"false",
";",
"// makes the current image into a previous image",
"setCurrentToPrevious",
"(",
")",
";",
"return",
"success",
";",
"}"
] |
Creates several tracks inside the target rectangle and compuets their motion
@param image Most recent video image.
@param targetRectangle Location of target in previous frame. Not modified.
@return true if tracking was successful or false if not
|
[
"Creates",
"several",
"tracks",
"inside",
"the",
"target",
"rectangle",
"and",
"compuets",
"their",
"motion"
] |
train
|
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldRegionTracker.java#L176-L192
|
khuxtable/seaglass
|
src/main/java/com/seaglasslookandfeel/ui/SeaGlassTableUI.java
|
SeaGlassTableUI.paintDraggedArea
|
private void paintDraggedArea(SeaGlassContext context, Graphics g, int rMin, int rMax, TableColumn draggedColumn, int distance) {
"""
DOCUMENT ME!
@param context DOCUMENT ME!
@param g DOCUMENT ME!
@param rMin DOCUMENT ME!
@param rMax DOCUMENT ME!
@param draggedColumn DOCUMENT ME!
@param distance DOCUMENT ME!
"""
int draggedColumnIndex = viewIndexForColumn(draggedColumn);
Rectangle minCell = table.getCellRect(rMin, draggedColumnIndex, true);
Rectangle maxCell = table.getCellRect(rMax, draggedColumnIndex, true);
Rectangle vacatedColumnRect = minCell.union(maxCell);
// Paint a gray well in place of the moving column.
g.setColor(table.getParent().getBackground());
g.fillRect(vacatedColumnRect.x, vacatedColumnRect.y, vacatedColumnRect.width, vacatedColumnRect.height);
// Move to the where the cell has been dragged.
vacatedColumnRect.x += distance;
// Fill the background.
g.setColor(context.getStyle().getColor(context, ColorType.BACKGROUND));
g.fillRect(vacatedColumnRect.x, vacatedColumnRect.y, vacatedColumnRect.width, vacatedColumnRect.height);
SynthGraphicsUtils synthG = context.getStyle().getGraphicsUtils(context);
// Paint the vertical grid lines if necessary.
if (table.getShowVerticalLines()) {
g.setColor(table.getGridColor());
int x1 = vacatedColumnRect.x;
int y1 = vacatedColumnRect.y;
int x2 = x1 + vacatedColumnRect.width - 1;
int y2 = y1 + vacatedColumnRect.height - 1;
// Left
synthG.drawLine(context, "Table.grid", g, x1 - 1, y1, x1 - 1, y2);
// Right
synthG.drawLine(context, "Table.grid", g, x2, y1, x2, y2);
}
for (int row = rMin; row <= rMax; row++) {
// Render the cell value
Rectangle r = table.getCellRect(row, draggedColumnIndex, false);
r.x += distance;
paintCell(context, g, r, row, draggedColumnIndex);
// Paint the (lower) horizontal grid line if necessary.
if (table.getShowHorizontalLines()) {
g.setColor(table.getGridColor());
Rectangle rcr = table.getCellRect(row, draggedColumnIndex, true);
rcr.x += distance;
int x1 = rcr.x;
int y1 = rcr.y;
int x2 = x1 + rcr.width - 1;
int y2 = y1 + rcr.height - 1;
synthG.drawLine(context, "Table.grid", g, x1, y2, x2, y2);
}
}
}
|
java
|
private void paintDraggedArea(SeaGlassContext context, Graphics g, int rMin, int rMax, TableColumn draggedColumn, int distance) {
int draggedColumnIndex = viewIndexForColumn(draggedColumn);
Rectangle minCell = table.getCellRect(rMin, draggedColumnIndex, true);
Rectangle maxCell = table.getCellRect(rMax, draggedColumnIndex, true);
Rectangle vacatedColumnRect = minCell.union(maxCell);
// Paint a gray well in place of the moving column.
g.setColor(table.getParent().getBackground());
g.fillRect(vacatedColumnRect.x, vacatedColumnRect.y, vacatedColumnRect.width, vacatedColumnRect.height);
// Move to the where the cell has been dragged.
vacatedColumnRect.x += distance;
// Fill the background.
g.setColor(context.getStyle().getColor(context, ColorType.BACKGROUND));
g.fillRect(vacatedColumnRect.x, vacatedColumnRect.y, vacatedColumnRect.width, vacatedColumnRect.height);
SynthGraphicsUtils synthG = context.getStyle().getGraphicsUtils(context);
// Paint the vertical grid lines if necessary.
if (table.getShowVerticalLines()) {
g.setColor(table.getGridColor());
int x1 = vacatedColumnRect.x;
int y1 = vacatedColumnRect.y;
int x2 = x1 + vacatedColumnRect.width - 1;
int y2 = y1 + vacatedColumnRect.height - 1;
// Left
synthG.drawLine(context, "Table.grid", g, x1 - 1, y1, x1 - 1, y2);
// Right
synthG.drawLine(context, "Table.grid", g, x2, y1, x2, y2);
}
for (int row = rMin; row <= rMax; row++) {
// Render the cell value
Rectangle r = table.getCellRect(row, draggedColumnIndex, false);
r.x += distance;
paintCell(context, g, r, row, draggedColumnIndex);
// Paint the (lower) horizontal grid line if necessary.
if (table.getShowHorizontalLines()) {
g.setColor(table.getGridColor());
Rectangle rcr = table.getCellRect(row, draggedColumnIndex, true);
rcr.x += distance;
int x1 = rcr.x;
int y1 = rcr.y;
int x2 = x1 + rcr.width - 1;
int y2 = y1 + rcr.height - 1;
synthG.drawLine(context, "Table.grid", g, x1, y2, x2, y2);
}
}
}
|
[
"private",
"void",
"paintDraggedArea",
"(",
"SeaGlassContext",
"context",
",",
"Graphics",
"g",
",",
"int",
"rMin",
",",
"int",
"rMax",
",",
"TableColumn",
"draggedColumn",
",",
"int",
"distance",
")",
"{",
"int",
"draggedColumnIndex",
"=",
"viewIndexForColumn",
"(",
"draggedColumn",
")",
";",
"Rectangle",
"minCell",
"=",
"table",
".",
"getCellRect",
"(",
"rMin",
",",
"draggedColumnIndex",
",",
"true",
")",
";",
"Rectangle",
"maxCell",
"=",
"table",
".",
"getCellRect",
"(",
"rMax",
",",
"draggedColumnIndex",
",",
"true",
")",
";",
"Rectangle",
"vacatedColumnRect",
"=",
"minCell",
".",
"union",
"(",
"maxCell",
")",
";",
"// Paint a gray well in place of the moving column.",
"g",
".",
"setColor",
"(",
"table",
".",
"getParent",
"(",
")",
".",
"getBackground",
"(",
")",
")",
";",
"g",
".",
"fillRect",
"(",
"vacatedColumnRect",
".",
"x",
",",
"vacatedColumnRect",
".",
"y",
",",
"vacatedColumnRect",
".",
"width",
",",
"vacatedColumnRect",
".",
"height",
")",
";",
"// Move to the where the cell has been dragged.",
"vacatedColumnRect",
".",
"x",
"+=",
"distance",
";",
"// Fill the background.",
"g",
".",
"setColor",
"(",
"context",
".",
"getStyle",
"(",
")",
".",
"getColor",
"(",
"context",
",",
"ColorType",
".",
"BACKGROUND",
")",
")",
";",
"g",
".",
"fillRect",
"(",
"vacatedColumnRect",
".",
"x",
",",
"vacatedColumnRect",
".",
"y",
",",
"vacatedColumnRect",
".",
"width",
",",
"vacatedColumnRect",
".",
"height",
")",
";",
"SynthGraphicsUtils",
"synthG",
"=",
"context",
".",
"getStyle",
"(",
")",
".",
"getGraphicsUtils",
"(",
"context",
")",
";",
"// Paint the vertical grid lines if necessary.",
"if",
"(",
"table",
".",
"getShowVerticalLines",
"(",
")",
")",
"{",
"g",
".",
"setColor",
"(",
"table",
".",
"getGridColor",
"(",
")",
")",
";",
"int",
"x1",
"=",
"vacatedColumnRect",
".",
"x",
";",
"int",
"y1",
"=",
"vacatedColumnRect",
".",
"y",
";",
"int",
"x2",
"=",
"x1",
"+",
"vacatedColumnRect",
".",
"width",
"-",
"1",
";",
"int",
"y2",
"=",
"y1",
"+",
"vacatedColumnRect",
".",
"height",
"-",
"1",
";",
"// Left",
"synthG",
".",
"drawLine",
"(",
"context",
",",
"\"Table.grid\"",
",",
"g",
",",
"x1",
"-",
"1",
",",
"y1",
",",
"x1",
"-",
"1",
",",
"y2",
")",
";",
"// Right",
"synthG",
".",
"drawLine",
"(",
"context",
",",
"\"Table.grid\"",
",",
"g",
",",
"x2",
",",
"y1",
",",
"x2",
",",
"y2",
")",
";",
"}",
"for",
"(",
"int",
"row",
"=",
"rMin",
";",
"row",
"<=",
"rMax",
";",
"row",
"++",
")",
"{",
"// Render the cell value",
"Rectangle",
"r",
"=",
"table",
".",
"getCellRect",
"(",
"row",
",",
"draggedColumnIndex",
",",
"false",
")",
";",
"r",
".",
"x",
"+=",
"distance",
";",
"paintCell",
"(",
"context",
",",
"g",
",",
"r",
",",
"row",
",",
"draggedColumnIndex",
")",
";",
"// Paint the (lower) horizontal grid line if necessary.",
"if",
"(",
"table",
".",
"getShowHorizontalLines",
"(",
")",
")",
"{",
"g",
".",
"setColor",
"(",
"table",
".",
"getGridColor",
"(",
")",
")",
";",
"Rectangle",
"rcr",
"=",
"table",
".",
"getCellRect",
"(",
"row",
",",
"draggedColumnIndex",
",",
"true",
")",
";",
"rcr",
".",
"x",
"+=",
"distance",
";",
"int",
"x1",
"=",
"rcr",
".",
"x",
";",
"int",
"y1",
"=",
"rcr",
".",
"y",
";",
"int",
"x2",
"=",
"x1",
"+",
"rcr",
".",
"width",
"-",
"1",
";",
"int",
"y2",
"=",
"y1",
"+",
"rcr",
".",
"height",
"-",
"1",
";",
"synthG",
".",
"drawLine",
"(",
"context",
",",
"\"Table.grid\"",
",",
"g",
",",
"x1",
",",
"y2",
",",
"x2",
",",
"y2",
")",
";",
"}",
"}",
"}"
] |
DOCUMENT ME!
@param context DOCUMENT ME!
@param g DOCUMENT ME!
@param rMin DOCUMENT ME!
@param rMax DOCUMENT ME!
@param draggedColumn DOCUMENT ME!
@param distance DOCUMENT ME!
|
[
"DOCUMENT",
"ME!"
] |
train
|
https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/ui/SeaGlassTableUI.java#L883-L938
|
fozziethebeat/S-Space
|
opt/src/main/java/edu/ucla/sspace/lra/LatentRelationalAnalysis.java
|
LatentRelationalAnalysis.indexDirectory
|
private static void indexDirectory(IndexWriter writer, File dir)
throws IOException {
"""
recursive method that calls itself when it finds a directory, or indexes if
it is at a file ending in ".txt"
"""
File[] files = dir.listFiles();
for (int i = 0; i < files.length; i++) {
File f = files[i];
if (f.isDirectory()) {
indexDirectory(writer, f);
} else if (f.getName().endsWith(".txt")) {
indexFile(writer, f);
}
}
}
|
java
|
private static void indexDirectory(IndexWriter writer, File dir)
throws IOException {
File[] files = dir.listFiles();
for (int i = 0; i < files.length; i++) {
File f = files[i];
if (f.isDirectory()) {
indexDirectory(writer, f);
} else if (f.getName().endsWith(".txt")) {
indexFile(writer, f);
}
}
}
|
[
"private",
"static",
"void",
"indexDirectory",
"(",
"IndexWriter",
"writer",
",",
"File",
"dir",
")",
"throws",
"IOException",
"{",
"File",
"[",
"]",
"files",
"=",
"dir",
".",
"listFiles",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"files",
".",
"length",
";",
"i",
"++",
")",
"{",
"File",
"f",
"=",
"files",
"[",
"i",
"]",
";",
"if",
"(",
"f",
".",
"isDirectory",
"(",
")",
")",
"{",
"indexDirectory",
"(",
"writer",
",",
"f",
")",
";",
"}",
"else",
"if",
"(",
"f",
".",
"getName",
"(",
")",
".",
"endsWith",
"(",
"\".txt\"",
")",
")",
"{",
"indexFile",
"(",
"writer",
",",
"f",
")",
";",
"}",
"}",
"}"
] |
recursive method that calls itself when it finds a directory, or indexes if
it is at a file ending in ".txt"
|
[
"recursive",
"method",
"that",
"calls",
"itself",
"when",
"it",
"finds",
"a",
"directory",
"or",
"indexes",
"if",
"it",
"is",
"at",
"a",
"file",
"ending",
"in",
".",
"txt"
] |
train
|
https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/opt/src/main/java/edu/ucla/sspace/lra/LatentRelationalAnalysis.java#L377-L390
|
liferay/com-liferay-commerce
|
commerce-api/src/main/java/com/liferay/commerce/model/CommerceCountryWrapper.java
|
CommerceCountryWrapper.setName
|
@Override
public void setName(String name, java.util.Locale locale) {
"""
Sets the localized name of this commerce country in the language.
@param name the localized name of this commerce country
@param locale the locale of the language
"""
_commerceCountry.setName(name, locale);
}
|
java
|
@Override
public void setName(String name, java.util.Locale locale) {
_commerceCountry.setName(name, locale);
}
|
[
"@",
"Override",
"public",
"void",
"setName",
"(",
"String",
"name",
",",
"java",
".",
"util",
".",
"Locale",
"locale",
")",
"{",
"_commerceCountry",
".",
"setName",
"(",
"name",
",",
"locale",
")",
";",
"}"
] |
Sets the localized name of this commerce country in the language.
@param name the localized name of this commerce country
@param locale the locale of the language
|
[
"Sets",
"the",
"localized",
"name",
"of",
"this",
"commerce",
"country",
"in",
"the",
"language",
"."
] |
train
|
https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-api/src/main/java/com/liferay/commerce/model/CommerceCountryWrapper.java#L693-L696
|
VueGWT/vue-gwt
|
core/src/main/java/com/axellience/vuegwt/core/client/observer/VueGWTObserverManager.java
|
VueGWTObserverManager.makeStaticallyInitializedPropertiesReactive
|
private void makeStaticallyInitializedPropertiesReactive(JsObject object, String className) {
"""
Due to GWT optimizations, properties on java object defined like this are not observable in
Vue.js when not running in dev mode: <br>
private String myText = "Default text"; private int myInt = 0; <br>
This is because GWT define the default value on the prototype and don't define it on the
object. Therefore Vue.js don't see those properties when initializing it's observer. To fix the
issue, we manually look for those properties and set them explicitly on the object.
@param object The Java object to observe
@param className The Java class name to observe
"""
Map<String, Object> cache = classesPropertyCaches.get(className);
if (cache == null) {
cache = initClassPropertiesCache(object, className);
}
JsPropertyMap<Object> javaObjectPropertyMap = ((JsPropertyMap<Object>) object);
cache.forEach((key, value) -> {
if (!object.hasOwnProperty(key)) {
javaObjectPropertyMap.set(key, value);
}
});
}
|
java
|
private void makeStaticallyInitializedPropertiesReactive(JsObject object, String className) {
Map<String, Object> cache = classesPropertyCaches.get(className);
if (cache == null) {
cache = initClassPropertiesCache(object, className);
}
JsPropertyMap<Object> javaObjectPropertyMap = ((JsPropertyMap<Object>) object);
cache.forEach((key, value) -> {
if (!object.hasOwnProperty(key)) {
javaObjectPropertyMap.set(key, value);
}
});
}
|
[
"private",
"void",
"makeStaticallyInitializedPropertiesReactive",
"(",
"JsObject",
"object",
",",
"String",
"className",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"cache",
"=",
"classesPropertyCaches",
".",
"get",
"(",
"className",
")",
";",
"if",
"(",
"cache",
"==",
"null",
")",
"{",
"cache",
"=",
"initClassPropertiesCache",
"(",
"object",
",",
"className",
")",
";",
"}",
"JsPropertyMap",
"<",
"Object",
">",
"javaObjectPropertyMap",
"=",
"(",
"(",
"JsPropertyMap",
"<",
"Object",
">",
")",
"object",
")",
";",
"cache",
".",
"forEach",
"(",
"(",
"key",
",",
"value",
")",
"->",
"{",
"if",
"(",
"!",
"object",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"javaObjectPropertyMap",
".",
"set",
"(",
"key",
",",
"value",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Due to GWT optimizations, properties on java object defined like this are not observable in
Vue.js when not running in dev mode: <br>
private String myText = "Default text"; private int myInt = 0; <br>
This is because GWT define the default value on the prototype and don't define it on the
object. Therefore Vue.js don't see those properties when initializing it's observer. To fix the
issue, we manually look for those properties and set them explicitly on the object.
@param object The Java object to observe
@param className The Java class name to observe
|
[
"Due",
"to",
"GWT",
"optimizations",
"properties",
"on",
"java",
"object",
"defined",
"like",
"this",
"are",
"not",
"observable",
"in",
"Vue",
".",
"js",
"when",
"not",
"running",
"in",
"dev",
"mode",
":",
"<br",
">",
"private",
"String",
"myText",
"=",
"Default",
"text",
";",
"private",
"int",
"myInt",
"=",
"0",
";",
"<br",
">",
"This",
"is",
"because",
"GWT",
"define",
"the",
"default",
"value",
"on",
"the",
"prototype",
"and",
"don",
"t",
"define",
"it",
"on",
"the",
"object",
".",
"Therefore",
"Vue",
".",
"js",
"don",
"t",
"see",
"those",
"properties",
"when",
"initializing",
"it",
"s",
"observer",
".",
"To",
"fix",
"the",
"issue",
"we",
"manually",
"look",
"for",
"those",
"properties",
"and",
"set",
"them",
"explicitly",
"on",
"the",
"object",
"."
] |
train
|
https://github.com/VueGWT/vue-gwt/blob/961cd83aed6fe8e2dd80c279847f1b3f62918a1f/core/src/main/java/com/axellience/vuegwt/core/client/observer/VueGWTObserverManager.java#L167-L179
|
Netflix/astyanax
|
astyanax-cql/src/main/java/com/netflix/astyanax/cql/reads/CFRowRangeQueryGen.java
|
CFRowRangeQueryGen.getQueryStatement
|
public BoundStatement getQueryStatement(CqlRowSliceQueryImpl<?,?> rowSliceQuery, boolean useCaching) {
"""
Main method used to generate the query for the specified row slice query.
Note that depending on the query signature, the caller may choose to enable/disable caching
@param rowSliceQuery: The Astaynax query for which we need to generate a java driver query
@param useCaching: boolean condition indicating whether we should use a previously cached prepared stmt or not.
If false, then the cache is ignored and we generate the prepared stmt for this query
If true, then the cached prepared stmt is used. If the cache has not been inited,
then the prepared stmt is constructed for this query and subsequently cached
@return BoundStatement: they statement for this Astyanax query
"""
switch (rowSliceQuery.getColQueryType()) {
case AllColumns:
return SelectAllColumnsForRowRange.getBoundStatement(rowSliceQuery, useCaching);
case ColumnSet:
return SelectColumnSetForRowRange.getBoundStatement(rowSliceQuery, useCaching);
case ColumnRange:
if (isCompositeColumn) {
return SelectCompositeColumnRangeForRowRange.getBoundStatement(rowSliceQuery, useCaching);
} else {
return SelectColumnRangeForRowRange.getBoundStatement(rowSliceQuery, useCaching);
}
default :
throw new RuntimeException("RowSliceQuery with row range use case not supported.");
}
}
|
java
|
public BoundStatement getQueryStatement(CqlRowSliceQueryImpl<?,?> rowSliceQuery, boolean useCaching) {
switch (rowSliceQuery.getColQueryType()) {
case AllColumns:
return SelectAllColumnsForRowRange.getBoundStatement(rowSliceQuery, useCaching);
case ColumnSet:
return SelectColumnSetForRowRange.getBoundStatement(rowSliceQuery, useCaching);
case ColumnRange:
if (isCompositeColumn) {
return SelectCompositeColumnRangeForRowRange.getBoundStatement(rowSliceQuery, useCaching);
} else {
return SelectColumnRangeForRowRange.getBoundStatement(rowSliceQuery, useCaching);
}
default :
throw new RuntimeException("RowSliceQuery with row range use case not supported.");
}
}
|
[
"public",
"BoundStatement",
"getQueryStatement",
"(",
"CqlRowSliceQueryImpl",
"<",
"?",
",",
"?",
">",
"rowSliceQuery",
",",
"boolean",
"useCaching",
")",
"{",
"switch",
"(",
"rowSliceQuery",
".",
"getColQueryType",
"(",
")",
")",
"{",
"case",
"AllColumns",
":",
"return",
"SelectAllColumnsForRowRange",
".",
"getBoundStatement",
"(",
"rowSliceQuery",
",",
"useCaching",
")",
";",
"case",
"ColumnSet",
":",
"return",
"SelectColumnSetForRowRange",
".",
"getBoundStatement",
"(",
"rowSliceQuery",
",",
"useCaching",
")",
";",
"case",
"ColumnRange",
":",
"if",
"(",
"isCompositeColumn",
")",
"{",
"return",
"SelectCompositeColumnRangeForRowRange",
".",
"getBoundStatement",
"(",
"rowSliceQuery",
",",
"useCaching",
")",
";",
"}",
"else",
"{",
"return",
"SelectColumnRangeForRowRange",
".",
"getBoundStatement",
"(",
"rowSliceQuery",
",",
"useCaching",
")",
";",
"}",
"default",
":",
"throw",
"new",
"RuntimeException",
"(",
"\"RowSliceQuery with row range use case not supported.\"",
")",
";",
"}",
"}"
] |
Main method used to generate the query for the specified row slice query.
Note that depending on the query signature, the caller may choose to enable/disable caching
@param rowSliceQuery: The Astaynax query for which we need to generate a java driver query
@param useCaching: boolean condition indicating whether we should use a previously cached prepared stmt or not.
If false, then the cache is ignored and we generate the prepared stmt for this query
If true, then the cached prepared stmt is used. If the cache has not been inited,
then the prepared stmt is constructed for this query and subsequently cached
@return BoundStatement: they statement for this Astyanax query
|
[
"Main",
"method",
"used",
"to",
"generate",
"the",
"query",
"for",
"the",
"specified",
"row",
"slice",
"query",
".",
"Note",
"that",
"depending",
"on",
"the",
"query",
"signature",
"the",
"caller",
"may",
"choose",
"to",
"enable",
"/",
"disable",
"caching"
] |
train
|
https://github.com/Netflix/astyanax/blob/bcc3fd26e2dda05a923751aa32b139f6209fecdf/astyanax-cql/src/main/java/com/netflix/astyanax/cql/reads/CFRowRangeQueryGen.java#L390-L407
|
molgenis/molgenis
|
molgenis-dataexplorer/src/main/java/org/molgenis/dataexplorer/negotiator/NegotiatorController.java
|
NegotiatorController.generateBase64Authentication
|
private static String generateBase64Authentication(String username, String password) {
"""
Generate base64 authentication based on username and password.
@return Authentication header value.
"""
requireNonNull(username, password);
String userPass = username + ":" + password;
String userPassBase64 = Base64.getEncoder().encodeToString(userPass.getBytes(UTF_8));
return "Basic " + userPassBase64;
}
|
java
|
private static String generateBase64Authentication(String username, String password) {
requireNonNull(username, password);
String userPass = username + ":" + password;
String userPassBase64 = Base64.getEncoder().encodeToString(userPass.getBytes(UTF_8));
return "Basic " + userPassBase64;
}
|
[
"private",
"static",
"String",
"generateBase64Authentication",
"(",
"String",
"username",
",",
"String",
"password",
")",
"{",
"requireNonNull",
"(",
"username",
",",
"password",
")",
";",
"String",
"userPass",
"=",
"username",
"+",
"\":\"",
"+",
"password",
";",
"String",
"userPassBase64",
"=",
"Base64",
".",
"getEncoder",
"(",
")",
".",
"encodeToString",
"(",
"userPass",
".",
"getBytes",
"(",
"UTF_8",
")",
")",
";",
"return",
"\"Basic \"",
"+",
"userPassBase64",
";",
"}"
] |
Generate base64 authentication based on username and password.
@return Authentication header value.
|
[
"Generate",
"base64",
"authentication",
"based",
"on",
"username",
"and",
"password",
"."
] |
train
|
https://github.com/molgenis/molgenis/blob/b4d0d6b27e6f6c8d7505a3863dc03b589601f987/molgenis-dataexplorer/src/main/java/org/molgenis/dataexplorer/negotiator/NegotiatorController.java#L270-L275
|
sebastiangraf/perfidix
|
src/main/java/org/perfidix/result/AbstractResult.java
|
AbstractResult.addData
|
final void addData(final AbstractMeter meter, final double data) {
"""
Adding a data to a meter.
@param meter the related meter
@param data the data to be added
"""
checkIfMeterExists(meter);
meterResults.get(meter).add(data);
}
|
java
|
final void addData(final AbstractMeter meter, final double data) {
checkIfMeterExists(meter);
meterResults.get(meter).add(data);
}
|
[
"final",
"void",
"addData",
"(",
"final",
"AbstractMeter",
"meter",
",",
"final",
"double",
"data",
")",
"{",
"checkIfMeterExists",
"(",
"meter",
")",
";",
"meterResults",
".",
"get",
"(",
"meter",
")",
".",
"add",
"(",
"data",
")",
";",
"}"
] |
Adding a data to a meter.
@param meter the related meter
@param data the data to be added
|
[
"Adding",
"a",
"data",
"to",
"a",
"meter",
"."
] |
train
|
https://github.com/sebastiangraf/perfidix/blob/f13aa793b6a3055215ed4edbb946c1bb5d564886/src/main/java/org/perfidix/result/AbstractResult.java#L226-L229
|
jtrfp/javamod
|
src/main/java/de/quippy/jflac/frame/EntropyPartitionedRice.java
|
EntropyPartitionedRice.readResidual
|
void readResidual(BitInputStream is, int predictorOrder, int partitionOrder, Header header, int[] residual) throws IOException {
"""
Read compressed signal residual data.
@param is The InputBitStream
@param predictorOrder The predicate order
@param partitionOrder The partition order
@param header The FLAC Frame Header
@param residual The residual signal (output)
@throws IOException On error reading from InputBitStream
"""
//System.out.println("readREsidual Pred="+predictorOrder+" part="+partitionOrder);
int sample = 0;
int partitions = 1 << partitionOrder;
int partitionSamples = partitionOrder > 0 ? header.blockSize >> partitionOrder : header.blockSize - predictorOrder;
contents.ensureSize(Math.max(6, partitionOrder));
contents.parameters = new int[partitions];
for (int partition = 0; partition < partitions; partition++) {
int riceParameter = is.readRawUInt(ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN);
contents.parameters[partition] = riceParameter;
if (riceParameter < ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER) {
int u = (partitionOrder == 0 || partition > 0) ? partitionSamples : partitionSamples - predictorOrder;
is.readRiceSignedBlock(residual, sample, u, riceParameter);
sample += u;
} else {
riceParameter = is.readRawUInt(ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN);
contents.rawBits[partition] = riceParameter;
for (int u = (partitionOrder == 0 || partition > 0) ? 0 : predictorOrder; u < partitionSamples; u++, sample++) {
residual[sample] = is.readRawInt(riceParameter);
}
}
}
}
|
java
|
void readResidual(BitInputStream is, int predictorOrder, int partitionOrder, Header header, int[] residual) throws IOException {
//System.out.println("readREsidual Pred="+predictorOrder+" part="+partitionOrder);
int sample = 0;
int partitions = 1 << partitionOrder;
int partitionSamples = partitionOrder > 0 ? header.blockSize >> partitionOrder : header.blockSize - predictorOrder;
contents.ensureSize(Math.max(6, partitionOrder));
contents.parameters = new int[partitions];
for (int partition = 0; partition < partitions; partition++) {
int riceParameter = is.readRawUInt(ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN);
contents.parameters[partition] = riceParameter;
if (riceParameter < ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER) {
int u = (partitionOrder == 0 || partition > 0) ? partitionSamples : partitionSamples - predictorOrder;
is.readRiceSignedBlock(residual, sample, u, riceParameter);
sample += u;
} else {
riceParameter = is.readRawUInt(ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN);
contents.rawBits[partition] = riceParameter;
for (int u = (partitionOrder == 0 || partition > 0) ? 0 : predictorOrder; u < partitionSamples; u++, sample++) {
residual[sample] = is.readRawInt(riceParameter);
}
}
}
}
|
[
"void",
"readResidual",
"(",
"BitInputStream",
"is",
",",
"int",
"predictorOrder",
",",
"int",
"partitionOrder",
",",
"Header",
"header",
",",
"int",
"[",
"]",
"residual",
")",
"throws",
"IOException",
"{",
"//System.out.println(\"readREsidual Pred=\"+predictorOrder+\" part=\"+partitionOrder);",
"int",
"sample",
"=",
"0",
";",
"int",
"partitions",
"=",
"1",
"<<",
"partitionOrder",
";",
"int",
"partitionSamples",
"=",
"partitionOrder",
">",
"0",
"?",
"header",
".",
"blockSize",
">>",
"partitionOrder",
":",
"header",
".",
"blockSize",
"-",
"predictorOrder",
";",
"contents",
".",
"ensureSize",
"(",
"Math",
".",
"max",
"(",
"6",
",",
"partitionOrder",
")",
")",
";",
"contents",
".",
"parameters",
"=",
"new",
"int",
"[",
"partitions",
"]",
";",
"for",
"(",
"int",
"partition",
"=",
"0",
";",
"partition",
"<",
"partitions",
";",
"partition",
"++",
")",
"{",
"int",
"riceParameter",
"=",
"is",
".",
"readRawUInt",
"(",
"ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN",
")",
";",
"contents",
".",
"parameters",
"[",
"partition",
"]",
"=",
"riceParameter",
";",
"if",
"(",
"riceParameter",
"<",
"ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER",
")",
"{",
"int",
"u",
"=",
"(",
"partitionOrder",
"==",
"0",
"||",
"partition",
">",
"0",
")",
"?",
"partitionSamples",
":",
"partitionSamples",
"-",
"predictorOrder",
";",
"is",
".",
"readRiceSignedBlock",
"(",
"residual",
",",
"sample",
",",
"u",
",",
"riceParameter",
")",
";",
"sample",
"+=",
"u",
";",
"}",
"else",
"{",
"riceParameter",
"=",
"is",
".",
"readRawUInt",
"(",
"ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN",
")",
";",
"contents",
".",
"rawBits",
"[",
"partition",
"]",
"=",
"riceParameter",
";",
"for",
"(",
"int",
"u",
"=",
"(",
"partitionOrder",
"==",
"0",
"||",
"partition",
">",
"0",
")",
"?",
"0",
":",
"predictorOrder",
";",
"u",
"<",
"partitionSamples",
";",
"u",
"++",
",",
"sample",
"++",
")",
"{",
"residual",
"[",
"sample",
"]",
"=",
"is",
".",
"readRawInt",
"(",
"riceParameter",
")",
";",
"}",
"}",
"}",
"}"
] |
Read compressed signal residual data.
@param is The InputBitStream
@param predictorOrder The predicate order
@param partitionOrder The partition order
@param header The FLAC Frame Header
@param residual The residual signal (output)
@throws IOException On error reading from InputBitStream
|
[
"Read",
"compressed",
"signal",
"residual",
"data",
"."
] |
train
|
https://github.com/jtrfp/javamod/blob/cda4fe943a589dc49415f4413453e2eece72076a/src/main/java/de/quippy/jflac/frame/EntropyPartitionedRice.java#L49-L72
|
JoeKerouac/utils
|
src/main/java/com/joe/utils/common/DateUtil.java
|
DateUtil.calc
|
private static long calc(Temporal arg0, Temporal arg1, DateUnit dateUnit) {
"""
计算arg0-arg1的时间差
@param arg0 arg0
@param arg1 arg1
@param dateUnit 返回结果的单位
@return arg0-arg1的时间差,精确到指定的单位(field),出错时返回-1
"""
return create(dateUnit).between(arg1, arg0);
}
|
java
|
private static long calc(Temporal arg0, Temporal arg1, DateUnit dateUnit) {
return create(dateUnit).between(arg1, arg0);
}
|
[
"private",
"static",
"long",
"calc",
"(",
"Temporal",
"arg0",
",",
"Temporal",
"arg1",
",",
"DateUnit",
"dateUnit",
")",
"{",
"return",
"create",
"(",
"dateUnit",
")",
".",
"between",
"(",
"arg1",
",",
"arg0",
")",
";",
"}"
] |
计算arg0-arg1的时间差
@param arg0 arg0
@param arg1 arg1
@param dateUnit 返回结果的单位
@return arg0-arg1的时间差,精确到指定的单位(field),出错时返回-1
|
[
"计算arg0",
"-",
"arg1的时间差"
] |
train
|
https://github.com/JoeKerouac/utils/blob/45e1b2dc4d736956674fc4dcbe6cf84eaee69278/src/main/java/com/joe/utils/common/DateUtil.java#L311-L313
|
matthewhorridge/owlapi-gwt
|
owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLFunctionalObjectPropertyAxiomImpl_CustomFieldSerializer.java
|
OWLFunctionalObjectPropertyAxiomImpl_CustomFieldSerializer.deserializeInstance
|
@Override
public void deserializeInstance(SerializationStreamReader streamReader, OWLFunctionalObjectPropertyAxiomImpl instance) throws SerializationException {
"""
Deserializes the content of the object from the
{@link com.google.gwt.user.client.rpc.SerializationStreamReader}.
@param streamReader the {@link com.google.gwt.user.client.rpc.SerializationStreamReader} to read the
object's content from
@param instance the object instance to deserialize
@throws com.google.gwt.user.client.rpc.SerializationException
if the deserialization operation is not
successful
"""
deserialize(streamReader, instance);
}
|
java
|
@Override
public void deserializeInstance(SerializationStreamReader streamReader, OWLFunctionalObjectPropertyAxiomImpl instance) throws SerializationException {
deserialize(streamReader, instance);
}
|
[
"@",
"Override",
"public",
"void",
"deserializeInstance",
"(",
"SerializationStreamReader",
"streamReader",
",",
"OWLFunctionalObjectPropertyAxiomImpl",
"instance",
")",
"throws",
"SerializationException",
"{",
"deserialize",
"(",
"streamReader",
",",
"instance",
")",
";",
"}"
] |
Deserializes the content of the object from the
{@link com.google.gwt.user.client.rpc.SerializationStreamReader}.
@param streamReader the {@link com.google.gwt.user.client.rpc.SerializationStreamReader} to read the
object's content from
@param instance the object instance to deserialize
@throws com.google.gwt.user.client.rpc.SerializationException
if the deserialization operation is not
successful
|
[
"Deserializes",
"the",
"content",
"of",
"the",
"object",
"from",
"the",
"{",
"@link",
"com",
".",
"google",
".",
"gwt",
".",
"user",
".",
"client",
".",
"rpc",
".",
"SerializationStreamReader",
"}",
"."
] |
train
|
https://github.com/matthewhorridge/owlapi-gwt/blob/7ab975fb6cef3c8947099983551672a3b5d4e2fd/owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLFunctionalObjectPropertyAxiomImpl_CustomFieldSerializer.java#L96-L99
|
fuinorg/utils4j
|
src/main/java/org/fuin/utils4j/Utils4J.java
|
Utils4J.getMethodSignature
|
private static String getMethodSignature(final String returnType, final String methodName, final Class<?>[] argTypes) {
"""
Creates a textual representation of the method.
@param returnType
Return type of the method - Can be <code>null</code>.
@param methodName
Name of the method - Cannot be <code>null</code>.
@param argTypes
The list of parameters - Can be <code>null</code>.
@return Textual signature of the method.
"""
final StringBuilder sb = new StringBuilder();
if (returnType != null) {
sb.append(returnType);
sb.append(" ");
}
sb.append(methodName);
sb.append("(");
if (argTypes != null) {
for (int i = 0; i < argTypes.length; i++) {
if (i > 0) {
sb.append(", ");
}
sb.append(argTypes[i].getName());
}
}
sb.append(")");
return sb.toString();
}
|
java
|
private static String getMethodSignature(final String returnType, final String methodName, final Class<?>[] argTypes) {
final StringBuilder sb = new StringBuilder();
if (returnType != null) {
sb.append(returnType);
sb.append(" ");
}
sb.append(methodName);
sb.append("(");
if (argTypes != null) {
for (int i = 0; i < argTypes.length; i++) {
if (i > 0) {
sb.append(", ");
}
sb.append(argTypes[i].getName());
}
}
sb.append(")");
return sb.toString();
}
|
[
"private",
"static",
"String",
"getMethodSignature",
"(",
"final",
"String",
"returnType",
",",
"final",
"String",
"methodName",
",",
"final",
"Class",
"<",
"?",
">",
"[",
"]",
"argTypes",
")",
"{",
"final",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"returnType",
"!=",
"null",
")",
"{",
"sb",
".",
"append",
"(",
"returnType",
")",
";",
"sb",
".",
"append",
"(",
"\" \"",
")",
";",
"}",
"sb",
".",
"append",
"(",
"methodName",
")",
";",
"sb",
".",
"append",
"(",
"\"(\"",
")",
";",
"if",
"(",
"argTypes",
"!=",
"null",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"argTypes",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"i",
">",
"0",
")",
"{",
"sb",
".",
"append",
"(",
"\", \"",
")",
";",
"}",
"sb",
".",
"append",
"(",
"argTypes",
"[",
"i",
"]",
".",
"getName",
"(",
")",
")",
";",
"}",
"}",
"sb",
".",
"append",
"(",
"\")\"",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] |
Creates a textual representation of the method.
@param returnType
Return type of the method - Can be <code>null</code>.
@param methodName
Name of the method - Cannot be <code>null</code>.
@param argTypes
The list of parameters - Can be <code>null</code>.
@return Textual signature of the method.
|
[
"Creates",
"a",
"textual",
"representation",
"of",
"the",
"method",
"."
] |
train
|
https://github.com/fuinorg/utils4j/blob/71cf88e0a8d8ed67bbac513bf3cab165cd7e3280/src/main/java/org/fuin/utils4j/Utils4J.java#L700-L718
|
Azure/azure-sdk-for-java
|
cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java
|
ModelsImpl.getIntentSuggestionsWithServiceResponseAsync
|
public Observable<ServiceResponse<List<IntentsSuggestionExample>>> getIntentSuggestionsWithServiceResponseAsync(UUID appId, String versionId, UUID intentId, GetIntentSuggestionsOptionalParameter getIntentSuggestionsOptionalParameter) {
"""
Suggests examples that would improve the accuracy of the intent model.
@param appId The application ID.
@param versionId The version ID.
@param intentId The intent classifier ID.
@param getIntentSuggestionsOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<IntentsSuggestionExample> object
"""
if (this.client.endpoint() == null) {
throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null.");
}
if (appId == null) {
throw new IllegalArgumentException("Parameter appId is required and cannot be null.");
}
if (versionId == null) {
throw new IllegalArgumentException("Parameter versionId is required and cannot be null.");
}
if (intentId == null) {
throw new IllegalArgumentException("Parameter intentId is required and cannot be null.");
}
final Integer take = getIntentSuggestionsOptionalParameter != null ? getIntentSuggestionsOptionalParameter.take() : null;
return getIntentSuggestionsWithServiceResponseAsync(appId, versionId, intentId, take);
}
|
java
|
public Observable<ServiceResponse<List<IntentsSuggestionExample>>> getIntentSuggestionsWithServiceResponseAsync(UUID appId, String versionId, UUID intentId, GetIntentSuggestionsOptionalParameter getIntentSuggestionsOptionalParameter) {
if (this.client.endpoint() == null) {
throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null.");
}
if (appId == null) {
throw new IllegalArgumentException("Parameter appId is required and cannot be null.");
}
if (versionId == null) {
throw new IllegalArgumentException("Parameter versionId is required and cannot be null.");
}
if (intentId == null) {
throw new IllegalArgumentException("Parameter intentId is required and cannot be null.");
}
final Integer take = getIntentSuggestionsOptionalParameter != null ? getIntentSuggestionsOptionalParameter.take() : null;
return getIntentSuggestionsWithServiceResponseAsync(appId, versionId, intentId, take);
}
|
[
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"List",
"<",
"IntentsSuggestionExample",
">",
">",
">",
"getIntentSuggestionsWithServiceResponseAsync",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"UUID",
"intentId",
",",
"GetIntentSuggestionsOptionalParameter",
"getIntentSuggestionsOptionalParameter",
")",
"{",
"if",
"(",
"this",
".",
"client",
".",
"endpoint",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter this.client.endpoint() is required and cannot be null.\"",
")",
";",
"}",
"if",
"(",
"appId",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter appId is required and cannot be null.\"",
")",
";",
"}",
"if",
"(",
"versionId",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter versionId is required and cannot be null.\"",
")",
";",
"}",
"if",
"(",
"intentId",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter intentId is required and cannot be null.\"",
")",
";",
"}",
"final",
"Integer",
"take",
"=",
"getIntentSuggestionsOptionalParameter",
"!=",
"null",
"?",
"getIntentSuggestionsOptionalParameter",
".",
"take",
"(",
")",
":",
"null",
";",
"return",
"getIntentSuggestionsWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
"intentId",
",",
"take",
")",
";",
"}"
] |
Suggests examples that would improve the accuracy of the intent model.
@param appId The application ID.
@param versionId The version ID.
@param intentId The intent classifier ID.
@param getIntentSuggestionsOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<IntentsSuggestionExample> object
|
[
"Suggests",
"examples",
"that",
"would",
"improve",
"the",
"accuracy",
"of",
"the",
"intent",
"model",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java#L5119-L5135
|
FasterXML/woodstox
|
src/main/java/com/ctc/wstx/io/InputSourceFactory.java
|
InputSourceFactory.constructDocumentSource
|
public static BranchingReaderSource constructDocumentSource
(ReaderConfig cfg, InputBootstrapper bs, String pubId, SystemId sysId,
Reader r, boolean realClose) {
"""
Factory method used for creating the main-level document reader
source.
"""
/* To resolve [WSTX-50] need to ensure that P_BASE_URL overrides
* the defaults if/as necessary
*/
URL url = cfg.getBaseURL();
if (url != null) {
sysId = SystemId.construct(url);
}
BranchingReaderSource rs = new BranchingReaderSource(cfg, pubId, sysId, r, realClose);
if (bs != null) {
rs.setInputOffsets(bs.getInputTotal(), bs.getInputRow(),
-bs.getInputColumn());
}
return rs;
}
|
java
|
public static BranchingReaderSource constructDocumentSource
(ReaderConfig cfg, InputBootstrapper bs, String pubId, SystemId sysId,
Reader r, boolean realClose)
{
/* To resolve [WSTX-50] need to ensure that P_BASE_URL overrides
* the defaults if/as necessary
*/
URL url = cfg.getBaseURL();
if (url != null) {
sysId = SystemId.construct(url);
}
BranchingReaderSource rs = new BranchingReaderSource(cfg, pubId, sysId, r, realClose);
if (bs != null) {
rs.setInputOffsets(bs.getInputTotal(), bs.getInputRow(),
-bs.getInputColumn());
}
return rs;
}
|
[
"public",
"static",
"BranchingReaderSource",
"constructDocumentSource",
"(",
"ReaderConfig",
"cfg",
",",
"InputBootstrapper",
"bs",
",",
"String",
"pubId",
",",
"SystemId",
"sysId",
",",
"Reader",
"r",
",",
"boolean",
"realClose",
")",
"{",
"/* To resolve [WSTX-50] need to ensure that P_BASE_URL overrides\n * the defaults if/as necessary\n */",
"URL",
"url",
"=",
"cfg",
".",
"getBaseURL",
"(",
")",
";",
"if",
"(",
"url",
"!=",
"null",
")",
"{",
"sysId",
"=",
"SystemId",
".",
"construct",
"(",
"url",
")",
";",
"}",
"BranchingReaderSource",
"rs",
"=",
"new",
"BranchingReaderSource",
"(",
"cfg",
",",
"pubId",
",",
"sysId",
",",
"r",
",",
"realClose",
")",
";",
"if",
"(",
"bs",
"!=",
"null",
")",
"{",
"rs",
".",
"setInputOffsets",
"(",
"bs",
".",
"getInputTotal",
"(",
")",
",",
"bs",
".",
"getInputRow",
"(",
")",
",",
"-",
"bs",
".",
"getInputColumn",
"(",
")",
")",
";",
"}",
"return",
"rs",
";",
"}"
] |
Factory method used for creating the main-level document reader
source.
|
[
"Factory",
"method",
"used",
"for",
"creating",
"the",
"main",
"-",
"level",
"document",
"reader",
"source",
"."
] |
train
|
https://github.com/FasterXML/woodstox/blob/ffcaabdc06672d9564c48c25d601d029b7fd6548/src/main/java/com/ctc/wstx/io/InputSourceFactory.java#L46-L63
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/internal/HttpChannelConfig.java
|
HttpChannelConfig.parseProtocolVersion
|
private void parseProtocolVersion(Map<?, ?> props) {
"""
Check the configuration to see if there is a desired http protocol version
that has been provided for this HTTP Channel
@param props
"""
Object protocolVersionProperty = props.get(HttpConfigConstants.PROPNAME_PROTOCOL_VERSION);
if (null != protocolVersionProperty) {
String protocolVersion = ((String) protocolVersionProperty).toLowerCase();
if (HttpConfigConstants.PROTOCOL_VERSION_11.equals(protocolVersion)) {
this.useH2ProtocolAttribute = Boolean.FALSE;
} else if (HttpConfigConstants.PROTOCOL_VERSION_2.equals(protocolVersion)) {
this.useH2ProtocolAttribute = Boolean.TRUE;
}
if ((TraceComponent.isAnyTracingEnabled()) && (tc.isEventEnabled()) && this.useH2ProtocolAttribute != null) {
Tr.event(tc, "HTTP Channel Config: versionProtocol has been set to " + protocolVersion);
}
}
}
|
java
|
private void parseProtocolVersion(Map<?, ?> props) {
Object protocolVersionProperty = props.get(HttpConfigConstants.PROPNAME_PROTOCOL_VERSION);
if (null != protocolVersionProperty) {
String protocolVersion = ((String) protocolVersionProperty).toLowerCase();
if (HttpConfigConstants.PROTOCOL_VERSION_11.equals(protocolVersion)) {
this.useH2ProtocolAttribute = Boolean.FALSE;
} else if (HttpConfigConstants.PROTOCOL_VERSION_2.equals(protocolVersion)) {
this.useH2ProtocolAttribute = Boolean.TRUE;
}
if ((TraceComponent.isAnyTracingEnabled()) && (tc.isEventEnabled()) && this.useH2ProtocolAttribute != null) {
Tr.event(tc, "HTTP Channel Config: versionProtocol has been set to " + protocolVersion);
}
}
}
|
[
"private",
"void",
"parseProtocolVersion",
"(",
"Map",
"<",
"?",
",",
"?",
">",
"props",
")",
"{",
"Object",
"protocolVersionProperty",
"=",
"props",
".",
"get",
"(",
"HttpConfigConstants",
".",
"PROPNAME_PROTOCOL_VERSION",
")",
";",
"if",
"(",
"null",
"!=",
"protocolVersionProperty",
")",
"{",
"String",
"protocolVersion",
"=",
"(",
"(",
"String",
")",
"protocolVersionProperty",
")",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"HttpConfigConstants",
".",
"PROTOCOL_VERSION_11",
".",
"equals",
"(",
"protocolVersion",
")",
")",
"{",
"this",
".",
"useH2ProtocolAttribute",
"=",
"Boolean",
".",
"FALSE",
";",
"}",
"else",
"if",
"(",
"HttpConfigConstants",
".",
"PROTOCOL_VERSION_2",
".",
"equals",
"(",
"protocolVersion",
")",
")",
"{",
"this",
".",
"useH2ProtocolAttribute",
"=",
"Boolean",
".",
"TRUE",
";",
"}",
"if",
"(",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
")",
"&&",
"(",
"tc",
".",
"isEventEnabled",
"(",
")",
")",
"&&",
"this",
".",
"useH2ProtocolAttribute",
"!=",
"null",
")",
"{",
"Tr",
".",
"event",
"(",
"tc",
",",
"\"HTTP Channel Config: versionProtocol has been set to \"",
"+",
"protocolVersion",
")",
";",
"}",
"}",
"}"
] |
Check the configuration to see if there is a desired http protocol version
that has been provided for this HTTP Channel
@param props
|
[
"Check",
"the",
"configuration",
"to",
"see",
"if",
"there",
"is",
"a",
"desired",
"http",
"protocol",
"version",
"that",
"has",
"been",
"provided",
"for",
"this",
"HTTP",
"Channel"
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/internal/HttpChannelConfig.java#L1411-L1429
|
apache/incubator-shardingsphere
|
sharding-core/sharding-core-rewrite/src/main/java/org/apache/shardingsphere/core/rewrite/SQLRewriteEngine.java
|
SQLRewriteEngine.generateSQL
|
public SQLUnit generateSQL(final TableUnit tableUnit, final SQLBuilder sqlBuilder, final ShardingDataSourceMetaData shardingDataSourceMetaData) {
"""
Generate SQL string.
@param tableUnit route table unit
@param sqlBuilder SQL builder
@param shardingDataSourceMetaData sharding data source meta data
@return SQL unit
"""
return sqlBuilder.toSQL(tableUnit, getTableTokens(tableUnit), shardingRule, shardingDataSourceMetaData);
}
|
java
|
public SQLUnit generateSQL(final TableUnit tableUnit, final SQLBuilder sqlBuilder, final ShardingDataSourceMetaData shardingDataSourceMetaData) {
return sqlBuilder.toSQL(tableUnit, getTableTokens(tableUnit), shardingRule, shardingDataSourceMetaData);
}
|
[
"public",
"SQLUnit",
"generateSQL",
"(",
"final",
"TableUnit",
"tableUnit",
",",
"final",
"SQLBuilder",
"sqlBuilder",
",",
"final",
"ShardingDataSourceMetaData",
"shardingDataSourceMetaData",
")",
"{",
"return",
"sqlBuilder",
".",
"toSQL",
"(",
"tableUnit",
",",
"getTableTokens",
"(",
"tableUnit",
")",
",",
"shardingRule",
",",
"shardingDataSourceMetaData",
")",
";",
"}"
] |
Generate SQL string.
@param tableUnit route table unit
@param sqlBuilder SQL builder
@param shardingDataSourceMetaData sharding data source meta data
@return SQL unit
|
[
"Generate",
"SQL",
"string",
"."
] |
train
|
https://github.com/apache/incubator-shardingsphere/blob/f88fd29fc345dfb31fdce12e9e96cbfa0fd2402d/sharding-core/sharding-core-rewrite/src/main/java/org/apache/shardingsphere/core/rewrite/SQLRewriteEngine.java#L514-L516
|
google/j2objc
|
jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/DateFormat.java
|
DateFormat.getDateInstance
|
public final static DateFormat getDateInstance(int style) {
"""
Returns the date formatter with the given formatting style
for the default <code>FORMAT</code> locale.
@param style the given formatting style. For example,
SHORT for "M/d/yy" in the US locale. As currently implemented, relative date
formatting only affects a limited range of calendar days before or after the
current date, based on the CLDR <field type="day">/<relative> data: For example,
in English, "Yesterday", "Today", and "Tomorrow". Outside of this range, relative
dates are formatted using the corresponding non-relative style.
@return a date formatter.
@see Category#FORMAT
"""
return get(style, -1, ULocale.getDefault(Category.FORMAT), null);
}
|
java
|
public final static DateFormat getDateInstance(int style)
{
return get(style, -1, ULocale.getDefault(Category.FORMAT), null);
}
|
[
"public",
"final",
"static",
"DateFormat",
"getDateInstance",
"(",
"int",
"style",
")",
"{",
"return",
"get",
"(",
"style",
",",
"-",
"1",
",",
"ULocale",
".",
"getDefault",
"(",
"Category",
".",
"FORMAT",
")",
",",
"null",
")",
";",
"}"
] |
Returns the date formatter with the given formatting style
for the default <code>FORMAT</code> locale.
@param style the given formatting style. For example,
SHORT for "M/d/yy" in the US locale. As currently implemented, relative date
formatting only affects a limited range of calendar days before or after the
current date, based on the CLDR <field type="day">/<relative> data: For example,
in English, "Yesterday", "Today", and "Tomorrow". Outside of this range, relative
dates are formatted using the corresponding non-relative style.
@return a date formatter.
@see Category#FORMAT
|
[
"Returns",
"the",
"date",
"formatter",
"with",
"the",
"given",
"formatting",
"style",
"for",
"the",
"default",
"<code",
">",
"FORMAT<",
"/",
"code",
">",
"locale",
"."
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/DateFormat.java#L1299-L1302
|
google/closure-templates
|
java/src/com/google/template/soy/jbcsrc/DetachState.java
|
DetachState.generateReattachTable
|
Statement generateReattachTable() {
"""
Returns a statement that generates the reattach jump table.
<p>Note: This statement should be the <em>first</em> statement in any detachable method.
"""
final Expression readField = stateField.accessor(thisExpr);
final Statement defaultCase =
Statement.throwExpression(MethodRef.RUNTIME_UNEXPECTED_STATE_ERROR.invoke(readField));
return new Statement() {
@Override
protected void doGen(final CodeBuilder adapter) {
int[] keys = new int[reattaches.size()];
for (int i = 0; i < keys.length; i++) {
keys[i] = i;
}
readField.gen(adapter);
// Generate a switch table. Note, while it might be preferable to just 'goto state', Java
// doesn't allow computable gotos (probably because it makes verification impossible). So
// instead we emulate that with a jump table. And anyway we still need to execute 'restore'
// logic to repopulate the local variable tables, so the 'case' statements are a natural
// place for that logic to live.
adapter.tableSwitch(
keys,
new TableSwitchGenerator() {
@Override
public void generateCase(int key, Label end) {
if (key == 0) {
// State 0 is special, it means initial state, so we just jump to the very end
adapter.goTo(end);
return;
}
ReattachState reattachState = reattaches.get(key);
// restore and jump!
reattachState.restoreStatement().gen(adapter);
adapter.goTo(reattachState.reattachPoint());
}
@Override
public void generateDefault() {
defaultCase.gen(adapter);
}
},
// Use tableswitch instead of lookupswitch. TableSwitch is appropriate because our case
// labels are sequential integers in the range [0, N). This means that switch is O(1)
// and
// there are no 'holes' meaning that it is compact in the bytecode.
true);
}
};
}
|
java
|
Statement generateReattachTable() {
final Expression readField = stateField.accessor(thisExpr);
final Statement defaultCase =
Statement.throwExpression(MethodRef.RUNTIME_UNEXPECTED_STATE_ERROR.invoke(readField));
return new Statement() {
@Override
protected void doGen(final CodeBuilder adapter) {
int[] keys = new int[reattaches.size()];
for (int i = 0; i < keys.length; i++) {
keys[i] = i;
}
readField.gen(adapter);
// Generate a switch table. Note, while it might be preferable to just 'goto state', Java
// doesn't allow computable gotos (probably because it makes verification impossible). So
// instead we emulate that with a jump table. And anyway we still need to execute 'restore'
// logic to repopulate the local variable tables, so the 'case' statements are a natural
// place for that logic to live.
adapter.tableSwitch(
keys,
new TableSwitchGenerator() {
@Override
public void generateCase(int key, Label end) {
if (key == 0) {
// State 0 is special, it means initial state, so we just jump to the very end
adapter.goTo(end);
return;
}
ReattachState reattachState = reattaches.get(key);
// restore and jump!
reattachState.restoreStatement().gen(adapter);
adapter.goTo(reattachState.reattachPoint());
}
@Override
public void generateDefault() {
defaultCase.gen(adapter);
}
},
// Use tableswitch instead of lookupswitch. TableSwitch is appropriate because our case
// labels are sequential integers in the range [0, N). This means that switch is O(1)
// and
// there are no 'holes' meaning that it is compact in the bytecode.
true);
}
};
}
|
[
"Statement",
"generateReattachTable",
"(",
")",
"{",
"final",
"Expression",
"readField",
"=",
"stateField",
".",
"accessor",
"(",
"thisExpr",
")",
";",
"final",
"Statement",
"defaultCase",
"=",
"Statement",
".",
"throwExpression",
"(",
"MethodRef",
".",
"RUNTIME_UNEXPECTED_STATE_ERROR",
".",
"invoke",
"(",
"readField",
")",
")",
";",
"return",
"new",
"Statement",
"(",
")",
"{",
"@",
"Override",
"protected",
"void",
"doGen",
"(",
"final",
"CodeBuilder",
"adapter",
")",
"{",
"int",
"[",
"]",
"keys",
"=",
"new",
"int",
"[",
"reattaches",
".",
"size",
"(",
")",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"i",
"++",
")",
"{",
"keys",
"[",
"i",
"]",
"=",
"i",
";",
"}",
"readField",
".",
"gen",
"(",
"adapter",
")",
";",
"// Generate a switch table. Note, while it might be preferable to just 'goto state', Java",
"// doesn't allow computable gotos (probably because it makes verification impossible). So",
"// instead we emulate that with a jump table. And anyway we still need to execute 'restore'",
"// logic to repopulate the local variable tables, so the 'case' statements are a natural",
"// place for that logic to live.",
"adapter",
".",
"tableSwitch",
"(",
"keys",
",",
"new",
"TableSwitchGenerator",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"generateCase",
"(",
"int",
"key",
",",
"Label",
"end",
")",
"{",
"if",
"(",
"key",
"==",
"0",
")",
"{",
"// State 0 is special, it means initial state, so we just jump to the very end",
"adapter",
".",
"goTo",
"(",
"end",
")",
";",
"return",
";",
"}",
"ReattachState",
"reattachState",
"=",
"reattaches",
".",
"get",
"(",
"key",
")",
";",
"// restore and jump!",
"reattachState",
".",
"restoreStatement",
"(",
")",
".",
"gen",
"(",
"adapter",
")",
";",
"adapter",
".",
"goTo",
"(",
"reattachState",
".",
"reattachPoint",
"(",
")",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"generateDefault",
"(",
")",
"{",
"defaultCase",
".",
"gen",
"(",
"adapter",
")",
";",
"}",
"}",
",",
"// Use tableswitch instead of lookupswitch. TableSwitch is appropriate because our case",
"// labels are sequential integers in the range [0, N). This means that switch is O(1)",
"// and",
"// there are no 'holes' meaning that it is compact in the bytecode.",
"true",
")",
";",
"}",
"}",
";",
"}"
] |
Returns a statement that generates the reattach jump table.
<p>Note: This statement should be the <em>first</em> statement in any detachable method.
|
[
"Returns",
"a",
"statement",
"that",
"generates",
"the",
"reattach",
"jump",
"table",
"."
] |
train
|
https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/DetachState.java#L301-L346
|
Pi4J/pi4j
|
pi4j-core/src/main/java/com/pi4j/wiringpi/Serial.java
|
Serial.serialPuts
|
public synchronized static void serialPuts(int fd, String data, String... args) {
"""
<p>void serialPuts (int fd, String data, String...arguments);</p>
<p>
Sends the nul-terminated formatted string to the serial device identified by the given file
descriptor.
</p>
<p>(ATTENTION: the 'data' argument can only be a maximum of 1024 characters.)</p>
@see <a
href="http://wiringpi.com/reference/serial-library/">http://wiringpi.com/reference/serial-library/</a>
@param fd The file descriptor of the serial port.
@param data The formatted data string to transmit to the serial port.
@param args Arguments to the format string.
"""
serialPuts(fd, String.format(data, (Object[]) args));
}
|
java
|
public synchronized static void serialPuts(int fd, String data, String... args) {
serialPuts(fd, String.format(data, (Object[]) args));
}
|
[
"public",
"synchronized",
"static",
"void",
"serialPuts",
"(",
"int",
"fd",
",",
"String",
"data",
",",
"String",
"...",
"args",
")",
"{",
"serialPuts",
"(",
"fd",
",",
"String",
".",
"format",
"(",
"data",
",",
"(",
"Object",
"[",
"]",
")",
"args",
")",
")",
";",
"}"
] |
<p>void serialPuts (int fd, String data, String...arguments);</p>
<p>
Sends the nul-terminated formatted string to the serial device identified by the given file
descriptor.
</p>
<p>(ATTENTION: the 'data' argument can only be a maximum of 1024 characters.)</p>
@see <a
href="http://wiringpi.com/reference/serial-library/">http://wiringpi.com/reference/serial-library/</a>
@param fd The file descriptor of the serial port.
@param data The formatted data string to transmit to the serial port.
@param args Arguments to the format string.
|
[
"<p",
">",
"void",
"serialPuts",
"(",
"int",
"fd",
"String",
"data",
"String",
"...",
"arguments",
")",
";",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/Pi4J/pi4j/blob/03cacc62223cc59b3118bfcefadabab979fd84c7/pi4j-core/src/main/java/com/pi4j/wiringpi/Serial.java#L224-L226
|
Azure/azure-sdk-for-java
|
batchai/resource-manager/v2018_05_01/src/main/java/com/microsoft/azure/management/batchai/v2018_05_01/implementation/JobsInner.java
|
JobsInner.listByExperimentWithServiceResponseAsync
|
public Observable<ServiceResponse<Page<JobInner>>> listByExperimentWithServiceResponseAsync(final String resourceGroupName, final String workspaceName, final String experimentName, final JobsListByExperimentOptions jobsListByExperimentOptions) {
"""
Gets a list of Jobs within the specified Experiment.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param workspaceName The name of the workspace. Workspace names can only contain a combination of alphanumeric characters along with dash (-) and underscore (_). The name must be from 1 through 64 characters long.
@param experimentName The name of the experiment. Experiment names can only contain a combination of alphanumeric characters along with dash (-) and underscore (_). The name must be from 1 through 64 characters long.
@param jobsListByExperimentOptions Additional parameters for the operation
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<JobInner> object
"""
return listByExperimentSinglePageAsync(resourceGroupName, workspaceName, experimentName, jobsListByExperimentOptions)
.concatMap(new Func1<ServiceResponse<Page<JobInner>>, Observable<ServiceResponse<Page<JobInner>>>>() {
@Override
public Observable<ServiceResponse<Page<JobInner>>> call(ServiceResponse<Page<JobInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(listByExperimentNextWithServiceResponseAsync(nextPageLink));
}
});
}
|
java
|
public Observable<ServiceResponse<Page<JobInner>>> listByExperimentWithServiceResponseAsync(final String resourceGroupName, final String workspaceName, final String experimentName, final JobsListByExperimentOptions jobsListByExperimentOptions) {
return listByExperimentSinglePageAsync(resourceGroupName, workspaceName, experimentName, jobsListByExperimentOptions)
.concatMap(new Func1<ServiceResponse<Page<JobInner>>, Observable<ServiceResponse<Page<JobInner>>>>() {
@Override
public Observable<ServiceResponse<Page<JobInner>>> call(ServiceResponse<Page<JobInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(listByExperimentNextWithServiceResponseAsync(nextPageLink));
}
});
}
|
[
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"JobInner",
">",
">",
">",
"listByExperimentWithServiceResponseAsync",
"(",
"final",
"String",
"resourceGroupName",
",",
"final",
"String",
"workspaceName",
",",
"final",
"String",
"experimentName",
",",
"final",
"JobsListByExperimentOptions",
"jobsListByExperimentOptions",
")",
"{",
"return",
"listByExperimentSinglePageAsync",
"(",
"resourceGroupName",
",",
"workspaceName",
",",
"experimentName",
",",
"jobsListByExperimentOptions",
")",
".",
"concatMap",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"JobInner",
">",
">",
",",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"JobInner",
">",
">",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"JobInner",
">",
">",
">",
"call",
"(",
"ServiceResponse",
"<",
"Page",
"<",
"JobInner",
">",
">",
"page",
")",
"{",
"String",
"nextPageLink",
"=",
"page",
".",
"body",
"(",
")",
".",
"nextPageLink",
"(",
")",
";",
"if",
"(",
"nextPageLink",
"==",
"null",
")",
"{",
"return",
"Observable",
".",
"just",
"(",
"page",
")",
";",
"}",
"return",
"Observable",
".",
"just",
"(",
"page",
")",
".",
"concatWith",
"(",
"listByExperimentNextWithServiceResponseAsync",
"(",
"nextPageLink",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Gets a list of Jobs within the specified Experiment.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param workspaceName The name of the workspace. Workspace names can only contain a combination of alphanumeric characters along with dash (-) and underscore (_). The name must be from 1 through 64 characters long.
@param experimentName The name of the experiment. Experiment names can only contain a combination of alphanumeric characters along with dash (-) and underscore (_). The name must be from 1 through 64 characters long.
@param jobsListByExperimentOptions Additional parameters for the operation
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<JobInner> object
|
[
"Gets",
"a",
"list",
"of",
"Jobs",
"within",
"the",
"specified",
"Experiment",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batchai/resource-manager/v2018_05_01/src/main/java/com/microsoft/azure/management/batchai/v2018_05_01/implementation/JobsInner.java#L323-L335
|
infinispan/infinispan
|
client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transaction/AbstractTransactionTable.java
|
AbstractTransactionTable.completeTransaction
|
int completeTransaction(Xid xid, boolean commit) {
"""
It completes the transaction with the commit or rollback request.
<p>
It can be a commit or rollback request.
@param xid The transaction {@link Xid}.
@param commit {@code True} to commit the transaction, {@link false} to rollback.
@return The server's return code.
"""
try {
TransactionOperationFactory factory = assertStartedAndReturnFactory();
CompleteTransactionOperation operation = factory.newCompleteTransactionOperation(xid, commit);
return operation.execute().get();
} catch (Exception e) {
getLog().debug("Exception while commit/rollback.", e);
return XAException.XA_HEURRB; //heuristically rolled-back
}
}
|
java
|
int completeTransaction(Xid xid, boolean commit) {
try {
TransactionOperationFactory factory = assertStartedAndReturnFactory();
CompleteTransactionOperation operation = factory.newCompleteTransactionOperation(xid, commit);
return operation.execute().get();
} catch (Exception e) {
getLog().debug("Exception while commit/rollback.", e);
return XAException.XA_HEURRB; //heuristically rolled-back
}
}
|
[
"int",
"completeTransaction",
"(",
"Xid",
"xid",
",",
"boolean",
"commit",
")",
"{",
"try",
"{",
"TransactionOperationFactory",
"factory",
"=",
"assertStartedAndReturnFactory",
"(",
")",
";",
"CompleteTransactionOperation",
"operation",
"=",
"factory",
".",
"newCompleteTransactionOperation",
"(",
"xid",
",",
"commit",
")",
";",
"return",
"operation",
".",
"execute",
"(",
")",
".",
"get",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"getLog",
"(",
")",
".",
"debug",
"(",
"\"Exception while commit/rollback.\"",
",",
"e",
")",
";",
"return",
"XAException",
".",
"XA_HEURRB",
";",
"//heuristically rolled-back",
"}",
"}"
] |
It completes the transaction with the commit or rollback request.
<p>
It can be a commit or rollback request.
@param xid The transaction {@link Xid}.
@param commit {@code True} to commit the transaction, {@link false} to rollback.
@return The server's return code.
|
[
"It",
"completes",
"the",
"transaction",
"with",
"the",
"commit",
"or",
"rollback",
"request",
".",
"<p",
">",
"It",
"can",
"be",
"a",
"commit",
"or",
"rollback",
"request",
"."
] |
train
|
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transaction/AbstractTransactionTable.java#L67-L76
|
mgm-tp/jfunk
|
jfunk-data-generator/src/main/java/com/mgmtp/jfunk/data/generator/util/CharacterSet.java
|
CharacterSet.createCharacterSet
|
public static CharacterSet createCharacterSet(final String encoding, final String goodExpression, final String badExpression,
final String characterSetId) throws UnsupportedEncodingException {
"""
Creates a new CharacterSet. If there is already a CharacterSet with the given ID this will be
returned.
"""
if (characterSets.get().containsKey(characterSetId)) {
LOG.info("CharacterSet with id=" + characterSetId + " already created");
return characterSets.get().get(characterSetId);
}
CharacterSet cs = new CharacterSet(encoding, goodExpression, badExpression, characterSetId);
characterSets.get().put(characterSetId, cs);
LOG.info("Added " + cs);
return cs;
}
|
java
|
public static CharacterSet createCharacterSet(final String encoding, final String goodExpression, final String badExpression,
final String characterSetId) throws UnsupportedEncodingException {
if (characterSets.get().containsKey(characterSetId)) {
LOG.info("CharacterSet with id=" + characterSetId + " already created");
return characterSets.get().get(characterSetId);
}
CharacterSet cs = new CharacterSet(encoding, goodExpression, badExpression, characterSetId);
characterSets.get().put(characterSetId, cs);
LOG.info("Added " + cs);
return cs;
}
|
[
"public",
"static",
"CharacterSet",
"createCharacterSet",
"(",
"final",
"String",
"encoding",
",",
"final",
"String",
"goodExpression",
",",
"final",
"String",
"badExpression",
",",
"final",
"String",
"characterSetId",
")",
"throws",
"UnsupportedEncodingException",
"{",
"if",
"(",
"characterSets",
".",
"get",
"(",
")",
".",
"containsKey",
"(",
"characterSetId",
")",
")",
"{",
"LOG",
".",
"info",
"(",
"\"CharacterSet with id=\"",
"+",
"characterSetId",
"+",
"\" already created\"",
")",
";",
"return",
"characterSets",
".",
"get",
"(",
")",
".",
"get",
"(",
"characterSetId",
")",
";",
"}",
"CharacterSet",
"cs",
"=",
"new",
"CharacterSet",
"(",
"encoding",
",",
"goodExpression",
",",
"badExpression",
",",
"characterSetId",
")",
";",
"characterSets",
".",
"get",
"(",
")",
".",
"put",
"(",
"characterSetId",
",",
"cs",
")",
";",
"LOG",
".",
"info",
"(",
"\"Added \"",
"+",
"cs",
")",
";",
"return",
"cs",
";",
"}"
] |
Creates a new CharacterSet. If there is already a CharacterSet with the given ID this will be
returned.
|
[
"Creates",
"a",
"new",
"CharacterSet",
".",
"If",
"there",
"is",
"already",
"a",
"CharacterSet",
"with",
"the",
"given",
"ID",
"this",
"will",
"be",
"returned",
"."
] |
train
|
https://github.com/mgm-tp/jfunk/blob/5b9fecac5778b988bb458085ded39ea9a4c7c2ae/jfunk-data-generator/src/main/java/com/mgmtp/jfunk/data/generator/util/CharacterSet.java#L228-L238
|
citrusframework/citrus
|
modules/citrus-java-dsl/src/main/java/com/consol/citrus/dsl/builder/SoapServerActionBuilder.java
|
SoapServerActionBuilder.sendFault
|
public SoapServerFaultResponseActionBuilder sendFault() {
"""
Generic response builder for sending SOAP fault messages to client.
@return
"""
SoapServerFaultResponseActionBuilder soapServerResponseActionBuilder = new SoapServerFaultResponseActionBuilder(action, soapServer)
.withApplicationContext(applicationContext);
return soapServerResponseActionBuilder;
}
|
java
|
public SoapServerFaultResponseActionBuilder sendFault() {
SoapServerFaultResponseActionBuilder soapServerResponseActionBuilder = new SoapServerFaultResponseActionBuilder(action, soapServer)
.withApplicationContext(applicationContext);
return soapServerResponseActionBuilder;
}
|
[
"public",
"SoapServerFaultResponseActionBuilder",
"sendFault",
"(",
")",
"{",
"SoapServerFaultResponseActionBuilder",
"soapServerResponseActionBuilder",
"=",
"new",
"SoapServerFaultResponseActionBuilder",
"(",
"action",
",",
"soapServer",
")",
".",
"withApplicationContext",
"(",
"applicationContext",
")",
";",
"return",
"soapServerResponseActionBuilder",
";",
"}"
] |
Generic response builder for sending SOAP fault messages to client.
@return
|
[
"Generic",
"response",
"builder",
"for",
"sending",
"SOAP",
"fault",
"messages",
"to",
"client",
"."
] |
train
|
https://github.com/citrusframework/citrus/blob/55c58ef74c01d511615e43646ca25c1b2301c56d/modules/citrus-java-dsl/src/main/java/com/consol/citrus/dsl/builder/SoapServerActionBuilder.java#L70-L74
|
alkacon/opencms-core
|
src-gwt/org/opencms/ugc/client/export/CmsXmlContentUgcApi.java
|
CmsXmlContentUgcApi.handleError
|
public void handleError(Throwable e, I_CmsErrorCallback callback) {
"""
Passes an exception to the given error handling callback and optionally outputs some debug info.<p>
@param e the exception
@param callback the error handling callback
"""
String errorCode = CmsUgcConstants.ErrorCode.errMisc.toString();
String message;
if (e instanceof CmsUgcException) {
CmsUgcException formException = (CmsUgcException)e;
errorCode = formException.getErrorCode().toString();
message = formException.getUserMessage();
} else {
message = e.getMessage();
}
if (callback != null) {
callback.call(errorCode, message, JavaScriptObject.createObject());
}
}
|
java
|
public void handleError(Throwable e, I_CmsErrorCallback callback) {
String errorCode = CmsUgcConstants.ErrorCode.errMisc.toString();
String message;
if (e instanceof CmsUgcException) {
CmsUgcException formException = (CmsUgcException)e;
errorCode = formException.getErrorCode().toString();
message = formException.getUserMessage();
} else {
message = e.getMessage();
}
if (callback != null) {
callback.call(errorCode, message, JavaScriptObject.createObject());
}
}
|
[
"public",
"void",
"handleError",
"(",
"Throwable",
"e",
",",
"I_CmsErrorCallback",
"callback",
")",
"{",
"String",
"errorCode",
"=",
"CmsUgcConstants",
".",
"ErrorCode",
".",
"errMisc",
".",
"toString",
"(",
")",
";",
"String",
"message",
";",
"if",
"(",
"e",
"instanceof",
"CmsUgcException",
")",
"{",
"CmsUgcException",
"formException",
"=",
"(",
"CmsUgcException",
")",
"e",
";",
"errorCode",
"=",
"formException",
".",
"getErrorCode",
"(",
")",
".",
"toString",
"(",
")",
";",
"message",
"=",
"formException",
".",
"getUserMessage",
"(",
")",
";",
"}",
"else",
"{",
"message",
"=",
"e",
".",
"getMessage",
"(",
")",
";",
"}",
"if",
"(",
"callback",
"!=",
"null",
")",
"{",
"callback",
".",
"call",
"(",
"errorCode",
",",
"message",
",",
"JavaScriptObject",
".",
"createObject",
"(",
")",
")",
";",
"}",
"}"
] |
Passes an exception to the given error handling callback and optionally outputs some debug info.<p>
@param e the exception
@param callback the error handling callback
|
[
"Passes",
"an",
"exception",
"to",
"the",
"given",
"error",
"handling",
"callback",
"and",
"optionally",
"outputs",
"some",
"debug",
"info",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/ugc/client/export/CmsXmlContentUgcApi.java#L131-L145
|
OpenLiberty/open-liberty
|
dev/com.ibm.websphere.security/src/com/ibm/websphere/security/audit/AuditEvent.java
|
AuditEvent.setMap
|
public void setMap(Map<String, Object> map) {
"""
Replace the entire event with the keys/values in the provided Map.
All existing keys/values will be lost.
@param map
"""
eventMap.clear();
eventMap.putAll(map);
}
|
java
|
public void setMap(Map<String, Object> map) {
eventMap.clear();
eventMap.putAll(map);
}
|
[
"public",
"void",
"setMap",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"map",
")",
"{",
"eventMap",
".",
"clear",
"(",
")",
";",
"eventMap",
".",
"putAll",
"(",
"map",
")",
";",
"}"
] |
Replace the entire event with the keys/values in the provided Map.
All existing keys/values will be lost.
@param map
|
[
"Replace",
"the",
"entire",
"event",
"with",
"the",
"keys",
"/",
"values",
"in",
"the",
"provided",
"Map",
".",
"All",
"existing",
"keys",
"/",
"values",
"will",
"be",
"lost",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.websphere.security/src/com/ibm/websphere/security/audit/AuditEvent.java#L393-L396
|
buschmais/jqa-java-plugin
|
src/main/java/com/buschmais/jqassistant/plugin/java/impl/scanner/visitor/VisitorHelper.java
|
VisitorHelper.getMethodDescriptor
|
MethodDescriptor getMethodDescriptor(TypeCache.CachedType<?> cachedType, String signature) {
"""
Return the method descriptor for the given type and method signature.
@param cachedType
The containing type.
@param signature
The method signature.
@return The method descriptor.
"""
MethodDescriptor methodDescriptor = cachedType.getMethod(signature);
if (methodDescriptor == null) {
if (signature.startsWith(CONSTRUCTOR_METHOD)) {
methodDescriptor = scannerContext.getStore().create(ConstructorDescriptor.class);
} else {
methodDescriptor = scannerContext.getStore().create(MethodDescriptor.class);
}
methodDescriptor.setSignature(signature);
cachedType.addMember(signature, methodDescriptor);
}
return methodDescriptor;
}
|
java
|
MethodDescriptor getMethodDescriptor(TypeCache.CachedType<?> cachedType, String signature) {
MethodDescriptor methodDescriptor = cachedType.getMethod(signature);
if (methodDescriptor == null) {
if (signature.startsWith(CONSTRUCTOR_METHOD)) {
methodDescriptor = scannerContext.getStore().create(ConstructorDescriptor.class);
} else {
methodDescriptor = scannerContext.getStore().create(MethodDescriptor.class);
}
methodDescriptor.setSignature(signature);
cachedType.addMember(signature, methodDescriptor);
}
return methodDescriptor;
}
|
[
"MethodDescriptor",
"getMethodDescriptor",
"(",
"TypeCache",
".",
"CachedType",
"<",
"?",
">",
"cachedType",
",",
"String",
"signature",
")",
"{",
"MethodDescriptor",
"methodDescriptor",
"=",
"cachedType",
".",
"getMethod",
"(",
"signature",
")",
";",
"if",
"(",
"methodDescriptor",
"==",
"null",
")",
"{",
"if",
"(",
"signature",
".",
"startsWith",
"(",
"CONSTRUCTOR_METHOD",
")",
")",
"{",
"methodDescriptor",
"=",
"scannerContext",
".",
"getStore",
"(",
")",
".",
"create",
"(",
"ConstructorDescriptor",
".",
"class",
")",
";",
"}",
"else",
"{",
"methodDescriptor",
"=",
"scannerContext",
".",
"getStore",
"(",
")",
".",
"create",
"(",
"MethodDescriptor",
".",
"class",
")",
";",
"}",
"methodDescriptor",
".",
"setSignature",
"(",
"signature",
")",
";",
"cachedType",
".",
"addMember",
"(",
"signature",
",",
"methodDescriptor",
")",
";",
"}",
"return",
"methodDescriptor",
";",
"}"
] |
Return the method descriptor for the given type and method signature.
@param cachedType
The containing type.
@param signature
The method signature.
@return The method descriptor.
|
[
"Return",
"the",
"method",
"descriptor",
"for",
"the",
"given",
"type",
"and",
"method",
"signature",
"."
] |
train
|
https://github.com/buschmais/jqa-java-plugin/blob/4c050943e9c28cf1c4a08aa962d5b5bf03c4fe54/src/main/java/com/buschmais/jqassistant/plugin/java/impl/scanner/visitor/VisitorHelper.java#L96-L108
|
querydsl/querydsl
|
querydsl-core/src/main/java/com/querydsl/core/types/dsl/Expressions.java
|
Expressions.stringTemplate
|
public static StringTemplate stringTemplate(Template template, List<?> args) {
"""
Create a new Template expression
@param template template
@param args template parameters
@return template expression
"""
return new StringTemplate(template, ImmutableList.copyOf(args));
}
|
java
|
public static StringTemplate stringTemplate(Template template, List<?> args) {
return new StringTemplate(template, ImmutableList.copyOf(args));
}
|
[
"public",
"static",
"StringTemplate",
"stringTemplate",
"(",
"Template",
"template",
",",
"List",
"<",
"?",
">",
"args",
")",
"{",
"return",
"new",
"StringTemplate",
"(",
"template",
",",
"ImmutableList",
".",
"copyOf",
"(",
"args",
")",
")",
";",
"}"
] |
Create a new Template expression
@param template template
@param args template parameters
@return template expression
|
[
"Create",
"a",
"new",
"Template",
"expression"
] |
train
|
https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-core/src/main/java/com/querydsl/core/types/dsl/Expressions.java#L949-L951
|
Azure/azure-sdk-for-java
|
recoveryservices/resource-manager/v2016_06_01/src/main/java/com/microsoft/azure/management/recoveryservices/v2016_06_01/implementation/UsagesInner.java
|
UsagesInner.listByVaultsAsync
|
public Observable<List<VaultUsageInner>> listByVaultsAsync(String resourceGroupName, String vaultName) {
"""
Fetches the usages of the vault.
@param resourceGroupName The name of the resource group where the recovery services vault is present.
@param vaultName The name of the recovery services vault.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<VaultUsageInner> object
"""
return listByVaultsWithServiceResponseAsync(resourceGroupName, vaultName).map(new Func1<ServiceResponse<List<VaultUsageInner>>, List<VaultUsageInner>>() {
@Override
public List<VaultUsageInner> call(ServiceResponse<List<VaultUsageInner>> response) {
return response.body();
}
});
}
|
java
|
public Observable<List<VaultUsageInner>> listByVaultsAsync(String resourceGroupName, String vaultName) {
return listByVaultsWithServiceResponseAsync(resourceGroupName, vaultName).map(new Func1<ServiceResponse<List<VaultUsageInner>>, List<VaultUsageInner>>() {
@Override
public List<VaultUsageInner> call(ServiceResponse<List<VaultUsageInner>> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"List",
"<",
"VaultUsageInner",
">",
">",
"listByVaultsAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"vaultName",
")",
"{",
"return",
"listByVaultsWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"vaultName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"List",
"<",
"VaultUsageInner",
">",
">",
",",
"List",
"<",
"VaultUsageInner",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"List",
"<",
"VaultUsageInner",
">",
"call",
"(",
"ServiceResponse",
"<",
"List",
"<",
"VaultUsageInner",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Fetches the usages of the vault.
@param resourceGroupName The name of the resource group where the recovery services vault is present.
@param vaultName The name of the recovery services vault.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<VaultUsageInner> object
|
[
"Fetches",
"the",
"usages",
"of",
"the",
"vault",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/recoveryservices/resource-manager/v2016_06_01/src/main/java/com/microsoft/azure/management/recoveryservices/v2016_06_01/implementation/UsagesInner.java#L96-L103
|
jsurfer/JsonSurfer
|
jsurfer-core/src/main/java/org/jsfr/json/JsonSurfer.java
|
JsonSurfer.collectOne
|
@Deprecated
public Object collectOne(Reader reader, JsonPath... paths) {
"""
Collect the first matched value and stop parsing immediately
@param reader json reader
@param paths JsonPath
@return Matched value
@deprecated use {@link #collectOne(InputStream, JsonPath...)} instead
"""
return collectOne(reader, Object.class, paths);
}
|
java
|
@Deprecated
public Object collectOne(Reader reader, JsonPath... paths) {
return collectOne(reader, Object.class, paths);
}
|
[
"@",
"Deprecated",
"public",
"Object",
"collectOne",
"(",
"Reader",
"reader",
",",
"JsonPath",
"...",
"paths",
")",
"{",
"return",
"collectOne",
"(",
"reader",
",",
"Object",
".",
"class",
",",
"paths",
")",
";",
"}"
] |
Collect the first matched value and stop parsing immediately
@param reader json reader
@param paths JsonPath
@return Matched value
@deprecated use {@link #collectOne(InputStream, JsonPath...)} instead
|
[
"Collect",
"the",
"first",
"matched",
"value",
"and",
"stop",
"parsing",
"immediately"
] |
train
|
https://github.com/jsurfer/JsonSurfer/blob/52bd75a453338b86e115092803da140bf99cee62/jsurfer-core/src/main/java/org/jsfr/json/JsonSurfer.java#L442-L445
|
ModeShape/modeshape
|
modeshape-schematic/src/main/java/org/modeshape/schematic/Schematic.java
|
Schematic.getDb
|
@SuppressWarnings( {
"""
Returns a DB with the given type and configuration document, by delegating to all the available {@link SchematicDbProvider}
services. This document is expected to contain a {@link Schematic#TYPE_FIELD type field} to indicate the type
@param document a {@link Document} containing the configuration of a particular DB type; may not be null
@param cl a {@link ClassLoader} instance to be used when searching for available DB provider.
@return a {@link SchematicDb} instance with the given alias, never {@code null}
@throws RuntimeException if a DB with the given alias cannot be found or it fails during initialization
""" "unchecked", "rawtypes" } )
public static <T extends SchematicDb> T getDb(Document document, ClassLoader cl) throws RuntimeException {
String type = document.getString(TYPE_FIELD);
if (type == null) {
throw new IllegalArgumentException("The configuration document '" + document + "' does not contain a '" + TYPE_FIELD + "' field");
}
ServiceLoader<SchematicDbProvider> providers = ServiceLoader.load(SchematicDbProvider.class, cl);
List<RuntimeException> raisedExceptions = new ArrayList<>();
return (T) StreamSupport.stream(providers.spliterator(), false)
.map(provider -> getDbFromProvider(type, document, raisedExceptions, provider))
.filter(Objects::nonNull)
.findFirst()
.orElseThrow(() -> {
if (!raisedExceptions.isEmpty()) {
return raisedExceptions.get(0);
} else {
return new RuntimeException(
"None of the existing persistence providers could return a Schematic DB with type '" + type + "'");
}
});
}
|
java
|
@SuppressWarnings( { "unchecked", "rawtypes" } )
public static <T extends SchematicDb> T getDb(Document document, ClassLoader cl) throws RuntimeException {
String type = document.getString(TYPE_FIELD);
if (type == null) {
throw new IllegalArgumentException("The configuration document '" + document + "' does not contain a '" + TYPE_FIELD + "' field");
}
ServiceLoader<SchematicDbProvider> providers = ServiceLoader.load(SchematicDbProvider.class, cl);
List<RuntimeException> raisedExceptions = new ArrayList<>();
return (T) StreamSupport.stream(providers.spliterator(), false)
.map(provider -> getDbFromProvider(type, document, raisedExceptions, provider))
.filter(Objects::nonNull)
.findFirst()
.orElseThrow(() -> {
if (!raisedExceptions.isEmpty()) {
return raisedExceptions.get(0);
} else {
return new RuntimeException(
"None of the existing persistence providers could return a Schematic DB with type '" + type + "'");
}
});
}
|
[
"@",
"SuppressWarnings",
"(",
"{",
"\"unchecked\"",
",",
"\"rawtypes\"",
"}",
")",
"public",
"static",
"<",
"T",
"extends",
"SchematicDb",
">",
"T",
"getDb",
"(",
"Document",
"document",
",",
"ClassLoader",
"cl",
")",
"throws",
"RuntimeException",
"{",
"String",
"type",
"=",
"document",
".",
"getString",
"(",
"TYPE_FIELD",
")",
";",
"if",
"(",
"type",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The configuration document '\"",
"+",
"document",
"+",
"\"' does not contain a '\"",
"+",
"TYPE_FIELD",
"+",
"\"' field\"",
")",
";",
"}",
"ServiceLoader",
"<",
"SchematicDbProvider",
">",
"providers",
"=",
"ServiceLoader",
".",
"load",
"(",
"SchematicDbProvider",
".",
"class",
",",
"cl",
")",
";",
"List",
"<",
"RuntimeException",
">",
"raisedExceptions",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"return",
"(",
"T",
")",
"StreamSupport",
".",
"stream",
"(",
"providers",
".",
"spliterator",
"(",
")",
",",
"false",
")",
".",
"map",
"(",
"provider",
"->",
"getDbFromProvider",
"(",
"type",
",",
"document",
",",
"raisedExceptions",
",",
"provider",
")",
")",
".",
"filter",
"(",
"Objects",
"::",
"nonNull",
")",
".",
"findFirst",
"(",
")",
".",
"orElseThrow",
"(",
"(",
")",
"->",
"{",
"if",
"(",
"!",
"raisedExceptions",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"raisedExceptions",
".",
"get",
"(",
"0",
")",
";",
"}",
"else",
"{",
"return",
"new",
"RuntimeException",
"(",
"\"None of the existing persistence providers could return a Schematic DB with type '\"",
"+",
"type",
"+",
"\"'\"",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Returns a DB with the given type and configuration document, by delegating to all the available {@link SchematicDbProvider}
services. This document is expected to contain a {@link Schematic#TYPE_FIELD type field} to indicate the type
@param document a {@link Document} containing the configuration of a particular DB type; may not be null
@param cl a {@link ClassLoader} instance to be used when searching for available DB provider.
@return a {@link SchematicDb} instance with the given alias, never {@code null}
@throws RuntimeException if a DB with the given alias cannot be found or it fails during initialization
|
[
"Returns",
"a",
"DB",
"with",
"the",
"given",
"type",
"and",
"configuration",
"document",
"by",
"delegating",
"to",
"all",
"the",
"available",
"{",
"@link",
"SchematicDbProvider",
"}",
"services",
".",
"This",
"document",
"is",
"expected",
"to",
"contain",
"a",
"{",
"@link",
"Schematic#TYPE_FIELD",
"type",
"field",
"}",
"to",
"indicate",
"the",
"type"
] |
train
|
https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-schematic/src/main/java/org/modeshape/schematic/Schematic.java#L65-L85
|
Netflix/servo
|
servo-core/src/main/java/com/netflix/servo/publish/JmxMetricPoller.java
|
JmxMetricPoller.safelyLoadAttributes
|
private static List<Attribute> safelyLoadAttributes(
MBeanServerConnection server, ObjectName objectName, List<String> matchingNames) {
"""
There are issues loading some JMX attributes on some systems. This protects us from a
single bad attribute stopping us reading any metrics (or just a random sampling) out of
the system.
"""
try {
// first try batch loading all attributes as this is faster
return batchLoadAttributes(server, objectName, matchingNames);
} catch (Exception e) {
// JBOSS ticket: https://issues.jboss.org/browse/AS7-4404
LOGGER.info("Error batch loading attributes for {} : {}", objectName, e.getMessage());
// some containers (jboss I am looking at you) fail the entire getAttributes request
// if one is broken we can get the working attributes if we ask for them individually
return individuallyLoadAttributes(server, objectName, matchingNames);
}
}
|
java
|
private static List<Attribute> safelyLoadAttributes(
MBeanServerConnection server, ObjectName objectName, List<String> matchingNames) {
try {
// first try batch loading all attributes as this is faster
return batchLoadAttributes(server, objectName, matchingNames);
} catch (Exception e) {
// JBOSS ticket: https://issues.jboss.org/browse/AS7-4404
LOGGER.info("Error batch loading attributes for {} : {}", objectName, e.getMessage());
// some containers (jboss I am looking at you) fail the entire getAttributes request
// if one is broken we can get the working attributes if we ask for them individually
return individuallyLoadAttributes(server, objectName, matchingNames);
}
}
|
[
"private",
"static",
"List",
"<",
"Attribute",
">",
"safelyLoadAttributes",
"(",
"MBeanServerConnection",
"server",
",",
"ObjectName",
"objectName",
",",
"List",
"<",
"String",
">",
"matchingNames",
")",
"{",
"try",
"{",
"// first try batch loading all attributes as this is faster",
"return",
"batchLoadAttributes",
"(",
"server",
",",
"objectName",
",",
"matchingNames",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// JBOSS ticket: https://issues.jboss.org/browse/AS7-4404",
"LOGGER",
".",
"info",
"(",
"\"Error batch loading attributes for {} : {}\"",
",",
"objectName",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"// some containers (jboss I am looking at you) fail the entire getAttributes request",
"// if one is broken we can get the working attributes if we ask for them individually",
"return",
"individuallyLoadAttributes",
"(",
"server",
",",
"objectName",
",",
"matchingNames",
")",
";",
"}",
"}"
] |
There are issues loading some JMX attributes on some systems. This protects us from a
single bad attribute stopping us reading any metrics (or just a random sampling) out of
the system.
|
[
"There",
"are",
"issues",
"loading",
"some",
"JMX",
"attributes",
"on",
"some",
"systems",
".",
"This",
"protects",
"us",
"from",
"a",
"single",
"bad",
"attribute",
"stopping",
"us",
"reading",
"any",
"metrics",
"(",
"or",
"just",
"a",
"random",
"sampling",
")",
"out",
"of",
"the",
"system",
"."
] |
train
|
https://github.com/Netflix/servo/blob/d67b5afce8c50bd9e9e31c288dbf4b78fb2ac815/servo-core/src/main/java/com/netflix/servo/publish/JmxMetricPoller.java#L306-L319
|
vlingo/vlingo-actors
|
src/main/java/io/vlingo/actors/World.java
|
World.resolveDynamic
|
public <DEPENDENCY> DEPENDENCY resolveDynamic(final String name, final Class<DEPENDENCY> anyDependencyClass) {
"""
Answers the {@code DEPENDENCY} instance of the {@code name} named dependency.
@param name the {@code String} name of the dynamic dependency
@param anyDependencyClass the {@code Class<DEPENDENCY>}
@param <DEPENDENCY> the dependency type
@return the DEPENDENCY instance
"""
return anyDependencyClass.cast(this.dynamicDependencies.get(name));
}
|
java
|
public <DEPENDENCY> DEPENDENCY resolveDynamic(final String name, final Class<DEPENDENCY> anyDependencyClass) {
return anyDependencyClass.cast(this.dynamicDependencies.get(name));
}
|
[
"public",
"<",
"DEPENDENCY",
">",
"DEPENDENCY",
"resolveDynamic",
"(",
"final",
"String",
"name",
",",
"final",
"Class",
"<",
"DEPENDENCY",
">",
"anyDependencyClass",
")",
"{",
"return",
"anyDependencyClass",
".",
"cast",
"(",
"this",
".",
"dynamicDependencies",
".",
"get",
"(",
"name",
")",
")",
";",
"}"
] |
Answers the {@code DEPENDENCY} instance of the {@code name} named dependency.
@param name the {@code String} name of the dynamic dependency
@param anyDependencyClass the {@code Class<DEPENDENCY>}
@param <DEPENDENCY> the dependency type
@return the DEPENDENCY instance
|
[
"Answers",
"the",
"{"
] |
train
|
https://github.com/vlingo/vlingo-actors/blob/c7d046fd139c0490cf0fd2588d7dc2f792f13493/src/main/java/io/vlingo/actors/World.java#L393-L395
|
Javacord/Javacord
|
javacord-api/src/main/java/org/javacord/api/entity/message/embed/EmbedBuilder.java
|
EmbedBuilder.setImage
|
public EmbedBuilder setImage(BufferedImage image, String fileType) {
"""
Sets the image of the embed.
@param image The image.
@param fileType The type of the file, e.g. "png" or "gif".
@return The current instance in order to chain call methods.
"""
delegate.setImage(image, fileType);
return this;
}
|
java
|
public EmbedBuilder setImage(BufferedImage image, String fileType) {
delegate.setImage(image, fileType);
return this;
}
|
[
"public",
"EmbedBuilder",
"setImage",
"(",
"BufferedImage",
"image",
",",
"String",
"fileType",
")",
"{",
"delegate",
".",
"setImage",
"(",
"image",
",",
"fileType",
")",
";",
"return",
"this",
";",
"}"
] |
Sets the image of the embed.
@param image The image.
@param fileType The type of the file, e.g. "png" or "gif".
@return The current instance in order to chain call methods.
|
[
"Sets",
"the",
"image",
"of",
"the",
"embed",
"."
] |
train
|
https://github.com/Javacord/Javacord/blob/915aad084dc5e863284267529d0dccd625fc6886/javacord-api/src/main/java/org/javacord/api/entity/message/embed/EmbedBuilder.java#L326-L329
|
BBN-E/bue-common-open
|
common-core-open/src/main/java/com/bbn/bue/common/xml/XMLUtils.java
|
XMLUtils.childrenWithTag
|
public static Iterable<Element> childrenWithTag(Element e, String tag) {
"""
Returns an {@link Iterable} over all children of {@code e} with tag {@code tag}
"""
return new ElementChildrenIterable(e, tagNameIsPredicate(tag));
}
|
java
|
public static Iterable<Element> childrenWithTag(Element e, String tag) {
return new ElementChildrenIterable(e, tagNameIsPredicate(tag));
}
|
[
"public",
"static",
"Iterable",
"<",
"Element",
">",
"childrenWithTag",
"(",
"Element",
"e",
",",
"String",
"tag",
")",
"{",
"return",
"new",
"ElementChildrenIterable",
"(",
"e",
",",
"tagNameIsPredicate",
"(",
"tag",
")",
")",
";",
"}"
] |
Returns an {@link Iterable} over all children of {@code e} with tag {@code tag}
|
[
"Returns",
"an",
"{"
] |
train
|
https://github.com/BBN-E/bue-common-open/blob/d618652674d647867306e2e4b987a21b7c29c015/common-core-open/src/main/java/com/bbn/bue/common/xml/XMLUtils.java#L493-L495
|
phax/ph-css
|
ph-css/src/main/java/com/helger/css/writer/CSSWriter.java
|
CSSWriter.getCSSAsString
|
@Nonnull
public String getCSSAsString (@Nonnull final CascadingStyleSheet aCSS) {
"""
Create the CSS without a specific charset.
@param aCSS
The CSS object to be converted to text. May not be <code>null</code>
.
@return The text representation of the CSS.
@see #writeCSS(CascadingStyleSheet, Writer)
"""
final NonBlockingStringWriter aSW = new NonBlockingStringWriter ();
try
{
writeCSS (aCSS, aSW);
}
catch (final IOException ex)
{
// Should never occur since NonBlockingStringWriter does not throw such an
// exception
throw new IllegalStateException ("Totally unexpected", ex);
}
return aSW.getAsString ();
}
|
java
|
@Nonnull
public String getCSSAsString (@Nonnull final CascadingStyleSheet aCSS)
{
final NonBlockingStringWriter aSW = new NonBlockingStringWriter ();
try
{
writeCSS (aCSS, aSW);
}
catch (final IOException ex)
{
// Should never occur since NonBlockingStringWriter does not throw such an
// exception
throw new IllegalStateException ("Totally unexpected", ex);
}
return aSW.getAsString ();
}
|
[
"@",
"Nonnull",
"public",
"String",
"getCSSAsString",
"(",
"@",
"Nonnull",
"final",
"CascadingStyleSheet",
"aCSS",
")",
"{",
"final",
"NonBlockingStringWriter",
"aSW",
"=",
"new",
"NonBlockingStringWriter",
"(",
")",
";",
"try",
"{",
"writeCSS",
"(",
"aCSS",
",",
"aSW",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"ex",
")",
"{",
"// Should never occur since NonBlockingStringWriter does not throw such an",
"// exception",
"throw",
"new",
"IllegalStateException",
"(",
"\"Totally unexpected\"",
",",
"ex",
")",
";",
"}",
"return",
"aSW",
".",
"getAsString",
"(",
")",
";",
"}"
] |
Create the CSS without a specific charset.
@param aCSS
The CSS object to be converted to text. May not be <code>null</code>
.
@return The text representation of the CSS.
@see #writeCSS(CascadingStyleSheet, Writer)
|
[
"Create",
"the",
"CSS",
"without",
"a",
"specific",
"charset",
"."
] |
train
|
https://github.com/phax/ph-css/blob/c9da5bb4decc681de6e27ce31712aad4c00adafa/ph-css/src/main/java/com/helger/css/writer/CSSWriter.java#L363-L378
|
pmlopes/yoke
|
framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java
|
YokeRequest.loadSession
|
public void loadSession(final String sessionId, final Handler<Object> handler) {
"""
Loads a session given its session id and sets the "session" property in the request context.
@param sessionId the id to load
@param handler the success/complete handler
"""
if (sessionId == null) {
handler.handle(null);
return;
}
store.get(sessionId, new Handler<JsonObject>() {
@Override
public void handle(JsonObject session) {
if (session != null) {
put("session", session);
}
response().headersHandler(new Handler<Void>() {
@Override
public void handle(Void event) {
int responseStatus = response().getStatusCode();
// Only save on success and redirect status codes
if (responseStatus >= 200 && responseStatus < 400) {
JsonObject session = get("session");
if (session != null) {
store.set(sessionId, session, new Handler<Object>() {
@Override
public void handle(Object error) {
if (error != null) {
// TODO: better handling of errors
System.err.println(error);
}
}
});
}
}
}
});
handler.handle(null);
}
});
}
|
java
|
public void loadSession(final String sessionId, final Handler<Object> handler) {
if (sessionId == null) {
handler.handle(null);
return;
}
store.get(sessionId, new Handler<JsonObject>() {
@Override
public void handle(JsonObject session) {
if (session != null) {
put("session", session);
}
response().headersHandler(new Handler<Void>() {
@Override
public void handle(Void event) {
int responseStatus = response().getStatusCode();
// Only save on success and redirect status codes
if (responseStatus >= 200 && responseStatus < 400) {
JsonObject session = get("session");
if (session != null) {
store.set(sessionId, session, new Handler<Object>() {
@Override
public void handle(Object error) {
if (error != null) {
// TODO: better handling of errors
System.err.println(error);
}
}
});
}
}
}
});
handler.handle(null);
}
});
}
|
[
"public",
"void",
"loadSession",
"(",
"final",
"String",
"sessionId",
",",
"final",
"Handler",
"<",
"Object",
">",
"handler",
")",
"{",
"if",
"(",
"sessionId",
"==",
"null",
")",
"{",
"handler",
".",
"handle",
"(",
"null",
")",
";",
"return",
";",
"}",
"store",
".",
"get",
"(",
"sessionId",
",",
"new",
"Handler",
"<",
"JsonObject",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"handle",
"(",
"JsonObject",
"session",
")",
"{",
"if",
"(",
"session",
"!=",
"null",
")",
"{",
"put",
"(",
"\"session\"",
",",
"session",
")",
";",
"}",
"response",
"(",
")",
".",
"headersHandler",
"(",
"new",
"Handler",
"<",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"handle",
"(",
"Void",
"event",
")",
"{",
"int",
"responseStatus",
"=",
"response",
"(",
")",
".",
"getStatusCode",
"(",
")",
";",
"// Only save on success and redirect status codes",
"if",
"(",
"responseStatus",
">=",
"200",
"&&",
"responseStatus",
"<",
"400",
")",
"{",
"JsonObject",
"session",
"=",
"get",
"(",
"\"session\"",
")",
";",
"if",
"(",
"session",
"!=",
"null",
")",
"{",
"store",
".",
"set",
"(",
"sessionId",
",",
"session",
",",
"new",
"Handler",
"<",
"Object",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"handle",
"(",
"Object",
"error",
")",
"{",
"if",
"(",
"error",
"!=",
"null",
")",
"{",
"// TODO: better handling of errors",
"System",
".",
"err",
".",
"println",
"(",
"error",
")",
";",
"}",
"}",
"}",
")",
";",
"}",
"}",
"}",
"}",
")",
";",
"handler",
".",
"handle",
"(",
"null",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Loads a session given its session id and sets the "session" property in the request context.
@param sessionId the id to load
@param handler the success/complete handler
|
[
"Loads",
"a",
"session",
"given",
"its",
"session",
"id",
"and",
"sets",
"the",
"session",
"property",
"in",
"the",
"request",
"context",
"."
] |
train
|
https://github.com/pmlopes/yoke/blob/fe8a64036f09fb745f0644faddd46162d64faf3c/framework/src/main/java/com/jetdrone/vertx/yoke/middleware/YokeRequest.java#L346-L384
|
defei/codelogger-utils
|
src/main/java/org/codelogger/utils/StringUtils.java
|
StringUtils.containsIgnoreCase
|
public static boolean containsIgnoreCase(final String source, final String target) {
"""
Returns true if given string contains given target string ignore case,
false otherwise.<br>
@param source string to be tested.
@param target string to be tested.
@return true if given string contains given target string ignore case,
false otherwise.
"""
if (source != null && target != null) {
return indexOfIgnoreCase(source, target) != INDEX_OF_NOT_FOUND;
} else {
return false;
}
}
|
java
|
public static boolean containsIgnoreCase(final String source, final String target) {
if (source != null && target != null) {
return indexOfIgnoreCase(source, target) != INDEX_OF_NOT_FOUND;
} else {
return false;
}
}
|
[
"public",
"static",
"boolean",
"containsIgnoreCase",
"(",
"final",
"String",
"source",
",",
"final",
"String",
"target",
")",
"{",
"if",
"(",
"source",
"!=",
"null",
"&&",
"target",
"!=",
"null",
")",
"{",
"return",
"indexOfIgnoreCase",
"(",
"source",
",",
"target",
")",
"!=",
"INDEX_OF_NOT_FOUND",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Returns true if given string contains given target string ignore case,
false otherwise.<br>
@param source string to be tested.
@param target string to be tested.
@return true if given string contains given target string ignore case,
false otherwise.
|
[
"Returns",
"true",
"if",
"given",
"string",
"contains",
"given",
"target",
"string",
"ignore",
"case",
"false",
"otherwise",
".",
"<br",
">"
] |
train
|
https://github.com/defei/codelogger-utils/blob/d906f5d217b783c7ae3e53442cd6fb87b20ecc0a/src/main/java/org/codelogger/utils/StringUtils.java#L186-L193
|
Ashok-Varma/BottomNavigation
|
bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/BottomNavigationBar.java
|
BottomNavigationBar.setUpTab
|
private void setUpTab(boolean isNoTitleMode, BottomNavigationTab bottomNavigationTab, BottomNavigationItem currentItem, int itemWidth, int itemActiveWidth) {
"""
Internal method to setup tabs
@param isNoTitleMode if no title mode is required
@param bottomNavigationTab Tab item
@param currentItem data structure for tab item
@param itemWidth tab item in-active width
@param itemActiveWidth tab item active width
"""
bottomNavigationTab.setIsNoTitleMode(isNoTitleMode);
bottomNavigationTab.setInactiveWidth(itemWidth);
bottomNavigationTab.setActiveWidth(itemActiveWidth);
bottomNavigationTab.setPosition(mBottomNavigationItems.indexOf(currentItem));
bottomNavigationTab.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
BottomNavigationTab bottomNavigationTabView = (BottomNavigationTab) v;
selectTabInternal(bottomNavigationTabView.getPosition(), false, true, false);
}
});
mBottomNavigationTabs.add(bottomNavigationTab);
BottomNavigationHelper.bindTabWithData(currentItem, bottomNavigationTab, this);
bottomNavigationTab.initialise(mBackgroundStyle == BACKGROUND_STYLE_STATIC);
mTabContainer.addView(bottomNavigationTab);
}
|
java
|
private void setUpTab(boolean isNoTitleMode, BottomNavigationTab bottomNavigationTab, BottomNavigationItem currentItem, int itemWidth, int itemActiveWidth) {
bottomNavigationTab.setIsNoTitleMode(isNoTitleMode);
bottomNavigationTab.setInactiveWidth(itemWidth);
bottomNavigationTab.setActiveWidth(itemActiveWidth);
bottomNavigationTab.setPosition(mBottomNavigationItems.indexOf(currentItem));
bottomNavigationTab.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
BottomNavigationTab bottomNavigationTabView = (BottomNavigationTab) v;
selectTabInternal(bottomNavigationTabView.getPosition(), false, true, false);
}
});
mBottomNavigationTabs.add(bottomNavigationTab);
BottomNavigationHelper.bindTabWithData(currentItem, bottomNavigationTab, this);
bottomNavigationTab.initialise(mBackgroundStyle == BACKGROUND_STYLE_STATIC);
mTabContainer.addView(bottomNavigationTab);
}
|
[
"private",
"void",
"setUpTab",
"(",
"boolean",
"isNoTitleMode",
",",
"BottomNavigationTab",
"bottomNavigationTab",
",",
"BottomNavigationItem",
"currentItem",
",",
"int",
"itemWidth",
",",
"int",
"itemActiveWidth",
")",
"{",
"bottomNavigationTab",
".",
"setIsNoTitleMode",
"(",
"isNoTitleMode",
")",
";",
"bottomNavigationTab",
".",
"setInactiveWidth",
"(",
"itemWidth",
")",
";",
"bottomNavigationTab",
".",
"setActiveWidth",
"(",
"itemActiveWidth",
")",
";",
"bottomNavigationTab",
".",
"setPosition",
"(",
"mBottomNavigationItems",
".",
"indexOf",
"(",
"currentItem",
")",
")",
";",
"bottomNavigationTab",
".",
"setOnClickListener",
"(",
"new",
"OnClickListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onClick",
"(",
"View",
"v",
")",
"{",
"BottomNavigationTab",
"bottomNavigationTabView",
"=",
"(",
"BottomNavigationTab",
")",
"v",
";",
"selectTabInternal",
"(",
"bottomNavigationTabView",
".",
"getPosition",
"(",
")",
",",
"false",
",",
"true",
",",
"false",
")",
";",
"}",
"}",
")",
";",
"mBottomNavigationTabs",
".",
"add",
"(",
"bottomNavigationTab",
")",
";",
"BottomNavigationHelper",
".",
"bindTabWithData",
"(",
"currentItem",
",",
"bottomNavigationTab",
",",
"this",
")",
";",
"bottomNavigationTab",
".",
"initialise",
"(",
"mBackgroundStyle",
"==",
"BACKGROUND_STYLE_STATIC",
")",
";",
"mTabContainer",
".",
"addView",
"(",
"bottomNavigationTab",
")",
";",
"}"
] |
Internal method to setup tabs
@param isNoTitleMode if no title mode is required
@param bottomNavigationTab Tab item
@param currentItem data structure for tab item
@param itemWidth tab item in-active width
@param itemActiveWidth tab item active width
|
[
"Internal",
"method",
"to",
"setup",
"tabs"
] |
train
|
https://github.com/Ashok-Varma/BottomNavigation/blob/a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b/bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/BottomNavigationBar.java#L492-L513
|
ixa-ehu/ixa-pipe-ml
|
src/main/java/eus/ixa/ixa/pipe/ml/tok/RuleBasedTokenizer.java
|
RuleBasedTokenizer.getTokens
|
private String[] getTokens(String line) {
"""
Actual tokenization function.
@param line
the sentence to be tokenized
@return an array containing the tokens for the sentence
"""
// these are fine because they do not affect offsets
line = line.trim();
line = doubleSpaces.matcher(line).replaceAll(" ");
// remove non printable stuff
line = asciiHex.matcher(line).replaceAll(" ");
line = generalBlankPunctuation.matcher(line).replaceAll(" ");
// separate question and exclamation marks
line = qexc.matcher(line).replaceAll(" $1 ");
// separate dash if before or after space
line = spaceDashSpace.matcher(line).replaceAll(" $1 ");
// tokenize everything but these characters [^\p{Alnum}s.'`,-?!/]
line = specials.matcher(line).replaceAll(" $1 ");
// do not separate multidots
line = generateMultidots(line);
// separate "," except if within numbers (1,200)
line = noDigitComma.matcher(line).replaceAll("$1 $2");
line = commaNoDigit.matcher(line).replaceAll("$1 $2");
// separate pre and post digit
line = digitCommaNoDigit.matcher(line).replaceAll("$1 $2 $3");
line = noDigitCommaDigit.matcher(line).replaceAll("$1 $2 $3");
// contractions it's, l'agila, c'est, don't
line = treatContractions(line);
// exceptions for period tokenization
line = this.nonBreaker.TokenizerNonBreaker(line);
// restore multidots
line = restoreMultidots(line);
// urls
// TODO normalize URLs after tokenization for offsets
line = detokenizeURLs(line);
line = beginLink.matcher(line).replaceAll("$1://");
line = endLink.matcher(line).replaceAll("$1$2");
// these are fine because they do not affect offsets
line = line.trim();
line = doubleSpaces.matcher(line).replaceAll(" ");
line = detokenParagraphs.matcher(line).replaceAll("$1$2");
if (DEBUG) {
System.out.println("->Tokens:" + line);
}
final String[] tokens = line.split(" ");
return tokens;
}
|
java
|
private String[] getTokens(String line) {
// these are fine because they do not affect offsets
line = line.trim();
line = doubleSpaces.matcher(line).replaceAll(" ");
// remove non printable stuff
line = asciiHex.matcher(line).replaceAll(" ");
line = generalBlankPunctuation.matcher(line).replaceAll(" ");
// separate question and exclamation marks
line = qexc.matcher(line).replaceAll(" $1 ");
// separate dash if before or after space
line = spaceDashSpace.matcher(line).replaceAll(" $1 ");
// tokenize everything but these characters [^\p{Alnum}s.'`,-?!/]
line = specials.matcher(line).replaceAll(" $1 ");
// do not separate multidots
line = generateMultidots(line);
// separate "," except if within numbers (1,200)
line = noDigitComma.matcher(line).replaceAll("$1 $2");
line = commaNoDigit.matcher(line).replaceAll("$1 $2");
// separate pre and post digit
line = digitCommaNoDigit.matcher(line).replaceAll("$1 $2 $3");
line = noDigitCommaDigit.matcher(line).replaceAll("$1 $2 $3");
// contractions it's, l'agila, c'est, don't
line = treatContractions(line);
// exceptions for period tokenization
line = this.nonBreaker.TokenizerNonBreaker(line);
// restore multidots
line = restoreMultidots(line);
// urls
// TODO normalize URLs after tokenization for offsets
line = detokenizeURLs(line);
line = beginLink.matcher(line).replaceAll("$1://");
line = endLink.matcher(line).replaceAll("$1$2");
// these are fine because they do not affect offsets
line = line.trim();
line = doubleSpaces.matcher(line).replaceAll(" ");
line = detokenParagraphs.matcher(line).replaceAll("$1$2");
if (DEBUG) {
System.out.println("->Tokens:" + line);
}
final String[] tokens = line.split(" ");
return tokens;
}
|
[
"private",
"String",
"[",
"]",
"getTokens",
"(",
"String",
"line",
")",
"{",
"// these are fine because they do not affect offsets",
"line",
"=",
"line",
".",
"trim",
"(",
")",
";",
"line",
"=",
"doubleSpaces",
".",
"matcher",
"(",
"line",
")",
".",
"replaceAll",
"(",
"\" \"",
")",
";",
"// remove non printable stuff",
"line",
"=",
"asciiHex",
".",
"matcher",
"(",
"line",
")",
".",
"replaceAll",
"(",
"\" \"",
")",
";",
"line",
"=",
"generalBlankPunctuation",
".",
"matcher",
"(",
"line",
")",
".",
"replaceAll",
"(",
"\" \"",
")",
";",
"// separate question and exclamation marks",
"line",
"=",
"qexc",
".",
"matcher",
"(",
"line",
")",
".",
"replaceAll",
"(",
"\" $1 \"",
")",
";",
"// separate dash if before or after space",
"line",
"=",
"spaceDashSpace",
".",
"matcher",
"(",
"line",
")",
".",
"replaceAll",
"(",
"\" $1 \"",
")",
";",
"// tokenize everything but these characters [^\\p{Alnum}s.'`,-?!/]",
"line",
"=",
"specials",
".",
"matcher",
"(",
"line",
")",
".",
"replaceAll",
"(",
"\" $1 \"",
")",
";",
"// do not separate multidots",
"line",
"=",
"generateMultidots",
"(",
"line",
")",
";",
"// separate \",\" except if within numbers (1,200)",
"line",
"=",
"noDigitComma",
".",
"matcher",
"(",
"line",
")",
".",
"replaceAll",
"(",
"\"$1 $2\"",
")",
";",
"line",
"=",
"commaNoDigit",
".",
"matcher",
"(",
"line",
")",
".",
"replaceAll",
"(",
"\"$1 $2\"",
")",
";",
"// separate pre and post digit",
"line",
"=",
"digitCommaNoDigit",
".",
"matcher",
"(",
"line",
")",
".",
"replaceAll",
"(",
"\"$1 $2 $3\"",
")",
";",
"line",
"=",
"noDigitCommaDigit",
".",
"matcher",
"(",
"line",
")",
".",
"replaceAll",
"(",
"\"$1 $2 $3\"",
")",
";",
"// contractions it's, l'agila, c'est, don't",
"line",
"=",
"treatContractions",
"(",
"line",
")",
";",
"// exceptions for period tokenization",
"line",
"=",
"this",
".",
"nonBreaker",
".",
"TokenizerNonBreaker",
"(",
"line",
")",
";",
"// restore multidots",
"line",
"=",
"restoreMultidots",
"(",
"line",
")",
";",
"// urls",
"// TODO normalize URLs after tokenization for offsets",
"line",
"=",
"detokenizeURLs",
"(",
"line",
")",
";",
"line",
"=",
"beginLink",
".",
"matcher",
"(",
"line",
")",
".",
"replaceAll",
"(",
"\"$1://\"",
")",
";",
"line",
"=",
"endLink",
".",
"matcher",
"(",
"line",
")",
".",
"replaceAll",
"(",
"\"$1$2\"",
")",
";",
"// these are fine because they do not affect offsets",
"line",
"=",
"line",
".",
"trim",
"(",
")",
";",
"line",
"=",
"doubleSpaces",
".",
"matcher",
"(",
"line",
")",
".",
"replaceAll",
"(",
"\" \"",
")",
";",
"line",
"=",
"detokenParagraphs",
".",
"matcher",
"(",
"line",
")",
".",
"replaceAll",
"(",
"\"$1$2\"",
")",
";",
"if",
"(",
"DEBUG",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"->Tokens:\"",
"+",
"line",
")",
";",
"}",
"final",
"String",
"[",
"]",
"tokens",
"=",
"line",
".",
"split",
"(",
"\" \"",
")",
";",
"return",
"tokens",
";",
"}"
] |
Actual tokenization function.
@param line
the sentence to be tokenized
@return an array containing the tokens for the sentence
|
[
"Actual",
"tokenization",
"function",
"."
] |
train
|
https://github.com/ixa-ehu/ixa-pipe-ml/blob/c817fa1e40e96ed15fc79d22c3a7c25f1a40d172/src/main/java/eus/ixa/ixa/pipe/ml/tok/RuleBasedTokenizer.java#L264-L313
|
cdk/cdk
|
display/renderbasic/src/main/java/org/openscience/cdk/renderer/elements/MarkedElement.java
|
MarkedElement.markupMol
|
public static MarkedElement markupMol(IRenderingElement elem, IAtomContainer mol) {
"""
Markup a molecule with the class 'mol' and optionally the ids/classes
from it's properties.
@param elem rendering element
@param mol molecule
@return the marked element
"""
assert elem != null;
MarkedElement tagElem = markupChemObj(elem, mol);
tagElem.aggClass("mol");
return tagElem;
}
|
java
|
public static MarkedElement markupMol(IRenderingElement elem, IAtomContainer mol) {
assert elem != null;
MarkedElement tagElem = markupChemObj(elem, mol);
tagElem.aggClass("mol");
return tagElem;
}
|
[
"public",
"static",
"MarkedElement",
"markupMol",
"(",
"IRenderingElement",
"elem",
",",
"IAtomContainer",
"mol",
")",
"{",
"assert",
"elem",
"!=",
"null",
";",
"MarkedElement",
"tagElem",
"=",
"markupChemObj",
"(",
"elem",
",",
"mol",
")",
";",
"tagElem",
".",
"aggClass",
"(",
"\"mol\"",
")",
";",
"return",
"tagElem",
";",
"}"
] |
Markup a molecule with the class 'mol' and optionally the ids/classes
from it's properties.
@param elem rendering element
@param mol molecule
@return the marked element
|
[
"Markup",
"a",
"molecule",
"with",
"the",
"class",
"mol",
"and",
"optionally",
"the",
"ids",
"/",
"classes",
"from",
"it",
"s",
"properties",
"."
] |
train
|
https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/display/renderbasic/src/main/java/org/openscience/cdk/renderer/elements/MarkedElement.java#L151-L156
|
osmdroid/osmdroid
|
osmdroid-android/src/main/java/org/osmdroid/views/overlay/LinearRing.java
|
LinearRing.isCloseTo
|
boolean isCloseTo(final GeoPoint pPoint, final double tolerance,
final Projection pProjection, final boolean pClosePath) {
"""
Detection is done in screen coordinates.
@param tolerance in pixels
@return true if the Polyline is close enough to the point.
"""
return getCloseTo(pPoint, tolerance, pProjection, pClosePath) != null;
}
|
java
|
boolean isCloseTo(final GeoPoint pPoint, final double tolerance,
final Projection pProjection, final boolean pClosePath) {
return getCloseTo(pPoint, tolerance, pProjection, pClosePath) != null;
}
|
[
"boolean",
"isCloseTo",
"(",
"final",
"GeoPoint",
"pPoint",
",",
"final",
"double",
"tolerance",
",",
"final",
"Projection",
"pProjection",
",",
"final",
"boolean",
"pClosePath",
")",
"{",
"return",
"getCloseTo",
"(",
"pPoint",
",",
"tolerance",
",",
"pProjection",
",",
"pClosePath",
")",
"!=",
"null",
";",
"}"
] |
Detection is done in screen coordinates.
@param tolerance in pixels
@return true if the Polyline is close enough to the point.
|
[
"Detection",
"is",
"done",
"in",
"screen",
"coordinates",
"."
] |
train
|
https://github.com/osmdroid/osmdroid/blob/3b178b2f078497dd88c137110e87aafe45ad2b16/osmdroid-android/src/main/java/org/osmdroid/views/overlay/LinearRing.java#L363-L366
|
samskivert/samskivert
|
src/main/java/com/samskivert/util/CollectionUtil.java
|
CollectionUtil.maxList
|
public static <T extends Comparable<? super T>> List<T> maxList (Iterable<T> iterable) {
"""
Return a List containing all the elements of the specified Iterable that compare as being
equal to the maximum element.
@throws NoSuchElementException if the Iterable is empty.
"""
return maxList(iterable, new Comparator<T>() {
public int compare (T o1, T o2) {
return o1.compareTo(o2);
}
});
}
|
java
|
public static <T extends Comparable<? super T>> List<T> maxList (Iterable<T> iterable)
{
return maxList(iterable, new Comparator<T>() {
public int compare (T o1, T o2) {
return o1.compareTo(o2);
}
});
}
|
[
"public",
"static",
"<",
"T",
"extends",
"Comparable",
"<",
"?",
"super",
"T",
">",
">",
"List",
"<",
"T",
">",
"maxList",
"(",
"Iterable",
"<",
"T",
">",
"iterable",
")",
"{",
"return",
"maxList",
"(",
"iterable",
",",
"new",
"Comparator",
"<",
"T",
">",
"(",
")",
"{",
"public",
"int",
"compare",
"(",
"T",
"o1",
",",
"T",
"o2",
")",
"{",
"return",
"o1",
".",
"compareTo",
"(",
"o2",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Return a List containing all the elements of the specified Iterable that compare as being
equal to the maximum element.
@throws NoSuchElementException if the Iterable is empty.
|
[
"Return",
"a",
"List",
"containing",
"all",
"the",
"elements",
"of",
"the",
"specified",
"Iterable",
"that",
"compare",
"as",
"being",
"equal",
"to",
"the",
"maximum",
"element",
"."
] |
train
|
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/CollectionUtil.java#L123-L130
|
alkacon/opencms-core
|
src/org/opencms/jlan/CmsJlanRepository.java
|
CmsJlanRepository.createLoggingProxy
|
public static DiskInterface createLoggingProxy(final DiskInterface impl) {
"""
Creates a dynamic proxy for a disk interface which logs the method calls and their results.<p>
@param impl the disk interface for which a logging proxy should be created
@return the dynamic proxy which logs methods calls
"""
return (DiskInterface)Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class[] {DiskInterface.class},
new InvocationHandler() {
@SuppressWarnings("synthetic-access")
public Object invoke(Object target, Method method, Object[] params) throws Throwable {
// Just to be on the safe side performance-wise, we only log the parameters/result
// if the info channel is enabled
if (LOG.isInfoEnabled()) {
List<String> paramStrings = new ArrayList<String>();
for (Object param : params) {
paramStrings.add("" + param);
}
String paramsAsString = CmsStringUtil.listAsString(paramStrings, ", ");
LOG.info("Call: " + method.getName() + " " + paramsAsString);
}
try {
Object result = method.invoke(impl, params);
if (LOG.isInfoEnabled()) {
LOG.info("Returned from " + method.getName() + ": " + result);
}
return result;
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
if ((cause != null) && (cause instanceof CmsSilentWrapperException)) {
// not really an error
LOG.info(cause.getCause().getLocalizedMessage(), cause.getCause());
} else {
LOG.error(e.getLocalizedMessage(), e);
}
throw e.getCause();
}
}
});
}
|
java
|
public static DiskInterface createLoggingProxy(final DiskInterface impl) {
return (DiskInterface)Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class[] {DiskInterface.class},
new InvocationHandler() {
@SuppressWarnings("synthetic-access")
public Object invoke(Object target, Method method, Object[] params) throws Throwable {
// Just to be on the safe side performance-wise, we only log the parameters/result
// if the info channel is enabled
if (LOG.isInfoEnabled()) {
List<String> paramStrings = new ArrayList<String>();
for (Object param : params) {
paramStrings.add("" + param);
}
String paramsAsString = CmsStringUtil.listAsString(paramStrings, ", ");
LOG.info("Call: " + method.getName() + " " + paramsAsString);
}
try {
Object result = method.invoke(impl, params);
if (LOG.isInfoEnabled()) {
LOG.info("Returned from " + method.getName() + ": " + result);
}
return result;
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
if ((cause != null) && (cause instanceof CmsSilentWrapperException)) {
// not really an error
LOG.info(cause.getCause().getLocalizedMessage(), cause.getCause());
} else {
LOG.error(e.getLocalizedMessage(), e);
}
throw e.getCause();
}
}
});
}
|
[
"public",
"static",
"DiskInterface",
"createLoggingProxy",
"(",
"final",
"DiskInterface",
"impl",
")",
"{",
"return",
"(",
"DiskInterface",
")",
"Proxy",
".",
"newProxyInstance",
"(",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
",",
"new",
"Class",
"[",
"]",
"{",
"DiskInterface",
".",
"class",
"}",
",",
"new",
"InvocationHandler",
"(",
")",
"{",
"@",
"SuppressWarnings",
"(",
"\"synthetic-access\"",
")",
"public",
"Object",
"invoke",
"(",
"Object",
"target",
",",
"Method",
"method",
",",
"Object",
"[",
"]",
"params",
")",
"throws",
"Throwable",
"{",
"// Just to be on the safe side performance-wise, we only log the parameters/result",
"// if the info channel is enabled",
"if",
"(",
"LOG",
".",
"isInfoEnabled",
"(",
")",
")",
"{",
"List",
"<",
"String",
">",
"paramStrings",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"Object",
"param",
":",
"params",
")",
"{",
"paramStrings",
".",
"add",
"(",
"\"\"",
"+",
"param",
")",
";",
"}",
"String",
"paramsAsString",
"=",
"CmsStringUtil",
".",
"listAsString",
"(",
"paramStrings",
",",
"\", \"",
")",
";",
"LOG",
".",
"info",
"(",
"\"Call: \"",
"+",
"method",
".",
"getName",
"(",
")",
"+",
"\" \"",
"+",
"paramsAsString",
")",
";",
"}",
"try",
"{",
"Object",
"result",
"=",
"method",
".",
"invoke",
"(",
"impl",
",",
"params",
")",
";",
"if",
"(",
"LOG",
".",
"isInfoEnabled",
"(",
")",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Returned from \"",
"+",
"method",
".",
"getName",
"(",
")",
"+",
"\": \"",
"+",
"result",
")",
";",
"}",
"return",
"result",
";",
"}",
"catch",
"(",
"InvocationTargetException",
"e",
")",
"{",
"Throwable",
"cause",
"=",
"e",
".",
"getCause",
"(",
")",
";",
"if",
"(",
"(",
"cause",
"!=",
"null",
")",
"&&",
"(",
"cause",
"instanceof",
"CmsSilentWrapperException",
")",
")",
"{",
"// not really an error",
"LOG",
".",
"info",
"(",
"cause",
".",
"getCause",
"(",
")",
".",
"getLocalizedMessage",
"(",
")",
",",
"cause",
".",
"getCause",
"(",
")",
")",
";",
"}",
"else",
"{",
"LOG",
".",
"error",
"(",
"e",
".",
"getLocalizedMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"throw",
"e",
".",
"getCause",
"(",
")",
";",
"}",
"}",
"}",
")",
";",
"}"
] |
Creates a dynamic proxy for a disk interface which logs the method calls and their results.<p>
@param impl the disk interface for which a logging proxy should be created
@return the dynamic proxy which logs methods calls
|
[
"Creates",
"a",
"dynamic",
"proxy",
"for",
"a",
"disk",
"interface",
"which",
"logs",
"the",
"method",
"calls",
"and",
"their",
"results",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jlan/CmsJlanRepository.java#L141-L179
|
ltsopensource/light-task-scheduler
|
lts-core/src/main/java/com/github/ltsopensource/core/commons/utils/GenericsUtils.java
|
GenericsUtils.getMethodGenericReturnType
|
public static Class getMethodGenericReturnType(Method method, int index) {
"""
通过反射,获得方法返回值泛型参数的实际类型. 如: public Map<String, Buyer> getNames(){}
@param method 方法
@param index 泛型参数所在索引,从0开始.
@return 泛型参数的实际类型, 如果没有实现ParameterizedType接口,即不支持泛型,所以直接返回<code>Object.class</code>
"""
Type returnType = method.getGenericReturnType();
if(returnType instanceof ParameterizedType){
ParameterizedType type = (ParameterizedType) returnType;
Type[] typeArguments = type.getActualTypeArguments();
if (index >= typeArguments.length || index < 0) {
throw new IllegalArgumentException("index "+ (index<0 ? " must > 0 " : " over total arguments"));
}
return (Class)typeArguments[index];
}
return Object.class;
}
|
java
|
public static Class getMethodGenericReturnType(Method method, int index) {
Type returnType = method.getGenericReturnType();
if(returnType instanceof ParameterizedType){
ParameterizedType type = (ParameterizedType) returnType;
Type[] typeArguments = type.getActualTypeArguments();
if (index >= typeArguments.length || index < 0) {
throw new IllegalArgumentException("index "+ (index<0 ? " must > 0 " : " over total arguments"));
}
return (Class)typeArguments[index];
}
return Object.class;
}
|
[
"public",
"static",
"Class",
"getMethodGenericReturnType",
"(",
"Method",
"method",
",",
"int",
"index",
")",
"{",
"Type",
"returnType",
"=",
"method",
".",
"getGenericReturnType",
"(",
")",
";",
"if",
"(",
"returnType",
"instanceof",
"ParameterizedType",
")",
"{",
"ParameterizedType",
"type",
"=",
"(",
"ParameterizedType",
")",
"returnType",
";",
"Type",
"[",
"]",
"typeArguments",
"=",
"type",
".",
"getActualTypeArguments",
"(",
")",
";",
"if",
"(",
"index",
">=",
"typeArguments",
".",
"length",
"||",
"index",
"<",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"index \"",
"+",
"(",
"index",
"<",
"0",
"?",
"\" must > 0 \"",
":",
"\" over total arguments\"",
")",
")",
";",
"}",
"return",
"(",
"Class",
")",
"typeArguments",
"[",
"index",
"]",
";",
"}",
"return",
"Object",
".",
"class",
";",
"}"
] |
通过反射,获得方法返回值泛型参数的实际类型. 如: public Map<String, Buyer> getNames(){}
@param method 方法
@param index 泛型参数所在索引,从0开始.
@return 泛型参数的实际类型, 如果没有实现ParameterizedType接口,即不支持泛型,所以直接返回<code>Object.class</code>
|
[
"通过反射",
"获得方法返回值泛型参数的实际类型",
".",
"如",
":",
"public",
"Map<String",
"Buyer",
">",
"getNames",
"()",
"{}"
] |
train
|
https://github.com/ltsopensource/light-task-scheduler/blob/64d3aa000ff5022be5e94f511b58f405e5f4c8eb/lts-core/src/main/java/com/github/ltsopensource/core/commons/utils/GenericsUtils.java#L55-L66
|
exoplatform/jcr
|
exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/Utils.java
|
Utils.readString
|
String readString(Node node, String propertyName) throws OrganizationServiceException {
"""
Returns property value represented in {@link String}.
@param node
the parent node
@param propertyName
the property name to read from
@return the string value if property exists or null otherwise
@throws OrganizationServiceException
if unexpected exception is occurred during reading
"""
try
{
return node.getProperty(propertyName).getString();
}
catch (PathNotFoundException e)
{
return null;
}
catch (ValueFormatException e)
{
throw new OrganizationServiceException("Property " + propertyName + " contains wrong value format", e);
}
catch (RepositoryException e)
{
throw new OrganizationServiceException("Can not read property " + propertyName, e);
}
}
|
java
|
String readString(Node node, String propertyName) throws OrganizationServiceException
{
try
{
return node.getProperty(propertyName).getString();
}
catch (PathNotFoundException e)
{
return null;
}
catch (ValueFormatException e)
{
throw new OrganizationServiceException("Property " + propertyName + " contains wrong value format", e);
}
catch (RepositoryException e)
{
throw new OrganizationServiceException("Can not read property " + propertyName, e);
}
}
|
[
"String",
"readString",
"(",
"Node",
"node",
",",
"String",
"propertyName",
")",
"throws",
"OrganizationServiceException",
"{",
"try",
"{",
"return",
"node",
".",
"getProperty",
"(",
"propertyName",
")",
".",
"getString",
"(",
")",
";",
"}",
"catch",
"(",
"PathNotFoundException",
"e",
")",
"{",
"return",
"null",
";",
"}",
"catch",
"(",
"ValueFormatException",
"e",
")",
"{",
"throw",
"new",
"OrganizationServiceException",
"(",
"\"Property \"",
"+",
"propertyName",
"+",
"\" contains wrong value format\"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"RepositoryException",
"e",
")",
"{",
"throw",
"new",
"OrganizationServiceException",
"(",
"\"Can not read property \"",
"+",
"propertyName",
",",
"e",
")",
";",
"}",
"}"
] |
Returns property value represented in {@link String}.
@param node
the parent node
@param propertyName
the property name to read from
@return the string value if property exists or null otherwise
@throws OrganizationServiceException
if unexpected exception is occurred during reading
|
[
"Returns",
"property",
"value",
"represented",
"in",
"{",
"@link",
"String",
"}",
"."
] |
train
|
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/Utils.java#L95-L113
|
biojava/biojava
|
biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AtomCache.java
|
AtomCache.getStructureForCathDomain
|
public Structure getStructureForCathDomain(StructureName structureName) throws IOException, StructureException {
"""
Returns a {@link Structure} corresponding to the CATH identifier supplied in {@code structureName}, using the the {@link CathDatabase}
at {@link CathFactory#getCathDatabase()}.
"""
return getStructureForCathDomain(structureName, CathFactory.getCathDatabase());
}
|
java
|
public Structure getStructureForCathDomain(StructureName structureName) throws IOException, StructureException {
return getStructureForCathDomain(structureName, CathFactory.getCathDatabase());
}
|
[
"public",
"Structure",
"getStructureForCathDomain",
"(",
"StructureName",
"structureName",
")",
"throws",
"IOException",
",",
"StructureException",
"{",
"return",
"getStructureForCathDomain",
"(",
"structureName",
",",
"CathFactory",
".",
"getCathDatabase",
"(",
")",
")",
";",
"}"
] |
Returns a {@link Structure} corresponding to the CATH identifier supplied in {@code structureName}, using the the {@link CathDatabase}
at {@link CathFactory#getCathDatabase()}.
|
[
"Returns",
"a",
"{"
] |
train
|
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AtomCache.java#L817-L819
|
TakahikoKawasaki/nv-websocket-client
|
src/main/java/com/neovisionaries/ws/client/WebSocketFrame.java
|
WebSocketFrame.setCloseFramePayload
|
public WebSocketFrame setCloseFramePayload(int closeCode, String reason) {
"""
Set the payload that conforms to the payload format of close frames.
<p>
The given parameters are encoded based on the rules described in
"<a href="http://tools.ietf.org/html/rfc6455#section-5.5.1"
>5.5.1. Close</a>" of RFC 6455.
</p>
<p>
Note that the reason should not be too long because the payload
length of a <a href="http://tools.ietf.org/html/rfc6455#section-5.5"
>control frame</a> must be 125 bytes or less.
</p>
@param closeCode
The close code.
@param reason
The reason. {@code null} is accepted. An empty string
is treated in the same way as {@code null}.
@return
{@code this} object.
@see <a href="http://tools.ietf.org/html/rfc6455#section-5.5.1"
>RFC 6455, 5.5.1. Close</a>
@see WebSocketCloseCode
"""
// Convert the close code to a 2-byte unsigned integer
// in network byte order.
byte[] encodedCloseCode = new byte[] {
(byte)((closeCode >> 8) & 0xFF),
(byte)((closeCode ) & 0xFF)
};
// If a reason string is not given.
if (reason == null || reason.length() == 0)
{
// Use the close code only.
return setPayload(encodedCloseCode);
}
// Convert the reason into a byte array.
byte[] encodedReason = Misc.getBytesUTF8(reason);
// Concatenate the close code and the reason.
byte[] payload = new byte[2 + encodedReason.length];
System.arraycopy(encodedCloseCode, 0, payload, 0, 2);
System.arraycopy(encodedReason, 0, payload, 2, encodedReason.length);
// Use the concatenated string.
return setPayload(payload);
}
|
java
|
public WebSocketFrame setCloseFramePayload(int closeCode, String reason)
{
// Convert the close code to a 2-byte unsigned integer
// in network byte order.
byte[] encodedCloseCode = new byte[] {
(byte)((closeCode >> 8) & 0xFF),
(byte)((closeCode ) & 0xFF)
};
// If a reason string is not given.
if (reason == null || reason.length() == 0)
{
// Use the close code only.
return setPayload(encodedCloseCode);
}
// Convert the reason into a byte array.
byte[] encodedReason = Misc.getBytesUTF8(reason);
// Concatenate the close code and the reason.
byte[] payload = new byte[2 + encodedReason.length];
System.arraycopy(encodedCloseCode, 0, payload, 0, 2);
System.arraycopy(encodedReason, 0, payload, 2, encodedReason.length);
// Use the concatenated string.
return setPayload(payload);
}
|
[
"public",
"WebSocketFrame",
"setCloseFramePayload",
"(",
"int",
"closeCode",
",",
"String",
"reason",
")",
"{",
"// Convert the close code to a 2-byte unsigned integer",
"// in network byte order.",
"byte",
"[",
"]",
"encodedCloseCode",
"=",
"new",
"byte",
"[",
"]",
"{",
"(",
"byte",
")",
"(",
"(",
"closeCode",
">>",
"8",
")",
"&",
"0xFF",
")",
",",
"(",
"byte",
")",
"(",
"(",
"closeCode",
")",
"&",
"0xFF",
")",
"}",
";",
"// If a reason string is not given.",
"if",
"(",
"reason",
"==",
"null",
"||",
"reason",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"// Use the close code only.",
"return",
"setPayload",
"(",
"encodedCloseCode",
")",
";",
"}",
"// Convert the reason into a byte array.",
"byte",
"[",
"]",
"encodedReason",
"=",
"Misc",
".",
"getBytesUTF8",
"(",
"reason",
")",
";",
"// Concatenate the close code and the reason.",
"byte",
"[",
"]",
"payload",
"=",
"new",
"byte",
"[",
"2",
"+",
"encodedReason",
".",
"length",
"]",
";",
"System",
".",
"arraycopy",
"(",
"encodedCloseCode",
",",
"0",
",",
"payload",
",",
"0",
",",
"2",
")",
";",
"System",
".",
"arraycopy",
"(",
"encodedReason",
",",
"0",
",",
"payload",
",",
"2",
",",
"encodedReason",
".",
"length",
")",
";",
"// Use the concatenated string.",
"return",
"setPayload",
"(",
"payload",
")",
";",
"}"
] |
Set the payload that conforms to the payload format of close frames.
<p>
The given parameters are encoded based on the rules described in
"<a href="http://tools.ietf.org/html/rfc6455#section-5.5.1"
>5.5.1. Close</a>" of RFC 6455.
</p>
<p>
Note that the reason should not be too long because the payload
length of a <a href="http://tools.ietf.org/html/rfc6455#section-5.5"
>control frame</a> must be 125 bytes or less.
</p>
@param closeCode
The close code.
@param reason
The reason. {@code null} is accepted. An empty string
is treated in the same way as {@code null}.
@return
{@code this} object.
@see <a href="http://tools.ietf.org/html/rfc6455#section-5.5.1"
>RFC 6455, 5.5.1. Close</a>
@see WebSocketCloseCode
|
[
"Set",
"the",
"payload",
"that",
"conforms",
"to",
"the",
"payload",
"format",
"of",
"close",
"frames",
"."
] |
train
|
https://github.com/TakahikoKawasaki/nv-websocket-client/blob/efaec21181d740ad3808313acf679313179e0825/src/main/java/com/neovisionaries/ws/client/WebSocketFrame.java#L559-L585
|
twitter/cloudhopper-commons
|
ch-commons-util/src/main/java/com/cloudhopper/commons/util/StringUtil.java
|
StringUtil.formatForPrint
|
public final static String formatForPrint(String input) {
"""
Used to print out a string for error messages,
chops is off at 60 chars for historical reasons.
"""
if (input.length() > 60) {
StringBuffer tmp = new StringBuffer(input.substring(0, 60));
tmp.append("&");
input = tmp.toString();
}
return input;
}
|
java
|
public final static String formatForPrint(String input) {
if (input.length() > 60) {
StringBuffer tmp = new StringBuffer(input.substring(0, 60));
tmp.append("&");
input = tmp.toString();
}
return input;
}
|
[
"public",
"final",
"static",
"String",
"formatForPrint",
"(",
"String",
"input",
")",
"{",
"if",
"(",
"input",
".",
"length",
"(",
")",
">",
"60",
")",
"{",
"StringBuffer",
"tmp",
"=",
"new",
"StringBuffer",
"(",
"input",
".",
"substring",
"(",
"0",
",",
"60",
")",
")",
";",
"tmp",
".",
"append",
"(",
"\"&\"",
")",
";",
"input",
"=",
"tmp",
".",
"toString",
"(",
")",
";",
"}",
"return",
"input",
";",
"}"
] |
Used to print out a string for error messages,
chops is off at 60 chars for historical reasons.
|
[
"Used",
"to",
"print",
"out",
"a",
"string",
"for",
"error",
"messages",
"chops",
"is",
"off",
"at",
"60",
"chars",
"for",
"historical",
"reasons",
"."
] |
train
|
https://github.com/twitter/cloudhopper-commons/blob/b5bc397dbec4537e8149e7ec0733c1d7ed477499/ch-commons-util/src/main/java/com/cloudhopper/commons/util/StringUtil.java#L373-L380
|
Putnami/putnami-web-toolkit
|
core/src/main/java/com/google/gwt/event/shared/HandlerManager.java
|
HandlerManager.getHandler
|
public <H extends EventHandler> H getHandler(GwtEvent.Type<H> type, int index) {
"""
Gets the handler at the given index.
@param <H> the event handler type
@param index the index
@param type the handler's event type
@return the given handler
"""
return this.eventBus.superGetHandler(type, index);
}
|
java
|
public <H extends EventHandler> H getHandler(GwtEvent.Type<H> type, int index) {
return this.eventBus.superGetHandler(type, index);
}
|
[
"public",
"<",
"H",
"extends",
"EventHandler",
">",
"H",
"getHandler",
"(",
"GwtEvent",
".",
"Type",
"<",
"H",
">",
"type",
",",
"int",
"index",
")",
"{",
"return",
"this",
".",
"eventBus",
".",
"superGetHandler",
"(",
"type",
",",
"index",
")",
";",
"}"
] |
Gets the handler at the given index.
@param <H> the event handler type
@param index the index
@param type the handler's event type
@return the given handler
|
[
"Gets",
"the",
"handler",
"at",
"the",
"given",
"index",
"."
] |
train
|
https://github.com/Putnami/putnami-web-toolkit/blob/129aa781d1bda508e579d194693ca3034b4d470b/core/src/main/java/com/google/gwt/event/shared/HandlerManager.java#L154-L156
|
groupon/robo-remote
|
UIAutomatorClient/src/main/com/groupon/roboremote/uiautomatorclient/components/BaseObject.java
|
BaseObject.callMethod
|
protected JSONArray callMethod(String method, Object ... args) throws Exception {
"""
Call a function on this object
@param method
@param args
@return
@throws Exception
"""
return new QueryBuilder().retrieveResult(storedId).call(method, args).storeResult("LAST_" + getStoredId()).execute();
}
|
java
|
protected JSONArray callMethod(String method, Object ... args) throws Exception {
return new QueryBuilder().retrieveResult(storedId).call(method, args).storeResult("LAST_" + getStoredId()).execute();
}
|
[
"protected",
"JSONArray",
"callMethod",
"(",
"String",
"method",
",",
"Object",
"...",
"args",
")",
"throws",
"Exception",
"{",
"return",
"new",
"QueryBuilder",
"(",
")",
".",
"retrieveResult",
"(",
"storedId",
")",
".",
"call",
"(",
"method",
",",
"args",
")",
".",
"storeResult",
"(",
"\"LAST_\"",
"+",
"getStoredId",
"(",
")",
")",
".",
"execute",
"(",
")",
";",
"}"
] |
Call a function on this object
@param method
@param args
@return
@throws Exception
|
[
"Call",
"a",
"function",
"on",
"this",
"object"
] |
train
|
https://github.com/groupon/robo-remote/blob/12d242faad50bf90f98657ca9a0c0c3ae1993f07/UIAutomatorClient/src/main/com/groupon/roboremote/uiautomatorclient/components/BaseObject.java#L64-L66
|
deeplearning4j/deeplearning4j
|
datavec/datavec-spark/src/main/java/org/datavec/spark/transform/AnalyzeSpark.java
|
AnalyzeSpark.sampleInvalidFromColumn
|
public static List<Writable> sampleInvalidFromColumn(int numToSample, String columnName, Schema schema,
JavaRDD<List<Writable>> data) {
"""
Randomly sample a set of invalid values from a specified column.
Values are considered invalid according to the Schema / ColumnMetaData
@param numToSample Maximum number of invalid values to sample
@param columnName Same of the column from which to sample invalid values
@param schema Data schema
@param data Data
@return List of invalid examples
"""
return sampleInvalidFromColumn(numToSample, columnName, schema, data, false);
}
|
java
|
public static List<Writable> sampleInvalidFromColumn(int numToSample, String columnName, Schema schema,
JavaRDD<List<Writable>> data) {
return sampleInvalidFromColumn(numToSample, columnName, schema, data, false);
}
|
[
"public",
"static",
"List",
"<",
"Writable",
">",
"sampleInvalidFromColumn",
"(",
"int",
"numToSample",
",",
"String",
"columnName",
",",
"Schema",
"schema",
",",
"JavaRDD",
"<",
"List",
"<",
"Writable",
">",
">",
"data",
")",
"{",
"return",
"sampleInvalidFromColumn",
"(",
"numToSample",
",",
"columnName",
",",
"schema",
",",
"data",
",",
"false",
")",
";",
"}"
] |
Randomly sample a set of invalid values from a specified column.
Values are considered invalid according to the Schema / ColumnMetaData
@param numToSample Maximum number of invalid values to sample
@param columnName Same of the column from which to sample invalid values
@param schema Data schema
@param data Data
@return List of invalid examples
|
[
"Randomly",
"sample",
"a",
"set",
"of",
"invalid",
"values",
"from",
"a",
"specified",
"column",
".",
"Values",
"are",
"considered",
"invalid",
"according",
"to",
"the",
"Schema",
"/",
"ColumnMetaData"
] |
train
|
https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/datavec/datavec-spark/src/main/java/org/datavec/spark/transform/AnalyzeSpark.java#L312-L315
|
lessthanoptimal/ejml
|
main/ejml-zdense/src/org/ejml/dense/row/MatrixFeatures_ZDRM.java
|
MatrixFeatures_ZDRM.isHermitian
|
public static boolean isHermitian(ZMatrixRMaj Q , double tol ) {
"""
<p>Hermitian matrix is a square matrix with complex entries that are equal to its own conjugate transpose.</p>
<p>a[i,j] = conj(a[j,i])</p>
@param Q The matrix being tested. Not modified.
@param tol Tolerance.
@return True if it passes the test.
"""
if( Q.numCols != Q.numRows )
return false;
Complex_F64 a = new Complex_F64();
Complex_F64 b = new Complex_F64();
for( int i = 0; i < Q.numCols; i++ ) {
for( int j = i; j < Q.numCols; j++ ) {
Q.get(i,j,a);
Q.get(j,i,b);
if( Math.abs(a.real-b.real)>tol)
return false;
if( Math.abs(a.imaginary+b.imaginary)>tol)
return false;
}
}
return true;
}
|
java
|
public static boolean isHermitian(ZMatrixRMaj Q , double tol ) {
if( Q.numCols != Q.numRows )
return false;
Complex_F64 a = new Complex_F64();
Complex_F64 b = new Complex_F64();
for( int i = 0; i < Q.numCols; i++ ) {
for( int j = i; j < Q.numCols; j++ ) {
Q.get(i,j,a);
Q.get(j,i,b);
if( Math.abs(a.real-b.real)>tol)
return false;
if( Math.abs(a.imaginary+b.imaginary)>tol)
return false;
}
}
return true;
}
|
[
"public",
"static",
"boolean",
"isHermitian",
"(",
"ZMatrixRMaj",
"Q",
",",
"double",
"tol",
")",
"{",
"if",
"(",
"Q",
".",
"numCols",
"!=",
"Q",
".",
"numRows",
")",
"return",
"false",
";",
"Complex_F64",
"a",
"=",
"new",
"Complex_F64",
"(",
")",
";",
"Complex_F64",
"b",
"=",
"new",
"Complex_F64",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"Q",
".",
"numCols",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"i",
";",
"j",
"<",
"Q",
".",
"numCols",
";",
"j",
"++",
")",
"{",
"Q",
".",
"get",
"(",
"i",
",",
"j",
",",
"a",
")",
";",
"Q",
".",
"get",
"(",
"j",
",",
"i",
",",
"b",
")",
";",
"if",
"(",
"Math",
".",
"abs",
"(",
"a",
".",
"real",
"-",
"b",
".",
"real",
")",
">",
"tol",
")",
"return",
"false",
";",
"if",
"(",
"Math",
".",
"abs",
"(",
"a",
".",
"imaginary",
"+",
"b",
".",
"imaginary",
")",
">",
"tol",
")",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
<p>Hermitian matrix is a square matrix with complex entries that are equal to its own conjugate transpose.</p>
<p>a[i,j] = conj(a[j,i])</p>
@param Q The matrix being tested. Not modified.
@param tol Tolerance.
@return True if it passes the test.
|
[
"<p",
">",
"Hermitian",
"matrix",
"is",
"a",
"square",
"matrix",
"with",
"complex",
"entries",
"that",
"are",
"equal",
"to",
"its",
"own",
"conjugate",
"transpose",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-zdense/src/org/ejml/dense/row/MatrixFeatures_ZDRM.java#L264-L284
|
cloudendpoints/endpoints-management-java
|
endpoints-control/src/main/java/com/google/api/control/model/Distributions.java
|
Distributions.createLinear
|
public static Distribution createLinear(int numFiniteBuckets, double width, double offset) {
"""
Creates a {@code Distribution} with {@code LinearBuckets}.
@param numFiniteBuckets initializes the number of finite buckets
@param width initializes the width of each bucket
@param offset initializes the offset of the start bucket
@return a {@code Distribution} with {@code LinearBuckets}
@throws IllegalArgumentException if a bad input prevents creation.
"""
if (numFiniteBuckets <= 0) {
throw new IllegalArgumentException(MSG_BAD_NUM_FINITE_BUCKETS);
}
if (width <= 0.0) {
throw new IllegalArgumentException(String.format(MSG_DOUBLE_TOO_LOW, "width", 0.0));
}
LinearBuckets buckets = LinearBuckets.newBuilder().setOffset(offset).setWidth(width)
.setNumFiniteBuckets(numFiniteBuckets).build();
Builder builder = Distribution.newBuilder().setLinearBuckets(buckets);
for (int i = 0; i < numFiniteBuckets + 2; i++) {
builder.addBucketCounts(0L);
}
return builder.build();
}
|
java
|
public static Distribution createLinear(int numFiniteBuckets, double width, double offset) {
if (numFiniteBuckets <= 0) {
throw new IllegalArgumentException(MSG_BAD_NUM_FINITE_BUCKETS);
}
if (width <= 0.0) {
throw new IllegalArgumentException(String.format(MSG_DOUBLE_TOO_LOW, "width", 0.0));
}
LinearBuckets buckets = LinearBuckets.newBuilder().setOffset(offset).setWidth(width)
.setNumFiniteBuckets(numFiniteBuckets).build();
Builder builder = Distribution.newBuilder().setLinearBuckets(buckets);
for (int i = 0; i < numFiniteBuckets + 2; i++) {
builder.addBucketCounts(0L);
}
return builder.build();
}
|
[
"public",
"static",
"Distribution",
"createLinear",
"(",
"int",
"numFiniteBuckets",
",",
"double",
"width",
",",
"double",
"offset",
")",
"{",
"if",
"(",
"numFiniteBuckets",
"<=",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"MSG_BAD_NUM_FINITE_BUCKETS",
")",
";",
"}",
"if",
"(",
"width",
"<=",
"0.0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"MSG_DOUBLE_TOO_LOW",
",",
"\"width\"",
",",
"0.0",
")",
")",
";",
"}",
"LinearBuckets",
"buckets",
"=",
"LinearBuckets",
".",
"newBuilder",
"(",
")",
".",
"setOffset",
"(",
"offset",
")",
".",
"setWidth",
"(",
"width",
")",
".",
"setNumFiniteBuckets",
"(",
"numFiniteBuckets",
")",
".",
"build",
"(",
")",
";",
"Builder",
"builder",
"=",
"Distribution",
".",
"newBuilder",
"(",
")",
".",
"setLinearBuckets",
"(",
"buckets",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"numFiniteBuckets",
"+",
"2",
";",
"i",
"++",
")",
"{",
"builder",
".",
"addBucketCounts",
"(",
"0L",
")",
";",
"}",
"return",
"builder",
".",
"build",
"(",
")",
";",
"}"
] |
Creates a {@code Distribution} with {@code LinearBuckets}.
@param numFiniteBuckets initializes the number of finite buckets
@param width initializes the width of each bucket
@param offset initializes the offset of the start bucket
@return a {@code Distribution} with {@code LinearBuckets}
@throws IllegalArgumentException if a bad input prevents creation.
|
[
"Creates",
"a",
"{",
"@code",
"Distribution",
"}",
"with",
"{",
"@code",
"LinearBuckets",
"}",
"."
] |
train
|
https://github.com/cloudendpoints/endpoints-management-java/blob/5bbf20ddadbbd51b890049e3c338c28abe2c9f94/endpoints-control/src/main/java/com/google/api/control/model/Distributions.java#L89-L103
|
baratine/baratine
|
kraken/src/main/java/com/caucho/v5/kelp/segment/SegmentServiceImpl.java
|
SegmentServiceImpl.readMetaTable
|
private boolean readMetaTable(ReadStream is, int crc)
throws IOException {
"""
Read metadata for a table.
<pre><code>
key byte[32]
rowLength int16
keyOffset int16
keyLength int16
crc int32
</code></pre>
"""
byte []key = new byte[TABLE_KEY_SIZE];
is.read(key, 0, key.length);
crc = Crc32Caucho.generate(crc, key);
int rowLength = BitsUtil.readInt16(is);
crc = Crc32Caucho.generateInt16(crc, rowLength);
int keyOffset = BitsUtil.readInt16(is);
crc = Crc32Caucho.generateInt16(crc, keyOffset);
int keyLength = BitsUtil.readInt16(is);
crc = Crc32Caucho.generateInt16(crc, keyLength);
int dataLength = BitsUtil.readInt16(is);
crc = Crc32Caucho.generateInt16(crc, dataLength);
byte []data = new byte[dataLength];
is.readAll(data, 0, data.length);
crc = Crc32Caucho.generate(crc, data);
int crcFile = BitsUtil.readInt(is);
if (crcFile != crc) {
log.fine("meta-table crc mismatch");
return false;
}
TableEntry entry = new TableEntry(key,
rowLength,
keyOffset,
keyLength,
data);
_tableList.add(entry);
return true;
}
|
java
|
private boolean readMetaTable(ReadStream is, int crc)
throws IOException
{
byte []key = new byte[TABLE_KEY_SIZE];
is.read(key, 0, key.length);
crc = Crc32Caucho.generate(crc, key);
int rowLength = BitsUtil.readInt16(is);
crc = Crc32Caucho.generateInt16(crc, rowLength);
int keyOffset = BitsUtil.readInt16(is);
crc = Crc32Caucho.generateInt16(crc, keyOffset);
int keyLength = BitsUtil.readInt16(is);
crc = Crc32Caucho.generateInt16(crc, keyLength);
int dataLength = BitsUtil.readInt16(is);
crc = Crc32Caucho.generateInt16(crc, dataLength);
byte []data = new byte[dataLength];
is.readAll(data, 0, data.length);
crc = Crc32Caucho.generate(crc, data);
int crcFile = BitsUtil.readInt(is);
if (crcFile != crc) {
log.fine("meta-table crc mismatch");
return false;
}
TableEntry entry = new TableEntry(key,
rowLength,
keyOffset,
keyLength,
data);
_tableList.add(entry);
return true;
}
|
[
"private",
"boolean",
"readMetaTable",
"(",
"ReadStream",
"is",
",",
"int",
"crc",
")",
"throws",
"IOException",
"{",
"byte",
"[",
"]",
"key",
"=",
"new",
"byte",
"[",
"TABLE_KEY_SIZE",
"]",
";",
"is",
".",
"read",
"(",
"key",
",",
"0",
",",
"key",
".",
"length",
")",
";",
"crc",
"=",
"Crc32Caucho",
".",
"generate",
"(",
"crc",
",",
"key",
")",
";",
"int",
"rowLength",
"=",
"BitsUtil",
".",
"readInt16",
"(",
"is",
")",
";",
"crc",
"=",
"Crc32Caucho",
".",
"generateInt16",
"(",
"crc",
",",
"rowLength",
")",
";",
"int",
"keyOffset",
"=",
"BitsUtil",
".",
"readInt16",
"(",
"is",
")",
";",
"crc",
"=",
"Crc32Caucho",
".",
"generateInt16",
"(",
"crc",
",",
"keyOffset",
")",
";",
"int",
"keyLength",
"=",
"BitsUtil",
".",
"readInt16",
"(",
"is",
")",
";",
"crc",
"=",
"Crc32Caucho",
".",
"generateInt16",
"(",
"crc",
",",
"keyLength",
")",
";",
"int",
"dataLength",
"=",
"BitsUtil",
".",
"readInt16",
"(",
"is",
")",
";",
"crc",
"=",
"Crc32Caucho",
".",
"generateInt16",
"(",
"crc",
",",
"dataLength",
")",
";",
"byte",
"[",
"]",
"data",
"=",
"new",
"byte",
"[",
"dataLength",
"]",
";",
"is",
".",
"readAll",
"(",
"data",
",",
"0",
",",
"data",
".",
"length",
")",
";",
"crc",
"=",
"Crc32Caucho",
".",
"generate",
"(",
"crc",
",",
"data",
")",
";",
"int",
"crcFile",
"=",
"BitsUtil",
".",
"readInt",
"(",
"is",
")",
";",
"if",
"(",
"crcFile",
"!=",
"crc",
")",
"{",
"log",
".",
"fine",
"(",
"\"meta-table crc mismatch\"",
")",
";",
"return",
"false",
";",
"}",
"TableEntry",
"entry",
"=",
"new",
"TableEntry",
"(",
"key",
",",
"rowLength",
",",
"keyOffset",
",",
"keyLength",
",",
"data",
")",
";",
"_tableList",
".",
"add",
"(",
"entry",
")",
";",
"return",
"true",
";",
"}"
] |
Read metadata for a table.
<pre><code>
key byte[32]
rowLength int16
keyOffset int16
keyLength int16
crc int32
</code></pre>
|
[
"Read",
"metadata",
"for",
"a",
"table",
"."
] |
train
|
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/segment/SegmentServiceImpl.java#L770-L811
|
aws/aws-sdk-java
|
aws-java-sdk-backup/src/main/java/com/amazonaws/services/backup/model/GetRecoveryPointRestoreMetadataResult.java
|
GetRecoveryPointRestoreMetadataResult.withRestoreMetadata
|
public GetRecoveryPointRestoreMetadataResult withRestoreMetadata(java.util.Map<String, String> restoreMetadata) {
"""
<p>
A set of metadata key-value pairs that lists the metadata key-value pairs that are required to restore the
recovery point.
</p>
@param restoreMetadata
A set of metadata key-value pairs that lists the metadata key-value pairs that are required to restore the
recovery point.
@return Returns a reference to this object so that method calls can be chained together.
"""
setRestoreMetadata(restoreMetadata);
return this;
}
|
java
|
public GetRecoveryPointRestoreMetadataResult withRestoreMetadata(java.util.Map<String, String> restoreMetadata) {
setRestoreMetadata(restoreMetadata);
return this;
}
|
[
"public",
"GetRecoveryPointRestoreMetadataResult",
"withRestoreMetadata",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"restoreMetadata",
")",
"{",
"setRestoreMetadata",
"(",
"restoreMetadata",
")",
";",
"return",
"this",
";",
"}"
] |
<p>
A set of metadata key-value pairs that lists the metadata key-value pairs that are required to restore the
recovery point.
</p>
@param restoreMetadata
A set of metadata key-value pairs that lists the metadata key-value pairs that are required to restore the
recovery point.
@return Returns a reference to this object so that method calls can be chained together.
|
[
"<p",
">",
"A",
"set",
"of",
"metadata",
"key",
"-",
"value",
"pairs",
"that",
"lists",
"the",
"metadata",
"key",
"-",
"value",
"pairs",
"that",
"are",
"required",
"to",
"restore",
"the",
"recovery",
"point",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-backup/src/main/java/com/amazonaws/services/backup/model/GetRecoveryPointRestoreMetadataResult.java#L182-L185
|
zaproxy/zaproxy
|
src/org/parosproxy/paros/db/paros/ParosTableHistory.java
|
ParosTableHistory.getHistoryIdsExceptOfHistType
|
@Override
public List<Integer> getHistoryIdsExceptOfHistType(long sessionId, int... histTypes) throws DatabaseException {
"""
Returns all the history record IDs of the given session except the ones with the given history types.
*
@param sessionId the ID of session of the history records
@param histTypes the history types of the history records that should be excluded
@return a {@code List} with all the history IDs of the given session and history types, never {@code null}
@throws DatabaseException if an error occurred while getting the history IDs
@since 2.3.0
@see #getHistoryIdsOfHistType(long, int...)
"""
return getHistoryIdsByParams(sessionId, 0, false, histTypes);
}
|
java
|
@Override
public List<Integer> getHistoryIdsExceptOfHistType(long sessionId, int... histTypes) throws DatabaseException {
return getHistoryIdsByParams(sessionId, 0, false, histTypes);
}
|
[
"@",
"Override",
"public",
"List",
"<",
"Integer",
">",
"getHistoryIdsExceptOfHistType",
"(",
"long",
"sessionId",
",",
"int",
"...",
"histTypes",
")",
"throws",
"DatabaseException",
"{",
"return",
"getHistoryIdsByParams",
"(",
"sessionId",
",",
"0",
",",
"false",
",",
"histTypes",
")",
";",
"}"
] |
Returns all the history record IDs of the given session except the ones with the given history types.
*
@param sessionId the ID of session of the history records
@param histTypes the history types of the history records that should be excluded
@return a {@code List} with all the history IDs of the given session and history types, never {@code null}
@throws DatabaseException if an error occurred while getting the history IDs
@since 2.3.0
@see #getHistoryIdsOfHistType(long, int...)
|
[
"Returns",
"all",
"the",
"history",
"record",
"IDs",
"of",
"the",
"given",
"session",
"except",
"the",
"ones",
"with",
"the",
"given",
"history",
"types",
".",
"*"
] |
train
|
https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/parosproxy/paros/db/paros/ParosTableHistory.java#L504-L507
|
baidubce/bce-sdk-java
|
src/main/java/com/baidubce/services/bos/BosClient.java
|
BosClient.fetchObject
|
public FetchObjectResponse fetchObject(String bucketName, String key, String sourceUrl) {
"""
Fetches a source object to a new destination in Bos.
@param bucketName The name of the bucket in which the new object will be created.
@param key The key in the destination bucket under which the new object will be created.
@param sourceUrl The url full path for fetching.
@return A FetchObjectResponse object containing the information returned by Bos for the newly fetching.
"""
FetchObjectRequest request = new FetchObjectRequest(bucketName, key, sourceUrl);
return this.fetchObject(request);
}
|
java
|
public FetchObjectResponse fetchObject(String bucketName, String key, String sourceUrl) {
FetchObjectRequest request = new FetchObjectRequest(bucketName, key, sourceUrl);
return this.fetchObject(request);
}
|
[
"public",
"FetchObjectResponse",
"fetchObject",
"(",
"String",
"bucketName",
",",
"String",
"key",
",",
"String",
"sourceUrl",
")",
"{",
"FetchObjectRequest",
"request",
"=",
"new",
"FetchObjectRequest",
"(",
"bucketName",
",",
"key",
",",
"sourceUrl",
")",
";",
"return",
"this",
".",
"fetchObject",
"(",
"request",
")",
";",
"}"
] |
Fetches a source object to a new destination in Bos.
@param bucketName The name of the bucket in which the new object will be created.
@param key The key in the destination bucket under which the new object will be created.
@param sourceUrl The url full path for fetching.
@return A FetchObjectResponse object containing the information returned by Bos for the newly fetching.
|
[
"Fetches",
"a",
"source",
"object",
"to",
"a",
"new",
"destination",
"in",
"Bos",
"."
] |
train
|
https://github.com/baidubce/bce-sdk-java/blob/f7140f28dd82121515c88ded7bfe769a37d0ec4a/src/main/java/com/baidubce/services/bos/BosClient.java#L1005-L1008
|
banq/jdonframework
|
src/main/java/com/jdon/util/UtilValidate.java
|
UtilValidate.isDate
|
public static boolean isDate(String date) {
"""
isDate returns true if string argument date forms a valid date.
"""
if (isEmpty(date)) return defaultEmptyOK;
String month;
String day;
String year;
int dateSlash1 = date.indexOf("/");
int dateSlash2 = date.lastIndexOf("/");
if (dateSlash1 <= 0 || dateSlash1 == dateSlash2) return false;
month = date.substring(0, dateSlash1);
day = date.substring(dateSlash1 + 1, dateSlash2);
year = date.substring(dateSlash2 + 1);
return isDate(year, month, day);
}
|
java
|
public static boolean isDate(String date) {
if (isEmpty(date)) return defaultEmptyOK;
String month;
String day;
String year;
int dateSlash1 = date.indexOf("/");
int dateSlash2 = date.lastIndexOf("/");
if (dateSlash1 <= 0 || dateSlash1 == dateSlash2) return false;
month = date.substring(0, dateSlash1);
day = date.substring(dateSlash1 + 1, dateSlash2);
year = date.substring(dateSlash2 + 1);
return isDate(year, month, day);
}
|
[
"public",
"static",
"boolean",
"isDate",
"(",
"String",
"date",
")",
"{",
"if",
"(",
"isEmpty",
"(",
"date",
")",
")",
"return",
"defaultEmptyOK",
";",
"String",
"month",
";",
"String",
"day",
";",
"String",
"year",
";",
"int",
"dateSlash1",
"=",
"date",
".",
"indexOf",
"(",
"\"/\"",
")",
";",
"int",
"dateSlash2",
"=",
"date",
".",
"lastIndexOf",
"(",
"\"/\"",
")",
";",
"if",
"(",
"dateSlash1",
"<=",
"0",
"||",
"dateSlash1",
"==",
"dateSlash2",
")",
"return",
"false",
";",
"month",
"=",
"date",
".",
"substring",
"(",
"0",
",",
"dateSlash1",
")",
";",
"day",
"=",
"date",
".",
"substring",
"(",
"dateSlash1",
"+",
"1",
",",
"dateSlash2",
")",
";",
"year",
"=",
"date",
".",
"substring",
"(",
"dateSlash2",
"+",
"1",
")",
";",
"return",
"isDate",
"(",
"year",
",",
"month",
",",
"day",
")",
";",
"}"
] |
isDate returns true if string argument date forms a valid date.
|
[
"isDate",
"returns",
"true",
"if",
"string",
"argument",
"date",
"forms",
"a",
"valid",
"date",
"."
] |
train
|
https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/util/UtilValidate.java#L761-L776
|
shrinkwrap/shrinkwrap
|
impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/nio2/file/ShrinkWrapPath.java
|
ShrinkWrapPath.countOccurrences
|
private int countOccurrences(final String string, char c, int offset) {
"""
Returns the number of occurrences of the specified character in the specified {@link String}, starting at the
specified offset
@param string
@param c
@param offset
@return
"""
assert string != null : "String must be specified";
return ((offset = string.indexOf(c, offset)) == -1) ? 0 : 1 + countOccurrences(string, c, offset + 1);
}
|
java
|
private int countOccurrences(final String string, char c, int offset) {
assert string != null : "String must be specified";
return ((offset = string.indexOf(c, offset)) == -1) ? 0 : 1 + countOccurrences(string, c, offset + 1);
}
|
[
"private",
"int",
"countOccurrences",
"(",
"final",
"String",
"string",
",",
"char",
"c",
",",
"int",
"offset",
")",
"{",
"assert",
"string",
"!=",
"null",
":",
"\"String must be specified\"",
";",
"return",
"(",
"(",
"offset",
"=",
"string",
".",
"indexOf",
"(",
"c",
",",
"offset",
")",
")",
"==",
"-",
"1",
")",
"?",
"0",
":",
"1",
"+",
"countOccurrences",
"(",
"string",
",",
"c",
",",
"offset",
"+",
"1",
")",
";",
"}"
] |
Returns the number of occurrences of the specified character in the specified {@link String}, starting at the
specified offset
@param string
@param c
@param offset
@return
|
[
"Returns",
"the",
"number",
"of",
"occurrences",
"of",
"the",
"specified",
"character",
"in",
"the",
"specified",
"{",
"@link",
"String",
"}",
"starting",
"at",
"the",
"specified",
"offset"
] |
train
|
https://github.com/shrinkwrap/shrinkwrap/blob/3f8a1a6d344651428c709a63ebb52d35343c5387/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/nio2/file/ShrinkWrapPath.java#L218-L221
|
Azure/azure-sdk-for-java
|
cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java
|
ModelsImpl.createEntityRoleAsync
|
public Observable<UUID> createEntityRoleAsync(UUID appId, String versionId, UUID entityId, CreateEntityRoleOptionalParameter createEntityRoleOptionalParameter) {
"""
Create an entity role for an entity in the application.
@param appId The application ID.
@param versionId The version ID.
@param entityId The entity model ID.
@param createEntityRoleOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the UUID object
"""
return createEntityRoleWithServiceResponseAsync(appId, versionId, entityId, createEntityRoleOptionalParameter).map(new Func1<ServiceResponse<UUID>, UUID>() {
@Override
public UUID call(ServiceResponse<UUID> response) {
return response.body();
}
});
}
|
java
|
public Observable<UUID> createEntityRoleAsync(UUID appId, String versionId, UUID entityId, CreateEntityRoleOptionalParameter createEntityRoleOptionalParameter) {
return createEntityRoleWithServiceResponseAsync(appId, versionId, entityId, createEntityRoleOptionalParameter).map(new Func1<ServiceResponse<UUID>, UUID>() {
@Override
public UUID call(ServiceResponse<UUID> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"UUID",
">",
"createEntityRoleAsync",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"UUID",
"entityId",
",",
"CreateEntityRoleOptionalParameter",
"createEntityRoleOptionalParameter",
")",
"{",
"return",
"createEntityRoleWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
"entityId",
",",
"createEntityRoleOptionalParameter",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"UUID",
">",
",",
"UUID",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"UUID",
"call",
"(",
"ServiceResponse",
"<",
"UUID",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Create an entity role for an entity in the application.
@param appId The application ID.
@param versionId The version ID.
@param entityId The entity model ID.
@param createEntityRoleOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the UUID object
|
[
"Create",
"an",
"entity",
"role",
"for",
"an",
"entity",
"in",
"the",
"application",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java#L7781-L7788
|
KyoriPowered/text
|
api/src/main/java/net/kyori/text/TextComponent.java
|
TextComponent.of
|
public static TextComponent of(final @NonNull String content, final @Nullable TextColor color, final TextDecoration@NonNull... decorations) {
"""
Creates a text component with content, and optional color and decorations.
@param content the plain text content
@param color the color
@param decorations the decorations
@return the text component
"""
final Set<TextDecoration> activeDecorations = new HashSet<>(decorations.length);
Collections.addAll(activeDecorations, decorations);
return of(content, color, activeDecorations);
}
|
java
|
public static TextComponent of(final @NonNull String content, final @Nullable TextColor color, final TextDecoration@NonNull... decorations) {
final Set<TextDecoration> activeDecorations = new HashSet<>(decorations.length);
Collections.addAll(activeDecorations, decorations);
return of(content, color, activeDecorations);
}
|
[
"public",
"static",
"TextComponent",
"of",
"(",
"final",
"@",
"NonNull",
"String",
"content",
",",
"final",
"@",
"Nullable",
"TextColor",
"color",
",",
"final",
"TextDecoration",
"@",
"NonNull",
".",
".",
".",
"decorations",
")",
"{",
"final",
"Set",
"<",
"TextDecoration",
">",
"activeDecorations",
"=",
"new",
"HashSet",
"<>",
"(",
"decorations",
".",
"length",
")",
";",
"Collections",
".",
"addAll",
"(",
"activeDecorations",
",",
"decorations",
")",
";",
"return",
"of",
"(",
"content",
",",
"color",
",",
"activeDecorations",
")",
";",
"}"
] |
Creates a text component with content, and optional color and decorations.
@param content the plain text content
@param color the color
@param decorations the decorations
@return the text component
|
[
"Creates",
"a",
"text",
"component",
"with",
"content",
"and",
"optional",
"color",
"and",
"decorations",
"."
] |
train
|
https://github.com/KyoriPowered/text/blob/4496c593bf89e8fb036dd6efe26f8ac60f7655c9/api/src/main/java/net/kyori/text/TextComponent.java#L163-L167
|
datasalt/pangool
|
core/src/main/java/com/datasalt/pangool/utils/HadoopUtils.java
|
HadoopUtils.stringToFile
|
public static void stringToFile(FileSystem fs, Path path, String string)
throws IOException {
"""
Creates a file with the given string, overwritting if needed.
"""
OutputStream os = fs.create(path, true);
PrintWriter pw = new PrintWriter(os);
pw.append(string);
pw.close();
}
|
java
|
public static void stringToFile(FileSystem fs, Path path, String string)
throws IOException {
OutputStream os = fs.create(path, true);
PrintWriter pw = new PrintWriter(os);
pw.append(string);
pw.close();
}
|
[
"public",
"static",
"void",
"stringToFile",
"(",
"FileSystem",
"fs",
",",
"Path",
"path",
",",
"String",
"string",
")",
"throws",
"IOException",
"{",
"OutputStream",
"os",
"=",
"fs",
".",
"create",
"(",
"path",
",",
"true",
")",
";",
"PrintWriter",
"pw",
"=",
"new",
"PrintWriter",
"(",
"os",
")",
";",
"pw",
".",
"append",
"(",
"string",
")",
";",
"pw",
".",
"close",
"(",
")",
";",
"}"
] |
Creates a file with the given string, overwritting if needed.
|
[
"Creates",
"a",
"file",
"with",
"the",
"given",
"string",
"overwritting",
"if",
"needed",
"."
] |
train
|
https://github.com/datasalt/pangool/blob/bfd312dd78cba03febaf7988ae96a3d4bc585408/core/src/main/java/com/datasalt/pangool/utils/HadoopUtils.java#L59-L65
|
groupon/odo
|
client/src/main/java/com/groupon/odo/client/Client.java
|
Client.addMethodToResponseOverride
|
public boolean addMethodToResponseOverride(String pathName, String methodName) {
"""
Add a method to the enabled response overrides for a path
@param pathName name of path
@param methodName name of method
@return true if success, false otherwise
"""
// need to find out the ID for the method
// TODO: change api for adding methods to take the name instead of ID
try {
Integer overrideId = getOverrideIdForMethodName(methodName);
// now post to path api to add this is a selected override
BasicNameValuePair[] params = {
new BasicNameValuePair("addOverride", overrideId.toString()),
new BasicNameValuePair("profileIdentifier", this._profileName)
};
JSONObject response = new JSONObject(doPost(BASE_PATH + uriEncode(pathName), params));
// check enabled endpoints array to see if this overrideID exists
JSONArray enabled = response.getJSONArray("enabledEndpoints");
for (int x = 0; x < enabled.length(); x++) {
if (enabled.getJSONObject(x).getInt("overrideId") == overrideId) {
return true;
}
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
|
java
|
public boolean addMethodToResponseOverride(String pathName, String methodName) {
// need to find out the ID for the method
// TODO: change api for adding methods to take the name instead of ID
try {
Integer overrideId = getOverrideIdForMethodName(methodName);
// now post to path api to add this is a selected override
BasicNameValuePair[] params = {
new BasicNameValuePair("addOverride", overrideId.toString()),
new BasicNameValuePair("profileIdentifier", this._profileName)
};
JSONObject response = new JSONObject(doPost(BASE_PATH + uriEncode(pathName), params));
// check enabled endpoints array to see if this overrideID exists
JSONArray enabled = response.getJSONArray("enabledEndpoints");
for (int x = 0; x < enabled.length(); x++) {
if (enabled.getJSONObject(x).getInt("overrideId") == overrideId) {
return true;
}
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
|
[
"public",
"boolean",
"addMethodToResponseOverride",
"(",
"String",
"pathName",
",",
"String",
"methodName",
")",
"{",
"// need to find out the ID for the method",
"// TODO: change api for adding methods to take the name instead of ID",
"try",
"{",
"Integer",
"overrideId",
"=",
"getOverrideIdForMethodName",
"(",
"methodName",
")",
";",
"// now post to path api to add this is a selected override",
"BasicNameValuePair",
"[",
"]",
"params",
"=",
"{",
"new",
"BasicNameValuePair",
"(",
"\"addOverride\"",
",",
"overrideId",
".",
"toString",
"(",
")",
")",
",",
"new",
"BasicNameValuePair",
"(",
"\"profileIdentifier\"",
",",
"this",
".",
"_profileName",
")",
"}",
";",
"JSONObject",
"response",
"=",
"new",
"JSONObject",
"(",
"doPost",
"(",
"BASE_PATH",
"+",
"uriEncode",
"(",
"pathName",
")",
",",
"params",
")",
")",
";",
"// check enabled endpoints array to see if this overrideID exists",
"JSONArray",
"enabled",
"=",
"response",
".",
"getJSONArray",
"(",
"\"enabledEndpoints\"",
")",
";",
"for",
"(",
"int",
"x",
"=",
"0",
";",
"x",
"<",
"enabled",
".",
"length",
"(",
")",
";",
"x",
"++",
")",
"{",
"if",
"(",
"enabled",
".",
"getJSONObject",
"(",
"x",
")",
".",
"getInt",
"(",
"\"overrideId\"",
")",
"==",
"overrideId",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Add a method to the enabled response overrides for a path
@param pathName name of path
@param methodName name of method
@return true if success, false otherwise
|
[
"Add",
"a",
"method",
"to",
"the",
"enabled",
"response",
"overrides",
"for",
"a",
"path"
] |
train
|
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/client/src/main/java/com/groupon/odo/client/Client.java#L617-L641
|
phax/ph-commons
|
ph-commons/src/main/java/com/helger/commons/string/StringParser.java
|
StringParser.parseLong
|
public static long parseLong (@Nullable final String sStr, @Nonnegative final int nRadix, final long nDefault) {
"""
Parse the given {@link String} as long with the specified radix.
@param sStr
The string to parse. May be <code>null</code>.
@param nRadix
The radix to use. Must be ≥ {@link Character#MIN_RADIX} and ≤
{@link Character#MAX_RADIX}.
@param nDefault
The default value to be returned if the passed object could not be
converted to a valid value.
@return The default if the string does not represent a valid value.
"""
if (sStr != null && sStr.length () > 0)
try
{
return Long.parseLong (sStr, nRadix);
}
catch (final NumberFormatException ex)
{
// Fall through
}
return nDefault;
}
|
java
|
public static long parseLong (@Nullable final String sStr, @Nonnegative final int nRadix, final long nDefault)
{
if (sStr != null && sStr.length () > 0)
try
{
return Long.parseLong (sStr, nRadix);
}
catch (final NumberFormatException ex)
{
// Fall through
}
return nDefault;
}
|
[
"public",
"static",
"long",
"parseLong",
"(",
"@",
"Nullable",
"final",
"String",
"sStr",
",",
"@",
"Nonnegative",
"final",
"int",
"nRadix",
",",
"final",
"long",
"nDefault",
")",
"{",
"if",
"(",
"sStr",
"!=",
"null",
"&&",
"sStr",
".",
"length",
"(",
")",
">",
"0",
")",
"try",
"{",
"return",
"Long",
".",
"parseLong",
"(",
"sStr",
",",
"nRadix",
")",
";",
"}",
"catch",
"(",
"final",
"NumberFormatException",
"ex",
")",
"{",
"// Fall through",
"}",
"return",
"nDefault",
";",
"}"
] |
Parse the given {@link String} as long with the specified radix.
@param sStr
The string to parse. May be <code>null</code>.
@param nRadix
The radix to use. Must be ≥ {@link Character#MIN_RADIX} and ≤
{@link Character#MAX_RADIX}.
@param nDefault
The default value to be returned if the passed object could not be
converted to a valid value.
@return The default if the string does not represent a valid value.
|
[
"Parse",
"the",
"given",
"{",
"@link",
"String",
"}",
"as",
"long",
"with",
"the",
"specified",
"radix",
"."
] |
train
|
https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/string/StringParser.java#L1035-L1047
|
ontop/ontop
|
core/optimization/src/main/java/it/unibz/inf/ontop/iq/optimizer/impl/BottomUpUnionAndBindingLiftOptimizer.java
|
BottomUpUnionAndBindingLiftOptimizer.liftTree
|
private IQTree liftTree(IQTree queryTree, VariableGenerator variableGenerator) {
"""
Recursive (to reach the descendency but does not loop over itself)
"""
if (queryTree instanceof UnaryIQTree)
return liftUnary((UnaryIQTree) queryTree, variableGenerator);
else if (queryTree instanceof NaryIQTree)
return liftNary((NaryIQTree) queryTree, variableGenerator);
else if (queryTree instanceof BinaryNonCommutativeIQTree)
return liftBinaryNonCommutative((BinaryNonCommutativeIQTree) queryTree, variableGenerator);
// Leaf node
else
return queryTree;
}
|
java
|
private IQTree liftTree(IQTree queryTree, VariableGenerator variableGenerator) {
if (queryTree instanceof UnaryIQTree)
return liftUnary((UnaryIQTree) queryTree, variableGenerator);
else if (queryTree instanceof NaryIQTree)
return liftNary((NaryIQTree) queryTree, variableGenerator);
else if (queryTree instanceof BinaryNonCommutativeIQTree)
return liftBinaryNonCommutative((BinaryNonCommutativeIQTree) queryTree, variableGenerator);
// Leaf node
else
return queryTree;
}
|
[
"private",
"IQTree",
"liftTree",
"(",
"IQTree",
"queryTree",
",",
"VariableGenerator",
"variableGenerator",
")",
"{",
"if",
"(",
"queryTree",
"instanceof",
"UnaryIQTree",
")",
"return",
"liftUnary",
"(",
"(",
"UnaryIQTree",
")",
"queryTree",
",",
"variableGenerator",
")",
";",
"else",
"if",
"(",
"queryTree",
"instanceof",
"NaryIQTree",
")",
"return",
"liftNary",
"(",
"(",
"NaryIQTree",
")",
"queryTree",
",",
"variableGenerator",
")",
";",
"else",
"if",
"(",
"queryTree",
"instanceof",
"BinaryNonCommutativeIQTree",
")",
"return",
"liftBinaryNonCommutative",
"(",
"(",
"BinaryNonCommutativeIQTree",
")",
"queryTree",
",",
"variableGenerator",
")",
";",
"// Leaf node",
"else",
"return",
"queryTree",
";",
"}"
] |
Recursive (to reach the descendency but does not loop over itself)
|
[
"Recursive",
"(",
"to",
"reach",
"the",
"descendency",
"but",
"does",
"not",
"loop",
"over",
"itself",
")"
] |
train
|
https://github.com/ontop/ontop/blob/ddf78b26981b6129ee9a1a59310016830f5352e4/core/optimization/src/main/java/it/unibz/inf/ontop/iq/optimizer/impl/BottomUpUnionAndBindingLiftOptimizer.java#L75-L85
|
grpc/grpc-java
|
core/src/main/java/io/grpc/internal/ServiceConfigUtil.java
|
ServiceConfigUtil.unwrapLoadBalancingConfig
|
@SuppressWarnings("unchecked")
public static LbConfig unwrapLoadBalancingConfig(Map<String, ?> lbConfig) {
"""
Unwrap a LoadBalancingConfig JSON object into a {@link LbConfig}. The input is a JSON object
(map) with exactly one entry, where the key is the policy name and the value is a config object
for that policy.
"""
if (lbConfig.size() != 1) {
throw new RuntimeException(
"There are " + lbConfig.size() + " fields in a LoadBalancingConfig object. Exactly one"
+ " is expected. Config=" + lbConfig);
}
String key = lbConfig.entrySet().iterator().next().getKey();
return new LbConfig(key, getObject(lbConfig, key));
}
|
java
|
@SuppressWarnings("unchecked")
public static LbConfig unwrapLoadBalancingConfig(Map<String, ?> lbConfig) {
if (lbConfig.size() != 1) {
throw new RuntimeException(
"There are " + lbConfig.size() + " fields in a LoadBalancingConfig object. Exactly one"
+ " is expected. Config=" + lbConfig);
}
String key = lbConfig.entrySet().iterator().next().getKey();
return new LbConfig(key, getObject(lbConfig, key));
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"LbConfig",
"unwrapLoadBalancingConfig",
"(",
"Map",
"<",
"String",
",",
"?",
">",
"lbConfig",
")",
"{",
"if",
"(",
"lbConfig",
".",
"size",
"(",
")",
"!=",
"1",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"There are \"",
"+",
"lbConfig",
".",
"size",
"(",
")",
"+",
"\" fields in a LoadBalancingConfig object. Exactly one\"",
"+",
"\" is expected. Config=\"",
"+",
"lbConfig",
")",
";",
"}",
"String",
"key",
"=",
"lbConfig",
".",
"entrySet",
"(",
")",
".",
"iterator",
"(",
")",
".",
"next",
"(",
")",
".",
"getKey",
"(",
")",
";",
"return",
"new",
"LbConfig",
"(",
"key",
",",
"getObject",
"(",
"lbConfig",
",",
"key",
")",
")",
";",
"}"
] |
Unwrap a LoadBalancingConfig JSON object into a {@link LbConfig}. The input is a JSON object
(map) with exactly one entry, where the key is the policy name and the value is a config object
for that policy.
|
[
"Unwrap",
"a",
"LoadBalancingConfig",
"JSON",
"object",
"into",
"a",
"{"
] |
train
|
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/core/src/main/java/io/grpc/internal/ServiceConfigUtil.java#L356-L365
|
DiUS/pact-jvm
|
pact-jvm-consumer/src/main/java/au/com/dius/pact/consumer/dsl/PactDslJsonArray.java
|
PactDslJsonArray.arrayMaxLike
|
public static PactDslJsonBody arrayMaxLike(int maxSize, int numberExamples) {
"""
Array with a maximum size where each item must match the following example
@param maxSize maximum size
@param numberExamples Number of examples to generate
"""
if (numberExamples > maxSize) {
throw new IllegalArgumentException(String.format("Number of example %d is more than the maximum size of %d",
numberExamples, maxSize));
}
PactDslJsonArray parent = new PactDslJsonArray("", "", null, true);
parent.setNumberExamples(numberExamples);
parent.matchers.addRule("", parent.matchMax(maxSize));
return new PactDslJsonBody(".", "", parent);
}
|
java
|
public static PactDslJsonBody arrayMaxLike(int maxSize, int numberExamples) {
if (numberExamples > maxSize) {
throw new IllegalArgumentException(String.format("Number of example %d is more than the maximum size of %d",
numberExamples, maxSize));
}
PactDslJsonArray parent = new PactDslJsonArray("", "", null, true);
parent.setNumberExamples(numberExamples);
parent.matchers.addRule("", parent.matchMax(maxSize));
return new PactDslJsonBody(".", "", parent);
}
|
[
"public",
"static",
"PactDslJsonBody",
"arrayMaxLike",
"(",
"int",
"maxSize",
",",
"int",
"numberExamples",
")",
"{",
"if",
"(",
"numberExamples",
">",
"maxSize",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"\"Number of example %d is more than the maximum size of %d\"",
",",
"numberExamples",
",",
"maxSize",
")",
")",
";",
"}",
"PactDslJsonArray",
"parent",
"=",
"new",
"PactDslJsonArray",
"(",
"\"\"",
",",
"\"\"",
",",
"null",
",",
"true",
")",
";",
"parent",
".",
"setNumberExamples",
"(",
"numberExamples",
")",
";",
"parent",
".",
"matchers",
".",
"addRule",
"(",
"\"\"",
",",
"parent",
".",
"matchMax",
"(",
"maxSize",
")",
")",
";",
"return",
"new",
"PactDslJsonBody",
"(",
"\".\"",
",",
"\"\"",
",",
"parent",
")",
";",
"}"
] |
Array with a maximum size where each item must match the following example
@param maxSize maximum size
@param numberExamples Number of examples to generate
|
[
"Array",
"with",
"a",
"maximum",
"size",
"where",
"each",
"item",
"must",
"match",
"the",
"following",
"example"
] |
train
|
https://github.com/DiUS/pact-jvm/blob/2f447e9dd4ac152a6a36b7fcf8962d07de9ef3ef/pact-jvm-consumer/src/main/java/au/com/dius/pact/consumer/dsl/PactDslJsonArray.java#L827-L836
|
jeremylong/DependencyCheck
|
core/src/main/java/org/owasp/dependencycheck/reporting/ReportGenerator.java
|
ReportGenerator.prettyPrint
|
private static void prettyPrint(JsonReader reader, JsonWriter writer) throws IOException {
"""
Streams from a json reader to a json writer and performs pretty printing.
This function is copied from https://sites.google.com/site/gson/streaming
@param reader json reader
@param writer json writer
@throws IOException thrown if the json is malformed
"""
writer.setIndent(" ");
while (true) {
final JsonToken token = reader.peek();
switch (token) {
case BEGIN_ARRAY:
reader.beginArray();
writer.beginArray();
break;
case END_ARRAY:
reader.endArray();
writer.endArray();
break;
case BEGIN_OBJECT:
reader.beginObject();
writer.beginObject();
break;
case END_OBJECT:
reader.endObject();
writer.endObject();
break;
case NAME:
final String name = reader.nextName();
writer.name(name);
break;
case STRING:
final String s = reader.nextString();
writer.value(s);
break;
case NUMBER:
final String n = reader.nextString();
writer.value(new BigDecimal(n));
break;
case BOOLEAN:
final boolean b = reader.nextBoolean();
writer.value(b);
break;
case NULL:
reader.nextNull();
writer.nullValue();
break;
case END_DOCUMENT:
return;
default:
LOGGER.debug("Unexpected JSON toekn {}", token.toString());
break;
}
}
}
|
java
|
private static void prettyPrint(JsonReader reader, JsonWriter writer) throws IOException {
writer.setIndent(" ");
while (true) {
final JsonToken token = reader.peek();
switch (token) {
case BEGIN_ARRAY:
reader.beginArray();
writer.beginArray();
break;
case END_ARRAY:
reader.endArray();
writer.endArray();
break;
case BEGIN_OBJECT:
reader.beginObject();
writer.beginObject();
break;
case END_OBJECT:
reader.endObject();
writer.endObject();
break;
case NAME:
final String name = reader.nextName();
writer.name(name);
break;
case STRING:
final String s = reader.nextString();
writer.value(s);
break;
case NUMBER:
final String n = reader.nextString();
writer.value(new BigDecimal(n));
break;
case BOOLEAN:
final boolean b = reader.nextBoolean();
writer.value(b);
break;
case NULL:
reader.nextNull();
writer.nullValue();
break;
case END_DOCUMENT:
return;
default:
LOGGER.debug("Unexpected JSON toekn {}", token.toString());
break;
}
}
}
|
[
"private",
"static",
"void",
"prettyPrint",
"(",
"JsonReader",
"reader",
",",
"JsonWriter",
"writer",
")",
"throws",
"IOException",
"{",
"writer",
".",
"setIndent",
"(",
"\" \"",
")",
";",
"while",
"(",
"true",
")",
"{",
"final",
"JsonToken",
"token",
"=",
"reader",
".",
"peek",
"(",
")",
";",
"switch",
"(",
"token",
")",
"{",
"case",
"BEGIN_ARRAY",
":",
"reader",
".",
"beginArray",
"(",
")",
";",
"writer",
".",
"beginArray",
"(",
")",
";",
"break",
";",
"case",
"END_ARRAY",
":",
"reader",
".",
"endArray",
"(",
")",
";",
"writer",
".",
"endArray",
"(",
")",
";",
"break",
";",
"case",
"BEGIN_OBJECT",
":",
"reader",
".",
"beginObject",
"(",
")",
";",
"writer",
".",
"beginObject",
"(",
")",
";",
"break",
";",
"case",
"END_OBJECT",
":",
"reader",
".",
"endObject",
"(",
")",
";",
"writer",
".",
"endObject",
"(",
")",
";",
"break",
";",
"case",
"NAME",
":",
"final",
"String",
"name",
"=",
"reader",
".",
"nextName",
"(",
")",
";",
"writer",
".",
"name",
"(",
"name",
")",
";",
"break",
";",
"case",
"STRING",
":",
"final",
"String",
"s",
"=",
"reader",
".",
"nextString",
"(",
")",
";",
"writer",
".",
"value",
"(",
"s",
")",
";",
"break",
";",
"case",
"NUMBER",
":",
"final",
"String",
"n",
"=",
"reader",
".",
"nextString",
"(",
")",
";",
"writer",
".",
"value",
"(",
"new",
"BigDecimal",
"(",
"n",
")",
")",
";",
"break",
";",
"case",
"BOOLEAN",
":",
"final",
"boolean",
"b",
"=",
"reader",
".",
"nextBoolean",
"(",
")",
";",
"writer",
".",
"value",
"(",
"b",
")",
";",
"break",
";",
"case",
"NULL",
":",
"reader",
".",
"nextNull",
"(",
")",
";",
"writer",
".",
"nullValue",
"(",
")",
";",
"break",
";",
"case",
"END_DOCUMENT",
":",
"return",
";",
"default",
":",
"LOGGER",
".",
"debug",
"(",
"\"Unexpected JSON toekn {}\"",
",",
"token",
".",
"toString",
"(",
")",
")",
";",
"break",
";",
"}",
"}",
"}"
] |
Streams from a json reader to a json writer and performs pretty printing.
This function is copied from https://sites.google.com/site/gson/streaming
@param reader json reader
@param writer json writer
@throws IOException thrown if the json is malformed
|
[
"Streams",
"from",
"a",
"json",
"reader",
"to",
"a",
"json",
"writer",
"and",
"performs",
"pretty",
"printing",
"."
] |
train
|
https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/core/src/main/java/org/owasp/dependencycheck/reporting/ReportGenerator.java#L429-L477
|
camunda/camunda-bpm-platform
|
engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/hal/HalLinker.java
|
HalLinker.createLink
|
public void createLink(HalRelation rel, String... pathParams) {
"""
Creates a link in a given relation.
@param rel the {@link HalRelation} for which a link should be constructed
@param pathParams the path params to populate the url template with.
"""
if(pathParams != null && pathParams.length > 0 && pathParams[0] != null) {
Set<String> linkedResourceIds = linkedResources.get(rel);
if(linkedResourceIds == null) {
linkedResourceIds = new HashSet<String>();
linkedResources.put(rel, linkedResourceIds);
}
// Hmm... use the last id in the pathParams as linked resource id
linkedResourceIds.add(pathParams[pathParams.length - 1]);
resource.addLink(rel.relName, rel.uriTemplate.build((Object[])pathParams));
}
}
|
java
|
public void createLink(HalRelation rel, String... pathParams) {
if(pathParams != null && pathParams.length > 0 && pathParams[0] != null) {
Set<String> linkedResourceIds = linkedResources.get(rel);
if(linkedResourceIds == null) {
linkedResourceIds = new HashSet<String>();
linkedResources.put(rel, linkedResourceIds);
}
// Hmm... use the last id in the pathParams as linked resource id
linkedResourceIds.add(pathParams[pathParams.length - 1]);
resource.addLink(rel.relName, rel.uriTemplate.build((Object[])pathParams));
}
}
|
[
"public",
"void",
"createLink",
"(",
"HalRelation",
"rel",
",",
"String",
"...",
"pathParams",
")",
"{",
"if",
"(",
"pathParams",
"!=",
"null",
"&&",
"pathParams",
".",
"length",
">",
"0",
"&&",
"pathParams",
"[",
"0",
"]",
"!=",
"null",
")",
"{",
"Set",
"<",
"String",
">",
"linkedResourceIds",
"=",
"linkedResources",
".",
"get",
"(",
"rel",
")",
";",
"if",
"(",
"linkedResourceIds",
"==",
"null",
")",
"{",
"linkedResourceIds",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"linkedResources",
".",
"put",
"(",
"rel",
",",
"linkedResourceIds",
")",
";",
"}",
"// Hmm... use the last id in the pathParams as linked resource id",
"linkedResourceIds",
".",
"add",
"(",
"pathParams",
"[",
"pathParams",
".",
"length",
"-",
"1",
"]",
")",
";",
"resource",
".",
"addLink",
"(",
"rel",
".",
"relName",
",",
"rel",
".",
"uriTemplate",
".",
"build",
"(",
"(",
"Object",
"[",
"]",
")",
"pathParams",
")",
")",
";",
"}",
"}"
] |
Creates a link in a given relation.
@param rel the {@link HalRelation} for which a link should be constructed
@param pathParams the path params to populate the url template with.
|
[
"Creates",
"a",
"link",
"in",
"a",
"given",
"relation",
"."
] |
train
|
https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/hal/HalLinker.java#L55-L68
|
elki-project/elki
|
elki-database/src/main/java/de/lmu/ifi/dbs/elki/database/query/range/LinearScanEuclideanDistanceRangeQuery.java
|
LinearScanEuclideanDistanceRangeQuery.linearScan
|
private void linearScan(Relation<? extends O> relation, DBIDIter iter, O obj, double range, ModifiableDoubleDBIDList result) {
"""
Main loop for linear scan,
@param relation Data relation
@param iter Iterator
@param obj Query object
@param range Query radius
@param result Output data structure
"""
final SquaredEuclideanDistanceFunction squared = SquaredEuclideanDistanceFunction.STATIC;
// Avoid a loss in numerical precision when using the squared radius:
final double upper = range * 1.0000001;
// This should be more precise, but slower:
// upper = MathUtil.floatToDoubleUpper((float)range);
final double sqrange = upper * upper;
while(iter.valid()) {
final double sqdistance = squared.distance(obj, relation.get(iter));
if(sqdistance <= sqrange) {
final double dist = FastMath.sqrt(sqdistance);
if(dist <= range) { // double check, as we increased the radius above
result.add(dist, iter);
}
}
iter.advance();
}
}
|
java
|
private void linearScan(Relation<? extends O> relation, DBIDIter iter, O obj, double range, ModifiableDoubleDBIDList result) {
final SquaredEuclideanDistanceFunction squared = SquaredEuclideanDistanceFunction.STATIC;
// Avoid a loss in numerical precision when using the squared radius:
final double upper = range * 1.0000001;
// This should be more precise, but slower:
// upper = MathUtil.floatToDoubleUpper((float)range);
final double sqrange = upper * upper;
while(iter.valid()) {
final double sqdistance = squared.distance(obj, relation.get(iter));
if(sqdistance <= sqrange) {
final double dist = FastMath.sqrt(sqdistance);
if(dist <= range) { // double check, as we increased the radius above
result.add(dist, iter);
}
}
iter.advance();
}
}
|
[
"private",
"void",
"linearScan",
"(",
"Relation",
"<",
"?",
"extends",
"O",
">",
"relation",
",",
"DBIDIter",
"iter",
",",
"O",
"obj",
",",
"double",
"range",
",",
"ModifiableDoubleDBIDList",
"result",
")",
"{",
"final",
"SquaredEuclideanDistanceFunction",
"squared",
"=",
"SquaredEuclideanDistanceFunction",
".",
"STATIC",
";",
"// Avoid a loss in numerical precision when using the squared radius:",
"final",
"double",
"upper",
"=",
"range",
"*",
"1.0000001",
";",
"// This should be more precise, but slower:",
"// upper = MathUtil.floatToDoubleUpper((float)range);",
"final",
"double",
"sqrange",
"=",
"upper",
"*",
"upper",
";",
"while",
"(",
"iter",
".",
"valid",
"(",
")",
")",
"{",
"final",
"double",
"sqdistance",
"=",
"squared",
".",
"distance",
"(",
"obj",
",",
"relation",
".",
"get",
"(",
"iter",
")",
")",
";",
"if",
"(",
"sqdistance",
"<=",
"sqrange",
")",
"{",
"final",
"double",
"dist",
"=",
"FastMath",
".",
"sqrt",
"(",
"sqdistance",
")",
";",
"if",
"(",
"dist",
"<=",
"range",
")",
"{",
"// double check, as we increased the radius above",
"result",
".",
"add",
"(",
"dist",
",",
"iter",
")",
";",
"}",
"}",
"iter",
".",
"advance",
"(",
")",
";",
"}",
"}"
] |
Main loop for linear scan,
@param relation Data relation
@param iter Iterator
@param obj Query object
@param range Query radius
@param result Output data structure
|
[
"Main",
"loop",
"for",
"linear",
"scan"
] |
train
|
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-database/src/main/java/de/lmu/ifi/dbs/elki/database/query/range/LinearScanEuclideanDistanceRangeQuery.java#L95-L112
|
Jasig/uPortal
|
uPortal-layout/uPortal-layout-impl/src/main/java/org/apereo/portal/layout/simple/RDBMUserLayoutStore.java
|
RDBMUserLayoutStore.getNextStructId
|
protected String getNextStructId(final IPerson person, final String prefix) {
"""
Return the next available structure id for a user
@return next free structure ID
"""
final int userId = person.getID();
return nextStructTransactionOperations.execute(
status ->
jdbcOperations.execute(
new ConnectionCallback<String>() {
@Override
public String doInConnection(Connection con)
throws SQLException, DataAccessException {
try (Statement stmt = con.createStatement()) {
String sQuery =
"SELECT NEXT_STRUCT_ID FROM UP_USER WHERE USER_ID="
+ userId;
logger.debug("getNextStructId(): {}", sQuery);
int currentStructId;
try (ResultSet rs = stmt.executeQuery(sQuery)) {
if (rs.next()) {
currentStructId = rs.getInt(1);
} else {
throw new SQLException(
"no rows returned for query ["
+ sQuery
+ "]");
}
}
int nextStructId = currentStructId + 1;
String sUpdate =
"UPDATE UP_USER SET NEXT_STRUCT_ID="
+ nextStructId
+ " WHERE USER_ID="
+ userId
+ " AND NEXT_STRUCT_ID="
+ currentStructId;
logger.debug("getNextStructId(): {}", sUpdate);
stmt.executeUpdate(sUpdate);
return prefix + nextStructId;
}
}
}));
}
|
java
|
protected String getNextStructId(final IPerson person, final String prefix) {
final int userId = person.getID();
return nextStructTransactionOperations.execute(
status ->
jdbcOperations.execute(
new ConnectionCallback<String>() {
@Override
public String doInConnection(Connection con)
throws SQLException, DataAccessException {
try (Statement stmt = con.createStatement()) {
String sQuery =
"SELECT NEXT_STRUCT_ID FROM UP_USER WHERE USER_ID="
+ userId;
logger.debug("getNextStructId(): {}", sQuery);
int currentStructId;
try (ResultSet rs = stmt.executeQuery(sQuery)) {
if (rs.next()) {
currentStructId = rs.getInt(1);
} else {
throw new SQLException(
"no rows returned for query ["
+ sQuery
+ "]");
}
}
int nextStructId = currentStructId + 1;
String sUpdate =
"UPDATE UP_USER SET NEXT_STRUCT_ID="
+ nextStructId
+ " WHERE USER_ID="
+ userId
+ " AND NEXT_STRUCT_ID="
+ currentStructId;
logger.debug("getNextStructId(): {}", sUpdate);
stmt.executeUpdate(sUpdate);
return prefix + nextStructId;
}
}
}));
}
|
[
"protected",
"String",
"getNextStructId",
"(",
"final",
"IPerson",
"person",
",",
"final",
"String",
"prefix",
")",
"{",
"final",
"int",
"userId",
"=",
"person",
".",
"getID",
"(",
")",
";",
"return",
"nextStructTransactionOperations",
".",
"execute",
"(",
"status",
"->",
"jdbcOperations",
".",
"execute",
"(",
"new",
"ConnectionCallback",
"<",
"String",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"String",
"doInConnection",
"(",
"Connection",
"con",
")",
"throws",
"SQLException",
",",
"DataAccessException",
"{",
"try",
"(",
"Statement",
"stmt",
"=",
"con",
".",
"createStatement",
"(",
")",
")",
"{",
"String",
"sQuery",
"=",
"\"SELECT NEXT_STRUCT_ID FROM UP_USER WHERE USER_ID=\"",
"+",
"userId",
";",
"logger",
".",
"debug",
"(",
"\"getNextStructId(): {}\"",
",",
"sQuery",
")",
";",
"int",
"currentStructId",
";",
"try",
"(",
"ResultSet",
"rs",
"=",
"stmt",
".",
"executeQuery",
"(",
"sQuery",
")",
")",
"{",
"if",
"(",
"rs",
".",
"next",
"(",
")",
")",
"{",
"currentStructId",
"=",
"rs",
".",
"getInt",
"(",
"1",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"SQLException",
"(",
"\"no rows returned for query [\"",
"+",
"sQuery",
"+",
"\"]\"",
")",
";",
"}",
"}",
"int",
"nextStructId",
"=",
"currentStructId",
"+",
"1",
";",
"String",
"sUpdate",
"=",
"\"UPDATE UP_USER SET NEXT_STRUCT_ID=\"",
"+",
"nextStructId",
"+",
"\" WHERE USER_ID=\"",
"+",
"userId",
"+",
"\" AND NEXT_STRUCT_ID=\"",
"+",
"currentStructId",
";",
"logger",
".",
"debug",
"(",
"\"getNextStructId(): {}\"",
",",
"sUpdate",
")",
";",
"stmt",
".",
"executeUpdate",
"(",
"sUpdate",
")",
";",
"return",
"prefix",
"+",
"nextStructId",
";",
"}",
"}",
"}",
")",
")",
";",
"}"
] |
Return the next available structure id for a user
@return next free structure ID
|
[
"Return",
"the",
"next",
"available",
"structure",
"id",
"for",
"a",
"user"
] |
train
|
https://github.com/Jasig/uPortal/blob/c1986542abb9acd214268f2df21c6305ad2f262b/uPortal-layout/uPortal-layout-impl/src/main/java/org/apereo/portal/layout/simple/RDBMUserLayoutStore.java#L367-L407
|
deeplearning4j/deeplearning4j
|
nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/dataset/api/preprocessor/AbstractMultiDataSetNormalizer.java
|
AbstractMultiDataSetNormalizer.revertLabels
|
public void revertLabels(@NonNull INDArray[] labels, INDArray[] labelsMask) {
"""
Undo (revert) the normalization applied by this normalizer to the labels arrays.
If labels normalization is disabled (i.e., {@link #isFitLabel()} == false) then this is a no-op.
Can also be used to undo normalization for network output arrays, in the case of regression.
@param labels Labels arrays to revert the normalization on
"""
for (int i = 0; i < labels.length; i++) {
INDArray mask = (labelsMask == null ? null : labelsMask[i]);
revertLabels(labels[i], mask, i);
}
}
|
java
|
public void revertLabels(@NonNull INDArray[] labels, INDArray[] labelsMask) {
for (int i = 0; i < labels.length; i++) {
INDArray mask = (labelsMask == null ? null : labelsMask[i]);
revertLabels(labels[i], mask, i);
}
}
|
[
"public",
"void",
"revertLabels",
"(",
"@",
"NonNull",
"INDArray",
"[",
"]",
"labels",
",",
"INDArray",
"[",
"]",
"labelsMask",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"labels",
".",
"length",
";",
"i",
"++",
")",
"{",
"INDArray",
"mask",
"=",
"(",
"labelsMask",
"==",
"null",
"?",
"null",
":",
"labelsMask",
"[",
"i",
"]",
")",
";",
"revertLabels",
"(",
"labels",
"[",
"i",
"]",
",",
"mask",
",",
"i",
")",
";",
"}",
"}"
] |
Undo (revert) the normalization applied by this normalizer to the labels arrays.
If labels normalization is disabled (i.e., {@link #isFitLabel()} == false) then this is a no-op.
Can also be used to undo normalization for network output arrays, in the case of regression.
@param labels Labels arrays to revert the normalization on
|
[
"Undo",
"(",
"revert",
")",
"the",
"normalization",
"applied",
"by",
"this",
"normalizer",
"to",
"the",
"labels",
"arrays",
".",
"If",
"labels",
"normalization",
"is",
"disabled",
"(",
"i",
".",
"e",
".",
"{",
"@link",
"#isFitLabel",
"()",
"}",
"==",
"false",
")",
"then",
"this",
"is",
"a",
"no",
"-",
"op",
".",
"Can",
"also",
"be",
"used",
"to",
"undo",
"normalization",
"for",
"network",
"output",
"arrays",
"in",
"the",
"case",
"of",
"regression",
"."
] |
train
|
https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/dataset/api/preprocessor/AbstractMultiDataSetNormalizer.java#L257-L262
|
ehcache/ehcache3
|
impl/src/main/java/org/ehcache/impl/internal/resilience/RobustResilienceStrategy.java
|
RobustResilienceStrategy.removeAllFailure
|
@Override
public void removeAllFailure(Iterable<? extends K> keys, StoreAccessException e) {
"""
Do nothing.
@param keys the keys being removed
@param e the triggered failure
"""
cleanup(keys, e);
}
|
java
|
@Override
public void removeAllFailure(Iterable<? extends K> keys, StoreAccessException e) {
cleanup(keys, e);
}
|
[
"@",
"Override",
"public",
"void",
"removeAllFailure",
"(",
"Iterable",
"<",
"?",
"extends",
"K",
">",
"keys",
",",
"StoreAccessException",
"e",
")",
"{",
"cleanup",
"(",
"keys",
",",
"e",
")",
";",
"}"
] |
Do nothing.
@param keys the keys being removed
@param e the triggered failure
|
[
"Do",
"nothing",
"."
] |
train
|
https://github.com/ehcache/ehcache3/blob/3cceda57185e522f8d241ddb75146d67ee2af898/impl/src/main/java/org/ehcache/impl/internal/resilience/RobustResilienceStrategy.java#L198-L201
|
linroid/FilterMenu
|
library/src/main/java/com/linroid/filtermenu/library/FilterMenuLayout.java
|
FilterMenuLayout.isClockwise
|
private boolean isClockwise(Point center, Point a, Point b) {
"""
judge a->b is ordered clockwise
@param center
@param a
@param b
@return
"""
double cross = (a.x - center.x) * (b.y - center.y) - (b.x - center.x) * (a.y - center.y);
return cross > 0;
}
|
java
|
private boolean isClockwise(Point center, Point a, Point b) {
double cross = (a.x - center.x) * (b.y - center.y) - (b.x - center.x) * (a.y - center.y);
return cross > 0;
}
|
[
"private",
"boolean",
"isClockwise",
"(",
"Point",
"center",
",",
"Point",
"a",
",",
"Point",
"b",
")",
"{",
"double",
"cross",
"=",
"(",
"a",
".",
"x",
"-",
"center",
".",
"x",
")",
"*",
"(",
"b",
".",
"y",
"-",
"center",
".",
"y",
")",
"-",
"(",
"b",
".",
"x",
"-",
"center",
".",
"x",
")",
"*",
"(",
"a",
".",
"y",
"-",
"center",
".",
"y",
")",
";",
"return",
"cross",
">",
"0",
";",
"}"
] |
judge a->b is ordered clockwise
@param center
@param a
@param b
@return
|
[
"judge",
"a",
"-",
">",
"b",
"is",
"ordered",
"clockwise"
] |
train
|
https://github.com/linroid/FilterMenu/blob/5a6e5472631c2304b71a51034683f38271962ef5/library/src/main/java/com/linroid/filtermenu/library/FilterMenuLayout.java#L748-L751
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.jsp/src/com/ibm/ws/jsp/translator/document/XMLEncodingDetector.java
|
XMLEncodingDetector.scanSurrogates
|
private boolean scanSurrogates(XMLStringBuffer buf)
throws IOException, JspCoreException {
"""
Scans surrogates and append them to the specified buffer.
<p>
<strong>Note:</strong> This assumes the current char has already been
identified as a high surrogate.
@param buf The StringBuffer to append the read surrogates to.
@returns True if it succeeded.
"""
int high = scanChar();
int low = peekChar();
if (!XMLChar.isLowSurrogate(low)) {
throw new JspCoreException("jsp.error.xml.invalidCharInContent", new Object[] { Integer.toString(high, 16) });
//err.jspError("jsp.error.xml.invalidCharInContent", Integer.toString(high, 16));
//return false;
}
scanChar();
// convert surrogates to supplemental character
int c = XMLChar.supplemental((char)high, (char)low);
// supplemental character must be a valid XML character
if (!XMLChar.isValid(c)) {
throw new JspCoreException("jsp.error.xml.invalidCharInContent", new Object[] { Integer.toString(c, 16) });
//err.jspError("jsp.error.xml.invalidCharInContent", Integer.toString(c, 16));
//return false;
}
// fill in the buffer
buf.append((char)high);
buf.append((char)low);
return true;
}
|
java
|
private boolean scanSurrogates(XMLStringBuffer buf)
throws IOException, JspCoreException {
int high = scanChar();
int low = peekChar();
if (!XMLChar.isLowSurrogate(low)) {
throw new JspCoreException("jsp.error.xml.invalidCharInContent", new Object[] { Integer.toString(high, 16) });
//err.jspError("jsp.error.xml.invalidCharInContent", Integer.toString(high, 16));
//return false;
}
scanChar();
// convert surrogates to supplemental character
int c = XMLChar.supplemental((char)high, (char)low);
// supplemental character must be a valid XML character
if (!XMLChar.isValid(c)) {
throw new JspCoreException("jsp.error.xml.invalidCharInContent", new Object[] { Integer.toString(c, 16) });
//err.jspError("jsp.error.xml.invalidCharInContent", Integer.toString(c, 16));
//return false;
}
// fill in the buffer
buf.append((char)high);
buf.append((char)low);
return true;
}
|
[
"private",
"boolean",
"scanSurrogates",
"(",
"XMLStringBuffer",
"buf",
")",
"throws",
"IOException",
",",
"JspCoreException",
"{",
"int",
"high",
"=",
"scanChar",
"(",
")",
";",
"int",
"low",
"=",
"peekChar",
"(",
")",
";",
"if",
"(",
"!",
"XMLChar",
".",
"isLowSurrogate",
"(",
"low",
")",
")",
"{",
"throw",
"new",
"JspCoreException",
"(",
"\"jsp.error.xml.invalidCharInContent\"",
",",
"new",
"Object",
"[",
"]",
"{",
"Integer",
".",
"toString",
"(",
"high",
",",
"16",
")",
"}",
")",
";",
"//err.jspError(\"jsp.error.xml.invalidCharInContent\", Integer.toString(high, 16));",
"//return false;",
"}",
"scanChar",
"(",
")",
";",
"// convert surrogates to supplemental character",
"int",
"c",
"=",
"XMLChar",
".",
"supplemental",
"(",
"(",
"char",
")",
"high",
",",
"(",
"char",
")",
"low",
")",
";",
"// supplemental character must be a valid XML character",
"if",
"(",
"!",
"XMLChar",
".",
"isValid",
"(",
"c",
")",
")",
"{",
"throw",
"new",
"JspCoreException",
"(",
"\"jsp.error.xml.invalidCharInContent\"",
",",
"new",
"Object",
"[",
"]",
"{",
"Integer",
".",
"toString",
"(",
"c",
",",
"16",
")",
"}",
")",
";",
"//err.jspError(\"jsp.error.xml.invalidCharInContent\", Integer.toString(c, 16)); ",
"//return false;",
"}",
"// fill in the buffer",
"buf",
".",
"append",
"(",
"(",
"char",
")",
"high",
")",
";",
"buf",
".",
"append",
"(",
"(",
"char",
")",
"low",
")",
";",
"return",
"true",
";",
"}"
] |
Scans surrogates and append them to the specified buffer.
<p>
<strong>Note:</strong> This assumes the current char has already been
identified as a high surrogate.
@param buf The StringBuffer to append the read surrogates to.
@returns True if it succeeded.
|
[
"Scans",
"surrogates",
"and",
"append",
"them",
"to",
"the",
"specified",
"buffer",
".",
"<p",
">",
"<strong",
">",
"Note",
":",
"<",
"/",
"strong",
">",
"This",
"assumes",
"the",
"current",
"char",
"has",
"already",
"been",
"identified",
"as",
"a",
"high",
"surrogate",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jsp/src/com/ibm/ws/jsp/translator/document/XMLEncodingDetector.java#L1594-L1622
|
jbundle/jbundle
|
base/base/src/main/java/org/jbundle/base/field/convert/MergeConverter.java
|
MergeConverter.setString
|
public int setString(String strString, boolean bDisplayOption, int iMoveMode) // init this field override for other value {
"""
Convert and move string to this field.
Set the current string of the current next converter..
@param strString the state to set the data to.
@param bDisplayOption Display the data on the screen if true.
@param iMoveMode INIT, SCREEN, or READ move mode.
@return The error code (or NORMAL_RETURN).
"""
if (this.getNextConverter() != null)
return this.getNextConverter().setString(strString, bDisplayOption, iMoveMode);
else
return super.setString(strString, bDisplayOption, iMoveMode);
}
|
java
|
public int setString(String strString, boolean bDisplayOption, int iMoveMode) // init this field override for other value
{
if (this.getNextConverter() != null)
return this.getNextConverter().setString(strString, bDisplayOption, iMoveMode);
else
return super.setString(strString, bDisplayOption, iMoveMode);
}
|
[
"public",
"int",
"setString",
"(",
"String",
"strString",
",",
"boolean",
"bDisplayOption",
",",
"int",
"iMoveMode",
")",
"// init this field override for other value",
"{",
"if",
"(",
"this",
".",
"getNextConverter",
"(",
")",
"!=",
"null",
")",
"return",
"this",
".",
"getNextConverter",
"(",
")",
".",
"setString",
"(",
"strString",
",",
"bDisplayOption",
",",
"iMoveMode",
")",
";",
"else",
"return",
"super",
".",
"setString",
"(",
"strString",
",",
"bDisplayOption",
",",
"iMoveMode",
")",
";",
"}"
] |
Convert and move string to this field.
Set the current string of the current next converter..
@param strString the state to set the data to.
@param bDisplayOption Display the data on the screen if true.
@param iMoveMode INIT, SCREEN, or READ move mode.
@return The error code (or NORMAL_RETURN).
|
[
"Convert",
"and",
"move",
"string",
"to",
"this",
"field",
".",
"Set",
"the",
"current",
"string",
"of",
"the",
"current",
"next",
"converter",
".."
] |
train
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/convert/MergeConverter.java#L153-L159
|
sarl/sarl
|
contribs/io.sarl.pythongenerator/io.sarl.pythongenerator.generator/src/io/sarl/pythongenerator/generator/generator/PyGenerator.java
|
PyGenerator._generate
|
protected void _generate(SarlSkill skill, IExtraLanguageGeneratorContext context) {
"""
Generate the given object.
@param skill the skill.
@param context the context.
"""
final JvmDeclaredType jvmType = getJvmModelAssociations().getInferredType(skill);
final PyAppendable appendable = createAppendable(jvmType, context);
List<JvmTypeReference> superTypes = getSuperTypes(skill.getExtends(), skill.getImplements());
if (superTypes.isEmpty()) {
superTypes = Collections.singletonList(getTypeReferences().getTypeForName(Skill.class, skill));
}
final String qualifiedName = this.qualifiedNameProvider.getFullyQualifiedName(skill).toString();
if (generateTypeDeclaration(
qualifiedName,
skill.getName(), skill.isAbstract(), superTypes,
getTypeBuilder().getDocumentation(skill),
true,
skill.getMembers(), appendable, context, (it, context2) -> {
generateGuardEvaluators(qualifiedName, it, context2);
})) {
final QualifiedName name = getQualifiedNameProvider().getFullyQualifiedName(skill);
writeFile(name, appendable, context);
}
}
|
java
|
protected void _generate(SarlSkill skill, IExtraLanguageGeneratorContext context) {
final JvmDeclaredType jvmType = getJvmModelAssociations().getInferredType(skill);
final PyAppendable appendable = createAppendable(jvmType, context);
List<JvmTypeReference> superTypes = getSuperTypes(skill.getExtends(), skill.getImplements());
if (superTypes.isEmpty()) {
superTypes = Collections.singletonList(getTypeReferences().getTypeForName(Skill.class, skill));
}
final String qualifiedName = this.qualifiedNameProvider.getFullyQualifiedName(skill).toString();
if (generateTypeDeclaration(
qualifiedName,
skill.getName(), skill.isAbstract(), superTypes,
getTypeBuilder().getDocumentation(skill),
true,
skill.getMembers(), appendable, context, (it, context2) -> {
generateGuardEvaluators(qualifiedName, it, context2);
})) {
final QualifiedName name = getQualifiedNameProvider().getFullyQualifiedName(skill);
writeFile(name, appendable, context);
}
}
|
[
"protected",
"void",
"_generate",
"(",
"SarlSkill",
"skill",
",",
"IExtraLanguageGeneratorContext",
"context",
")",
"{",
"final",
"JvmDeclaredType",
"jvmType",
"=",
"getJvmModelAssociations",
"(",
")",
".",
"getInferredType",
"(",
"skill",
")",
";",
"final",
"PyAppendable",
"appendable",
"=",
"createAppendable",
"(",
"jvmType",
",",
"context",
")",
";",
"List",
"<",
"JvmTypeReference",
">",
"superTypes",
"=",
"getSuperTypes",
"(",
"skill",
".",
"getExtends",
"(",
")",
",",
"skill",
".",
"getImplements",
"(",
")",
")",
";",
"if",
"(",
"superTypes",
".",
"isEmpty",
"(",
")",
")",
"{",
"superTypes",
"=",
"Collections",
".",
"singletonList",
"(",
"getTypeReferences",
"(",
")",
".",
"getTypeForName",
"(",
"Skill",
".",
"class",
",",
"skill",
")",
")",
";",
"}",
"final",
"String",
"qualifiedName",
"=",
"this",
".",
"qualifiedNameProvider",
".",
"getFullyQualifiedName",
"(",
"skill",
")",
".",
"toString",
"(",
")",
";",
"if",
"(",
"generateTypeDeclaration",
"(",
"qualifiedName",
",",
"skill",
".",
"getName",
"(",
")",
",",
"skill",
".",
"isAbstract",
"(",
")",
",",
"superTypes",
",",
"getTypeBuilder",
"(",
")",
".",
"getDocumentation",
"(",
"skill",
")",
",",
"true",
",",
"skill",
".",
"getMembers",
"(",
")",
",",
"appendable",
",",
"context",
",",
"(",
"it",
",",
"context2",
")",
"->",
"{",
"generateGuardEvaluators",
"(",
"qualifiedName",
",",
"it",
",",
"context2",
")",
";",
"}",
")",
")",
"{",
"final",
"QualifiedName",
"name",
"=",
"getQualifiedNameProvider",
"(",
")",
".",
"getFullyQualifiedName",
"(",
"skill",
")",
";",
"writeFile",
"(",
"name",
",",
"appendable",
",",
"context",
")",
";",
"}",
"}"
] |
Generate the given object.
@param skill the skill.
@param context the context.
|
[
"Generate",
"the",
"given",
"object",
"."
] |
train
|
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/contribs/io.sarl.pythongenerator/io.sarl.pythongenerator.generator/src/io/sarl/pythongenerator/generator/generator/PyGenerator.java#L850-L870
|
deeplearning4j/deeplearning4j
|
nd4j/nd4j-common/src/main/java/org/nd4j/util/ArchiveUtils.java
|
ArchiveUtils.zipExtractSingleFile
|
public static void zipExtractSingleFile(File zipFile, File destination, String pathInZip) throws IOException {
"""
Extract a single file from a .zip file. Does not support directories
@param zipFile Zip file to extract from
@param destination Destination file
@param pathInZip Path in the zip to extract
@throws IOException If exception occurs while reading/writing
"""
try (ZipFile zf = new ZipFile(zipFile); InputStream is = new BufferedInputStream(zf.getInputStream(zf.getEntry(pathInZip)));
OutputStream os = new BufferedOutputStream(new FileOutputStream(destination))) {
IOUtils.copy(is, os);
}
}
|
java
|
public static void zipExtractSingleFile(File zipFile, File destination, String pathInZip) throws IOException {
try (ZipFile zf = new ZipFile(zipFile); InputStream is = new BufferedInputStream(zf.getInputStream(zf.getEntry(pathInZip)));
OutputStream os = new BufferedOutputStream(new FileOutputStream(destination))) {
IOUtils.copy(is, os);
}
}
|
[
"public",
"static",
"void",
"zipExtractSingleFile",
"(",
"File",
"zipFile",
",",
"File",
"destination",
",",
"String",
"pathInZip",
")",
"throws",
"IOException",
"{",
"try",
"(",
"ZipFile",
"zf",
"=",
"new",
"ZipFile",
"(",
"zipFile",
")",
";",
"InputStream",
"is",
"=",
"new",
"BufferedInputStream",
"(",
"zf",
".",
"getInputStream",
"(",
"zf",
".",
"getEntry",
"(",
"pathInZip",
")",
")",
")",
";",
"OutputStream",
"os",
"=",
"new",
"BufferedOutputStream",
"(",
"new",
"FileOutputStream",
"(",
"destination",
")",
")",
")",
"{",
"IOUtils",
".",
"copy",
"(",
"is",
",",
"os",
")",
";",
"}",
"}"
] |
Extract a single file from a .zip file. Does not support directories
@param zipFile Zip file to extract from
@param destination Destination file
@param pathInZip Path in the zip to extract
@throws IOException If exception occurs while reading/writing
|
[
"Extract",
"a",
"single",
"file",
"from",
"a",
".",
"zip",
"file",
".",
"Does",
"not",
"support",
"directories"
] |
train
|
https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-common/src/main/java/org/nd4j/util/ArchiveUtils.java#L202-L207
|
versionone/VersionOne.SDK.Java.ObjectModel
|
src/main/java/com/versionone/om/Request.java
|
Request.generateDefect
|
public Defect generateDefect(Map<String, Object> attributes) {
"""
Creates a Defect from this Request.
@param attributes additional attributes for the Defect.
@return A Defect in the VersionOne system related to this Issue.
"""
Defect result = getInstance().createNew(Defect.class, this);
getInstance().create().addAttributes(result, attributes);
result.save();
return result;
}
|
java
|
public Defect generateDefect(Map<String, Object> attributes) {
Defect result = getInstance().createNew(Defect.class, this);
getInstance().create().addAttributes(result, attributes);
result.save();
return result;
}
|
[
"public",
"Defect",
"generateDefect",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"attributes",
")",
"{",
"Defect",
"result",
"=",
"getInstance",
"(",
")",
".",
"createNew",
"(",
"Defect",
".",
"class",
",",
"this",
")",
";",
"getInstance",
"(",
")",
".",
"create",
"(",
")",
".",
"addAttributes",
"(",
"result",
",",
"attributes",
")",
";",
"result",
".",
"save",
"(",
")",
";",
"return",
"result",
";",
"}"
] |
Creates a Defect from this Request.
@param attributes additional attributes for the Defect.
@return A Defect in the VersionOne system related to this Issue.
|
[
"Creates",
"a",
"Defect",
"from",
"this",
"Request",
"."
] |
train
|
https://github.com/versionone/VersionOne.SDK.Java.ObjectModel/blob/59d35b67c849299631bca45ee94143237eb2ae1a/src/main/java/com/versionone/om/Request.java#L238-L243
|
petergeneric/stdlib
|
guice/common/src/main/java/com/peterphi/std/guice/restclient/resteasy/impl/ResteasyClientFactoryImpl.java
|
ResteasyClientFactoryImpl.getOrCreateClient
|
public ResteasyClient getOrCreateClient(final boolean fastFail,
final AuthScope authScope,
final Credentials credentials,
final boolean preemptiveAuth,
final boolean storeCookies,
Consumer<HttpClientBuilder> customiser) {
"""
Build a new Resteasy Client, optionally with authentication credentials
@param fastFail
if true, use fast fail timeouts, otherwise false to use default timeouts
@param authScope
the auth scope to use - if null then defaults to <code>AuthScope.ANY</code>
@param credentials
the credentials to use (optional, e.g. {@link org.apache.http.auth.UsernamePasswordCredentials})
@param customiser
optional HttpClientBuilder customiser.
@return
"""
customiser = createHttpClientCustomiser(fastFail, authScope, credentials, preemptiveAuth, storeCookies, customiser);
return getOrCreateClient(customiser, null);
}
|
java
|
public ResteasyClient getOrCreateClient(final boolean fastFail,
final AuthScope authScope,
final Credentials credentials,
final boolean preemptiveAuth,
final boolean storeCookies,
Consumer<HttpClientBuilder> customiser)
{
customiser = createHttpClientCustomiser(fastFail, authScope, credentials, preemptiveAuth, storeCookies, customiser);
return getOrCreateClient(customiser, null);
}
|
[
"public",
"ResteasyClient",
"getOrCreateClient",
"(",
"final",
"boolean",
"fastFail",
",",
"final",
"AuthScope",
"authScope",
",",
"final",
"Credentials",
"credentials",
",",
"final",
"boolean",
"preemptiveAuth",
",",
"final",
"boolean",
"storeCookies",
",",
"Consumer",
"<",
"HttpClientBuilder",
">",
"customiser",
")",
"{",
"customiser",
"=",
"createHttpClientCustomiser",
"(",
"fastFail",
",",
"authScope",
",",
"credentials",
",",
"preemptiveAuth",
",",
"storeCookies",
",",
"customiser",
")",
";",
"return",
"getOrCreateClient",
"(",
"customiser",
",",
"null",
")",
";",
"}"
] |
Build a new Resteasy Client, optionally with authentication credentials
@param fastFail
if true, use fast fail timeouts, otherwise false to use default timeouts
@param authScope
the auth scope to use - if null then defaults to <code>AuthScope.ANY</code>
@param credentials
the credentials to use (optional, e.g. {@link org.apache.http.auth.UsernamePasswordCredentials})
@param customiser
optional HttpClientBuilder customiser.
@return
|
[
"Build",
"a",
"new",
"Resteasy",
"Client",
"optionally",
"with",
"authentication",
"credentials"
] |
train
|
https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/common/src/main/java/com/peterphi/std/guice/restclient/resteasy/impl/ResteasyClientFactoryImpl.java#L140-L151
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMResources.java
|
JMResources.getStringWithClasspathOrFilePath
|
public static String getStringWithClasspathOrFilePath(
String classpathOrFilePath, String charsetName) {
"""
Gets string with classpath or file path.
@param classpathOrFilePath the classpath or file path
@param charsetName the charset name
@return the string with classpath or file path
"""
return getStringAsOptWithClasspath(classpathOrFilePath, charsetName)
.orElseGet(() -> getStringAsOptWithFilePath
(classpathOrFilePath, charsetName).orElse(null));
}
|
java
|
public static String getStringWithClasspathOrFilePath(
String classpathOrFilePath, String charsetName) {
return getStringAsOptWithClasspath(classpathOrFilePath, charsetName)
.orElseGet(() -> getStringAsOptWithFilePath
(classpathOrFilePath, charsetName).orElse(null));
}
|
[
"public",
"static",
"String",
"getStringWithClasspathOrFilePath",
"(",
"String",
"classpathOrFilePath",
",",
"String",
"charsetName",
")",
"{",
"return",
"getStringAsOptWithClasspath",
"(",
"classpathOrFilePath",
",",
"charsetName",
")",
".",
"orElseGet",
"(",
"(",
")",
"->",
"getStringAsOptWithFilePath",
"(",
"classpathOrFilePath",
",",
"charsetName",
")",
".",
"orElse",
"(",
"null",
")",
")",
";",
"}"
] |
Gets string with classpath or file path.
@param classpathOrFilePath the classpath or file path
@param charsetName the charset name
@return the string with classpath or file path
|
[
"Gets",
"string",
"with",
"classpath",
"or",
"file",
"path",
"."
] |
train
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMResources.java#L352-L357
|
apache/groovy
|
src/main/groovy/groovy/util/FactoryBuilderSupport.java
|
FactoryBuilderSupport.doInvokeMethod
|
private Object doInvokeMethod(String methodName, Object name, Object args) {
"""
This method is the workhorse of the builder.
@param methodName the name of the method being invoked
@param name the name of the node
@param args the arguments passed into the node
@return the object from the factory
"""
Reference explicitResult = new Reference();
if (checkExplicitMethod(methodName, args, explicitResult)) {
return explicitResult.get();
} else {
try {
return dispatchNodeCall(name, args);
} catch(MissingMethodException mme) {
if(mme.getMethod().equals(methodName) && methodMissingDelegate != null) {
return methodMissingDelegate.call(methodName, args);
}
throw mme;
}
}
}
|
java
|
private Object doInvokeMethod(String methodName, Object name, Object args) {
Reference explicitResult = new Reference();
if (checkExplicitMethod(methodName, args, explicitResult)) {
return explicitResult.get();
} else {
try {
return dispatchNodeCall(name, args);
} catch(MissingMethodException mme) {
if(mme.getMethod().equals(methodName) && methodMissingDelegate != null) {
return methodMissingDelegate.call(methodName, args);
}
throw mme;
}
}
}
|
[
"private",
"Object",
"doInvokeMethod",
"(",
"String",
"methodName",
",",
"Object",
"name",
",",
"Object",
"args",
")",
"{",
"Reference",
"explicitResult",
"=",
"new",
"Reference",
"(",
")",
";",
"if",
"(",
"checkExplicitMethod",
"(",
"methodName",
",",
"args",
",",
"explicitResult",
")",
")",
"{",
"return",
"explicitResult",
".",
"get",
"(",
")",
";",
"}",
"else",
"{",
"try",
"{",
"return",
"dispatchNodeCall",
"(",
"name",
",",
"args",
")",
";",
"}",
"catch",
"(",
"MissingMethodException",
"mme",
")",
"{",
"if",
"(",
"mme",
".",
"getMethod",
"(",
")",
".",
"equals",
"(",
"methodName",
")",
"&&",
"methodMissingDelegate",
"!=",
"null",
")",
"{",
"return",
"methodMissingDelegate",
".",
"call",
"(",
"methodName",
",",
"args",
")",
";",
"}",
"throw",
"mme",
";",
"}",
"}",
"}"
] |
This method is the workhorse of the builder.
@param methodName the name of the method being invoked
@param name the name of the node
@param args the arguments passed into the node
@return the object from the factory
|
[
"This",
"method",
"is",
"the",
"workhorse",
"of",
"the",
"builder",
"."
] |
train
|
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/FactoryBuilderSupport.java#L782-L796
|
wisdom-framework/wisdom
|
extensions/wisdom-npm-runner-maven-plugin/src/main/java/org/wisdom/mojo/npm/NpmRunnerMojo.java
|
NpmRunnerMojo.fileCreated
|
@Override
public boolean fileCreated(File file) throws WatchingException {
"""
An accepted file was created - executes the NPM.
@param file is the file.
@return {@code true}
@throws org.wisdom.maven.WatchingException if the execution fails.
"""
try {
execute();
} catch (MojoExecutionException e) {
throw new WatchingException("Cannot execute the NPM '" + name + "'", e);
}
return true;
}
|
java
|
@Override
public boolean fileCreated(File file) throws WatchingException {
try {
execute();
} catch (MojoExecutionException e) {
throw new WatchingException("Cannot execute the NPM '" + name + "'", e);
}
return true;
}
|
[
"@",
"Override",
"public",
"boolean",
"fileCreated",
"(",
"File",
"file",
")",
"throws",
"WatchingException",
"{",
"try",
"{",
"execute",
"(",
")",
";",
"}",
"catch",
"(",
"MojoExecutionException",
"e",
")",
"{",
"throw",
"new",
"WatchingException",
"(",
"\"Cannot execute the NPM '\"",
"+",
"name",
"+",
"\"'\"",
",",
"e",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
An accepted file was created - executes the NPM.
@param file is the file.
@return {@code true}
@throws org.wisdom.maven.WatchingException if the execution fails.
|
[
"An",
"accepted",
"file",
"was",
"created",
"-",
"executes",
"the",
"NPM",
"."
] |
train
|
https://github.com/wisdom-framework/wisdom/blob/a35b6431200fec56b178c0ff60837ed73fd7874d/extensions/wisdom-npm-runner-maven-plugin/src/main/java/org/wisdom/mojo/npm/NpmRunnerMojo.java#L107-L115
|
lazy-koala/java-toolkit
|
fast-toolkit3d/src/main/java/com/thankjava/toolkit3d/core/ehcache/EhcacheManager.java
|
EhcacheManager.setCache
|
public void setCache(String cacheName, String cacheKey, Object object) {
"""
设置缓存
<p>Function: setCache</p>
<p>Description: </p>
@param cacheName 缓存名 ehcache.xml 里面配置的缓存策略
@param cacheKey 缓存key
@param object
@author [email protected]
@date 2016年4月18日 下午5:41:37
@version 1.0
"""
Cache cache = cacheManager.getCache(cacheName);
if (cache == null) {
return;
}
cache.put(new Element(cacheKey, object));
}
|
java
|
public void setCache(String cacheName, String cacheKey, Object object) {
Cache cache = cacheManager.getCache(cacheName);
if (cache == null) {
return;
}
cache.put(new Element(cacheKey, object));
}
|
[
"public",
"void",
"setCache",
"(",
"String",
"cacheName",
",",
"String",
"cacheKey",
",",
"Object",
"object",
")",
"{",
"Cache",
"cache",
"=",
"cacheManager",
".",
"getCache",
"(",
"cacheName",
")",
";",
"if",
"(",
"cache",
"==",
"null",
")",
"{",
"return",
";",
"}",
"cache",
".",
"put",
"(",
"new",
"Element",
"(",
"cacheKey",
",",
"object",
")",
")",
";",
"}"
] |
设置缓存
<p>Function: setCache</p>
<p>Description: </p>
@param cacheName 缓存名 ehcache.xml 里面配置的缓存策略
@param cacheKey 缓存key
@param object
@author [email protected]
@date 2016年4月18日 下午5:41:37
@version 1.0
|
[
"设置缓存",
"<p",
">",
"Function",
":",
"setCache<",
"/",
"p",
">",
"<p",
">",
"Description",
":",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/lazy-koala/java-toolkit/blob/f46055fae0cc73049597a3708e515f5c6582d27a/fast-toolkit3d/src/main/java/com/thankjava/toolkit3d/core/ehcache/EhcacheManager.java#L33-L39
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapConnection.java
|
LdapConnection.getNameParser
|
public NameParser getNameParser() throws WIMException {
"""
Retrieves the parser associated with the root context.
@return The {@link NameParser}.
@throws WIMException If the {@link NameParser} could not be queried from the LDAP server.
"""
if (iNameParser == null) {
TimedDirContext ctx = iContextManager.getDirContext();
try {
try {
iNameParser = ctx.getNameParser("");
} catch (NamingException e) {
if (!ContextManager.isConnectionException(e)) {
throw e;
}
ctx = iContextManager.reCreateDirContext(ctx, e.toString());
iNameParser = ctx.getNameParser("");
}
} catch (NamingException e) {
String msg = Tr.formatMessage(tc, WIMMessageKey.NAMING_EXCEPTION, WIMMessageHelper.generateMsgParms(e.toString(true)), e);
throw new WIMSystemException(WIMMessageKey.NAMING_EXCEPTION, msg, e);
} finally {
iContextManager.releaseDirContext(ctx);
}
}
return iNameParser;
}
|
java
|
public NameParser getNameParser() throws WIMException {
if (iNameParser == null) {
TimedDirContext ctx = iContextManager.getDirContext();
try {
try {
iNameParser = ctx.getNameParser("");
} catch (NamingException e) {
if (!ContextManager.isConnectionException(e)) {
throw e;
}
ctx = iContextManager.reCreateDirContext(ctx, e.toString());
iNameParser = ctx.getNameParser("");
}
} catch (NamingException e) {
String msg = Tr.formatMessage(tc, WIMMessageKey.NAMING_EXCEPTION, WIMMessageHelper.generateMsgParms(e.toString(true)), e);
throw new WIMSystemException(WIMMessageKey.NAMING_EXCEPTION, msg, e);
} finally {
iContextManager.releaseDirContext(ctx);
}
}
return iNameParser;
}
|
[
"public",
"NameParser",
"getNameParser",
"(",
")",
"throws",
"WIMException",
"{",
"if",
"(",
"iNameParser",
"==",
"null",
")",
"{",
"TimedDirContext",
"ctx",
"=",
"iContextManager",
".",
"getDirContext",
"(",
")",
";",
"try",
"{",
"try",
"{",
"iNameParser",
"=",
"ctx",
".",
"getNameParser",
"(",
"\"\"",
")",
";",
"}",
"catch",
"(",
"NamingException",
"e",
")",
"{",
"if",
"(",
"!",
"ContextManager",
".",
"isConnectionException",
"(",
"e",
")",
")",
"{",
"throw",
"e",
";",
"}",
"ctx",
"=",
"iContextManager",
".",
"reCreateDirContext",
"(",
"ctx",
",",
"e",
".",
"toString",
"(",
")",
")",
";",
"iNameParser",
"=",
"ctx",
".",
"getNameParser",
"(",
"\"\"",
")",
";",
"}",
"}",
"catch",
"(",
"NamingException",
"e",
")",
"{",
"String",
"msg",
"=",
"Tr",
".",
"formatMessage",
"(",
"tc",
",",
"WIMMessageKey",
".",
"NAMING_EXCEPTION",
",",
"WIMMessageHelper",
".",
"generateMsgParms",
"(",
"e",
".",
"toString",
"(",
"true",
")",
")",
",",
"e",
")",
";",
"throw",
"new",
"WIMSystemException",
"(",
"WIMMessageKey",
".",
"NAMING_EXCEPTION",
",",
"msg",
",",
"e",
")",
";",
"}",
"finally",
"{",
"iContextManager",
".",
"releaseDirContext",
"(",
"ctx",
")",
";",
"}",
"}",
"return",
"iNameParser",
";",
"}"
] |
Retrieves the parser associated with the root context.
@return The {@link NameParser}.
@throws WIMException If the {@link NameParser} could not be queried from the LDAP server.
|
[
"Retrieves",
"the",
"parser",
"associated",
"with",
"the",
"root",
"context",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapConnection.java#L270-L291
|
google/closure-templates
|
java/src/com/google/template/soy/sharedpasses/render/RenderVisitorAssistantForMsgs.java
|
RenderVisitorAssistantForMsgs.renderMsgFromTranslation
|
private void renderMsgFromTranslation(
MsgNode msg, ImmutableList<SoyMsgPart> msgParts, @Nullable ULocale locale) {
"""
Private helper for visitMsgFallbackGroupNode() to render a message from its translation.
"""
SoyMsgPart firstPart = msgParts.get(0);
if (firstPart instanceof SoyMsgPluralPart) {
new PlrselMsgPartsVisitor(msg, locale).visitPart((SoyMsgPluralPart) firstPart);
} else if (firstPart instanceof SoyMsgSelectPart) {
new PlrselMsgPartsVisitor(msg, locale).visitPart((SoyMsgSelectPart) firstPart);
} else {
for (SoyMsgPart msgPart : msgParts) {
if (msgPart instanceof SoyMsgRawTextPart) {
RenderVisitor.append(
master.getCurrOutputBufForUseByAssistants(),
((SoyMsgRawTextPart) msgPart).getRawText());
} else if (msgPart instanceof SoyMsgPlaceholderPart) {
String placeholderName = ((SoyMsgPlaceholderPart) msgPart).getPlaceholderName();
visit(msg.getRepPlaceholderNode(placeholderName));
} else {
throw new AssertionError();
}
}
}
}
|
java
|
private void renderMsgFromTranslation(
MsgNode msg, ImmutableList<SoyMsgPart> msgParts, @Nullable ULocale locale) {
SoyMsgPart firstPart = msgParts.get(0);
if (firstPart instanceof SoyMsgPluralPart) {
new PlrselMsgPartsVisitor(msg, locale).visitPart((SoyMsgPluralPart) firstPart);
} else if (firstPart instanceof SoyMsgSelectPart) {
new PlrselMsgPartsVisitor(msg, locale).visitPart((SoyMsgSelectPart) firstPart);
} else {
for (SoyMsgPart msgPart : msgParts) {
if (msgPart instanceof SoyMsgRawTextPart) {
RenderVisitor.append(
master.getCurrOutputBufForUseByAssistants(),
((SoyMsgRawTextPart) msgPart).getRawText());
} else if (msgPart instanceof SoyMsgPlaceholderPart) {
String placeholderName = ((SoyMsgPlaceholderPart) msgPart).getPlaceholderName();
visit(msg.getRepPlaceholderNode(placeholderName));
} else {
throw new AssertionError();
}
}
}
}
|
[
"private",
"void",
"renderMsgFromTranslation",
"(",
"MsgNode",
"msg",
",",
"ImmutableList",
"<",
"SoyMsgPart",
">",
"msgParts",
",",
"@",
"Nullable",
"ULocale",
"locale",
")",
"{",
"SoyMsgPart",
"firstPart",
"=",
"msgParts",
".",
"get",
"(",
"0",
")",
";",
"if",
"(",
"firstPart",
"instanceof",
"SoyMsgPluralPart",
")",
"{",
"new",
"PlrselMsgPartsVisitor",
"(",
"msg",
",",
"locale",
")",
".",
"visitPart",
"(",
"(",
"SoyMsgPluralPart",
")",
"firstPart",
")",
";",
"}",
"else",
"if",
"(",
"firstPart",
"instanceof",
"SoyMsgSelectPart",
")",
"{",
"new",
"PlrselMsgPartsVisitor",
"(",
"msg",
",",
"locale",
")",
".",
"visitPart",
"(",
"(",
"SoyMsgSelectPart",
")",
"firstPart",
")",
";",
"}",
"else",
"{",
"for",
"(",
"SoyMsgPart",
"msgPart",
":",
"msgParts",
")",
"{",
"if",
"(",
"msgPart",
"instanceof",
"SoyMsgRawTextPart",
")",
"{",
"RenderVisitor",
".",
"append",
"(",
"master",
".",
"getCurrOutputBufForUseByAssistants",
"(",
")",
",",
"(",
"(",
"SoyMsgRawTextPart",
")",
"msgPart",
")",
".",
"getRawText",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"msgPart",
"instanceof",
"SoyMsgPlaceholderPart",
")",
"{",
"String",
"placeholderName",
"=",
"(",
"(",
"SoyMsgPlaceholderPart",
")",
"msgPart",
")",
".",
"getPlaceholderName",
"(",
")",
";",
"visit",
"(",
"msg",
".",
"getRepPlaceholderNode",
"(",
"placeholderName",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"AssertionError",
"(",
")",
";",
"}",
"}",
"}",
"}"
] |
Private helper for visitMsgFallbackGroupNode() to render a message from its translation.
|
[
"Private",
"helper",
"for",
"visitMsgFallbackGroupNode",
"()",
"to",
"render",
"a",
"message",
"from",
"its",
"translation",
"."
] |
train
|
https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/sharedpasses/render/RenderVisitorAssistantForMsgs.java#L103-L130
|
moparisthebest/beehive
|
beehive-netui-compiler/src/main/java/org/apache/beehive/netui/compiler/CompilerUtils.java
|
CompilerUtils.getFormClassName
|
public static String getFormClassName( TypeDeclaration jclass, CoreAnnotationProcessorEnv env ) {
"""
Get a Class.forName-able string for the given type signature.
"""
if ( isAssignableFrom( STRUTS_FORM_CLASS_NAME, jclass, env ) )
{
return getLoadableName( jclass );
}
else if ( isAssignableFrom( BEA_XMLOBJECT_CLASS_NAME, jclass, env ) )
{
return XML_FORM_CLASS_NAME;
}
else if ( isAssignableFrom( APACHE_XMLOBJECT_CLASS_NAME, jclass, env ) )
{
return XML_FORM_CLASS_NAME;
}
else
{
return ANY_FORM_CLASS_NAME;
}
}
|
java
|
public static String getFormClassName( TypeDeclaration jclass, CoreAnnotationProcessorEnv env )
{
if ( isAssignableFrom( STRUTS_FORM_CLASS_NAME, jclass, env ) )
{
return getLoadableName( jclass );
}
else if ( isAssignableFrom( BEA_XMLOBJECT_CLASS_NAME, jclass, env ) )
{
return XML_FORM_CLASS_NAME;
}
else if ( isAssignableFrom( APACHE_XMLOBJECT_CLASS_NAME, jclass, env ) )
{
return XML_FORM_CLASS_NAME;
}
else
{
return ANY_FORM_CLASS_NAME;
}
}
|
[
"public",
"static",
"String",
"getFormClassName",
"(",
"TypeDeclaration",
"jclass",
",",
"CoreAnnotationProcessorEnv",
"env",
")",
"{",
"if",
"(",
"isAssignableFrom",
"(",
"STRUTS_FORM_CLASS_NAME",
",",
"jclass",
",",
"env",
")",
")",
"{",
"return",
"getLoadableName",
"(",
"jclass",
")",
";",
"}",
"else",
"if",
"(",
"isAssignableFrom",
"(",
"BEA_XMLOBJECT_CLASS_NAME",
",",
"jclass",
",",
"env",
")",
")",
"{",
"return",
"XML_FORM_CLASS_NAME",
";",
"}",
"else",
"if",
"(",
"isAssignableFrom",
"(",
"APACHE_XMLOBJECT_CLASS_NAME",
",",
"jclass",
",",
"env",
")",
")",
"{",
"return",
"XML_FORM_CLASS_NAME",
";",
"}",
"else",
"{",
"return",
"ANY_FORM_CLASS_NAME",
";",
"}",
"}"
] |
Get a Class.forName-able string for the given type signature.
|
[
"Get",
"a",
"Class",
".",
"forName",
"-",
"able",
"string",
"for",
"the",
"given",
"type",
"signature",
"."
] |
train
|
https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-netui-compiler/src/main/java/org/apache/beehive/netui/compiler/CompilerUtils.java#L548-L566
|
fernandospr/javapns-jdk16
|
src/main/java/javapns/communication/ConnectionToAppleServer.java
|
ConnectionToAppleServer.getSSLSocket
|
public SSLSocket getSSLSocket() throws KeystoreException, CommunicationException {
"""
Create a SSLSocket which will be used to send data to Apple
@return the SSLSocket
@throws KeystoreException
@throws CommunicationException
"""
SSLSocketFactory socketFactory = getSSLSocketFactory();
logger.debug("Creating SSLSocket to " + getServerHost() + ":" + getServerPort());
try {
if (ProxyManager.isUsingProxy(server)) {
return tunnelThroughProxy(socketFactory);
} else {
return (SSLSocket) socketFactory.createSocket(getServerHost(), getServerPort());
}
} catch (Exception e) {
throw new CommunicationException("Communication exception: " + e, e);
}
}
|
java
|
public SSLSocket getSSLSocket() throws KeystoreException, CommunicationException {
SSLSocketFactory socketFactory = getSSLSocketFactory();
logger.debug("Creating SSLSocket to " + getServerHost() + ":" + getServerPort());
try {
if (ProxyManager.isUsingProxy(server)) {
return tunnelThroughProxy(socketFactory);
} else {
return (SSLSocket) socketFactory.createSocket(getServerHost(), getServerPort());
}
} catch (Exception e) {
throw new CommunicationException("Communication exception: " + e, e);
}
}
|
[
"public",
"SSLSocket",
"getSSLSocket",
"(",
")",
"throws",
"KeystoreException",
",",
"CommunicationException",
"{",
"SSLSocketFactory",
"socketFactory",
"=",
"getSSLSocketFactory",
"(",
")",
";",
"logger",
".",
"debug",
"(",
"\"Creating SSLSocket to \"",
"+",
"getServerHost",
"(",
")",
"+",
"\":\"",
"+",
"getServerPort",
"(",
")",
")",
";",
"try",
"{",
"if",
"(",
"ProxyManager",
".",
"isUsingProxy",
"(",
"server",
")",
")",
"{",
"return",
"tunnelThroughProxy",
"(",
"socketFactory",
")",
";",
"}",
"else",
"{",
"return",
"(",
"SSLSocket",
")",
"socketFactory",
".",
"createSocket",
"(",
"getServerHost",
"(",
")",
",",
"getServerPort",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"CommunicationException",
"(",
"\"Communication exception: \"",
"+",
"e",
",",
"e",
")",
";",
"}",
"}"
] |
Create a SSLSocket which will be used to send data to Apple
@return the SSLSocket
@throws KeystoreException
@throws CommunicationException
|
[
"Create",
"a",
"SSLSocket",
"which",
"will",
"be",
"used",
"to",
"send",
"data",
"to",
"Apple"
] |
train
|
https://github.com/fernandospr/javapns-jdk16/blob/84de6d9328ab01af92f77cc60c4554de02420909/src/main/java/javapns/communication/ConnectionToAppleServer.java#L145-L158
|
alkacon/opencms-core
|
src/org/opencms/gwt/CmsPropertyEditorHelper.java
|
CmsPropertyEditorHelper.isWritable
|
protected boolean isWritable(CmsObject cms, CmsResource resource) throws CmsException {
"""
Returns whether the current user has write permissions, the resource is lockable or already locked by the current user and is in the current project.<p>
@param cms the cms context
@param resource the resource
@return <code>true</code> if the resource is writable
@throws CmsException in case checking the permissions fails
"""
boolean writable = cms.hasPermissions(
resource,
CmsPermissionSet.ACCESS_WRITE,
false,
CmsResourceFilter.IGNORE_EXPIRATION);
if (writable) {
CmsLock lock = cms.getLock(resource);
writable = lock.isUnlocked() || lock.isOwnedBy(cms.getRequestContext().getCurrentUser());
if (writable) {
CmsResourceUtil resUtil = new CmsResourceUtil(cms, resource);
writable = resUtil.isInsideProject() && !resUtil.getProjectState().isLockedForPublishing();
}
}
return writable;
}
|
java
|
protected boolean isWritable(CmsObject cms, CmsResource resource) throws CmsException {
boolean writable = cms.hasPermissions(
resource,
CmsPermissionSet.ACCESS_WRITE,
false,
CmsResourceFilter.IGNORE_EXPIRATION);
if (writable) {
CmsLock lock = cms.getLock(resource);
writable = lock.isUnlocked() || lock.isOwnedBy(cms.getRequestContext().getCurrentUser());
if (writable) {
CmsResourceUtil resUtil = new CmsResourceUtil(cms, resource);
writable = resUtil.isInsideProject() && !resUtil.getProjectState().isLockedForPublishing();
}
}
return writable;
}
|
[
"protected",
"boolean",
"isWritable",
"(",
"CmsObject",
"cms",
",",
"CmsResource",
"resource",
")",
"throws",
"CmsException",
"{",
"boolean",
"writable",
"=",
"cms",
".",
"hasPermissions",
"(",
"resource",
",",
"CmsPermissionSet",
".",
"ACCESS_WRITE",
",",
"false",
",",
"CmsResourceFilter",
".",
"IGNORE_EXPIRATION",
")",
";",
"if",
"(",
"writable",
")",
"{",
"CmsLock",
"lock",
"=",
"cms",
".",
"getLock",
"(",
"resource",
")",
";",
"writable",
"=",
"lock",
".",
"isUnlocked",
"(",
")",
"||",
"lock",
".",
"isOwnedBy",
"(",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"getCurrentUser",
"(",
")",
")",
";",
"if",
"(",
"writable",
")",
"{",
"CmsResourceUtil",
"resUtil",
"=",
"new",
"CmsResourceUtil",
"(",
"cms",
",",
"resource",
")",
";",
"writable",
"=",
"resUtil",
".",
"isInsideProject",
"(",
")",
"&&",
"!",
"resUtil",
".",
"getProjectState",
"(",
")",
".",
"isLockedForPublishing",
"(",
")",
";",
"}",
"}",
"return",
"writable",
";",
"}"
] |
Returns whether the current user has write permissions, the resource is lockable or already locked by the current user and is in the current project.<p>
@param cms the cms context
@param resource the resource
@return <code>true</code> if the resource is writable
@throws CmsException in case checking the permissions fails
|
[
"Returns",
"whether",
"the",
"current",
"user",
"has",
"write",
"permissions",
"the",
"resource",
"is",
"lockable",
"or",
"already",
"locked",
"by",
"the",
"current",
"user",
"and",
"is",
"in",
"the",
"current",
"project",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/gwt/CmsPropertyEditorHelper.java#L432-L448
|
iig-uni-freiburg/SEWOL
|
ext/org/deckfour/xes/extension/std/XConceptExtension.java
|
XConceptExtension.assignInstance
|
public void assignInstance(XEvent event, String instance) {
"""
Assigns any event its activity instance identifier, as defined by this
extension's instance attribute.
@param event
Event to assign activity instance identifier to.
@param name
The activity instance identifier to be assigned.
"""
if (instance != null && instance.trim().length() > 0) {
XAttributeLiteral attr = (XAttributeLiteral) ATTR_INSTANCE.clone();
attr.setValue(instance);
event.getAttributes().put(KEY_INSTANCE, attr);
}
}
|
java
|
public void assignInstance(XEvent event, String instance) {
if (instance != null && instance.trim().length() > 0) {
XAttributeLiteral attr = (XAttributeLiteral) ATTR_INSTANCE.clone();
attr.setValue(instance);
event.getAttributes().put(KEY_INSTANCE, attr);
}
}
|
[
"public",
"void",
"assignInstance",
"(",
"XEvent",
"event",
",",
"String",
"instance",
")",
"{",
"if",
"(",
"instance",
"!=",
"null",
"&&",
"instance",
".",
"trim",
"(",
")",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"XAttributeLiteral",
"attr",
"=",
"(",
"XAttributeLiteral",
")",
"ATTR_INSTANCE",
".",
"clone",
"(",
")",
";",
"attr",
".",
"setValue",
"(",
"instance",
")",
";",
"event",
".",
"getAttributes",
"(",
")",
".",
"put",
"(",
"KEY_INSTANCE",
",",
"attr",
")",
";",
"}",
"}"
] |
Assigns any event its activity instance identifier, as defined by this
extension's instance attribute.
@param event
Event to assign activity instance identifier to.
@param name
The activity instance identifier to be assigned.
|
[
"Assigns",
"any",
"event",
"its",
"activity",
"instance",
"identifier",
"as",
"defined",
"by",
"this",
"extension",
"s",
"instance",
"attribute",
"."
] |
train
|
https://github.com/iig-uni-freiburg/SEWOL/blob/e791cb07a6e62ecf837d760d58a25f32fbf6bbca/ext/org/deckfour/xes/extension/std/XConceptExtension.java#L214-L220
|
raydac/java-binary-block-parser
|
jbbp/src/main/java/com/igormaznitsa/jbbp/utils/JBBPDslBuilder.java
|
JBBPDslBuilder.BitArray
|
public JBBPDslBuilder BitArray(final JBBPBitNumber bits, final int size) {
"""
Add anonymous fixed length bit array.
@param bits length of the field, must not be null
@param size number of elements in array, if negative then till the end of stream
@return the builder instance, must not be null
"""
return this.BitArray(null, bits, arraySizeToString(size));
}
|
java
|
public JBBPDslBuilder BitArray(final JBBPBitNumber bits, final int size) {
return this.BitArray(null, bits, arraySizeToString(size));
}
|
[
"public",
"JBBPDslBuilder",
"BitArray",
"(",
"final",
"JBBPBitNumber",
"bits",
",",
"final",
"int",
"size",
")",
"{",
"return",
"this",
".",
"BitArray",
"(",
"null",
",",
"bits",
",",
"arraySizeToString",
"(",
"size",
")",
")",
";",
"}"
] |
Add anonymous fixed length bit array.
@param bits length of the field, must not be null
@param size number of elements in array, if negative then till the end of stream
@return the builder instance, must not be null
|
[
"Add",
"anonymous",
"fixed",
"length",
"bit",
"array",
"."
] |
train
|
https://github.com/raydac/java-binary-block-parser/blob/6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b/jbbp/src/main/java/com/igormaznitsa/jbbp/utils/JBBPDslBuilder.java#L664-L666
|
biojava/biojava
|
biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/SequenceMixin.java
|
SequenceMixin.countAT
|
public static int countAT(Sequence<NucleotideCompound> sequence) {
"""
Returns the count of AT in the given sequence
@param sequence The {@link NucleotideCompound} {@link Sequence} to perform
the AT analysis on
@return The number of AT compounds in the sequence
"""
CompoundSet<NucleotideCompound> cs = sequence.getCompoundSet();
NucleotideCompound A = cs.getCompoundForString("A");
NucleotideCompound T = cs.getCompoundForString("T");
NucleotideCompound a = cs.getCompoundForString("a");
NucleotideCompound t = cs.getCompoundForString("t");
return countCompounds(sequence, A, T, a, t);
}
|
java
|
public static int countAT(Sequence<NucleotideCompound> sequence) {
CompoundSet<NucleotideCompound> cs = sequence.getCompoundSet();
NucleotideCompound A = cs.getCompoundForString("A");
NucleotideCompound T = cs.getCompoundForString("T");
NucleotideCompound a = cs.getCompoundForString("a");
NucleotideCompound t = cs.getCompoundForString("t");
return countCompounds(sequence, A, T, a, t);
}
|
[
"public",
"static",
"int",
"countAT",
"(",
"Sequence",
"<",
"NucleotideCompound",
">",
"sequence",
")",
"{",
"CompoundSet",
"<",
"NucleotideCompound",
">",
"cs",
"=",
"sequence",
".",
"getCompoundSet",
"(",
")",
";",
"NucleotideCompound",
"A",
"=",
"cs",
".",
"getCompoundForString",
"(",
"\"A\"",
")",
";",
"NucleotideCompound",
"T",
"=",
"cs",
".",
"getCompoundForString",
"(",
"\"T\"",
")",
";",
"NucleotideCompound",
"a",
"=",
"cs",
".",
"getCompoundForString",
"(",
"\"a\"",
")",
";",
"NucleotideCompound",
"t",
"=",
"cs",
".",
"getCompoundForString",
"(",
"\"t\"",
")",
";",
"return",
"countCompounds",
"(",
"sequence",
",",
"A",
",",
"T",
",",
"a",
",",
"t",
")",
";",
"}"
] |
Returns the count of AT in the given sequence
@param sequence The {@link NucleotideCompound} {@link Sequence} to perform
the AT analysis on
@return The number of AT compounds in the sequence
|
[
"Returns",
"the",
"count",
"of",
"AT",
"in",
"the",
"given",
"sequence"
] |
train
|
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/SequenceMixin.java#L97-L104
|
fhoeben/hsac-fitnesse-fixtures
|
src/main/java/nl/hsac/fitnesse/fixture/util/MapHelper.java
|
MapHelper.setValuesForIn
|
public void setValuesForIn(String values, String name, Map<String, Object> map) {
"""
Stores list of values in map.
@param values comma separated list of values.
@param name name to use this list for.
@param map map to store values in.
"""
String cleanName = htmlCleaner.cleanupValue(name);
String[] valueArrays = values.split("\\s*,\\s*");
List<Object> valueObjects = new ArrayList<Object>(valueArrays.length);
for (int i = 0; i < valueArrays.length; i++) {
Object cleanValue = getCleanValue(valueArrays[i]);
valueObjects.add(cleanValue);
}
setValueForIn(valueObjects, cleanName, map);
}
|
java
|
public void setValuesForIn(String values, String name, Map<String, Object> map) {
String cleanName = htmlCleaner.cleanupValue(name);
String[] valueArrays = values.split("\\s*,\\s*");
List<Object> valueObjects = new ArrayList<Object>(valueArrays.length);
for (int i = 0; i < valueArrays.length; i++) {
Object cleanValue = getCleanValue(valueArrays[i]);
valueObjects.add(cleanValue);
}
setValueForIn(valueObjects, cleanName, map);
}
|
[
"public",
"void",
"setValuesForIn",
"(",
"String",
"values",
",",
"String",
"name",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"map",
")",
"{",
"String",
"cleanName",
"=",
"htmlCleaner",
".",
"cleanupValue",
"(",
"name",
")",
";",
"String",
"[",
"]",
"valueArrays",
"=",
"values",
".",
"split",
"(",
"\"\\\\s*,\\\\s*\"",
")",
";",
"List",
"<",
"Object",
">",
"valueObjects",
"=",
"new",
"ArrayList",
"<",
"Object",
">",
"(",
"valueArrays",
".",
"length",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"valueArrays",
".",
"length",
";",
"i",
"++",
")",
"{",
"Object",
"cleanValue",
"=",
"getCleanValue",
"(",
"valueArrays",
"[",
"i",
"]",
")",
";",
"valueObjects",
".",
"add",
"(",
"cleanValue",
")",
";",
"}",
"setValueForIn",
"(",
"valueObjects",
",",
"cleanName",
",",
"map",
")",
";",
"}"
] |
Stores list of values in map.
@param values comma separated list of values.
@param name name to use this list for.
@param map map to store values in.
|
[
"Stores",
"list",
"of",
"values",
"in",
"map",
"."
] |
train
|
https://github.com/fhoeben/hsac-fitnesse-fixtures/blob/4e9018d7386a9aa65bfcbf07eb28ae064edd1732/src/main/java/nl/hsac/fitnesse/fixture/util/MapHelper.java#L134-L143
|
apache/groovy
|
src/main/java/org/codehaus/groovy/runtime/IOGroovyMethods.java
|
IOGroovyMethods.withStream
|
public static <T, U extends OutputStream> T withStream(U os, @ClosureParams(value=FirstParam.class) Closure<T> closure) throws IOException {
"""
Passes this OutputStream to the closure, ensuring that the stream
is closed after the closure returns, regardless of errors.
@param os the stream which is used and then closed
@param closure the closure that the stream is passed into
@return the value returned by the closure
@throws IOException if an IOException occurs.
@since 1.5.2
"""
try {
T result = closure.call(os);
os.flush();
OutputStream temp = os;
os = null;
temp.close();
return result;
} finally {
closeWithWarning(os);
}
}
|
java
|
public static <T, U extends OutputStream> T withStream(U os, @ClosureParams(value=FirstParam.class) Closure<T> closure) throws IOException {
try {
T result = closure.call(os);
os.flush();
OutputStream temp = os;
os = null;
temp.close();
return result;
} finally {
closeWithWarning(os);
}
}
|
[
"public",
"static",
"<",
"T",
",",
"U",
"extends",
"OutputStream",
">",
"T",
"withStream",
"(",
"U",
"os",
",",
"@",
"ClosureParams",
"(",
"value",
"=",
"FirstParam",
".",
"class",
")",
"Closure",
"<",
"T",
">",
"closure",
")",
"throws",
"IOException",
"{",
"try",
"{",
"T",
"result",
"=",
"closure",
".",
"call",
"(",
"os",
")",
";",
"os",
".",
"flush",
"(",
")",
";",
"OutputStream",
"temp",
"=",
"os",
";",
"os",
"=",
"null",
";",
"temp",
".",
"close",
"(",
")",
";",
"return",
"result",
";",
"}",
"finally",
"{",
"closeWithWarning",
"(",
"os",
")",
";",
"}",
"}"
] |
Passes this OutputStream to the closure, ensuring that the stream
is closed after the closure returns, regardless of errors.
@param os the stream which is used and then closed
@param closure the closure that the stream is passed into
@return the value returned by the closure
@throws IOException if an IOException occurs.
@since 1.5.2
|
[
"Passes",
"this",
"OutputStream",
"to",
"the",
"closure",
"ensuring",
"that",
"the",
"stream",
"is",
"closed",
"after",
"the",
"closure",
"returns",
"regardless",
"of",
"errors",
"."
] |
train
|
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/IOGroovyMethods.java#L1295-L1308
|
baratine/baratine
|
web/src/main/java/com/caucho/v5/http/dispatch/InvocationDecoder.java
|
InvocationDecoder.splitQuery
|
public void splitQuery(I invocation, String rawURI)
throws IOException {
"""
Splits out the query string, and normalizes the URI, assuming nothing
needs unescaping.
"""
int p = rawURI.indexOf('?');
if (p > 0) {
invocation.setQueryString(rawURI.substring(p + 1));
rawURI = rawURI.substring(0, p);
}
invocation.setRawURI(rawURI);
String uri = normalizeUri(rawURI);
invocation.setURI(uri);
}
|
java
|
public void splitQuery(I invocation, String rawURI)
throws IOException
{
int p = rawURI.indexOf('?');
if (p > 0) {
invocation.setQueryString(rawURI.substring(p + 1));
rawURI = rawURI.substring(0, p);
}
invocation.setRawURI(rawURI);
String uri = normalizeUri(rawURI);
invocation.setURI(uri);
}
|
[
"public",
"void",
"splitQuery",
"(",
"I",
"invocation",
",",
"String",
"rawURI",
")",
"throws",
"IOException",
"{",
"int",
"p",
"=",
"rawURI",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"p",
">",
"0",
")",
"{",
"invocation",
".",
"setQueryString",
"(",
"rawURI",
".",
"substring",
"(",
"p",
"+",
"1",
")",
")",
";",
"rawURI",
"=",
"rawURI",
".",
"substring",
"(",
"0",
",",
"p",
")",
";",
"}",
"invocation",
".",
"setRawURI",
"(",
"rawURI",
")",
";",
"String",
"uri",
"=",
"normalizeUri",
"(",
"rawURI",
")",
";",
"invocation",
".",
"setURI",
"(",
"uri",
")",
";",
"}"
] |
Splits out the query string, and normalizes the URI, assuming nothing
needs unescaping.
|
[
"Splits",
"out",
"the",
"query",
"string",
"and",
"normalizes",
"the",
"URI",
"assuming",
"nothing",
"needs",
"unescaping",
"."
] |
train
|
https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/http/dispatch/InvocationDecoder.java#L143-L158
|
zaproxy/zaproxy
|
src/org/zaproxy/zap/extension/httpsessions/ExtensionHttpSessions.java
|
ExtensionHttpSessions.isRemovedDefaultSessionToken
|
private boolean isRemovedDefaultSessionToken(String site, String token) {
"""
Checks if a particular default session token was removed by an user as a session token for a
site.
@param site the site. This parameter has to be formed as defined in the
{@link ExtensionHttpSessions} class documentation.
@param token the token
@return true, if it is a previously removed default session token
"""
if (removedDefaultTokens == null)
return false;
HashSet<String> removed = removedDefaultTokens.get(site);
if (removed == null || !removed.contains(token))
return false;
return true;
}
|
java
|
private boolean isRemovedDefaultSessionToken(String site, String token) {
if (removedDefaultTokens == null)
return false;
HashSet<String> removed = removedDefaultTokens.get(site);
if (removed == null || !removed.contains(token))
return false;
return true;
}
|
[
"private",
"boolean",
"isRemovedDefaultSessionToken",
"(",
"String",
"site",
",",
"String",
"token",
")",
"{",
"if",
"(",
"removedDefaultTokens",
"==",
"null",
")",
"return",
"false",
";",
"HashSet",
"<",
"String",
">",
"removed",
"=",
"removedDefaultTokens",
".",
"get",
"(",
"site",
")",
";",
"if",
"(",
"removed",
"==",
"null",
"||",
"!",
"removed",
".",
"contains",
"(",
"token",
")",
")",
"return",
"false",
";",
"return",
"true",
";",
"}"
] |
Checks if a particular default session token was removed by an user as a session token for a
site.
@param site the site. This parameter has to be formed as defined in the
{@link ExtensionHttpSessions} class documentation.
@param token the token
@return true, if it is a previously removed default session token
|
[
"Checks",
"if",
"a",
"particular",
"default",
"session",
"token",
"was",
"removed",
"by",
"an",
"user",
"as",
"a",
"session",
"token",
"for",
"a",
"site",
"."
] |
train
|
https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/zaproxy/zap/extension/httpsessions/ExtensionHttpSessions.java#L309-L316
|
netty/netty
|
codec-http/src/main/java/io/netty/handler/codec/http/HttpHeaders.java
|
HttpHeaders.addIntHeader
|
@Deprecated
public static void addIntHeader(HttpMessage message, String name, int value) {
"""
@deprecated Use {@link #add(CharSequence, Iterable)} instead.
@see #addIntHeader(HttpMessage, CharSequence, int)
"""
message.headers().add(name, value);
}
|
java
|
@Deprecated
public static void addIntHeader(HttpMessage message, String name, int value) {
message.headers().add(name, value);
}
|
[
"@",
"Deprecated",
"public",
"static",
"void",
"addIntHeader",
"(",
"HttpMessage",
"message",
",",
"String",
"name",
",",
"int",
"value",
")",
"{",
"message",
".",
"headers",
"(",
")",
".",
"add",
"(",
"name",
",",
"value",
")",
";",
"}"
] |
@deprecated Use {@link #add(CharSequence, Iterable)} instead.
@see #addIntHeader(HttpMessage, CharSequence, int)
|
[
"@deprecated",
"Use",
"{",
"@link",
"#add",
"(",
"CharSequence",
"Iterable",
")",
"}",
"instead",
"."
] |
train
|
https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec-http/src/main/java/io/netty/handler/codec/http/HttpHeaders.java#L806-L809
|
shrinkwrap/shrinkwrap
|
api/src/main/java/org/jboss/shrinkwrap/api/asset/ByteArrayIOUtil.java
|
ByteArrayIOUtil.asByteArray
|
static byte[] asByteArray(final InputStream in) throws IllegalArgumentException {
"""
Obtains the contents of the specified stream as a byte array
@param in
InputStream
@throws IllegalArgumentException
If the stream was not specified
@return the byte[] for the given InputStream
"""
// Precondition check
if (in == null) {
throw new IllegalArgumentException("stream must be specified");
}
// Get content as an array of bytes
final ByteArrayOutputStream out = new ByteArrayOutputStream(8192);
final int len = 4096;
final byte[] buffer = new byte[len];
int read = 0;
try {
while (((read = in.read(buffer)) != -1)) {
out.write(buffer, 0, read);
}
} catch (final IOException ioe) {
throw new RuntimeException("Error in obtainting bytes from " + in, ioe);
} finally {
try {
in.close();
} catch (final IOException ignore) {
if (log.isLoggable(Level.FINER)) {
log.finer("Could not close stream due to: " + ignore.getMessage() + "; ignoring");
}
}
// We don't need to close the outstream, it's a byte array out
}
// Represent as byte array
final byte[] content = out.toByteArray();
// Return
return content;
}
|
java
|
static byte[] asByteArray(final InputStream in) throws IllegalArgumentException {
// Precondition check
if (in == null) {
throw new IllegalArgumentException("stream must be specified");
}
// Get content as an array of bytes
final ByteArrayOutputStream out = new ByteArrayOutputStream(8192);
final int len = 4096;
final byte[] buffer = new byte[len];
int read = 0;
try {
while (((read = in.read(buffer)) != -1)) {
out.write(buffer, 0, read);
}
} catch (final IOException ioe) {
throw new RuntimeException("Error in obtainting bytes from " + in, ioe);
} finally {
try {
in.close();
} catch (final IOException ignore) {
if (log.isLoggable(Level.FINER)) {
log.finer("Could not close stream due to: " + ignore.getMessage() + "; ignoring");
}
}
// We don't need to close the outstream, it's a byte array out
}
// Represent as byte array
final byte[] content = out.toByteArray();
// Return
return content;
}
|
[
"static",
"byte",
"[",
"]",
"asByteArray",
"(",
"final",
"InputStream",
"in",
")",
"throws",
"IllegalArgumentException",
"{",
"// Precondition check",
"if",
"(",
"in",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"stream must be specified\"",
")",
";",
"}",
"// Get content as an array of bytes",
"final",
"ByteArrayOutputStream",
"out",
"=",
"new",
"ByteArrayOutputStream",
"(",
"8192",
")",
";",
"final",
"int",
"len",
"=",
"4096",
";",
"final",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"len",
"]",
";",
"int",
"read",
"=",
"0",
";",
"try",
"{",
"while",
"(",
"(",
"(",
"read",
"=",
"in",
".",
"read",
"(",
"buffer",
")",
")",
"!=",
"-",
"1",
")",
")",
"{",
"out",
".",
"write",
"(",
"buffer",
",",
"0",
",",
"read",
")",
";",
"}",
"}",
"catch",
"(",
"final",
"IOException",
"ioe",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Error in obtainting bytes from \"",
"+",
"in",
",",
"ioe",
")",
";",
"}",
"finally",
"{",
"try",
"{",
"in",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"ignore",
")",
"{",
"if",
"(",
"log",
".",
"isLoggable",
"(",
"Level",
".",
"FINER",
")",
")",
"{",
"log",
".",
"finer",
"(",
"\"Could not close stream due to: \"",
"+",
"ignore",
".",
"getMessage",
"(",
")",
"+",
"\"; ignoring\"",
")",
";",
"}",
"}",
"// We don't need to close the outstream, it's a byte array out",
"}",
"// Represent as byte array",
"final",
"byte",
"[",
"]",
"content",
"=",
"out",
".",
"toByteArray",
"(",
")",
";",
"// Return",
"return",
"content",
";",
"}"
] |
Obtains the contents of the specified stream as a byte array
@param in
InputStream
@throws IllegalArgumentException
If the stream was not specified
@return the byte[] for the given InputStream
|
[
"Obtains",
"the",
"contents",
"of",
"the",
"specified",
"stream",
"as",
"a",
"byte",
"array"
] |
train
|
https://github.com/shrinkwrap/shrinkwrap/blob/3f8a1a6d344651428c709a63ebb52d35343c5387/api/src/main/java/org/jboss/shrinkwrap/api/asset/ByteArrayIOUtil.java#L44-L77
|
samskivert/samskivert
|
src/main/java/com/samskivert/servlet/user/UserRepository.java
|
UserRepository.insertUser
|
protected int insertUser (final User user)
throws UserExistsException, PersistenceException {
"""
Inserts the supplied user record into the user database, assigning it a userid in the
process, which is returned.
"""
executeUpdate(new Operation<Object>() {
public Object invoke (Connection conn, DatabaseLiaison liaison)
throws PersistenceException, SQLException
{
try {
_utable.insert(conn, user);
// update the userid now that it's known
user.userId = liaison.lastInsertedId(conn, null, _utable.getName(), "userId");
// nothing to return
return null;
} catch (SQLException sqe) {
if (liaison.isDuplicateRowException(sqe)) {
throw new UserExistsException("error.user_exists");
} else {
throw sqe;
}
}
}
});
return user.userId;
}
|
java
|
protected int insertUser (final User user)
throws UserExistsException, PersistenceException
{
executeUpdate(new Operation<Object>() {
public Object invoke (Connection conn, DatabaseLiaison liaison)
throws PersistenceException, SQLException
{
try {
_utable.insert(conn, user);
// update the userid now that it's known
user.userId = liaison.lastInsertedId(conn, null, _utable.getName(), "userId");
// nothing to return
return null;
} catch (SQLException sqe) {
if (liaison.isDuplicateRowException(sqe)) {
throw new UserExistsException("error.user_exists");
} else {
throw sqe;
}
}
}
});
return user.userId;
}
|
[
"protected",
"int",
"insertUser",
"(",
"final",
"User",
"user",
")",
"throws",
"UserExistsException",
",",
"PersistenceException",
"{",
"executeUpdate",
"(",
"new",
"Operation",
"<",
"Object",
">",
"(",
")",
"{",
"public",
"Object",
"invoke",
"(",
"Connection",
"conn",
",",
"DatabaseLiaison",
"liaison",
")",
"throws",
"PersistenceException",
",",
"SQLException",
"{",
"try",
"{",
"_utable",
".",
"insert",
"(",
"conn",
",",
"user",
")",
";",
"// update the userid now that it's known",
"user",
".",
"userId",
"=",
"liaison",
".",
"lastInsertedId",
"(",
"conn",
",",
"null",
",",
"_utable",
".",
"getName",
"(",
")",
",",
"\"userId\"",
")",
";",
"// nothing to return",
"return",
"null",
";",
"}",
"catch",
"(",
"SQLException",
"sqe",
")",
"{",
"if",
"(",
"liaison",
".",
"isDuplicateRowException",
"(",
"sqe",
")",
")",
"{",
"throw",
"new",
"UserExistsException",
"(",
"\"error.user_exists\"",
")",
";",
"}",
"else",
"{",
"throw",
"sqe",
";",
"}",
"}",
"}",
"}",
")",
";",
"return",
"user",
".",
"userId",
";",
"}"
] |
Inserts the supplied user record into the user database, assigning it a userid in the
process, which is returned.
|
[
"Inserts",
"the",
"supplied",
"user",
"record",
"into",
"the",
"user",
"database",
"assigning",
"it",
"a",
"userid",
"in",
"the",
"process",
"which",
"is",
"returned",
"."
] |
train
|
https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/servlet/user/UserRepository.java#L391-L416
|
sarl/sarl
|
main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/labeling/SARLImages.java
|
SARLImages.forBehavior
|
public ImageDescriptor forBehavior(JvmVisibility visibility, int flags) {
"""
Replies the image descriptor for the "behaviors".
@param visibility the visibility of the behavior.
@param flags the mark flags. See {@link JavaElementImageDescriptor#setAdornments(int)} for
a description of the available flags.
@return the image descriptor for the behaviors.
"""
return getDecorated(getTypeImageDescriptor(
SarlElementType.BEHAVIOR, false, false, toFlags(visibility), USE_LIGHT_ICONS), flags);
}
|
java
|
public ImageDescriptor forBehavior(JvmVisibility visibility, int flags) {
return getDecorated(getTypeImageDescriptor(
SarlElementType.BEHAVIOR, false, false, toFlags(visibility), USE_LIGHT_ICONS), flags);
}
|
[
"public",
"ImageDescriptor",
"forBehavior",
"(",
"JvmVisibility",
"visibility",
",",
"int",
"flags",
")",
"{",
"return",
"getDecorated",
"(",
"getTypeImageDescriptor",
"(",
"SarlElementType",
".",
"BEHAVIOR",
",",
"false",
",",
"false",
",",
"toFlags",
"(",
"visibility",
")",
",",
"USE_LIGHT_ICONS",
")",
",",
"flags",
")",
";",
"}"
] |
Replies the image descriptor for the "behaviors".
@param visibility the visibility of the behavior.
@param flags the mark flags. See {@link JavaElementImageDescriptor#setAdornments(int)} for
a description of the available flags.
@return the image descriptor for the behaviors.
|
[
"Replies",
"the",
"image",
"descriptor",
"for",
"the",
"behaviors",
"."
] |
train
|
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/labeling/SARLImages.java#L139-L142
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.