repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
riccardove/easyjasub | easyjasub-lib/src/main/java/com/github/riccardove/easyjasub/bdsup2sub/BDSup2SubWrapper.java | BDSup2SubWrapper.validateTimes | private void validateTimes(int idx, SubPicture subPic,
SubPicture subPicNext, SubPicture subPicPrev) {
long startTime = subPic.getStartTime();
long endTime = subPic.getEndTime();
final long delay = 5000 * 90; // default delay for missing end time (5
// seconds)
idx += 1; // only used for display
// get end time of last frame
long lastEndTime = subPicPrev != null ? subPicPrev.getEndTime() : -1;
if (startTime < lastEndTime) {
startTime = lastEndTime;
}
// get start time of next frame
long nextStartTime = subPicNext != null ? subPicNext.getStartTime() : 0;
if (nextStartTime == 0) {
if (endTime > startTime) {
nextStartTime = endTime;
} else {
// completely messed up:
// end time and next start time are invalid
nextStartTime = startTime + delay;
}
}
if (endTime <= startTime) {
endTime = startTime + delay;
if (endTime > nextStartTime) {
endTime = nextStartTime;
}
} else if (endTime > nextStartTime) {
endTime = nextStartTime;
}
int minTimePTS = configuration.getMinTimePTS();
if (endTime - startTime < minTimePTS) {
if (configuration.getFixShortFrames()) {
endTime = startTime + minTimePTS;
if (endTime > nextStartTime) {
endTime = nextStartTime;
}
}
}
if (subPic.getStartTime() != startTime) {
subPic.setStartTime(SubtitleUtils.syncTimePTS(startTime,
configuration.getFpsTrg(), configuration.getFpsTrg()));
}
if (subPic.getEndTime() != endTime) {
subPic.setEndTime(SubtitleUtils.syncTimePTS(endTime,
configuration.getFpsTrg(), configuration.getFpsTrg()));
}
} | java | private void validateTimes(int idx, SubPicture subPic,
SubPicture subPicNext, SubPicture subPicPrev) {
long startTime = subPic.getStartTime();
long endTime = subPic.getEndTime();
final long delay = 5000 * 90; // default delay for missing end time (5
// seconds)
idx += 1; // only used for display
// get end time of last frame
long lastEndTime = subPicPrev != null ? subPicPrev.getEndTime() : -1;
if (startTime < lastEndTime) {
startTime = lastEndTime;
}
// get start time of next frame
long nextStartTime = subPicNext != null ? subPicNext.getStartTime() : 0;
if (nextStartTime == 0) {
if (endTime > startTime) {
nextStartTime = endTime;
} else {
// completely messed up:
// end time and next start time are invalid
nextStartTime = startTime + delay;
}
}
if (endTime <= startTime) {
endTime = startTime + delay;
if (endTime > nextStartTime) {
endTime = nextStartTime;
}
} else if (endTime > nextStartTime) {
endTime = nextStartTime;
}
int minTimePTS = configuration.getMinTimePTS();
if (endTime - startTime < minTimePTS) {
if (configuration.getFixShortFrames()) {
endTime = startTime + minTimePTS;
if (endTime > nextStartTime) {
endTime = nextStartTime;
}
}
}
if (subPic.getStartTime() != startTime) {
subPic.setStartTime(SubtitleUtils.syncTimePTS(startTime,
configuration.getFpsTrg(), configuration.getFpsTrg()));
}
if (subPic.getEndTime() != endTime) {
subPic.setEndTime(SubtitleUtils.syncTimePTS(endTime,
configuration.getFpsTrg(), configuration.getFpsTrg()));
}
} | [
"private",
"void",
"validateTimes",
"(",
"int",
"idx",
",",
"SubPicture",
"subPic",
",",
"SubPicture",
"subPicNext",
",",
"SubPicture",
"subPicPrev",
")",
"{",
"long",
"startTime",
"=",
"subPic",
".",
"getStartTime",
"(",
")",
";",
"long",
"endTime",
"=",
"subPic",
".",
"getEndTime",
"(",
")",
";",
"final",
"long",
"delay",
"=",
"5000",
"*",
"90",
";",
"// default delay for missing end time (5\r",
"// seconds)\r",
"idx",
"+=",
"1",
";",
"// only used for display\r",
"// get end time of last frame\r",
"long",
"lastEndTime",
"=",
"subPicPrev",
"!=",
"null",
"?",
"subPicPrev",
".",
"getEndTime",
"(",
")",
":",
"-",
"1",
";",
"if",
"(",
"startTime",
"<",
"lastEndTime",
")",
"{",
"startTime",
"=",
"lastEndTime",
";",
"}",
"// get start time of next frame\r",
"long",
"nextStartTime",
"=",
"subPicNext",
"!=",
"null",
"?",
"subPicNext",
".",
"getStartTime",
"(",
")",
":",
"0",
";",
"if",
"(",
"nextStartTime",
"==",
"0",
")",
"{",
"if",
"(",
"endTime",
">",
"startTime",
")",
"{",
"nextStartTime",
"=",
"endTime",
";",
"}",
"else",
"{",
"// completely messed up:\r",
"// end time and next start time are invalid\r",
"nextStartTime",
"=",
"startTime",
"+",
"delay",
";",
"}",
"}",
"if",
"(",
"endTime",
"<=",
"startTime",
")",
"{",
"endTime",
"=",
"startTime",
"+",
"delay",
";",
"if",
"(",
"endTime",
">",
"nextStartTime",
")",
"{",
"endTime",
"=",
"nextStartTime",
";",
"}",
"}",
"else",
"if",
"(",
"endTime",
">",
"nextStartTime",
")",
"{",
"endTime",
"=",
"nextStartTime",
";",
"}",
"int",
"minTimePTS",
"=",
"configuration",
".",
"getMinTimePTS",
"(",
")",
";",
"if",
"(",
"endTime",
"-",
"startTime",
"<",
"minTimePTS",
")",
"{",
"if",
"(",
"configuration",
".",
"getFixShortFrames",
"(",
")",
")",
"{",
"endTime",
"=",
"startTime",
"+",
"minTimePTS",
";",
"if",
"(",
"endTime",
">",
"nextStartTime",
")",
"{",
"endTime",
"=",
"nextStartTime",
";",
"}",
"}",
"}",
"if",
"(",
"subPic",
".",
"getStartTime",
"(",
")",
"!=",
"startTime",
")",
"{",
"subPic",
".",
"setStartTime",
"(",
"SubtitleUtils",
".",
"syncTimePTS",
"(",
"startTime",
",",
"configuration",
".",
"getFpsTrg",
"(",
")",
",",
"configuration",
".",
"getFpsTrg",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"subPic",
".",
"getEndTime",
"(",
")",
"!=",
"endTime",
")",
"{",
"subPic",
".",
"setEndTime",
"(",
"SubtitleUtils",
".",
"syncTimePTS",
"(",
"endTime",
",",
"configuration",
".",
"getFpsTrg",
"(",
")",
",",
"configuration",
".",
"getFpsTrg",
"(",
")",
")",
")",
";",
"}",
"}"
] | Check start and end time, fix overlaps etc.
@param idx
Index of subpicture (just for display)
@param subPic
Subpicture to check/fix
@param subPicNext
Next subpicture
@param subPicPrev
Previous subpicture | [
"Check",
"start",
"and",
"end",
"time",
"fix",
"overlaps",
"etc",
"."
] | 58d6af66b1b1c738326c74d9ad5e4ad514120e27 | https://github.com/riccardove/easyjasub/blob/58d6af66b1b1c738326c74d9ad5e4ad514120e27/easyjasub-lib/src/main/java/com/github/riccardove/easyjasub/bdsup2sub/BDSup2SubWrapper.java#L273-L329 | train |
riccardove/easyjasub | easyjasub-lib/src/main/java/com/github/riccardove/easyjasub/bdsup2sub/BDSup2SubWrapper.java | BDSup2SubWrapper.getSubPicturesToBeExported | private List<Integer> getSubPicturesToBeExported() {
List<Integer> subPicturesToBeExported = new ArrayList<Integer>();
for (int i = 0; i < subPictures.length; i++) {
SubPicture subPicture = subPictures[i];
if (!subPicture.isExcluded()
&& (!configuration.isExportForced() || subPicture
.isForced())) {
subPicturesToBeExported.add(i);
}
}
return subPicturesToBeExported;
} | java | private List<Integer> getSubPicturesToBeExported() {
List<Integer> subPicturesToBeExported = new ArrayList<Integer>();
for (int i = 0; i < subPictures.length; i++) {
SubPicture subPicture = subPictures[i];
if (!subPicture.isExcluded()
&& (!configuration.isExportForced() || subPicture
.isForced())) {
subPicturesToBeExported.add(i);
}
}
return subPicturesToBeExported;
} | [
"private",
"List",
"<",
"Integer",
">",
"getSubPicturesToBeExported",
"(",
")",
"{",
"List",
"<",
"Integer",
">",
"subPicturesToBeExported",
"=",
"new",
"ArrayList",
"<",
"Integer",
">",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"subPictures",
".",
"length",
";",
"i",
"++",
")",
"{",
"SubPicture",
"subPicture",
"=",
"subPictures",
"[",
"i",
"]",
";",
"if",
"(",
"!",
"subPicture",
".",
"isExcluded",
"(",
")",
"&&",
"(",
"!",
"configuration",
".",
"isExportForced",
"(",
")",
"||",
"subPicture",
".",
"isForced",
"(",
")",
")",
")",
"{",
"subPicturesToBeExported",
".",
"add",
"(",
"i",
")",
";",
"}",
"}",
"return",
"subPicturesToBeExported",
";",
"}"
] | Return indexes of subpictures to be exported.
@return indexes of subpictures to be exported | [
"Return",
"indexes",
"of",
"subpictures",
"to",
"be",
"exported",
"."
] | 58d6af66b1b1c738326c74d9ad5e4ad514120e27 | https://github.com/riccardove/easyjasub/blob/58d6af66b1b1c738326c74d9ad5e4ad514120e27/easyjasub-lib/src/main/java/com/github/riccardove/easyjasub/bdsup2sub/BDSup2SubWrapper.java#L714-L725 | train |
riccardove/easyjasub | easyjasub-lib/src/main/java/com/github/riccardove/easyjasub/bdsup2sub/BDSup2SubWrapper.java | BDSup2SubWrapper.determineFramePal | private void determineFramePal(int index) {
if ((inMode != InputMode.VOBSUB && inMode != InputMode.SUPIFO)
|| configuration.getPaletteMode() != PaletteMode.KEEP_EXISTING) {
// get the primary color from the source palette
int rgbSrc[] = subtitleStream.getPalette().getRGB(
subtitleStream.getPrimaryColorIndex());
// match with primary color from 16 color target palette
// note: skip index 0 , primary colors at even positions
// special treatment for index 1: white
Palette trgPallete = currentDVDPalette;
int minDistance = 0xffffff; // init > 0xff*0xff*3 = 0x02fa03
int colIdx = 0;
for (int idx = 1; idx < trgPallete.getSize(); idx += 2) {
int rgb[] = trgPallete.getRGB(idx);
// distance vector (skip sqrt)
int rd = rgbSrc[0] - rgb[0];
int gd = rgbSrc[1] - rgb[1];
int bd = rgbSrc[2] - rgb[2];
int distance = rd * rd + gd * gd + bd * bd;
// new minimum distance ?
if (distance < minDistance) {
colIdx = idx;
minDistance = distance;
if (minDistance == 0) {
break;
}
}
// special treatment for index 1 (white)
if (idx == 1) {
idx--; // -> continue with index = 2
}
}
// set new frame palette
int palFrame[] = new int[4];
palFrame[0] = 0; // black - transparent color
palFrame[1] = colIdx; // primary color
if (colIdx == 1) {
palFrame[2] = colIdx + 2; // special handling: white + dark grey
} else {
palFrame[2] = colIdx + 1; // darker version of primary color
}
palFrame[3] = 0; // black - opaque
subVobTrg.setAlpha(DEFAULT_ALPHA);
subVobTrg.setPal(palFrame);
trgPal = SupDvdUtil.decodePalette(subVobTrg, trgPallete);
}
} | java | private void determineFramePal(int index) {
if ((inMode != InputMode.VOBSUB && inMode != InputMode.SUPIFO)
|| configuration.getPaletteMode() != PaletteMode.KEEP_EXISTING) {
// get the primary color from the source palette
int rgbSrc[] = subtitleStream.getPalette().getRGB(
subtitleStream.getPrimaryColorIndex());
// match with primary color from 16 color target palette
// note: skip index 0 , primary colors at even positions
// special treatment for index 1: white
Palette trgPallete = currentDVDPalette;
int minDistance = 0xffffff; // init > 0xff*0xff*3 = 0x02fa03
int colIdx = 0;
for (int idx = 1; idx < trgPallete.getSize(); idx += 2) {
int rgb[] = trgPallete.getRGB(idx);
// distance vector (skip sqrt)
int rd = rgbSrc[0] - rgb[0];
int gd = rgbSrc[1] - rgb[1];
int bd = rgbSrc[2] - rgb[2];
int distance = rd * rd + gd * gd + bd * bd;
// new minimum distance ?
if (distance < minDistance) {
colIdx = idx;
minDistance = distance;
if (minDistance == 0) {
break;
}
}
// special treatment for index 1 (white)
if (idx == 1) {
idx--; // -> continue with index = 2
}
}
// set new frame palette
int palFrame[] = new int[4];
palFrame[0] = 0; // black - transparent color
palFrame[1] = colIdx; // primary color
if (colIdx == 1) {
palFrame[2] = colIdx + 2; // special handling: white + dark grey
} else {
palFrame[2] = colIdx + 1; // darker version of primary color
}
palFrame[3] = 0; // black - opaque
subVobTrg.setAlpha(DEFAULT_ALPHA);
subVobTrg.setPal(palFrame);
trgPal = SupDvdUtil.decodePalette(subVobTrg, trgPallete);
}
} | [
"private",
"void",
"determineFramePal",
"(",
"int",
"index",
")",
"{",
"if",
"(",
"(",
"inMode",
"!=",
"InputMode",
".",
"VOBSUB",
"&&",
"inMode",
"!=",
"InputMode",
".",
"SUPIFO",
")",
"||",
"configuration",
".",
"getPaletteMode",
"(",
")",
"!=",
"PaletteMode",
".",
"KEEP_EXISTING",
")",
"{",
"// get the primary color from the source palette\r",
"int",
"rgbSrc",
"[",
"]",
"=",
"subtitleStream",
".",
"getPalette",
"(",
")",
".",
"getRGB",
"(",
"subtitleStream",
".",
"getPrimaryColorIndex",
"(",
")",
")",
";",
"// match with primary color from 16 color target palette\r",
"// note: skip index 0 , primary colors at even positions\r",
"// special treatment for index 1: white\r",
"Palette",
"trgPallete",
"=",
"currentDVDPalette",
";",
"int",
"minDistance",
"=",
"0xffffff",
";",
"// init > 0xff*0xff*3 = 0x02fa03\r",
"int",
"colIdx",
"=",
"0",
";",
"for",
"(",
"int",
"idx",
"=",
"1",
";",
"idx",
"<",
"trgPallete",
".",
"getSize",
"(",
")",
";",
"idx",
"+=",
"2",
")",
"{",
"int",
"rgb",
"[",
"]",
"=",
"trgPallete",
".",
"getRGB",
"(",
"idx",
")",
";",
"// distance vector (skip sqrt)\r",
"int",
"rd",
"=",
"rgbSrc",
"[",
"0",
"]",
"-",
"rgb",
"[",
"0",
"]",
";",
"int",
"gd",
"=",
"rgbSrc",
"[",
"1",
"]",
"-",
"rgb",
"[",
"1",
"]",
";",
"int",
"bd",
"=",
"rgbSrc",
"[",
"2",
"]",
"-",
"rgb",
"[",
"2",
"]",
";",
"int",
"distance",
"=",
"rd",
"*",
"rd",
"+",
"gd",
"*",
"gd",
"+",
"bd",
"*",
"bd",
";",
"// new minimum distance ?\r",
"if",
"(",
"distance",
"<",
"minDistance",
")",
"{",
"colIdx",
"=",
"idx",
";",
"minDistance",
"=",
"distance",
";",
"if",
"(",
"minDistance",
"==",
"0",
")",
"{",
"break",
";",
"}",
"}",
"// special treatment for index 1 (white)\r",
"if",
"(",
"idx",
"==",
"1",
")",
"{",
"idx",
"--",
";",
"// -> continue with index = 2\r",
"}",
"}",
"// set new frame palette\r",
"int",
"palFrame",
"[",
"]",
"=",
"new",
"int",
"[",
"4",
"]",
";",
"palFrame",
"[",
"0",
"]",
"=",
"0",
";",
"// black - transparent color\r",
"palFrame",
"[",
"1",
"]",
"=",
"colIdx",
";",
"// primary color\r",
"if",
"(",
"colIdx",
"==",
"1",
")",
"{",
"palFrame",
"[",
"2",
"]",
"=",
"colIdx",
"+",
"2",
";",
"// special handling: white + dark grey\r",
"}",
"else",
"{",
"palFrame",
"[",
"2",
"]",
"=",
"colIdx",
"+",
"1",
";",
"// darker version of primary color\r",
"}",
"palFrame",
"[",
"3",
"]",
"=",
"0",
";",
"// black - opaque\r",
"subVobTrg",
".",
"setAlpha",
"(",
"DEFAULT_ALPHA",
")",
";",
"subVobTrg",
".",
"setPal",
"(",
"palFrame",
")",
";",
"trgPal",
"=",
"SupDvdUtil",
".",
"decodePalette",
"(",
"subVobTrg",
",",
"trgPallete",
")",
";",
"}",
"}"
] | Create the frame individual 4-color palette for VobSub mode.
@index Index of caption | [
"Create",
"the",
"frame",
"individual",
"4",
"-",
"color",
"palette",
"for",
"VobSub",
"mode",
"."
] | 58d6af66b1b1c738326c74d9ad5e4ad514120e27 | https://github.com/riccardove/easyjasub/blob/58d6af66b1b1c738326c74d9ad5e4ad514120e27/easyjasub-lib/src/main/java/com/github/riccardove/easyjasub/bdsup2sub/BDSup2SubWrapper.java#L736-L786 | train |
padrig64/ValidationFramework | validationframework-core/src/main/java/com/google/code/validationframework/base/transform/ChainedTransformer.java | ChainedTransformer.chain | @SuppressWarnings("unchecked")
public <TO> ChainedTransformer<I, TO> chain(Transformer<O, TO> transformer) {
if (transformer != null) {
transformers.add(transformer);
}
return (ChainedTransformer<I, TO>) this;
} | java | @SuppressWarnings("unchecked")
public <TO> ChainedTransformer<I, TO> chain(Transformer<O, TO> transformer) {
if (transformer != null) {
transformers.add(transformer);
}
return (ChainedTransformer<I, TO>) this;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"TO",
">",
"ChainedTransformer",
"<",
"I",
",",
"TO",
">",
"chain",
"(",
"Transformer",
"<",
"O",
",",
"TO",
">",
"transformer",
")",
"{",
"if",
"(",
"transformer",
"!=",
"null",
")",
"{",
"transformers",
".",
"add",
"(",
"transformer",
")",
";",
"}",
"return",
"(",
"ChainedTransformer",
"<",
"I",
",",
"TO",
">",
")",
"this",
";",
"}"
] | Adds the specified transformer to the chain.
@param transformer Transformer to be added.
@param <TO> Type of output of the specified transformer.
@return This. | [
"Adds",
"the",
"specified",
"transformer",
"to",
"the",
"chain",
"."
] | 2dd3c7b3403993db366d24a927645f467ccd1dda | https://github.com/padrig64/ValidationFramework/blob/2dd3c7b3403993db366d24a927645f467ccd1dda/validationframework-core/src/main/java/com/google/code/validationframework/base/transform/ChainedTransformer.java#L69-L75 | train |
padrig64/ValidationFramework | validationframework-core/src/main/java/com/google/code/validationframework/base/validator/ResultAggregationValidator.java | ResultAggregationValidator.processResult | protected void processResult(RHI aggregatedResult) {
// Process the result with all result handlers
for (ResultHandler<RHI> resultHandler : resultHandlers) {
resultHandler.handleResult(aggregatedResult);
}
} | java | protected void processResult(RHI aggregatedResult) {
// Process the result with all result handlers
for (ResultHandler<RHI> resultHandler : resultHandlers) {
resultHandler.handleResult(aggregatedResult);
}
} | [
"protected",
"void",
"processResult",
"(",
"RHI",
"aggregatedResult",
")",
"{",
"// Process the result with all result handlers",
"for",
"(",
"ResultHandler",
"<",
"RHI",
">",
"resultHandler",
":",
"resultHandlers",
")",
"{",
"resultHandler",
".",
"handleResult",
"(",
"aggregatedResult",
")",
";",
"}",
"}"
] | Handles the specified aggregated result using all result handlers.
@param aggregatedResult Aggregated result to be processed by all result handlers. | [
"Handles",
"the",
"specified",
"aggregated",
"result",
"using",
"all",
"result",
"handlers",
"."
] | 2dd3c7b3403993db366d24a927645f467ccd1dda | https://github.com/padrig64/ValidationFramework/blob/2dd3c7b3403993db366d24a927645f467ccd1dda/validationframework-core/src/main/java/com/google/code/validationframework/base/validator/ResultAggregationValidator.java#L120-L125 | train |
checkstyle-addons/checkstyle-addons | src/main/java/com/thomasjensen/checkstyle/addons/util/Util.java | Util.getFirstIdent | @CheckForNull
public static String getFirstIdent(@Nonnull final DetailAST pAst)
{
String result = null;
DetailAST ast = pAst.findFirstToken(TokenTypes.IDENT);
if (ast != null) {
result = ast.getText();
}
return result;
} | java | @CheckForNull
public static String getFirstIdent(@Nonnull final DetailAST pAst)
{
String result = null;
DetailAST ast = pAst.findFirstToken(TokenTypes.IDENT);
if (ast != null) {
result = ast.getText();
}
return result;
} | [
"@",
"CheckForNull",
"public",
"static",
"String",
"getFirstIdent",
"(",
"@",
"Nonnull",
"final",
"DetailAST",
"pAst",
")",
"{",
"String",
"result",
"=",
"null",
";",
"DetailAST",
"ast",
"=",
"pAst",
".",
"findFirstToken",
"(",
"TokenTypes",
".",
"IDENT",
")",
";",
"if",
"(",
"ast",
"!=",
"null",
")",
"{",
"result",
"=",
"ast",
".",
"getText",
"(",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Determine the text of the first direct IDENT child node.
@param pAst an AST
@return the first encountered IDENT text, or <code>null</code> if none was found | [
"Determine",
"the",
"text",
"of",
"the",
"first",
"direct",
"IDENT",
"child",
"node",
"."
] | fae1b4d341639c8e32c3e59ec5abdc0ffc11b865 | https://github.com/checkstyle-addons/checkstyle-addons/blob/fae1b4d341639c8e32c3e59ec5abdc0ffc11b865/src/main/java/com/thomasjensen/checkstyle/addons/util/Util.java#L67-L76 | train |
checkstyle-addons/checkstyle-addons | src/main/java/com/thomasjensen/checkstyle/addons/util/Util.java | Util.getFullIdent | @CheckForNull
public static String getFullIdent(@Nonnull final DetailAST pAst)
{
String result = null;
DetailAST ast = checkTokens(pAst.getFirstChild(), TokenTypes.DOT, TokenTypes.IDENT);
if (ast != null) {
StringBuilder sb = new StringBuilder();
if (getFullIdentInternal(ast, sb)) {
result = sb.toString();
}
}
return result;
} | java | @CheckForNull
public static String getFullIdent(@Nonnull final DetailAST pAst)
{
String result = null;
DetailAST ast = checkTokens(pAst.getFirstChild(), TokenTypes.DOT, TokenTypes.IDENT);
if (ast != null) {
StringBuilder sb = new StringBuilder();
if (getFullIdentInternal(ast, sb)) {
result = sb.toString();
}
}
return result;
} | [
"@",
"CheckForNull",
"public",
"static",
"String",
"getFullIdent",
"(",
"@",
"Nonnull",
"final",
"DetailAST",
"pAst",
")",
"{",
"String",
"result",
"=",
"null",
";",
"DetailAST",
"ast",
"=",
"checkTokens",
"(",
"pAst",
".",
"getFirstChild",
"(",
")",
",",
"TokenTypes",
".",
"DOT",
",",
"TokenTypes",
".",
"IDENT",
")",
";",
"if",
"(",
"ast",
"!=",
"null",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"getFullIdentInternal",
"(",
"ast",
",",
"sb",
")",
")",
"{",
"result",
"=",
"sb",
".",
"toString",
"(",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] | Determine the full identifier of the current element on the AST. The identifier is built from DOT and IDENT
elements found directly below the specified element. Other elements encountered are ignored.
@param pAst an AST
@return the full identifier constructed from either the first encountered IDENT or DOT; <code>null</code> if no
identifier could be constructed | [
"Determine",
"the",
"full",
"identifier",
"of",
"the",
"current",
"element",
"on",
"the",
"AST",
".",
"The",
"identifier",
"is",
"built",
"from",
"DOT",
"and",
"IDENT",
"elements",
"found",
"directly",
"below",
"the",
"specified",
"element",
".",
"Other",
"elements",
"encountered",
"are",
"ignored",
"."
] | fae1b4d341639c8e32c3e59ec5abdc0ffc11b865 | https://github.com/checkstyle-addons/checkstyle-addons/blob/fae1b4d341639c8e32c3e59ec5abdc0ffc11b865/src/main/java/com/thomasjensen/checkstyle/addons/util/Util.java#L88-L100 | train |
checkstyle-addons/checkstyle-addons | src/main/java/com/thomasjensen/checkstyle/addons/util/Util.java | Util.containsString | public static boolean containsString(@Nullable final Iterable<String> pIterable, @Nullable final String pSearched,
final boolean pCaseSensitive)
{
boolean result = false;
if (pSearched != null && pIterable != null) {
for (String s : pIterable) {
if (stringEquals(pSearched, s, pCaseSensitive)) {
result = true;
break;
}
}
}
return result;
} | java | public static boolean containsString(@Nullable final Iterable<String> pIterable, @Nullable final String pSearched,
final boolean pCaseSensitive)
{
boolean result = false;
if (pSearched != null && pIterable != null) {
for (String s : pIterable) {
if (stringEquals(pSearched, s, pCaseSensitive)) {
result = true;
break;
}
}
}
return result;
} | [
"public",
"static",
"boolean",
"containsString",
"(",
"@",
"Nullable",
"final",
"Iterable",
"<",
"String",
">",
"pIterable",
",",
"@",
"Nullable",
"final",
"String",
"pSearched",
",",
"final",
"boolean",
"pCaseSensitive",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"if",
"(",
"pSearched",
"!=",
"null",
"&&",
"pIterable",
"!=",
"null",
")",
"{",
"for",
"(",
"String",
"s",
":",
"pIterable",
")",
"{",
"if",
"(",
"stringEquals",
"(",
"pSearched",
",",
"s",
",",
"pCaseSensitive",
")",
")",
"{",
"result",
"=",
"true",
";",
"break",
";",
"}",
"}",
"}",
"return",
"result",
";",
"}"
] | Search for a String in a collection.
@param pIterable the list of String to be searched
@param pSearched the String to search for
@param pCaseSensitive if comparisons should be case sensitive
@return <code>true</code> if found, <code>false</code> otherwise | [
"Search",
"for",
"a",
"String",
"in",
"a",
"collection",
"."
] | fae1b4d341639c8e32c3e59ec5abdc0ffc11b865 | https://github.com/checkstyle-addons/checkstyle-addons/blob/fae1b4d341639c8e32c3e59ec5abdc0ffc11b865/src/main/java/com/thomasjensen/checkstyle/addons/util/Util.java#L242-L255 | train |
checkstyle-addons/checkstyle-addons | src/main/java/com/thomasjensen/checkstyle/addons/util/Util.java | Util.stringEquals | public static boolean stringEquals(@Nullable final String pStr1, @Nullable final String pStr2,
final boolean pCaseSensitive)
{
boolean result = false;
if (pStr1 == null && pStr2 == null) {
result = true;
}
else if (pStr1 != null) {
if (pCaseSensitive) {
result = pStr1.equals(pStr2);
}
else {
result = pStr1.equalsIgnoreCase(pStr2);
}
}
return result;
} | java | public static boolean stringEquals(@Nullable final String pStr1, @Nullable final String pStr2,
final boolean pCaseSensitive)
{
boolean result = false;
if (pStr1 == null && pStr2 == null) {
result = true;
}
else if (pStr1 != null) {
if (pCaseSensitive) {
result = pStr1.equals(pStr2);
}
else {
result = pStr1.equalsIgnoreCase(pStr2);
}
}
return result;
} | [
"public",
"static",
"boolean",
"stringEquals",
"(",
"@",
"Nullable",
"final",
"String",
"pStr1",
",",
"@",
"Nullable",
"final",
"String",
"pStr2",
",",
"final",
"boolean",
"pCaseSensitive",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"if",
"(",
"pStr1",
"==",
"null",
"&&",
"pStr2",
"==",
"null",
")",
"{",
"result",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"pStr1",
"!=",
"null",
")",
"{",
"if",
"(",
"pCaseSensitive",
")",
"{",
"result",
"=",
"pStr1",
".",
"equals",
"(",
"pStr2",
")",
";",
"}",
"else",
"{",
"result",
"=",
"pStr1",
".",
"equalsIgnoreCase",
"(",
"pStr2",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] | Determine the equality of two Strings, optionally ignoring case.
@param pStr1 the first String
@param pStr2 the second String
@param pCaseSensitive if the comparison should be case sensitive
@return <code>true</code> if the String are equal, <code>false</code> otherwise | [
"Determine",
"the",
"equality",
"of",
"two",
"Strings",
"optionally",
"ignoring",
"case",
"."
] | fae1b4d341639c8e32c3e59ec5abdc0ffc11b865 | https://github.com/checkstyle-addons/checkstyle-addons/blob/fae1b4d341639c8e32c3e59ec5abdc0ffc11b865/src/main/java/com/thomasjensen/checkstyle/addons/util/Util.java#L267-L283 | train |
checkstyle-addons/checkstyle-addons | src/main/java/com/thomasjensen/checkstyle/addons/util/Util.java | Util.findLeftMostTokenInLine | @Nonnull
public static DetailAST findLeftMostTokenInLine(@Nonnull final DetailAST pAst)
{
return findLeftMostTokenInLineInternal(pAst, pAst.getLineNo(), pAst.getColumnNo());
} | java | @Nonnull
public static DetailAST findLeftMostTokenInLine(@Nonnull final DetailAST pAst)
{
return findLeftMostTokenInLineInternal(pAst, pAst.getLineNo(), pAst.getColumnNo());
} | [
"@",
"Nonnull",
"public",
"static",
"DetailAST",
"findLeftMostTokenInLine",
"(",
"@",
"Nonnull",
"final",
"DetailAST",
"pAst",
")",
"{",
"return",
"findLeftMostTokenInLineInternal",
"(",
"pAst",
",",
"pAst",
".",
"getLineNo",
"(",
")",
",",
"pAst",
".",
"getColumnNo",
"(",
")",
")",
";",
"}"
] | Find the left-most token in the given AST. The left-most token is the token with the smallest column number. Only
tokens which are located on the same line as the given AST are considered.
@param pAst the root of a subtree. This token is also considered for the result.
@return the left-most token | [
"Find",
"the",
"left",
"-",
"most",
"token",
"in",
"the",
"given",
"AST",
".",
"The",
"left",
"-",
"most",
"token",
"is",
"the",
"token",
"with",
"the",
"smallest",
"column",
"number",
".",
"Only",
"tokens",
"which",
"are",
"located",
"on",
"the",
"same",
"line",
"as",
"the",
"given",
"AST",
"are",
"considered",
"."
] | fae1b4d341639c8e32c3e59ec5abdc0ffc11b865 | https://github.com/checkstyle-addons/checkstyle-addons/blob/fae1b4d341639c8e32c3e59ec5abdc0ffc11b865/src/main/java/com/thomasjensen/checkstyle/addons/util/Util.java#L317-L321 | train |
padrig64/ValidationFramework | validationframework-swing/src/main/java/com/google/code/validationframework/swing/decoration/IconComponentDecoration.java | IconComponentDecoration.setToolTipText | public void setToolTipText(String text) {
this.toolTipText = text;
if (toolTipDialog != null) {
toolTipDialog.setText(text);
}
} | java | public void setToolTipText(String text) {
this.toolTipText = text;
if (toolTipDialog != null) {
toolTipDialog.setText(text);
}
} | [
"public",
"void",
"setToolTipText",
"(",
"String",
"text",
")",
"{",
"this",
".",
"toolTipText",
"=",
"text",
";",
"if",
"(",
"toolTipDialog",
"!=",
"null",
")",
"{",
"toolTipDialog",
".",
"setText",
"(",
"text",
")",
";",
"}",
"}"
] | Sets the text for the tooltip to be used on this decoration.
@param text Tooltip text for this decoration, or null if this decoration should have no tooltip. | [
"Sets",
"the",
"text",
"for",
"the",
"tooltip",
"to",
"be",
"used",
"on",
"this",
"decoration",
"."
] | 2dd3c7b3403993db366d24a927645f467ccd1dda | https://github.com/padrig64/ValidationFramework/blob/2dd3c7b3403993db366d24a927645f467ccd1dda/validationframework-swing/src/main/java/com/google/code/validationframework/swing/decoration/IconComponentDecoration.java#L272-L277 | train |
padrig64/ValidationFramework | validationframework-swing/src/main/java/com/google/code/validationframework/swing/decoration/IconComponentDecoration.java | IconComponentDecoration.updateToolTipDialogVisibility | private void updateToolTipDialogVisibility() {
// Determine whether tooltip should be/remain visible
boolean shouldBeVisible = isOverDecorationPainter() || isOverToolTipDialog();
// Create tooltip dialog if needed
if (shouldBeVisible) {
createToolTipDialogIfNeeded();
}
// Update tooltip dialog visibility if changed
if ((toolTipDialog != null) && (toolTipDialog.isVisible() != shouldBeVisible)) {
toolTipDialog.setVisible(shouldBeVisible);
}
} | java | private void updateToolTipDialogVisibility() {
// Determine whether tooltip should be/remain visible
boolean shouldBeVisible = isOverDecorationPainter() || isOverToolTipDialog();
// Create tooltip dialog if needed
if (shouldBeVisible) {
createToolTipDialogIfNeeded();
}
// Update tooltip dialog visibility if changed
if ((toolTipDialog != null) && (toolTipDialog.isVisible() != shouldBeVisible)) {
toolTipDialog.setVisible(shouldBeVisible);
}
} | [
"private",
"void",
"updateToolTipDialogVisibility",
"(",
")",
"{",
"// Determine whether tooltip should be/remain visible",
"boolean",
"shouldBeVisible",
"=",
"isOverDecorationPainter",
"(",
")",
"||",
"isOverToolTipDialog",
"(",
")",
";",
"// Create tooltip dialog if needed",
"if",
"(",
"shouldBeVisible",
")",
"{",
"createToolTipDialogIfNeeded",
"(",
")",
";",
"}",
"// Update tooltip dialog visibility if changed",
"if",
"(",
"(",
"toolTipDialog",
"!=",
"null",
")",
"&&",
"(",
"toolTipDialog",
".",
"isVisible",
"(",
")",
"!=",
"shouldBeVisible",
")",
")",
"{",
"toolTipDialog",
".",
"setVisible",
"(",
"shouldBeVisible",
")",
";",
"}",
"}"
] | Updates the visibility of the tooltip dialog according to the mouse pointer location, the visibility of the
decoration painter and the bounds of the decoration painter.
@see AbstractComponentDecoration#updateDecorationPainterVisibility() | [
"Updates",
"the",
"visibility",
"of",
"the",
"tooltip",
"dialog",
"according",
"to",
"the",
"mouse",
"pointer",
"location",
"the",
"visibility",
"of",
"the",
"decoration",
"painter",
"and",
"the",
"bounds",
"of",
"the",
"decoration",
"painter",
"."
] | 2dd3c7b3403993db366d24a927645f467ccd1dda | https://github.com/padrig64/ValidationFramework/blob/2dd3c7b3403993db366d24a927645f467ccd1dda/validationframework-swing/src/main/java/com/google/code/validationframework/swing/decoration/IconComponentDecoration.java#L312-L325 | train |
google/cloud-reporting | src/main/java/com/google/cloud/metrics/MetricsSender.java | MetricsSender.send | public void send(Event event) throws MetricsException {
HttpPost request = new HttpPost(MetricsUtils.GA_ENDPOINT_URL);
request.setEntity(MetricsUtils.buildPostBody(event, analyticsId, random));
try {
client.execute(request, RESPONSE_HANDLER);
} catch (IOException e) {
// All errors in the request execution, including non-2XX HTTP codes,
// will throw IOException or one of its subclasses.
throw new MetricsCommunicationException("Problem sending request to server", e);
}
} | java | public void send(Event event) throws MetricsException {
HttpPost request = new HttpPost(MetricsUtils.GA_ENDPOINT_URL);
request.setEntity(MetricsUtils.buildPostBody(event, analyticsId, random));
try {
client.execute(request, RESPONSE_HANDLER);
} catch (IOException e) {
// All errors in the request execution, including non-2XX HTTP codes,
// will throw IOException or one of its subclasses.
throw new MetricsCommunicationException("Problem sending request to server", e);
}
} | [
"public",
"void",
"send",
"(",
"Event",
"event",
")",
"throws",
"MetricsException",
"{",
"HttpPost",
"request",
"=",
"new",
"HttpPost",
"(",
"MetricsUtils",
".",
"GA_ENDPOINT_URL",
")",
";",
"request",
".",
"setEntity",
"(",
"MetricsUtils",
".",
"buildPostBody",
"(",
"event",
",",
"analyticsId",
",",
"random",
")",
")",
";",
"try",
"{",
"client",
".",
"execute",
"(",
"request",
",",
"RESPONSE_HANDLER",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"// All errors in the request execution, including non-2XX HTTP codes,",
"// will throw IOException or one of its subclasses.",
"throw",
"new",
"MetricsCommunicationException",
"(",
"\"Problem sending request to server\"",
",",
"e",
")",
";",
"}",
"}"
] | Translates an encapsulated event into a request to the Google Analytics API and sends the
resulting request. | [
"Translates",
"an",
"encapsulated",
"event",
"into",
"a",
"request",
"to",
"the",
"Google",
"Analytics",
"API",
"and",
"sends",
"the",
"resulting",
"request",
"."
] | af2a8ff6077a9763f7f2d405dd55c82efaead0ac | https://github.com/google/cloud-reporting/blob/af2a8ff6077a9763f7f2d405dd55c82efaead0ac/src/main/java/com/google/cloud/metrics/MetricsSender.java#L70-L80 | train |
detro/browsermob-proxy-client | src/main/java/com/github/detro/browsermobproxyclient/manager/BMPCLocalManager.java | BMPCLocalManager.isRunning | public synchronized boolean isRunning() {
if (null == process) return false;
try {
process.exitValue();
return false;
} catch(IllegalThreadStateException itse) {
return true;
}
} | java | public synchronized boolean isRunning() {
if (null == process) return false;
try {
process.exitValue();
return false;
} catch(IllegalThreadStateException itse) {
return true;
}
} | [
"public",
"synchronized",
"boolean",
"isRunning",
"(",
")",
"{",
"if",
"(",
"null",
"==",
"process",
")",
"return",
"false",
";",
"try",
"{",
"process",
".",
"exitValue",
"(",
")",
";",
"return",
"false",
";",
"}",
"catch",
"(",
"IllegalThreadStateException",
"itse",
")",
"{",
"return",
"true",
";",
"}",
"}"
] | Check if Local BrowserMob Proxy is running.
@return "true" if Local BrowserMob Proxy is running. | [
"Check",
"if",
"Local",
"BrowserMob",
"Proxy",
"is",
"running",
"."
] | da03deff8211b7e1153e36100c5ba60acd470a4f | https://github.com/detro/browsermob-proxy-client/blob/da03deff8211b7e1153e36100c5ba60acd470a4f/src/main/java/com/github/detro/browsermobproxyclient/manager/BMPCLocalManager.java#L184-L193 | train |
riccardove/easyjasub | easyjasub-lib/src/main/java/com/github/riccardove/easyjasub/EasyJaSubJapaneseTextConverter.java | EasyJaSubJapaneseTextConverter.convertToRomaji | private static String convertToRomaji(String katakana)
throws EasyJaSubException {
try {
return Kurikosu.convertKatakanaToRomaji(katakana);
} catch (EasyJaSubException ex) {
try {
return LuceneUtil.katakanaToRomaji(katakana);
} catch (Throwable luceneEx) {
throw ex;
}
}
} | java | private static String convertToRomaji(String katakana)
throws EasyJaSubException {
try {
return Kurikosu.convertKatakanaToRomaji(katakana);
} catch (EasyJaSubException ex) {
try {
return LuceneUtil.katakanaToRomaji(katakana);
} catch (Throwable luceneEx) {
throw ex;
}
}
} | [
"private",
"static",
"String",
"convertToRomaji",
"(",
"String",
"katakana",
")",
"throws",
"EasyJaSubException",
"{",
"try",
"{",
"return",
"Kurikosu",
".",
"convertKatakanaToRomaji",
"(",
"katakana",
")",
";",
"}",
"catch",
"(",
"EasyJaSubException",
"ex",
")",
"{",
"try",
"{",
"return",
"LuceneUtil",
".",
"katakanaToRomaji",
"(",
"katakana",
")",
";",
"}",
"catch",
"(",
"Throwable",
"luceneEx",
")",
"{",
"throw",
"ex",
";",
"}",
"}",
"}"
] | Convert katakana to romaji with Lucene converter if Kurikosu throws
errors | [
"Convert",
"katakana",
"to",
"romaji",
"with",
"Lucene",
"converter",
"if",
"Kurikosu",
"throws",
"errors"
] | 58d6af66b1b1c738326c74d9ad5e4ad514120e27 | https://github.com/riccardove/easyjasub/blob/58d6af66b1b1c738326c74d9ad5e4ad514120e27/easyjasub-lib/src/main/java/com/github/riccardove/easyjasub/EasyJaSubJapaneseTextConverter.java#L51-L62 | train |
padrig64/ValidationFramework | validationframework-experimental/src/main/java/com/google/code/validationframework/experimental/builder/context/simplevalidator/DataProviderContext.java | DataProviderContext.on | public DataProviderContext on(final Trigger... triggers) {
if (triggers != null) {
Collections.addAll(registeredTriggers, triggers);
}
return this;
} | java | public DataProviderContext on(final Trigger... triggers) {
if (triggers != null) {
Collections.addAll(registeredTriggers, triggers);
}
return this;
} | [
"public",
"DataProviderContext",
"on",
"(",
"final",
"Trigger",
"...",
"triggers",
")",
"{",
"if",
"(",
"triggers",
"!=",
"null",
")",
"{",
"Collections",
".",
"addAll",
"(",
"registeredTriggers",
",",
"triggers",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Adds more triggers to the validator.
@param triggers Triggers to be added.
@return Same data provider context. | [
"Adds",
"more",
"triggers",
"to",
"the",
"validator",
"."
] | 2dd3c7b3403993db366d24a927645f467ccd1dda | https://github.com/padrig64/ValidationFramework/blob/2dd3c7b3403993db366d24a927645f467ccd1dda/validationframework-experimental/src/main/java/com/google/code/validationframework/experimental/builder/context/simplevalidator/DataProviderContext.java#L79-L84 | train |
padrig64/ValidationFramework | validationframework-experimental/src/main/java/com/google/code/validationframework/experimental/builder/context/simplevalidator/DataProviderContext.java | DataProviderContext.read | public <D> RuleContext<D> read(final DataProvider<D>... dataProviders) {
final List<DataProvider<D>> registeredDataProviders = new ArrayList<DataProvider<D>>();
if (dataProviders != null) {
Collections.addAll(registeredDataProviders, dataProviders);
}
return new RuleContext<D>(registeredTriggers, registeredDataProviders);
} | java | public <D> RuleContext<D> read(final DataProvider<D>... dataProviders) {
final List<DataProvider<D>> registeredDataProviders = new ArrayList<DataProvider<D>>();
if (dataProviders != null) {
Collections.addAll(registeredDataProviders, dataProviders);
}
return new RuleContext<D>(registeredTriggers, registeredDataProviders);
} | [
"public",
"<",
"D",
">",
"RuleContext",
"<",
"D",
">",
"read",
"(",
"final",
"DataProvider",
"<",
"D",
">",
"...",
"dataProviders",
")",
"{",
"final",
"List",
"<",
"DataProvider",
"<",
"D",
">",
">",
"registeredDataProviders",
"=",
"new",
"ArrayList",
"<",
"DataProvider",
"<",
"D",
">",
">",
"(",
")",
";",
"if",
"(",
"dataProviders",
"!=",
"null",
")",
"{",
"Collections",
".",
"addAll",
"(",
"registeredDataProviders",
",",
"dataProviders",
")",
";",
"}",
"return",
"new",
"RuleContext",
"<",
"D",
">",
"(",
"registeredTriggers",
",",
"registeredDataProviders",
")",
";",
"}"
] | Adds the first data providers to the validator.
@param dataProviders Data providers to be added.
@param <D> Type of data to be validated.<br>It can be, for instance,
the type of data handled by a component, or the
type of the component itself.
@return Rule context allowing to add data providers and rules, but not triggers. | [
"Adds",
"the",
"first",
"data",
"providers",
"to",
"the",
"validator",
"."
] | 2dd3c7b3403993db366d24a927645f467ccd1dda | https://github.com/padrig64/ValidationFramework/blob/2dd3c7b3403993db366d24a927645f467ccd1dda/validationframework-experimental/src/main/java/com/google/code/validationframework/experimental/builder/context/simplevalidator/DataProviderContext.java#L123-L129 | train |
checkstyle-addons/checkstyle-addons | buildSrc/src/main/java/com/thomasjensen/checkstyle/addons/build/ClasspathBuilder.java | ClasspathBuilder.buildClassPath | public FileCollection buildClassPath(@Nonnull final DependencyConfig pDepConfig,
@Nullable final String pCsVersionOverride, final boolean pIsTestRun, @Nonnull final SourceSet pSourceSet1,
@Nullable final SourceSet... pOtherSourceSets)
{
FileCollection cp = getClassesDirs(pSourceSet1, pDepConfig).plus(
project.files(pSourceSet1.getOutput().getResourcesDir()));
if (pOtherSourceSets != null && pOtherSourceSets.length > 0) {
for (final SourceSet sourceSet : pOtherSourceSets) {
cp = cp.plus(getClassesDirs(sourceSet, pDepConfig)).plus(
project.files(sourceSet.getOutput().getResourcesDir()));
}
}
cp = cp.plus(project.files(//
calculateDependencies(pDepConfig, pCsVersionOverride, getConfigName(pSourceSet1, pIsTestRun))));
if (pOtherSourceSets != null && pOtherSourceSets.length > 0) {
for (final SourceSet sourceSet : pOtherSourceSets) {
cp = cp.plus(project.files(//
calculateDependencies(pDepConfig, pCsVersionOverride, getConfigName(sourceSet, pIsTestRun))));
}
}
// final Logger logger = task.getLogger();
// logger.lifecycle("---------------------------------------------------------------------------");
// logger.lifecycle("Classpath of " + task.getName() + " (" + task.getClass().getSimpleName() + "):");
// for (File f : cp) {
// logger.lifecycle("\t- " + f.getAbsolutePath());
// }
// logger.lifecycle("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
return cp;
} | java | public FileCollection buildClassPath(@Nonnull final DependencyConfig pDepConfig,
@Nullable final String pCsVersionOverride, final boolean pIsTestRun, @Nonnull final SourceSet pSourceSet1,
@Nullable final SourceSet... pOtherSourceSets)
{
FileCollection cp = getClassesDirs(pSourceSet1, pDepConfig).plus(
project.files(pSourceSet1.getOutput().getResourcesDir()));
if (pOtherSourceSets != null && pOtherSourceSets.length > 0) {
for (final SourceSet sourceSet : pOtherSourceSets) {
cp = cp.plus(getClassesDirs(sourceSet, pDepConfig)).plus(
project.files(sourceSet.getOutput().getResourcesDir()));
}
}
cp = cp.plus(project.files(//
calculateDependencies(pDepConfig, pCsVersionOverride, getConfigName(pSourceSet1, pIsTestRun))));
if (pOtherSourceSets != null && pOtherSourceSets.length > 0) {
for (final SourceSet sourceSet : pOtherSourceSets) {
cp = cp.plus(project.files(//
calculateDependencies(pDepConfig, pCsVersionOverride, getConfigName(sourceSet, pIsTestRun))));
}
}
// final Logger logger = task.getLogger();
// logger.lifecycle("---------------------------------------------------------------------------");
// logger.lifecycle("Classpath of " + task.getName() + " (" + task.getClass().getSimpleName() + "):");
// for (File f : cp) {
// logger.lifecycle("\t- " + f.getAbsolutePath());
// }
// logger.lifecycle("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
return cp;
} | [
"public",
"FileCollection",
"buildClassPath",
"(",
"@",
"Nonnull",
"final",
"DependencyConfig",
"pDepConfig",
",",
"@",
"Nullable",
"final",
"String",
"pCsVersionOverride",
",",
"final",
"boolean",
"pIsTestRun",
",",
"@",
"Nonnull",
"final",
"SourceSet",
"pSourceSet1",
",",
"@",
"Nullable",
"final",
"SourceSet",
"...",
"pOtherSourceSets",
")",
"{",
"FileCollection",
"cp",
"=",
"getClassesDirs",
"(",
"pSourceSet1",
",",
"pDepConfig",
")",
".",
"plus",
"(",
"project",
".",
"files",
"(",
"pSourceSet1",
".",
"getOutput",
"(",
")",
".",
"getResourcesDir",
"(",
")",
")",
")",
";",
"if",
"(",
"pOtherSourceSets",
"!=",
"null",
"&&",
"pOtherSourceSets",
".",
"length",
">",
"0",
")",
"{",
"for",
"(",
"final",
"SourceSet",
"sourceSet",
":",
"pOtherSourceSets",
")",
"{",
"cp",
"=",
"cp",
".",
"plus",
"(",
"getClassesDirs",
"(",
"sourceSet",
",",
"pDepConfig",
")",
")",
".",
"plus",
"(",
"project",
".",
"files",
"(",
"sourceSet",
".",
"getOutput",
"(",
")",
".",
"getResourcesDir",
"(",
")",
")",
")",
";",
"}",
"}",
"cp",
"=",
"cp",
".",
"plus",
"(",
"project",
".",
"files",
"(",
"//",
"calculateDependencies",
"(",
"pDepConfig",
",",
"pCsVersionOverride",
",",
"getConfigName",
"(",
"pSourceSet1",
",",
"pIsTestRun",
")",
")",
")",
")",
";",
"if",
"(",
"pOtherSourceSets",
"!=",
"null",
"&&",
"pOtherSourceSets",
".",
"length",
">",
"0",
")",
"{",
"for",
"(",
"final",
"SourceSet",
"sourceSet",
":",
"pOtherSourceSets",
")",
"{",
"cp",
"=",
"cp",
".",
"plus",
"(",
"project",
".",
"files",
"(",
"//",
"calculateDependencies",
"(",
"pDepConfig",
",",
"pCsVersionOverride",
",",
"getConfigName",
"(",
"sourceSet",
",",
"pIsTestRun",
")",
")",
")",
")",
";",
"}",
"}",
"// final Logger logger = task.getLogger();",
"// logger.lifecycle(\"---------------------------------------------------------------------------\");",
"// logger.lifecycle(\"Classpath of \" + task.getName() + \" (\" + task.getClass().getSimpleName() + \"):\");",
"// for (File f : cp) {",
"// logger.lifecycle(\"\\t- \" + f.getAbsolutePath());",
"// }",
"// logger.lifecycle(\"- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\");",
"return",
"cp",
";",
"}"
] | Run the classpath builder to produce a classpath for compilation, running the Javadoc generation, or running
unit tests.
@param pDepConfig the dependency configuration
@param pCsVersionOverride if a Checkstyle runtime should be used which is different from the base version given
as part of the dependency configuration
@param pIsTestRun if the resulting classpath if to be used to <em>execute</em> tests (rather than compile them)
@param pSourceSet1 source set to include first in the constructed classpath
@param pOtherSourceSets more source sets to include
@return the classpath | [
"Run",
"the",
"classpath",
"builder",
"to",
"produce",
"a",
"classpath",
"for",
"compilation",
"running",
"the",
"Javadoc",
"generation",
"or",
"running",
"unit",
"tests",
"."
] | fae1b4d341639c8e32c3e59ec5abdc0ffc11b865 | https://github.com/checkstyle-addons/checkstyle-addons/blob/fae1b4d341639c8e32c3e59ec5abdc0ffc11b865/buildSrc/src/main/java/com/thomasjensen/checkstyle/addons/build/ClasspathBuilder.java#L135-L165 | train |
padrig64/ValidationFramework | validationframework-core/src/main/java/com/google/code/validationframework/base/validator/generalvalidator/dsl/GeneralValidatorBuilder.java | GeneralValidatorBuilder.on | public static TriggerContext on(Trigger trigger) {
List<Trigger> addedTriggers = new ArrayList<Trigger>();
if (trigger != null) {
addedTriggers.add(trigger);
}
return new TriggerContext(addedTriggers);
} | java | public static TriggerContext on(Trigger trigger) {
List<Trigger> addedTriggers = new ArrayList<Trigger>();
if (trigger != null) {
addedTriggers.add(trigger);
}
return new TriggerContext(addedTriggers);
} | [
"public",
"static",
"TriggerContext",
"on",
"(",
"Trigger",
"trigger",
")",
"{",
"List",
"<",
"Trigger",
">",
"addedTriggers",
"=",
"new",
"ArrayList",
"<",
"Trigger",
">",
"(",
")",
";",
"if",
"(",
"trigger",
"!=",
"null",
")",
"{",
"addedTriggers",
".",
"add",
"(",
"trigger",
")",
";",
"}",
"return",
"new",
"TriggerContext",
"(",
"addedTriggers",
")",
";",
"}"
] | Adds the specified trigger to the validator under construction.
@param trigger Trigger to be added.
@return Context allowing further construction of the validator using the DSL. | [
"Adds",
"the",
"specified",
"trigger",
"to",
"the",
"validator",
"under",
"construction",
"."
] | 2dd3c7b3403993db366d24a927645f467ccd1dda | https://github.com/padrig64/ValidationFramework/blob/2dd3c7b3403993db366d24a927645f467ccd1dda/validationframework-core/src/main/java/com/google/code/validationframework/base/validator/generalvalidator/dsl/GeneralValidatorBuilder.java#L67-L73 | train |
anotheria/configureme | src/main/java/org/configureme/sources/FileLoader.java | FileLoader.getFileName | public static String getFileName(final ConfigurationSourceKey source){
//ensure an exception is thrown if we are not file.
if (source.getType()!=ConfigurationSourceKey.Type.FILE)
throw new AssertionError("Can only load configuration sources with type "+ConfigurationSourceKey.Type.FILE);
return source.getName()+ '.' +source.getFormat().getExtension();
} | java | public static String getFileName(final ConfigurationSourceKey source){
//ensure an exception is thrown if we are not file.
if (source.getType()!=ConfigurationSourceKey.Type.FILE)
throw new AssertionError("Can only load configuration sources with type "+ConfigurationSourceKey.Type.FILE);
return source.getName()+ '.' +source.getFormat().getExtension();
} | [
"public",
"static",
"String",
"getFileName",
"(",
"final",
"ConfigurationSourceKey",
"source",
")",
"{",
"//ensure an exception is thrown if we are not file.",
"if",
"(",
"source",
".",
"getType",
"(",
")",
"!=",
"ConfigurationSourceKey",
".",
"Type",
".",
"FILE",
")",
"throw",
"new",
"AssertionError",
"(",
"\"Can only load configuration sources with type \"",
"+",
"ConfigurationSourceKey",
".",
"Type",
".",
"FILE",
")",
";",
"return",
"source",
".",
"getName",
"(",
")",
"+",
"'",
"'",
"+",
"source",
".",
"getFormat",
"(",
")",
".",
"getExtension",
"(",
")",
";",
"}"
] | Returns the file name for the given source key.
@param source configuration source key
@return the file name for the given source key | [
"Returns",
"the",
"file",
"name",
"for",
"the",
"given",
"source",
"key",
"."
] | 1f52dd9109349623190586bdf5a592de8016e1fa | https://github.com/anotheria/configureme/blob/1f52dd9109349623190586bdf5a592de8016e1fa/src/main/java/org/configureme/sources/FileLoader.java#L37-L42 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/widget/PickerFragment.java | PickerFragment.setExtraFields | public void setExtraFields(Collection<String> fields) {
extraFields = new HashSet<String>();
if (fields != null) {
extraFields.addAll(fields);
}
} | java | public void setExtraFields(Collection<String> fields) {
extraFields = new HashSet<String>();
if (fields != null) {
extraFields.addAll(fields);
}
} | [
"public",
"void",
"setExtraFields",
"(",
"Collection",
"<",
"String",
">",
"fields",
")",
"{",
"extraFields",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"if",
"(",
"fields",
"!=",
"null",
")",
"{",
"extraFields",
".",
"addAll",
"(",
"fields",
")",
";",
"}",
"}"
] | Sets the extra fields to request for the retrieved graph objects.
@param fields the extra fields to request | [
"Sets",
"the",
"extra",
"fields",
"to",
"request",
"for",
"the",
"retrieved",
"graph",
"objects",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/widget/PickerFragment.java#L411-L416 | train |
mnlipp/jgrapes | org.jgrapes.util/src/org/jgrapes/util/events/KeyValueStoreData.java | KeyValueStoreData.data | public Map<String,String> data() {
try {
return event().get();
} catch (InterruptedException e) {
// Can only happen if invoked before completion
throw new IllegalStateException(e);
}
} | java | public Map<String,String> data() {
try {
return event().get();
} catch (InterruptedException e) {
// Can only happen if invoked before completion
throw new IllegalStateException(e);
}
} | [
"public",
"Map",
"<",
"String",
",",
"String",
">",
"data",
"(",
")",
"{",
"try",
"{",
"return",
"event",
"(",
")",
".",
"get",
"(",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"// Can only happen if invoked before completion",
"throw",
"new",
"IllegalStateException",
"(",
"e",
")",
";",
"}",
"}"
] | A shortcut to get the result of the completed query event.
@return the data | [
"A",
"shortcut",
"to",
"get",
"the",
"result",
"of",
"the",
"completed",
"query",
"event",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.util/src/org/jgrapes/util/events/KeyValueStoreData.java#L49-L56 | train |
mnlipp/jgrapes | examples/src/org/jgrapes/examples/io/tcpecho/EchoServer.java | EchoServer.onRead | @Handler
public void onRead(Input<ByteBuffer> event)
throws InterruptedException {
for (IOSubchannel channel : event.channels(IOSubchannel.class)) {
ManagedBuffer<ByteBuffer> out = channel.byteBufferPool().acquire();
out.backingBuffer().put(event.buffer().backingBuffer());
channel.respond(Output.fromSink(out, event.isEndOfRecord()));
}
} | java | @Handler
public void onRead(Input<ByteBuffer> event)
throws InterruptedException {
for (IOSubchannel channel : event.channels(IOSubchannel.class)) {
ManagedBuffer<ByteBuffer> out = channel.byteBufferPool().acquire();
out.backingBuffer().put(event.buffer().backingBuffer());
channel.respond(Output.fromSink(out, event.isEndOfRecord()));
}
} | [
"@",
"Handler",
"public",
"void",
"onRead",
"(",
"Input",
"<",
"ByteBuffer",
">",
"event",
")",
"throws",
"InterruptedException",
"{",
"for",
"(",
"IOSubchannel",
"channel",
":",
"event",
".",
"channels",
"(",
"IOSubchannel",
".",
"class",
")",
")",
"{",
"ManagedBuffer",
"<",
"ByteBuffer",
">",
"out",
"=",
"channel",
".",
"byteBufferPool",
"(",
")",
".",
"acquire",
"(",
")",
";",
"out",
".",
"backingBuffer",
"(",
")",
".",
"put",
"(",
"event",
".",
"buffer",
"(",
")",
".",
"backingBuffer",
"(",
")",
")",
";",
"channel",
".",
"respond",
"(",
"Output",
".",
"fromSink",
"(",
"out",
",",
"event",
".",
"isEndOfRecord",
"(",
")",
")",
")",
";",
"}",
"}"
] | Handle input data.
@param event the event
@throws InterruptedException the interrupted exception | [
"Handle",
"input",
"data",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/examples/src/org/jgrapes/examples/io/tcpecho/EchoServer.java#L71-L79 | train |
mnlipp/jgrapes | org.jgrapes.io/src/org/jgrapes/net/TcpConnectionManager.java | TcpConnectionManager.onOutput | @Handler
public void onOutput(Output<ByteBuffer> event,
TcpChannelImpl channel) throws InterruptedException {
if (channels.contains(channel)) {
channel.write(event);
}
} | java | @Handler
public void onOutput(Output<ByteBuffer> event,
TcpChannelImpl channel) throws InterruptedException {
if (channels.contains(channel)) {
channel.write(event);
}
} | [
"@",
"Handler",
"public",
"void",
"onOutput",
"(",
"Output",
"<",
"ByteBuffer",
">",
"event",
",",
"TcpChannelImpl",
"channel",
")",
"throws",
"InterruptedException",
"{",
"if",
"(",
"channels",
".",
"contains",
"(",
"channel",
")",
")",
"{",
"channel",
".",
"write",
"(",
"event",
")",
";",
"}",
"}"
] | Writes the data passed in the event.
The end of record flag is used to determine if a channel is
eligible for purging. If the flag is set and all output has
been processed, the channel is purgeable until input is
received or another output event causes the state to be
reevaluated.
@param event the event
@param channel the channel
@throws InterruptedException the interrupted exception | [
"Writes",
"the",
"data",
"passed",
"in",
"the",
"event",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.io/src/org/jgrapes/net/TcpConnectionManager.java#L130-L136 | train |
tommyettinger/RegExodus | src/main/java/regexodus/Replacer.java | Replacer.replace | public String replace(CharSequence text) {
TextBuffer tb = wrap(new StringBuilder(text.length()));
replace(pattern.matcher(text), substitution, tb);
return tb.toString();
} | java | public String replace(CharSequence text) {
TextBuffer tb = wrap(new StringBuilder(text.length()));
replace(pattern.matcher(text), substitution, tb);
return tb.toString();
} | [
"public",
"String",
"replace",
"(",
"CharSequence",
"text",
")",
"{",
"TextBuffer",
"tb",
"=",
"wrap",
"(",
"new",
"StringBuilder",
"(",
"text",
".",
"length",
"(",
")",
")",
")",
";",
"replace",
"(",
"pattern",
".",
"matcher",
"(",
"text",
")",
",",
"substitution",
",",
"tb",
")",
";",
"return",
"tb",
".",
"toString",
"(",
")",
";",
"}"
] | Takes all instances in text of the Pattern this was constructed with, and replaces them with substitution.
@param text a String, StringBuilder, or other CharSequence that may contain the text to replace
@return the post-replacement text | [
"Takes",
"all",
"instances",
"in",
"text",
"of",
"the",
"Pattern",
"this",
"was",
"constructed",
"with",
"and",
"replaces",
"them",
"with",
"substitution",
"."
] | d4af9bb7c132c5f9d29f45b76121f93b2f89de16 | https://github.com/tommyettinger/RegExodus/blob/d4af9bb7c132c5f9d29f45b76121f93b2f89de16/src/main/java/regexodus/Replacer.java#L126-L130 | train |
tommyettinger/RegExodus | src/main/java/regexodus/Replacer.java | Replacer.replace | public int replace(CharSequence text, StringBuilder sb) {
return replace(pattern.matcher(text), substitution, wrap(sb));
} | java | public int replace(CharSequence text, StringBuilder sb) {
return replace(pattern.matcher(text), substitution, wrap(sb));
} | [
"public",
"int",
"replace",
"(",
"CharSequence",
"text",
",",
"StringBuilder",
"sb",
")",
"{",
"return",
"replace",
"(",
"pattern",
".",
"matcher",
"(",
"text",
")",
",",
"substitution",
",",
"wrap",
"(",
"sb",
")",
")",
";",
"}"
] | Takes all occurrences of the pattern this was constructed with in text and replaces them with the substitution.
Appends the replaced text into sb.
@param text a String, StringBuilder, or other CharSequence that may contain the text to replace
@param sb the StringBuilder to append the result into
@return the number of individual replacements performed; the results are applied to sb | [
"Takes",
"all",
"occurrences",
"of",
"the",
"pattern",
"this",
"was",
"constructed",
"with",
"in",
"text",
"and",
"replaces",
"them",
"with",
"the",
"substitution",
".",
"Appends",
"the",
"replaced",
"text",
"into",
"sb",
"."
] | d4af9bb7c132c5f9d29f45b76121f93b2f89de16 | https://github.com/tommyettinger/RegExodus/blob/d4af9bb7c132c5f9d29f45b76121f93b2f89de16/src/main/java/regexodus/Replacer.java#L174-L176 | train |
mnlipp/jgrapes | org.jgrapes.http/src/org/jgrapes/http/LanguageSelector.java | LanguageSelector.onProtocolSwitchAccepted | @Handler(priority = 1000)
public void onProtocolSwitchAccepted(
ProtocolSwitchAccepted event, IOSubchannel channel) {
event.requestEvent().associated(Selection.class)
.ifPresent(
selection -> channel.setAssociated(Selection.class, selection));
} | java | @Handler(priority = 1000)
public void onProtocolSwitchAccepted(
ProtocolSwitchAccepted event, IOSubchannel channel) {
event.requestEvent().associated(Selection.class)
.ifPresent(
selection -> channel.setAssociated(Selection.class, selection));
} | [
"@",
"Handler",
"(",
"priority",
"=",
"1000",
")",
"public",
"void",
"onProtocolSwitchAccepted",
"(",
"ProtocolSwitchAccepted",
"event",
",",
"IOSubchannel",
"channel",
")",
"{",
"event",
".",
"requestEvent",
"(",
")",
".",
"associated",
"(",
"Selection",
".",
"class",
")",
".",
"ifPresent",
"(",
"selection",
"->",
"channel",
".",
"setAssociated",
"(",
"Selection",
".",
"class",
",",
"selection",
")",
")",
";",
"}"
] | Handles a procotol switch by associating the language selection
with the channel.
@param event the event
@param channel the channel | [
"Handles",
"a",
"procotol",
"switch",
"by",
"associating",
"the",
"language",
"selection",
"with",
"the",
"channel",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.http/src/org/jgrapes/http/LanguageSelector.java#L214-L220 | train |
mnlipp/jgrapes | org.jgrapes.http/src/org/jgrapes/http/LanguageSelector.java | LanguageSelector.associatedLocale | public static Locale associatedLocale(Associator assoc) {
return assoc.associated(Selection.class)
.map(sel -> sel.get()[0]).orElse(Locale.getDefault());
} | java | public static Locale associatedLocale(Associator assoc) {
return assoc.associated(Selection.class)
.map(sel -> sel.get()[0]).orElse(Locale.getDefault());
} | [
"public",
"static",
"Locale",
"associatedLocale",
"(",
"Associator",
"assoc",
")",
"{",
"return",
"assoc",
".",
"associated",
"(",
"Selection",
".",
"class",
")",
".",
"map",
"(",
"sel",
"->",
"sel",
".",
"get",
"(",
")",
"[",
"0",
"]",
")",
".",
"orElse",
"(",
"Locale",
".",
"getDefault",
"(",
")",
")",
";",
"}"
] | Convenience method to retrieve a locale from an associator.
@param assoc the associator
@return the locale | [
"Convenience",
"method",
"to",
"retrieve",
"a",
"locale",
"from",
"an",
"associator",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.http/src/org/jgrapes/http/LanguageSelector.java#L228-L231 | train |
meridor/perspective-backend | perspective-sql/src/main/java/org/meridor/perspective/sql/impl/task/strategy/IndexScanStrategy.java | IndexScanStrategy.fetch | private DataContainer fetch(String tableAlias, IndexBooleanExpression condition, Map<String, String> tableAliases) {
String tableName = tableAliases.get(tableAlias);
Set<String> ids = getIdsFromIndex(tableName, tableAlias, condition);
return fetchContainer(tableName, tableAlias, ids);
} | java | private DataContainer fetch(String tableAlias, IndexBooleanExpression condition, Map<String, String> tableAliases) {
String tableName = tableAliases.get(tableAlias);
Set<String> ids = getIdsFromIndex(tableName, tableAlias, condition);
return fetchContainer(tableName, tableAlias, ids);
} | [
"private",
"DataContainer",
"fetch",
"(",
"String",
"tableAlias",
",",
"IndexBooleanExpression",
"condition",
",",
"Map",
"<",
"String",
",",
"String",
">",
"tableAliases",
")",
"{",
"String",
"tableName",
"=",
"tableAliases",
".",
"get",
"(",
"tableAlias",
")",
";",
"Set",
"<",
"String",
">",
"ids",
"=",
"getIdsFromIndex",
"(",
"tableName",
",",
"tableAlias",
",",
"condition",
")",
";",
"return",
"fetchContainer",
"(",
"tableName",
",",
"tableAlias",
",",
"ids",
")",
";",
"}"
] | planner should guarantee that. | [
"planner",
"should",
"guarantee",
"that",
"."
] | 5f98083977a57115988678e97d1642ee83431258 | https://github.com/meridor/perspective-backend/blob/5f98083977a57115988678e97d1642ee83431258/perspective-sql/src/main/java/org/meridor/perspective/sql/impl/task/strategy/IndexScanStrategy.java#L68-L72 | train |
meridor/perspective-backend | perspective-sql/src/main/java/org/meridor/perspective/sql/impl/task/strategy/IndexScanStrategy.java | IndexScanStrategy.conditionToKeys | private static Set<Key> conditionToKeys(int keyLength, Map<String, Set<Object>> condition) {
return crossProduct(new ArrayList<>(condition.values())).stream()
.map(v -> Keys.key(keyLength, v.toArray()))
.collect(Collectors.toSet());
} | java | private static Set<Key> conditionToKeys(int keyLength, Map<String, Set<Object>> condition) {
return crossProduct(new ArrayList<>(condition.values())).stream()
.map(v -> Keys.key(keyLength, v.toArray()))
.collect(Collectors.toSet());
} | [
"private",
"static",
"Set",
"<",
"Key",
">",
"conditionToKeys",
"(",
"int",
"keyLength",
",",
"Map",
"<",
"String",
",",
"Set",
"<",
"Object",
">",
">",
"condition",
")",
"{",
"return",
"crossProduct",
"(",
"new",
"ArrayList",
"<>",
"(",
"condition",
".",
"values",
"(",
")",
")",
")",
".",
"stream",
"(",
")",
".",
"map",
"(",
"v",
"->",
"Keys",
".",
"key",
"(",
"keyLength",
",",
"v",
".",
"toArray",
"(",
")",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toSet",
"(",
")",
")",
";",
"}"
] | Set of objects is used for OR conditions. Otherwise set contains only one value. | [
"Set",
"of",
"objects",
"is",
"used",
"for",
"OR",
"conditions",
".",
"Otherwise",
"set",
"contains",
"only",
"one",
"value",
"."
] | 5f98083977a57115988678e97d1642ee83431258 | https://github.com/meridor/perspective-backend/blob/5f98083977a57115988678e97d1642ee83431258/perspective-sql/src/main/java/org/meridor/perspective/sql/impl/task/strategy/IndexScanStrategy.java#L133-L137 | train |
anotheria/configureme | src/main/java/org/configureme/repository/Attribute.java | Attribute.getValue | public Value getValue(final Environment in){
log.debug("looking up value for "+name+" in "+in);
return attributeValue.get(in);
} | java | public Value getValue(final Environment in){
log.debug("looking up value for "+name+" in "+in);
return attributeValue.get(in);
} | [
"public",
"Value",
"getValue",
"(",
"final",
"Environment",
"in",
")",
"{",
"log",
".",
"debug",
"(",
"\"looking up value for \"",
"+",
"name",
"+",
"\" in \"",
"+",
"in",
")",
";",
"return",
"attributeValue",
".",
"get",
"(",
"in",
")",
";",
"}"
] | Returns the value of the attribute in the given environment.
@param in the environment to look up
@return the value of the attribute in the given environment | [
"Returns",
"the",
"value",
"of",
"the",
"attribute",
"in",
"the",
"given",
"environment",
"."
] | 1f52dd9109349623190586bdf5a592de8016e1fa | https://github.com/anotheria/configureme/blob/1f52dd9109349623190586bdf5a592de8016e1fa/src/main/java/org/configureme/repository/Attribute.java#L54-L58 | train |
mnlipp/jgrapes | org.jgrapes.util/src/org/jgrapes/util/events/KeyValueStoreUpdate.java | KeyValueStoreUpdate.update | public KeyValueStoreUpdate update(String key, String value) {
actions.add(new Update(key, value));
return this;
} | java | public KeyValueStoreUpdate update(String key, String value) {
actions.add(new Update(key, value));
return this;
} | [
"public",
"KeyValueStoreUpdate",
"update",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"actions",
".",
"add",
"(",
"new",
"Update",
"(",
"key",
",",
"value",
")",
")",
";",
"return",
"this",
";",
"}"
] | Adds a new update action to the event.
@param key the key
@param value the value
@return the event for easy chaining | [
"Adds",
"a",
"new",
"update",
"action",
"to",
"the",
"event",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.util/src/org/jgrapes/util/events/KeyValueStoreUpdate.java#L42-L45 | train |
mnlipp/jgrapes | org.jgrapes.util/src/org/jgrapes/util/events/KeyValueStoreUpdate.java | KeyValueStoreUpdate.storeAs | public KeyValueStoreUpdate storeAs(String value, String... segments) {
actions.add(new Update("/" + String.join("/", segments), value));
return this;
} | java | public KeyValueStoreUpdate storeAs(String value, String... segments) {
actions.add(new Update("/" + String.join("/", segments), value));
return this;
} | [
"public",
"KeyValueStoreUpdate",
"storeAs",
"(",
"String",
"value",
",",
"String",
"...",
"segments",
")",
"{",
"actions",
".",
"add",
"(",
"new",
"Update",
"(",
"\"/\"",
"+",
"String",
".",
"join",
"(",
"\"/\"",
",",
"segments",
")",
",",
"value",
")",
")",
";",
"return",
"this",
";",
"}"
] | Adds a new update action to the event that stores the given value
on the path formed by the path segments.
@param value the value
@param segments the path segments
@return the event for easy chaining | [
"Adds",
"a",
"new",
"update",
"action",
"to",
"the",
"event",
"that",
"stores",
"the",
"given",
"value",
"on",
"the",
"path",
"formed",
"by",
"the",
"path",
"segments",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.util/src/org/jgrapes/util/events/KeyValueStoreUpdate.java#L55-L58 | train |
mnlipp/jgrapes | org.jgrapes.util/src/org/jgrapes/util/events/KeyValueStoreUpdate.java | KeyValueStoreUpdate.clearAll | public KeyValueStoreUpdate clearAll(String... segments) {
actions.add(new Deletion("/" + String.join("/", segments)));
return this;
} | java | public KeyValueStoreUpdate clearAll(String... segments) {
actions.add(new Deletion("/" + String.join("/", segments)));
return this;
} | [
"public",
"KeyValueStoreUpdate",
"clearAll",
"(",
"String",
"...",
"segments",
")",
"{",
"actions",
".",
"add",
"(",
"new",
"Deletion",
"(",
"\"/\"",
"+",
"String",
".",
"join",
"(",
"\"/\"",
",",
"segments",
")",
")",
")",
";",
"return",
"this",
";",
"}"
] | Adds a new deletion action that clears all keys with the given
path prefix.
@param segments the path segments
@return the event for easy chaining | [
"Adds",
"a",
"new",
"deletion",
"action",
"that",
"clears",
"all",
"keys",
"with",
"the",
"given",
"path",
"prefix",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.util/src/org/jgrapes/util/events/KeyValueStoreUpdate.java#L78-L81 | train |
anotheria/configureme | src/main/java/org/configureme/repository/AttributeValue.java | AttributeValue.set | public void set(Value value, Environment in){
values.put(in.expandedStringForm(), value);
} | java | public void set(Value value, Environment in){
values.put(in.expandedStringForm(), value);
} | [
"public",
"void",
"set",
"(",
"Value",
"value",
",",
"Environment",
"in",
")",
"{",
"values",
".",
"put",
"(",
"in",
".",
"expandedStringForm",
"(",
")",
",",
"value",
")",
";",
"}"
] | Sets the value in a given environment.
@param value the value to set
@param in the environment in which the value applies | [
"Sets",
"the",
"value",
"in",
"a",
"given",
"environment",
"."
] | 1f52dd9109349623190586bdf5a592de8016e1fa | https://github.com/anotheria/configureme/blob/1f52dd9109349623190586bdf5a592de8016e1fa/src/main/java/org/configureme/repository/AttributeValue.java#L60-L62 | train |
mnlipp/jgrapes | org.jgrapes.core/src/org/jgrapes/core/internal/ComponentProxy.java | ComponentProxy.getComponentProxy | @SuppressWarnings({ "PMD.DataflowAnomalyAnalysis" })
/* default */ static ComponentVertex getComponentProxy(
ComponentType component, Channel componentChannel) {
ComponentProxy componentProxy = null;
try {
Field field = getManagerField(component.getClass());
synchronized (component) {
if (!field.isAccessible()) { // NOPMD, handle problem first
field.setAccessible(true);
componentProxy = (ComponentProxy) field.get(component);
if (componentProxy == null) {
componentProxy = new ComponentProxy(
field, component, componentChannel);
}
field.setAccessible(false);
} else {
componentProxy = (ComponentProxy) field.get(component);
if (componentProxy == null) {
componentProxy = new ComponentProxy(
field, component, componentChannel);
}
}
}
} catch (SecurityException | IllegalAccessException e) {
throw (RuntimeException) (new IllegalArgumentException(
"Cannot access component's manager attribute")).initCause(e);
}
return componentProxy;
} | java | @SuppressWarnings({ "PMD.DataflowAnomalyAnalysis" })
/* default */ static ComponentVertex getComponentProxy(
ComponentType component, Channel componentChannel) {
ComponentProxy componentProxy = null;
try {
Field field = getManagerField(component.getClass());
synchronized (component) {
if (!field.isAccessible()) { // NOPMD, handle problem first
field.setAccessible(true);
componentProxy = (ComponentProxy) field.get(component);
if (componentProxy == null) {
componentProxy = new ComponentProxy(
field, component, componentChannel);
}
field.setAccessible(false);
} else {
componentProxy = (ComponentProxy) field.get(component);
if (componentProxy == null) {
componentProxy = new ComponentProxy(
field, component, componentChannel);
}
}
}
} catch (SecurityException | IllegalAccessException e) {
throw (RuntimeException) (new IllegalArgumentException(
"Cannot access component's manager attribute")).initCause(e);
}
return componentProxy;
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"PMD.DataflowAnomalyAnalysis\"",
"}",
")",
"/* default */",
"static",
"ComponentVertex",
"getComponentProxy",
"(",
"ComponentType",
"component",
",",
"Channel",
"componentChannel",
")",
"{",
"ComponentProxy",
"componentProxy",
"=",
"null",
";",
"try",
"{",
"Field",
"field",
"=",
"getManagerField",
"(",
"component",
".",
"getClass",
"(",
")",
")",
";",
"synchronized",
"(",
"component",
")",
"{",
"if",
"(",
"!",
"field",
".",
"isAccessible",
"(",
")",
")",
"{",
"// NOPMD, handle problem first",
"field",
".",
"setAccessible",
"(",
"true",
")",
";",
"componentProxy",
"=",
"(",
"ComponentProxy",
")",
"field",
".",
"get",
"(",
"component",
")",
";",
"if",
"(",
"componentProxy",
"==",
"null",
")",
"{",
"componentProxy",
"=",
"new",
"ComponentProxy",
"(",
"field",
",",
"component",
",",
"componentChannel",
")",
";",
"}",
"field",
".",
"setAccessible",
"(",
"false",
")",
";",
"}",
"else",
"{",
"componentProxy",
"=",
"(",
"ComponentProxy",
")",
"field",
".",
"get",
"(",
"component",
")",
";",
"if",
"(",
"componentProxy",
"==",
"null",
")",
"{",
"componentProxy",
"=",
"new",
"ComponentProxy",
"(",
"field",
",",
"component",
",",
"componentChannel",
")",
";",
"}",
"}",
"}",
"}",
"catch",
"(",
"SecurityException",
"|",
"IllegalAccessException",
"e",
")",
"{",
"throw",
"(",
"RuntimeException",
")",
"(",
"new",
"IllegalArgumentException",
"(",
"\"Cannot access component's manager attribute\"",
")",
")",
".",
"initCause",
"(",
"e",
")",
";",
"}",
"return",
"componentProxy",
";",
"}"
] | Return the component node for a component that is represented
by a proxy in the tree.
@param component the component
@param componentChannel the component's channel
@return the node representing the component in the tree | [
"Return",
"the",
"component",
"node",
"for",
"a",
"component",
"that",
"is",
"represented",
"by",
"a",
"proxy",
"in",
"the",
"tree",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.core/src/org/jgrapes/core/internal/ComponentProxy.java#L121-L149 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/Response.java | Response.getGraphObjectAs | public final <T extends GraphObject> T getGraphObjectAs(Class<T> graphObjectClass) {
if (graphObject == null) {
return null;
}
if (graphObjectClass == null) {
throw new NullPointerException("Must pass in a valid interface that extends GraphObject");
}
return graphObject.cast(graphObjectClass);
} | java | public final <T extends GraphObject> T getGraphObjectAs(Class<T> graphObjectClass) {
if (graphObject == null) {
return null;
}
if (graphObjectClass == null) {
throw new NullPointerException("Must pass in a valid interface that extends GraphObject");
}
return graphObject.cast(graphObjectClass);
} | [
"public",
"final",
"<",
"T",
"extends",
"GraphObject",
">",
"T",
"getGraphObjectAs",
"(",
"Class",
"<",
"T",
">",
"graphObjectClass",
")",
"{",
"if",
"(",
"graphObject",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"graphObjectClass",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"Must pass in a valid interface that extends GraphObject\"",
")",
";",
"}",
"return",
"graphObject",
".",
"cast",
"(",
"graphObjectClass",
")",
";",
"}"
] | The single graph object returned for this request, if any, cast into a particular type of GraphObject.
@param graphObjectClass the GraphObject-derived interface to cast the graph object into
@return the graph object returned, or null if none was returned (or if the result was a list)
@throws FacebookException If the passed in Class is not a valid GraphObject interface | [
"The",
"single",
"graph",
"object",
"returned",
"for",
"this",
"request",
"if",
"any",
"cast",
"into",
"a",
"particular",
"type",
"of",
"GraphObject",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/Response.java#L119-L127 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/Response.java | Response.getGraphObjectListAs | public final <T extends GraphObject> GraphObjectList<T> getGraphObjectListAs(Class<T> graphObjectClass) {
if (graphObjectList == null) {
return null;
}
return graphObjectList.castToListOf(graphObjectClass);
} | java | public final <T extends GraphObject> GraphObjectList<T> getGraphObjectListAs(Class<T> graphObjectClass) {
if (graphObjectList == null) {
return null;
}
return graphObjectList.castToListOf(graphObjectClass);
} | [
"public",
"final",
"<",
"T",
"extends",
"GraphObject",
">",
"GraphObjectList",
"<",
"T",
">",
"getGraphObjectListAs",
"(",
"Class",
"<",
"T",
">",
"graphObjectClass",
")",
"{",
"if",
"(",
"graphObjectList",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"graphObjectList",
".",
"castToListOf",
"(",
"graphObjectClass",
")",
";",
"}"
] | The list of graph objects returned for this request, if any, cast into a particular type of GraphObject.
@param graphObjectClass the GraphObject-derived interface to cast the graph objects into
@return the list of graph objects returned, or null if none was returned (or if the result was not a list)
@throws FacebookException If the passed in Class is not a valid GraphObject interface | [
"The",
"list",
"of",
"graph",
"objects",
"returned",
"for",
"this",
"request",
"if",
"any",
"cast",
"into",
"a",
"particular",
"type",
"of",
"GraphObject",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/Response.java#L145-L150 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/Response.java | Response.getRequestForPagedResults | public Request getRequestForPagedResults(PagingDirection direction) {
String link = null;
if (graphObject != null) {
PagedResults pagedResults = graphObject.cast(PagedResults.class);
PagingInfo pagingInfo = pagedResults.getPaging();
if (pagingInfo != null) {
if (direction == PagingDirection.NEXT) {
link = pagingInfo.getNext();
} else {
link = pagingInfo.getPrevious();
}
}
}
if (Utility.isNullOrEmpty(link)) {
return null;
}
if (link != null && link.equals(request.getUrlForSingleRequest())) {
// We got the same "next" link as we just tried to retrieve. This could happen if cached
// data is invalid. All we can do in this case is pretend we have finished.
return null;
}
Request pagingRequest;
try {
pagingRequest = new Request(request.getSession(), new URL(link));
} catch (MalformedURLException e) {
return null;
}
return pagingRequest;
} | java | public Request getRequestForPagedResults(PagingDirection direction) {
String link = null;
if (graphObject != null) {
PagedResults pagedResults = graphObject.cast(PagedResults.class);
PagingInfo pagingInfo = pagedResults.getPaging();
if (pagingInfo != null) {
if (direction == PagingDirection.NEXT) {
link = pagingInfo.getNext();
} else {
link = pagingInfo.getPrevious();
}
}
}
if (Utility.isNullOrEmpty(link)) {
return null;
}
if (link != null && link.equals(request.getUrlForSingleRequest())) {
// We got the same "next" link as we just tried to retrieve. This could happen if cached
// data is invalid. All we can do in this case is pretend we have finished.
return null;
}
Request pagingRequest;
try {
pagingRequest = new Request(request.getSession(), new URL(link));
} catch (MalformedURLException e) {
return null;
}
return pagingRequest;
} | [
"public",
"Request",
"getRequestForPagedResults",
"(",
"PagingDirection",
"direction",
")",
"{",
"String",
"link",
"=",
"null",
";",
"if",
"(",
"graphObject",
"!=",
"null",
")",
"{",
"PagedResults",
"pagedResults",
"=",
"graphObject",
".",
"cast",
"(",
"PagedResults",
".",
"class",
")",
";",
"PagingInfo",
"pagingInfo",
"=",
"pagedResults",
".",
"getPaging",
"(",
")",
";",
"if",
"(",
"pagingInfo",
"!=",
"null",
")",
"{",
"if",
"(",
"direction",
"==",
"PagingDirection",
".",
"NEXT",
")",
"{",
"link",
"=",
"pagingInfo",
".",
"getNext",
"(",
")",
";",
"}",
"else",
"{",
"link",
"=",
"pagingInfo",
".",
"getPrevious",
"(",
")",
";",
"}",
"}",
"}",
"if",
"(",
"Utility",
".",
"isNullOrEmpty",
"(",
"link",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"link",
"!=",
"null",
"&&",
"link",
".",
"equals",
"(",
"request",
".",
"getUrlForSingleRequest",
"(",
")",
")",
")",
"{",
"// We got the same \"next\" link as we just tried to retrieve. This could happen if cached",
"// data is invalid. All we can do in this case is pretend we have finished.",
"return",
"null",
";",
"}",
"Request",
"pagingRequest",
";",
"try",
"{",
"pagingRequest",
"=",
"new",
"Request",
"(",
"request",
".",
"getSession",
"(",
")",
",",
"new",
"URL",
"(",
"link",
")",
")",
";",
"}",
"catch",
"(",
"MalformedURLException",
"e",
")",
"{",
"return",
"null",
";",
"}",
"return",
"pagingRequest",
";",
"}"
] | If a Response contains results that contain paging information, returns a new
Request that will retrieve the next page of results, in whichever direction
is desired. If no paging information is available, returns null.
@param direction enum indicating whether to page forward or backward
@return a Request that will retrieve the next page of results in the desired
direction, or null if no paging information is available | [
"If",
"a",
"Response",
"contains",
"results",
"that",
"contain",
"paging",
"information",
"returns",
"a",
"new",
"Request",
"that",
"will",
"retrieve",
"the",
"next",
"page",
"of",
"results",
"in",
"whichever",
"direction",
"is",
"desired",
".",
"If",
"no",
"paging",
"information",
"is",
"available",
"returns",
"null",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/Response.java#L203-L234 | train |
mnlipp/jgrapes | org.jgrapes.http.freemarker/src/org/jgrapes/http/freemarker/FreeMarkerRequestHandler.java | FreeMarkerRequestHandler.freemarkerConfig | protected Configuration freemarkerConfig() {
if (fmConfig == null) {
fmConfig = new Configuration(Configuration.VERSION_2_3_26);
fmConfig.setClassLoaderForTemplateLoading(
contentLoader, contentPath);
fmConfig.setDefaultEncoding("utf-8");
fmConfig.setTemplateExceptionHandler(
TemplateExceptionHandler.RETHROW_HANDLER);
fmConfig.setLogTemplateExceptions(false);
}
return fmConfig;
} | java | protected Configuration freemarkerConfig() {
if (fmConfig == null) {
fmConfig = new Configuration(Configuration.VERSION_2_3_26);
fmConfig.setClassLoaderForTemplateLoading(
contentLoader, contentPath);
fmConfig.setDefaultEncoding("utf-8");
fmConfig.setTemplateExceptionHandler(
TemplateExceptionHandler.RETHROW_HANDLER);
fmConfig.setLogTemplateExceptions(false);
}
return fmConfig;
} | [
"protected",
"Configuration",
"freemarkerConfig",
"(",
")",
"{",
"if",
"(",
"fmConfig",
"==",
"null",
")",
"{",
"fmConfig",
"=",
"new",
"Configuration",
"(",
"Configuration",
".",
"VERSION_2_3_26",
")",
";",
"fmConfig",
".",
"setClassLoaderForTemplateLoading",
"(",
"contentLoader",
",",
"contentPath",
")",
";",
"fmConfig",
".",
"setDefaultEncoding",
"(",
"\"utf-8\"",
")",
";",
"fmConfig",
".",
"setTemplateExceptionHandler",
"(",
"TemplateExceptionHandler",
".",
"RETHROW_HANDLER",
")",
";",
"fmConfig",
".",
"setLogTemplateExceptions",
"(",
"false",
")",
";",
"}",
"return",
"fmConfig",
";",
"}"
] | Creates the configuration for freemarker template processing.
@return the configuration | [
"Creates",
"the",
"configuration",
"for",
"freemarker",
"template",
"processing",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.http.freemarker/src/org/jgrapes/http/freemarker/FreeMarkerRequestHandler.java#L302-L313 | train |
mnlipp/jgrapes | org.jgrapes.http.freemarker/src/org/jgrapes/http/freemarker/FreeMarkerRequestHandler.java | FreeMarkerRequestHandler.fmSessionModel | protected Map<String, Object> fmSessionModel(Optional<Session> session) {
@SuppressWarnings("PMD.UseConcurrentHashMap")
final Map<String, Object> model = new HashMap<>();
Locale locale = session.map(
sess -> sess.locale()).orElse(Locale.getDefault());
model.put("locale", locale);
final ResourceBundle resourceBundle = resourceBundle(locale);
model.put("resourceBundle", resourceBundle);
model.put("_", new TemplateMethodModelEx() {
@Override
@SuppressWarnings("PMD.EmptyCatchBlock")
public Object exec(@SuppressWarnings("rawtypes") List arguments)
throws TemplateModelException {
@SuppressWarnings("unchecked")
List<TemplateModel> args = (List<TemplateModel>) arguments;
if (!(args.get(0) instanceof SimpleScalar)) {
throw new TemplateModelException("Not a string.");
}
String key = ((SimpleScalar) args.get(0)).getAsString();
try {
return resourceBundle.getString(key);
} catch (MissingResourceException e) {
// no luck
}
return key;
}
});
return model;
} | java | protected Map<String, Object> fmSessionModel(Optional<Session> session) {
@SuppressWarnings("PMD.UseConcurrentHashMap")
final Map<String, Object> model = new HashMap<>();
Locale locale = session.map(
sess -> sess.locale()).orElse(Locale.getDefault());
model.put("locale", locale);
final ResourceBundle resourceBundle = resourceBundle(locale);
model.put("resourceBundle", resourceBundle);
model.put("_", new TemplateMethodModelEx() {
@Override
@SuppressWarnings("PMD.EmptyCatchBlock")
public Object exec(@SuppressWarnings("rawtypes") List arguments)
throws TemplateModelException {
@SuppressWarnings("unchecked")
List<TemplateModel> args = (List<TemplateModel>) arguments;
if (!(args.get(0) instanceof SimpleScalar)) {
throw new TemplateModelException("Not a string.");
}
String key = ((SimpleScalar) args.get(0)).getAsString();
try {
return resourceBundle.getString(key);
} catch (MissingResourceException e) {
// no luck
}
return key;
}
});
return model;
} | [
"protected",
"Map",
"<",
"String",
",",
"Object",
">",
"fmSessionModel",
"(",
"Optional",
"<",
"Session",
">",
"session",
")",
"{",
"@",
"SuppressWarnings",
"(",
"\"PMD.UseConcurrentHashMap\"",
")",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"model",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"Locale",
"locale",
"=",
"session",
".",
"map",
"(",
"sess",
"->",
"sess",
".",
"locale",
"(",
")",
")",
".",
"orElse",
"(",
"Locale",
".",
"getDefault",
"(",
")",
")",
";",
"model",
".",
"put",
"(",
"\"locale\"",
",",
"locale",
")",
";",
"final",
"ResourceBundle",
"resourceBundle",
"=",
"resourceBundle",
"(",
"locale",
")",
";",
"model",
".",
"put",
"(",
"\"resourceBundle\"",
",",
"resourceBundle",
")",
";",
"model",
".",
"put",
"(",
"\"_\"",
",",
"new",
"TemplateMethodModelEx",
"(",
")",
"{",
"@",
"Override",
"@",
"SuppressWarnings",
"(",
"\"PMD.EmptyCatchBlock\"",
")",
"public",
"Object",
"exec",
"(",
"@",
"SuppressWarnings",
"(",
"\"rawtypes\"",
")",
"List",
"arguments",
")",
"throws",
"TemplateModelException",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"List",
"<",
"TemplateModel",
">",
"args",
"=",
"(",
"List",
"<",
"TemplateModel",
">",
")",
"arguments",
";",
"if",
"(",
"!",
"(",
"args",
".",
"get",
"(",
"0",
")",
"instanceof",
"SimpleScalar",
")",
")",
"{",
"throw",
"new",
"TemplateModelException",
"(",
"\"Not a string.\"",
")",
";",
"}",
"String",
"key",
"=",
"(",
"(",
"SimpleScalar",
")",
"args",
".",
"get",
"(",
"0",
")",
")",
".",
"getAsString",
"(",
")",
";",
"try",
"{",
"return",
"resourceBundle",
".",
"getString",
"(",
"key",
")",
";",
"}",
"catch",
"(",
"MissingResourceException",
"e",
")",
"{",
"// no luck",
"}",
"return",
"key",
";",
"}",
"}",
")",
";",
"return",
"model",
";",
"}"
] | Build a freemarker model holding the information associated with the
session.
This model provides:
* The `locale` (of type {@link Locale}).
* The `resourceBundle` (of type {@link ResourceBundle}).
* A function "`_`" that looks up the given key in the
resource bundle.
@param session
the session
@return the model | [
"Build",
"a",
"freemarker",
"model",
"holding",
"the",
"information",
"associated",
"with",
"the",
"session",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.http.freemarker/src/org/jgrapes/http/freemarker/FreeMarkerRequestHandler.java#L332-L360 | train |
mnlipp/jgrapes | org.jgrapes.http.freemarker/src/org/jgrapes/http/freemarker/FreeMarkerRequestHandler.java | FreeMarkerRequestHandler.resourceBundle | protected ResourceBundle resourceBundle(Locale locale) {
return ResourceBundle.getBundle(
contentPath.replace('/', '.') + ".l10n", locale,
contentLoader, ResourceBundle.Control.getNoFallbackControl(
ResourceBundle.Control.FORMAT_DEFAULT));
} | java | protected ResourceBundle resourceBundle(Locale locale) {
return ResourceBundle.getBundle(
contentPath.replace('/', '.') + ".l10n", locale,
contentLoader, ResourceBundle.Control.getNoFallbackControl(
ResourceBundle.Control.FORMAT_DEFAULT));
} | [
"protected",
"ResourceBundle",
"resourceBundle",
"(",
"Locale",
"locale",
")",
"{",
"return",
"ResourceBundle",
".",
"getBundle",
"(",
"contentPath",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
"+",
"\".l10n\"",
",",
"locale",
",",
"contentLoader",
",",
"ResourceBundle",
".",
"Control",
".",
"getNoFallbackControl",
"(",
"ResourceBundle",
".",
"Control",
".",
"FORMAT_DEFAULT",
")",
")",
";",
"}"
] | Provides a resource bundle for localization.
The default implementation looks up a bundle using the
package name plus "l10n" as base name.
@return the resource bundle | [
"Provides",
"a",
"resource",
"bundle",
"for",
"localization",
".",
"The",
"default",
"implementation",
"looks",
"up",
"a",
"bundle",
"using",
"the",
"package",
"name",
"plus",
"l10n",
"as",
"base",
"name",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.http.freemarker/src/org/jgrapes/http/freemarker/FreeMarkerRequestHandler.java#L382-L387 | train |
mnlipp/jgrapes | org.jgrapes.io/src/org/jgrapes/io/util/ManagedBufferPool.java | ManagedBufferPool.removeBuffer | private void removeBuffer(W buffer) {
createdBufs.decrementAndGet();
if (bufferMonitor.remove(buffer) == null) {
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.WARNING,
"Attempt to remove unknown buffer from pool.",
new Throwable());
} else {
logger.warning("Attempt to remove unknown buffer from pool.");
}
}
} | java | private void removeBuffer(W buffer) {
createdBufs.decrementAndGet();
if (bufferMonitor.remove(buffer) == null) {
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.WARNING,
"Attempt to remove unknown buffer from pool.",
new Throwable());
} else {
logger.warning("Attempt to remove unknown buffer from pool.");
}
}
} | [
"private",
"void",
"removeBuffer",
"(",
"W",
"buffer",
")",
"{",
"createdBufs",
".",
"decrementAndGet",
"(",
")",
";",
"if",
"(",
"bufferMonitor",
".",
"remove",
"(",
"buffer",
")",
"==",
"null",
")",
"{",
"if",
"(",
"logger",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"{",
"logger",
".",
"log",
"(",
"Level",
".",
"WARNING",
",",
"\"Attempt to remove unknown buffer from pool.\"",
",",
"new",
"Throwable",
"(",
")",
")",
";",
"}",
"else",
"{",
"logger",
".",
"warning",
"(",
"\"Attempt to remove unknown buffer from pool.\"",
")",
";",
"}",
"}",
"}"
] | Removes the buffer from the pool.
@param buffer the buffer to remove | [
"Removes",
"the",
"buffer",
"from",
"the",
"pool",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.io/src/org/jgrapes/io/util/ManagedBufferPool.java#L216-L227 | train |
mnlipp/jgrapes | org.jgrapes.io/src/org/jgrapes/io/util/ManagedBufferPool.java | ManagedBufferPool.acquire | @SuppressWarnings("PMD.GuardLogStatement")
public W acquire() throws InterruptedException {
// Stop draining, because we obviously need this kind of buffers
Optional.ofNullable(idleTimer.getAndSet(null)).ifPresent(
timer -> timer.cancel());
if (createdBufs.get() < maximumBufs) {
// Haven't reached maximum, so if no buffer is queued, create one.
W buffer = queue.poll();
if (buffer != null) {
buffer.lockBuffer();
return buffer;
}
return createBuffer();
}
// Wait for buffer to become available.
if (logger.isLoggable(Level.FINE)) {
// If configured, log message after waiting some time.
W buffer = queue.poll(acquireWarningLimit, TimeUnit.MILLISECONDS);
if (buffer != null) {
buffer.lockBuffer();
return buffer;
}
logger.log(Level.FINE, new Throwable(),
() -> Thread.currentThread().getName() + " waiting > "
+ acquireWarningLimit + "ms for buffer, while executing:");
}
W buffer = queue.take();
buffer.lockBuffer();
return buffer;
} | java | @SuppressWarnings("PMD.GuardLogStatement")
public W acquire() throws InterruptedException {
// Stop draining, because we obviously need this kind of buffers
Optional.ofNullable(idleTimer.getAndSet(null)).ifPresent(
timer -> timer.cancel());
if (createdBufs.get() < maximumBufs) {
// Haven't reached maximum, so if no buffer is queued, create one.
W buffer = queue.poll();
if (buffer != null) {
buffer.lockBuffer();
return buffer;
}
return createBuffer();
}
// Wait for buffer to become available.
if (logger.isLoggable(Level.FINE)) {
// If configured, log message after waiting some time.
W buffer = queue.poll(acquireWarningLimit, TimeUnit.MILLISECONDS);
if (buffer != null) {
buffer.lockBuffer();
return buffer;
}
logger.log(Level.FINE, new Throwable(),
() -> Thread.currentThread().getName() + " waiting > "
+ acquireWarningLimit + "ms for buffer, while executing:");
}
W buffer = queue.take();
buffer.lockBuffer();
return buffer;
} | [
"@",
"SuppressWarnings",
"(",
"\"PMD.GuardLogStatement\"",
")",
"public",
"W",
"acquire",
"(",
")",
"throws",
"InterruptedException",
"{",
"// Stop draining, because we obviously need this kind of buffers",
"Optional",
".",
"ofNullable",
"(",
"idleTimer",
".",
"getAndSet",
"(",
"null",
")",
")",
".",
"ifPresent",
"(",
"timer",
"->",
"timer",
".",
"cancel",
"(",
")",
")",
";",
"if",
"(",
"createdBufs",
".",
"get",
"(",
")",
"<",
"maximumBufs",
")",
"{",
"// Haven't reached maximum, so if no buffer is queued, create one.",
"W",
"buffer",
"=",
"queue",
".",
"poll",
"(",
")",
";",
"if",
"(",
"buffer",
"!=",
"null",
")",
"{",
"buffer",
".",
"lockBuffer",
"(",
")",
";",
"return",
"buffer",
";",
"}",
"return",
"createBuffer",
"(",
")",
";",
"}",
"// Wait for buffer to become available.",
"if",
"(",
"logger",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"{",
"// If configured, log message after waiting some time.",
"W",
"buffer",
"=",
"queue",
".",
"poll",
"(",
"acquireWarningLimit",
",",
"TimeUnit",
".",
"MILLISECONDS",
")",
";",
"if",
"(",
"buffer",
"!=",
"null",
")",
"{",
"buffer",
".",
"lockBuffer",
"(",
")",
";",
"return",
"buffer",
";",
"}",
"logger",
".",
"log",
"(",
"Level",
".",
"FINE",
",",
"new",
"Throwable",
"(",
")",
",",
"(",
")",
"->",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\" waiting > \"",
"+",
"acquireWarningLimit",
"+",
"\"ms for buffer, while executing:\"",
")",
";",
"}",
"W",
"buffer",
"=",
"queue",
".",
"take",
"(",
")",
";",
"buffer",
".",
"lockBuffer",
"(",
")",
";",
"return",
"buffer",
";",
"}"
] | Acquires a managed buffer from the pool. If the pool is empty,
waits for a buffer to become available. The acquired buffer has
a lock count of one.
@return the acquired buffer
@throws InterruptedException if the current thread is interrupted | [
"Acquires",
"a",
"managed",
"buffer",
"from",
"the",
"pool",
".",
"If",
"the",
"pool",
"is",
"empty",
"waits",
"for",
"a",
"buffer",
"to",
"become",
"available",
".",
"The",
"acquired",
"buffer",
"has",
"a",
"lock",
"count",
"of",
"one",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.io/src/org/jgrapes/io/util/ManagedBufferPool.java#L249-L278 | train |
mnlipp/jgrapes | org.jgrapes.io/src/org/jgrapes/io/util/ManagedBufferPool.java | ManagedBufferPool.recollect | @Override
public void recollect(W buffer) {
if (queue.size() < preservedBufs) {
long effectiveDrainDelay
= drainDelay > 0 ? drainDelay : defaultDrainDelay;
if (effectiveDrainDelay > 0) {
// Enqueue
buffer.clear();
queue.add(buffer);
Timer old = idleTimer.getAndSet(Components.schedule(this::drain,
Duration.ofMillis(effectiveDrainDelay)));
if (old != null) {
old.cancel();
}
return;
}
}
// Discard
removeBuffer(buffer);
} | java | @Override
public void recollect(W buffer) {
if (queue.size() < preservedBufs) {
long effectiveDrainDelay
= drainDelay > 0 ? drainDelay : defaultDrainDelay;
if (effectiveDrainDelay > 0) {
// Enqueue
buffer.clear();
queue.add(buffer);
Timer old = idleTimer.getAndSet(Components.schedule(this::drain,
Duration.ofMillis(effectiveDrainDelay)));
if (old != null) {
old.cancel();
}
return;
}
}
// Discard
removeBuffer(buffer);
} | [
"@",
"Override",
"public",
"void",
"recollect",
"(",
"W",
"buffer",
")",
"{",
"if",
"(",
"queue",
".",
"size",
"(",
")",
"<",
"preservedBufs",
")",
"{",
"long",
"effectiveDrainDelay",
"=",
"drainDelay",
">",
"0",
"?",
"drainDelay",
":",
"defaultDrainDelay",
";",
"if",
"(",
"effectiveDrainDelay",
">",
"0",
")",
"{",
"// Enqueue",
"buffer",
".",
"clear",
"(",
")",
";",
"queue",
".",
"add",
"(",
"buffer",
")",
";",
"Timer",
"old",
"=",
"idleTimer",
".",
"getAndSet",
"(",
"Components",
".",
"schedule",
"(",
"this",
"::",
"drain",
",",
"Duration",
".",
"ofMillis",
"(",
"effectiveDrainDelay",
")",
")",
")",
";",
"if",
"(",
"old",
"!=",
"null",
")",
"{",
"old",
".",
"cancel",
"(",
")",
";",
"}",
"return",
";",
"}",
"}",
"// Discard",
"removeBuffer",
"(",
"buffer",
")",
";",
"}"
] | Re-adds the buffer to the pool. The buffer is cleared.
@param buffer the buffer
@see org.jgrapes.io.util.BufferCollector#recollect(org.jgrapes.io.util.ManagedBuffer) | [
"Re",
"-",
"adds",
"the",
"buffer",
"to",
"the",
"pool",
".",
"The",
"buffer",
"is",
"cleared",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.io/src/org/jgrapes/io/util/ManagedBufferPool.java#L286-L305 | train |
anotheria/configureme | src/main/java/org/configureme/repository/IncludeValue.java | IncludeValue.getIncludedValue | public Value getIncludedValue(Environment in){
return ConfigurationManager.INSTANCE.getConfiguration(configurationName, in).getAttribute(attributeName);
} | java | public Value getIncludedValue(Environment in){
return ConfigurationManager.INSTANCE.getConfiguration(configurationName, in).getAttribute(attributeName);
} | [
"public",
"Value",
"getIncludedValue",
"(",
"Environment",
"in",
")",
"{",
"return",
"ConfigurationManager",
".",
"INSTANCE",
".",
"getConfiguration",
"(",
"configurationName",
",",
"in",
")",
".",
"getAttribute",
"(",
"attributeName",
")",
";",
"}"
] | Resolves included value dynamically from the linked config in the specified environment.
@param in target environment.
@return a {@link org.configureme.repository.Value} object. | [
"Resolves",
"included",
"value",
"dynamically",
"from",
"the",
"linked",
"config",
"in",
"the",
"specified",
"environment",
"."
] | 1f52dd9109349623190586bdf5a592de8016e1fa | https://github.com/anotheria/configureme/blob/1f52dd9109349623190586bdf5a592de8016e1fa/src/main/java/org/configureme/repository/IncludeValue.java#L36-L38 | train |
anotheria/configureme | src/main/java/org/configureme/repository/IncludeValue.java | IncludeValue.getConfigName | public ConfigurationSourceKey getConfigName() {
return new ConfigurationSourceKey(ConfigurationSourceKey.Type.FILE, ConfigurationSourceKey.Format.JSON, configurationName);
} | java | public ConfigurationSourceKey getConfigName() {
return new ConfigurationSourceKey(ConfigurationSourceKey.Type.FILE, ConfigurationSourceKey.Format.JSON, configurationName);
} | [
"public",
"ConfigurationSourceKey",
"getConfigName",
"(",
")",
"{",
"return",
"new",
"ConfigurationSourceKey",
"(",
"ConfigurationSourceKey",
".",
"Type",
".",
"FILE",
",",
"ConfigurationSourceKey",
".",
"Format",
".",
"JSON",
",",
"configurationName",
")",
";",
"}"
] | Get configuration name of the linked config
@return configuration name of the linked config | [
"Get",
"configuration",
"name",
"of",
"the",
"linked",
"config"
] | 1f52dd9109349623190586bdf5a592de8016e1fa | https://github.com/anotheria/configureme/blob/1f52dd9109349623190586bdf5a592de8016e1fa/src/main/java/org/configureme/repository/IncludeValue.java#L45-L47 | train |
ologolo/streamline-api | src/org/daisy/streamline/api/config/Configuration.java | Configuration.copyWithIdentifier | Configuration copyWithIdentifier(String identifier) {
return new Configuration(details.builder().identifier(identifier).build(), new HashMap<>(config));
} | java | Configuration copyWithIdentifier(String identifier) {
return new Configuration(details.builder().identifier(identifier).build(), new HashMap<>(config));
} | [
"Configuration",
"copyWithIdentifier",
"(",
"String",
"identifier",
")",
"{",
"return",
"new",
"Configuration",
"(",
"details",
".",
"builder",
"(",
")",
".",
"identifier",
"(",
"identifier",
")",
".",
"build",
"(",
")",
",",
"new",
"HashMap",
"<>",
"(",
"config",
")",
")",
";",
"}"
] | Creates a configuration with the same content as this instance, but
with the specified identifier.
@param identifier the new identifier
@return a new configuration | [
"Creates",
"a",
"configuration",
"with",
"the",
"same",
"content",
"as",
"this",
"instance",
"but",
"with",
"the",
"specified",
"identifier",
"."
] | 4934b6da1de06e364ae90d6ea9b0929500da9cdb | https://github.com/ologolo/streamline-api/blob/4934b6da1de06e364ae90d6ea9b0929500da9cdb/src/org/daisy/streamline/api/config/Configuration.java#L52-L54 | train |
ologolo/streamline-api | src/org/daisy/streamline/api/config/Configuration.java | Configuration.write | void write(File f) throws FileNotFoundException, IOException {
try (ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream(f))) {
os.writeObject(this);
}
} | java | void write(File f) throws FileNotFoundException, IOException {
try (ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream(f))) {
os.writeObject(this);
}
} | [
"void",
"write",
"(",
"File",
"f",
")",
"throws",
"FileNotFoundException",
",",
"IOException",
"{",
"try",
"(",
"ObjectOutputStream",
"os",
"=",
"new",
"ObjectOutputStream",
"(",
"new",
"FileOutputStream",
"(",
"f",
")",
")",
")",
"{",
"os",
".",
"writeObject",
"(",
"this",
")",
";",
"}",
"}"
] | Writes the configuration to file.
@param f the file
@throws FileNotFoundException if the file does not exist, is a directory rather
than a regular file, or for some other reason cannot be opened for reading.
@throws IOException if an I/O problem occurs. | [
"Writes",
"the",
"configuration",
"to",
"file",
"."
] | 4934b6da1de06e364ae90d6ea9b0929500da9cdb | https://github.com/ologolo/streamline-api/blob/4934b6da1de06e364ae90d6ea9b0929500da9cdb/src/org/daisy/streamline/api/config/Configuration.java#L79-L83 | train |
anotheria/configureme | src/main/java/org/configureme/sources/ConfigurationSource.java | ConfigurationSource.fireUpdateEvent | public void fireUpdateEvent(final long timestamp){
synchronized(listeners){
for (final ConfigurationSourceListener listener : listeners){
try{
log.debug("Calling configurationSourceUpdated on "+listener);
listener.configurationSourceUpdated(this);
}catch(final Exception e){
log.error("Error in notifying configuration source listener:"+listener, e);
}
}
}
lastChangeTimestamp = timestamp;
} | java | public void fireUpdateEvent(final long timestamp){
synchronized(listeners){
for (final ConfigurationSourceListener listener : listeners){
try{
log.debug("Calling configurationSourceUpdated on "+listener);
listener.configurationSourceUpdated(this);
}catch(final Exception e){
log.error("Error in notifying configuration source listener:"+listener, e);
}
}
}
lastChangeTimestamp = timestamp;
} | [
"public",
"void",
"fireUpdateEvent",
"(",
"final",
"long",
"timestamp",
")",
"{",
"synchronized",
"(",
"listeners",
")",
"{",
"for",
"(",
"final",
"ConfigurationSourceListener",
"listener",
":",
"listeners",
")",
"{",
"try",
"{",
"log",
".",
"debug",
"(",
"\"Calling configurationSourceUpdated on \"",
"+",
"listener",
")",
";",
"listener",
".",
"configurationSourceUpdated",
"(",
"this",
")",
";",
"}",
"catch",
"(",
"final",
"Exception",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"Error in notifying configuration source listener:\"",
"+",
"listener",
",",
"e",
")",
";",
"}",
"}",
"}",
"lastChangeTimestamp",
"=",
"timestamp",
";",
"}"
] | Called by the ConfigurationSourceRegistry if a change in the underlying source is detected.
@param timestamp a long. | [
"Called",
"by",
"the",
"ConfigurationSourceRegistry",
"if",
"a",
"change",
"in",
"the",
"underlying",
"source",
"is",
"detected",
"."
] | 1f52dd9109349623190586bdf5a592de8016e1fa | https://github.com/anotheria/configureme/blob/1f52dd9109349623190586bdf5a592de8016e1fa/src/main/java/org/configureme/sources/ConfigurationSource.java#L108-L120 | train |
ologolo/streamline-api | src/org/daisy/streamline/api/config/Inventory.java | Inventory.remove | InventoryEntry remove(String key) {
InventoryEntry ret = configs.remove(key);
if (ret!=null) {
ret.getPath().delete();
}
return ret;
} | java | InventoryEntry remove(String key) {
InventoryEntry ret = configs.remove(key);
if (ret!=null) {
ret.getPath().delete();
}
return ret;
} | [
"InventoryEntry",
"remove",
"(",
"String",
"key",
")",
"{",
"InventoryEntry",
"ret",
"=",
"configs",
".",
"remove",
"(",
"key",
")",
";",
"if",
"(",
"ret",
"!=",
"null",
")",
"{",
"ret",
".",
"getPath",
"(",
")",
".",
"delete",
"(",
")",
";",
"}",
"return",
"ret",
";",
"}"
] | Removes the entry with the specified key.
@param key the key
@return returns the removed entry | [
"Removes",
"the",
"entry",
"with",
"the",
"specified",
"key",
"."
] | 4934b6da1de06e364ae90d6ea9b0929500da9cdb | https://github.com/ologolo/streamline-api/blob/4934b6da1de06e364ae90d6ea9b0929500da9cdb/src/org/daisy/streamline/api/config/Inventory.java#L73-L79 | train |
ologolo/streamline-api | src/org/daisy/streamline/api/config/Inventory.java | Inventory.removeMismatching | List<Configuration> removeMismatching() {
// List mismatching
List<InventoryEntry> mismatching = configs.values().stream()
.filter(v->
(v.getConfiguration().isPresent()
&& !v.getIdentifier().equals(v.getConfiguration().get().getDetails().getKey()))
).collect(Collectors.toList());
// Remove from inventory
mismatching.forEach(v->configs.remove(v.getIdentifier()));
// Return the list of removed configurations
return mismatching.stream()
.map(v->v.getConfiguration().get())
.collect(Collectors.toList());
} | java | List<Configuration> removeMismatching() {
// List mismatching
List<InventoryEntry> mismatching = configs.values().stream()
.filter(v->
(v.getConfiguration().isPresent()
&& !v.getIdentifier().equals(v.getConfiguration().get().getDetails().getKey()))
).collect(Collectors.toList());
// Remove from inventory
mismatching.forEach(v->configs.remove(v.getIdentifier()));
// Return the list of removed configurations
return mismatching.stream()
.map(v->v.getConfiguration().get())
.collect(Collectors.toList());
} | [
"List",
"<",
"Configuration",
">",
"removeMismatching",
"(",
")",
"{",
"// List mismatching",
"List",
"<",
"InventoryEntry",
">",
"mismatching",
"=",
"configs",
".",
"values",
"(",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"v",
"->",
"(",
"v",
".",
"getConfiguration",
"(",
")",
".",
"isPresent",
"(",
")",
"&&",
"!",
"v",
".",
"getIdentifier",
"(",
")",
".",
"equals",
"(",
"v",
".",
"getConfiguration",
"(",
")",
".",
"get",
"(",
")",
".",
"getDetails",
"(",
")",
".",
"getKey",
"(",
")",
")",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"// Remove from inventory",
"mismatching",
".",
"forEach",
"(",
"v",
"->",
"configs",
".",
"remove",
"(",
"v",
".",
"getIdentifier",
"(",
")",
")",
")",
";",
"// Return the list of removed configurations ",
"return",
"mismatching",
".",
"stream",
"(",
")",
".",
"map",
"(",
"v",
"->",
"v",
".",
"getConfiguration",
"(",
")",
".",
"get",
"(",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"}"
] | Removes configurations with mismatching identifiers.
@return a list of configurations with mismatching identifiers | [
"Removes",
"configurations",
"with",
"mismatching",
"identifiers",
"."
] | 4934b6da1de06e364ae90d6ea9b0929500da9cdb | https://github.com/ologolo/streamline-api/blob/4934b6da1de06e364ae90d6ea9b0929500da9cdb/src/org/daisy/streamline/api/config/Inventory.java#L98-L111 | train |
ologolo/streamline-api | src/org/daisy/streamline/api/config/Inventory.java | Inventory.removeUnreadable | List<File> removeUnreadable() {
// List unreadable
List<InventoryEntry> unreadable = configs.values()
.stream()
.filter(v->!v.getConfiguration().isPresent())
.collect(Collectors.toList());
// Remove from inventory
unreadable.forEach(v->configs.remove(v.getIdentifier()));
// Return the list of removed files
return unreadable.stream()
.map(v->v.getPath())
.collect(Collectors.toList());
} | java | List<File> removeUnreadable() {
// List unreadable
List<InventoryEntry> unreadable = configs.values()
.stream()
.filter(v->!v.getConfiguration().isPresent())
.collect(Collectors.toList());
// Remove from inventory
unreadable.forEach(v->configs.remove(v.getIdentifier()));
// Return the list of removed files
return unreadable.stream()
.map(v->v.getPath())
.collect(Collectors.toList());
} | [
"List",
"<",
"File",
">",
"removeUnreadable",
"(",
")",
"{",
"// List unreadable",
"List",
"<",
"InventoryEntry",
">",
"unreadable",
"=",
"configs",
".",
"values",
"(",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"v",
"->",
"!",
"v",
".",
"getConfiguration",
"(",
")",
".",
"isPresent",
"(",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"// Remove from inventory",
"unreadable",
".",
"forEach",
"(",
"v",
"->",
"configs",
".",
"remove",
"(",
"v",
".",
"getIdentifier",
"(",
")",
")",
")",
";",
"// Return the list of removed files",
"return",
"unreadable",
".",
"stream",
"(",
")",
".",
"map",
"(",
"v",
"->",
"v",
".",
"getPath",
"(",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"}"
] | Removes entries whose configurations are unreadable from the inventory.
@return the list of entries removed from the inventory | [
"Removes",
"entries",
"whose",
"configurations",
"are",
"unreadable",
"from",
"the",
"inventory",
"."
] | 4934b6da1de06e364ae90d6ea9b0929500da9cdb | https://github.com/ologolo/streamline-api/blob/4934b6da1de06e364ae90d6ea9b0929500da9cdb/src/org/daisy/streamline/api/config/Inventory.java#L117-L129 | train |
mnlipp/jgrapes | examples/src/org/jgrapes/http/demo/httpserver/FormProcessor.java | FormProcessor.onGet | @RequestHandler(patterns = "/form,/form/**")
public void onGet(Request.In.Get event, IOSubchannel channel)
throws ParseException {
ResponseCreationSupport.sendStaticContent(event, channel,
path -> FormProcessor.class.getResource(
ResourcePattern.removeSegments(path, 1)),
null);
} | java | @RequestHandler(patterns = "/form,/form/**")
public void onGet(Request.In.Get event, IOSubchannel channel)
throws ParseException {
ResponseCreationSupport.sendStaticContent(event, channel,
path -> FormProcessor.class.getResource(
ResourcePattern.removeSegments(path, 1)),
null);
} | [
"@",
"RequestHandler",
"(",
"patterns",
"=",
"\"/form,/form/**\"",
")",
"public",
"void",
"onGet",
"(",
"Request",
".",
"In",
".",
"Get",
"event",
",",
"IOSubchannel",
"channel",
")",
"throws",
"ParseException",
"{",
"ResponseCreationSupport",
".",
"sendStaticContent",
"(",
"event",
",",
"channel",
",",
"path",
"->",
"FormProcessor",
".",
"class",
".",
"getResource",
"(",
"ResourcePattern",
".",
"removeSegments",
"(",
"path",
",",
"1",
")",
")",
",",
"null",
")",
";",
"}"
] | Handle a `GET` request.
@param event the event
@param channel the channel
@throws ParseException the parse exception | [
"Handle",
"a",
"GET",
"request",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/examples/src/org/jgrapes/http/demo/httpserver/FormProcessor.java#L75-L82 | train |
mnlipp/jgrapes | examples/src/org/jgrapes/http/demo/httpserver/FormProcessor.java | FormProcessor.onPost | @RequestHandler(patterns = "/form,/form/**")
public void onPost(Request.In.Post event, IOSubchannel channel) {
FormContext ctx = channel
.associated(this, FormContext::new);
ctx.request = event.httpRequest();
ctx.session = event.associated(Session.class).get();
event.setResult(true);
event.stop();
} | java | @RequestHandler(patterns = "/form,/form/**")
public void onPost(Request.In.Post event, IOSubchannel channel) {
FormContext ctx = channel
.associated(this, FormContext::new);
ctx.request = event.httpRequest();
ctx.session = event.associated(Session.class).get();
event.setResult(true);
event.stop();
} | [
"@",
"RequestHandler",
"(",
"patterns",
"=",
"\"/form,/form/**\"",
")",
"public",
"void",
"onPost",
"(",
"Request",
".",
"In",
".",
"Post",
"event",
",",
"IOSubchannel",
"channel",
")",
"{",
"FormContext",
"ctx",
"=",
"channel",
".",
"associated",
"(",
"this",
",",
"FormContext",
"::",
"new",
")",
";",
"ctx",
".",
"request",
"=",
"event",
".",
"httpRequest",
"(",
")",
";",
"ctx",
".",
"session",
"=",
"event",
".",
"associated",
"(",
"Session",
".",
"class",
")",
".",
"get",
"(",
")",
";",
"event",
".",
"setResult",
"(",
"true",
")",
";",
"event",
".",
"stop",
"(",
")",
";",
"}"
] | Handle a `POST` request.
@param event the event
@param channel the channel | [
"Handle",
"a",
"POST",
"request",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/examples/src/org/jgrapes/http/demo/httpserver/FormProcessor.java#L90-L98 | train |
mnlipp/jgrapes | examples/src/org/jgrapes/http/demo/httpserver/FormProcessor.java | FormProcessor.onInput | @Handler
public void onInput(Input<ByteBuffer> event, IOSubchannel channel)
throws InterruptedException, UnsupportedEncodingException {
Optional<FormContext> ctx = channel.associated(this, FormContext.class);
if (!ctx.isPresent()) {
return;
}
ctx.get().fieldDecoder.addData(event.data());
if (!event.isEndOfRecord()) {
return;
}
long invocations = (Long) ctx.get().session.computeIfAbsent(
"invocations", key -> {
return 0L;
});
ctx.get().session.put("invocations", invocations + 1);
HttpResponse response = ctx.get().request.response().get();
response.setStatus(HttpStatus.OK);
response.setHasPayload(true);
response.setField(HttpField.CONTENT_TYPE,
MediaType.builder().setType("text", "plain")
.setParameter("charset", "utf-8").build());
String data = "First name: "
+ ctx.get().fieldDecoder.fields().get("firstname")
+ "\r\n" + "Last name: "
+ ctx.get().fieldDecoder.fields().get("lastname")
+ "\r\n" + "Previous invocations: " + invocations;
channel.respond(new Response(response));
ManagedBuffer<ByteBuffer> out = channel.byteBufferPool().acquire();
out.backingBuffer().put(data.getBytes("utf-8"));
channel.respond(Output.fromSink(out, true));
} | java | @Handler
public void onInput(Input<ByteBuffer> event, IOSubchannel channel)
throws InterruptedException, UnsupportedEncodingException {
Optional<FormContext> ctx = channel.associated(this, FormContext.class);
if (!ctx.isPresent()) {
return;
}
ctx.get().fieldDecoder.addData(event.data());
if (!event.isEndOfRecord()) {
return;
}
long invocations = (Long) ctx.get().session.computeIfAbsent(
"invocations", key -> {
return 0L;
});
ctx.get().session.put("invocations", invocations + 1);
HttpResponse response = ctx.get().request.response().get();
response.setStatus(HttpStatus.OK);
response.setHasPayload(true);
response.setField(HttpField.CONTENT_TYPE,
MediaType.builder().setType("text", "plain")
.setParameter("charset", "utf-8").build());
String data = "First name: "
+ ctx.get().fieldDecoder.fields().get("firstname")
+ "\r\n" + "Last name: "
+ ctx.get().fieldDecoder.fields().get("lastname")
+ "\r\n" + "Previous invocations: " + invocations;
channel.respond(new Response(response));
ManagedBuffer<ByteBuffer> out = channel.byteBufferPool().acquire();
out.backingBuffer().put(data.getBytes("utf-8"));
channel.respond(Output.fromSink(out, true));
} | [
"@",
"Handler",
"public",
"void",
"onInput",
"(",
"Input",
"<",
"ByteBuffer",
">",
"event",
",",
"IOSubchannel",
"channel",
")",
"throws",
"InterruptedException",
",",
"UnsupportedEncodingException",
"{",
"Optional",
"<",
"FormContext",
">",
"ctx",
"=",
"channel",
".",
"associated",
"(",
"this",
",",
"FormContext",
".",
"class",
")",
";",
"if",
"(",
"!",
"ctx",
".",
"isPresent",
"(",
")",
")",
"{",
"return",
";",
"}",
"ctx",
".",
"get",
"(",
")",
".",
"fieldDecoder",
".",
"addData",
"(",
"event",
".",
"data",
"(",
")",
")",
";",
"if",
"(",
"!",
"event",
".",
"isEndOfRecord",
"(",
")",
")",
"{",
"return",
";",
"}",
"long",
"invocations",
"=",
"(",
"Long",
")",
"ctx",
".",
"get",
"(",
")",
".",
"session",
".",
"computeIfAbsent",
"(",
"\"invocations\"",
",",
"key",
"->",
"{",
"return",
"0L",
";",
"}",
")",
";",
"ctx",
".",
"get",
"(",
")",
".",
"session",
".",
"put",
"(",
"\"invocations\"",
",",
"invocations",
"+",
"1",
")",
";",
"HttpResponse",
"response",
"=",
"ctx",
".",
"get",
"(",
")",
".",
"request",
".",
"response",
"(",
")",
".",
"get",
"(",
")",
";",
"response",
".",
"setStatus",
"(",
"HttpStatus",
".",
"OK",
")",
";",
"response",
".",
"setHasPayload",
"(",
"true",
")",
";",
"response",
".",
"setField",
"(",
"HttpField",
".",
"CONTENT_TYPE",
",",
"MediaType",
".",
"builder",
"(",
")",
".",
"setType",
"(",
"\"text\"",
",",
"\"plain\"",
")",
".",
"setParameter",
"(",
"\"charset\"",
",",
"\"utf-8\"",
")",
".",
"build",
"(",
")",
")",
";",
"String",
"data",
"=",
"\"First name: \"",
"+",
"ctx",
".",
"get",
"(",
")",
".",
"fieldDecoder",
".",
"fields",
"(",
")",
".",
"get",
"(",
"\"firstname\"",
")",
"+",
"\"\\r\\n\"",
"+",
"\"Last name: \"",
"+",
"ctx",
".",
"get",
"(",
")",
".",
"fieldDecoder",
".",
"fields",
"(",
")",
".",
"get",
"(",
"\"lastname\"",
")",
"+",
"\"\\r\\n\"",
"+",
"\"Previous invocations: \"",
"+",
"invocations",
";",
"channel",
".",
"respond",
"(",
"new",
"Response",
"(",
"response",
")",
")",
";",
"ManagedBuffer",
"<",
"ByteBuffer",
">",
"out",
"=",
"channel",
".",
"byteBufferPool",
"(",
")",
".",
"acquire",
"(",
")",
";",
"out",
".",
"backingBuffer",
"(",
")",
".",
"put",
"(",
"data",
".",
"getBytes",
"(",
"\"utf-8\"",
")",
")",
";",
"channel",
".",
"respond",
"(",
"Output",
".",
"fromSink",
"(",
"out",
",",
"true",
")",
")",
";",
"}"
] | Hanlde input.
@param event the event
@param channel the channel
@throws InterruptedException the interrupted exception
@throws UnsupportedEncodingException the unsupported encoding exception | [
"Hanlde",
"input",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/examples/src/org/jgrapes/http/demo/httpserver/FormProcessor.java#L108-L141 | train |
mnlipp/jgrapes | org.jgrapes.http/src/org/jgrapes/http/HttpConnector.java | HttpConnector.onConnected | @Handler(channels = NetworkChannel.class)
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
public void onConnected(Connected event, TcpChannel netConnChannel)
throws InterruptedException, IOException {
// Check if an app channel has been waiting for such a connection
WebAppMsgChannel[] appChannel = { null };
synchronized (connecting) {
connecting.computeIfPresent(event.remoteAddress(), (key, set) -> {
Iterator<WebAppMsgChannel> iter = set.iterator();
appChannel[0] = iter.next();
iter.remove();
return set.isEmpty() ? null : set;
});
}
if (appChannel[0] != null) {
appChannel[0].connected(netConnChannel);
}
} | java | @Handler(channels = NetworkChannel.class)
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
public void onConnected(Connected event, TcpChannel netConnChannel)
throws InterruptedException, IOException {
// Check if an app channel has been waiting for such a connection
WebAppMsgChannel[] appChannel = { null };
synchronized (connecting) {
connecting.computeIfPresent(event.remoteAddress(), (key, set) -> {
Iterator<WebAppMsgChannel> iter = set.iterator();
appChannel[0] = iter.next();
iter.remove();
return set.isEmpty() ? null : set;
});
}
if (appChannel[0] != null) {
appChannel[0].connected(netConnChannel);
}
} | [
"@",
"Handler",
"(",
"channels",
"=",
"NetworkChannel",
".",
"class",
")",
"@",
"SuppressWarnings",
"(",
"\"PMD.DataflowAnomalyAnalysis\"",
")",
"public",
"void",
"onConnected",
"(",
"Connected",
"event",
",",
"TcpChannel",
"netConnChannel",
")",
"throws",
"InterruptedException",
",",
"IOException",
"{",
"// Check if an app channel has been waiting for such a connection",
"WebAppMsgChannel",
"[",
"]",
"appChannel",
"=",
"{",
"null",
"}",
";",
"synchronized",
"(",
"connecting",
")",
"{",
"connecting",
".",
"computeIfPresent",
"(",
"event",
".",
"remoteAddress",
"(",
")",
",",
"(",
"key",
",",
"set",
")",
"->",
"{",
"Iterator",
"<",
"WebAppMsgChannel",
">",
"iter",
"=",
"set",
".",
"iterator",
"(",
")",
";",
"appChannel",
"[",
"0",
"]",
"=",
"iter",
".",
"next",
"(",
")",
";",
"iter",
".",
"remove",
"(",
")",
";",
"return",
"set",
".",
"isEmpty",
"(",
")",
"?",
"null",
":",
"set",
";",
"}",
")",
";",
"}",
"if",
"(",
"appChannel",
"[",
"0",
"]",
"!=",
"null",
")",
"{",
"appChannel",
"[",
"0",
"]",
".",
"connected",
"(",
"netConnChannel",
")",
";",
"}",
"}"
] | Called when the network connection is established. Triggers the
frther processing of the initial request.
@param event the event
@param netConnChannel the network layer channel
@throws InterruptedException if the execution is interrupted
@throws IOException Signals that an I/O exception has occurred. | [
"Called",
"when",
"the",
"network",
"connection",
"is",
"established",
".",
"Triggers",
"the",
"frther",
"processing",
"of",
"the",
"initial",
"request",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.http/src/org/jgrapes/http/HttpConnector.java#L170-L187 | train |
mnlipp/jgrapes | org.jgrapes.http/src/org/jgrapes/http/HttpConnector.java | HttpConnector.onInput | @Handler(channels = NetworkChannel.class)
public void onInput(Input<ByteBuffer> event, TcpChannel netConnChannel)
throws InterruptedException, ProtocolException {
Optional<WebAppMsgChannel> appChannel
= netConnChannel.associated(WebAppMsgChannel.class);
if (appChannel.isPresent()) {
appChannel.get().handleNetInput(event, netConnChannel);
}
} | java | @Handler(channels = NetworkChannel.class)
public void onInput(Input<ByteBuffer> event, TcpChannel netConnChannel)
throws InterruptedException, ProtocolException {
Optional<WebAppMsgChannel> appChannel
= netConnChannel.associated(WebAppMsgChannel.class);
if (appChannel.isPresent()) {
appChannel.get().handleNetInput(event, netConnChannel);
}
} | [
"@",
"Handler",
"(",
"channels",
"=",
"NetworkChannel",
".",
"class",
")",
"public",
"void",
"onInput",
"(",
"Input",
"<",
"ByteBuffer",
">",
"event",
",",
"TcpChannel",
"netConnChannel",
")",
"throws",
"InterruptedException",
",",
"ProtocolException",
"{",
"Optional",
"<",
"WebAppMsgChannel",
">",
"appChannel",
"=",
"netConnChannel",
".",
"associated",
"(",
"WebAppMsgChannel",
".",
"class",
")",
";",
"if",
"(",
"appChannel",
".",
"isPresent",
"(",
")",
")",
"{",
"appChannel",
".",
"get",
"(",
")",
".",
"handleNetInput",
"(",
"event",
",",
"netConnChannel",
")",
";",
"}",
"}"
] | Processes any input from the network layer.
@param event the event
@param netConnChannel the network layer channel
@throws InterruptedException if the thread is interrupted
@throws ProtocolException if the protocol is violated | [
"Processes",
"any",
"input",
"from",
"the",
"network",
"layer",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.http/src/org/jgrapes/http/HttpConnector.java#L239-L247 | train |
mnlipp/jgrapes | org.jgrapes.http/src/org/jgrapes/http/HttpConnector.java | HttpConnector.onClosed | @Handler(channels = NetworkChannel.class)
public void onClosed(Closed event, TcpChannel netConnChannel) {
netConnChannel.associated(WebAppMsgChannel.class).ifPresent(
appChannel -> appChannel.handleClosed(event));
pooled.remove(netConnChannel.remoteAddress(), netConnChannel);
} | java | @Handler(channels = NetworkChannel.class)
public void onClosed(Closed event, TcpChannel netConnChannel) {
netConnChannel.associated(WebAppMsgChannel.class).ifPresent(
appChannel -> appChannel.handleClosed(event));
pooled.remove(netConnChannel.remoteAddress(), netConnChannel);
} | [
"@",
"Handler",
"(",
"channels",
"=",
"NetworkChannel",
".",
"class",
")",
"public",
"void",
"onClosed",
"(",
"Closed",
"event",
",",
"TcpChannel",
"netConnChannel",
")",
"{",
"netConnChannel",
".",
"associated",
"(",
"WebAppMsgChannel",
".",
"class",
")",
".",
"ifPresent",
"(",
"appChannel",
"->",
"appChannel",
".",
"handleClosed",
"(",
"event",
")",
")",
";",
"pooled",
".",
"remove",
"(",
"netConnChannel",
".",
"remoteAddress",
"(",
")",
",",
"netConnChannel",
")",
";",
"}"
] | Called when the network connection is closed.
@param event the event
@param netConnChannel the net conn channel | [
"Called",
"when",
"the",
"network",
"connection",
"is",
"closed",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.http/src/org/jgrapes/http/HttpConnector.java#L255-L260 | train |
A-pZ/struts2-thymeleaf3-plugin | src/main/java/serendip/struts/plugins/thymeleaf/ThymeleafSpringResult.java | ThymeleafSpringResult.bindStrutsContext | Map<String, Object> bindStrutsContext(Object action) {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put(ACTION_VARIABLE_NAME, action);
if ( action instanceof ActionSupport) {
ActionSupport actSupport = (ActionSupport)action;
// Struts2 field errors.( Map<fieldname , fielderrors>)
Map<String, List<String>> fieldErrors = actSupport.getFieldErrors();
variables.put(FIELD_ERRORS_NAME, fieldErrors);
}
return variables;
} | java | Map<String, Object> bindStrutsContext(Object action) {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put(ACTION_VARIABLE_NAME, action);
if ( action instanceof ActionSupport) {
ActionSupport actSupport = (ActionSupport)action;
// Struts2 field errors.( Map<fieldname , fielderrors>)
Map<String, List<String>> fieldErrors = actSupport.getFieldErrors();
variables.put(FIELD_ERRORS_NAME, fieldErrors);
}
return variables;
} | [
"Map",
"<",
"String",
",",
"Object",
">",
"bindStrutsContext",
"(",
"Object",
"action",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"variables",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"variables",
".",
"put",
"(",
"ACTION_VARIABLE_NAME",
",",
"action",
")",
";",
"if",
"(",
"action",
"instanceof",
"ActionSupport",
")",
"{",
"ActionSupport",
"actSupport",
"=",
"(",
"ActionSupport",
")",
"action",
";",
"// Struts2 field errors.( Map<fieldname , fielderrors>)\r",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"fieldErrors",
"=",
"actSupport",
".",
"getFieldErrors",
"(",
")",
";",
"variables",
".",
"put",
"(",
"FIELD_ERRORS_NAME",
",",
"fieldErrors",
")",
";",
"}",
"return",
"variables",
";",
"}"
] | Binding Struts2 action and context, and field-errors list binding "field".
@param action Action instance
@return ContextMap | [
"Binding",
"Struts2",
"action",
"and",
"context",
"and",
"field",
"-",
"errors",
"list",
"binding",
"field",
"."
] | 36a4609c1d0a36019784c6dba951c9b27dcc8802 | https://github.com/A-pZ/struts2-thymeleaf3-plugin/blob/36a4609c1d0a36019784c6dba951c9b27dcc8802/src/main/java/serendip/struts/plugins/thymeleaf/ThymeleafSpringResult.java#L128-L141 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/Settings.java | Settings.sdkInitialize | public static synchronized void sdkInitialize(Context context) {
if (sdkInitialized == true) {
return;
}
BoltsMeasurementEventListener.getInstance(context.getApplicationContext());
sdkInitialized = true;
} | java | public static synchronized void sdkInitialize(Context context) {
if (sdkInitialized == true) {
return;
}
BoltsMeasurementEventListener.getInstance(context.getApplicationContext());
sdkInitialized = true;
} | [
"public",
"static",
"synchronized",
"void",
"sdkInitialize",
"(",
"Context",
"context",
")",
"{",
"if",
"(",
"sdkInitialized",
"==",
"true",
")",
"{",
"return",
";",
"}",
"BoltsMeasurementEventListener",
".",
"getInstance",
"(",
"context",
".",
"getApplicationContext",
"(",
")",
")",
";",
"sdkInitialized",
"=",
"true",
";",
"}"
] | Initialize SDK
This function will be called once in the application, it is tried to be called as early as possible;
This is the place to register broadcast listeners. | [
"Initialize",
"SDK",
"This",
"function",
"will",
"be",
"called",
"once",
"in",
"the",
"application",
"it",
"is",
"tried",
"to",
"be",
"called",
"as",
"early",
"as",
"possible",
";",
"This",
"is",
"the",
"place",
"to",
"register",
"broadcast",
"listeners",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/Settings.java#L111-L117 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/Settings.java | Settings.getExecutor | public static Executor getExecutor() {
synchronized (LOCK) {
if (Settings.executor == null) {
Executor executor = getAsyncTaskExecutor();
if (executor == null) {
executor = new ThreadPoolExecutor(DEFAULT_CORE_POOL_SIZE, DEFAULT_MAXIMUM_POOL_SIZE,
DEFAULT_KEEP_ALIVE, TimeUnit.SECONDS, DEFAULT_WORK_QUEUE, DEFAULT_THREAD_FACTORY);
}
Settings.executor = executor;
}
}
return Settings.executor;
} | java | public static Executor getExecutor() {
synchronized (LOCK) {
if (Settings.executor == null) {
Executor executor = getAsyncTaskExecutor();
if (executor == null) {
executor = new ThreadPoolExecutor(DEFAULT_CORE_POOL_SIZE, DEFAULT_MAXIMUM_POOL_SIZE,
DEFAULT_KEEP_ALIVE, TimeUnit.SECONDS, DEFAULT_WORK_QUEUE, DEFAULT_THREAD_FACTORY);
}
Settings.executor = executor;
}
}
return Settings.executor;
} | [
"public",
"static",
"Executor",
"getExecutor",
"(",
")",
"{",
"synchronized",
"(",
"LOCK",
")",
"{",
"if",
"(",
"Settings",
".",
"executor",
"==",
"null",
")",
"{",
"Executor",
"executor",
"=",
"getAsyncTaskExecutor",
"(",
")",
";",
"if",
"(",
"executor",
"==",
"null",
")",
"{",
"executor",
"=",
"new",
"ThreadPoolExecutor",
"(",
"DEFAULT_CORE_POOL_SIZE",
",",
"DEFAULT_MAXIMUM_POOL_SIZE",
",",
"DEFAULT_KEEP_ALIVE",
",",
"TimeUnit",
".",
"SECONDS",
",",
"DEFAULT_WORK_QUEUE",
",",
"DEFAULT_THREAD_FACTORY",
")",
";",
"}",
"Settings",
".",
"executor",
"=",
"executor",
";",
"}",
"}",
"return",
"Settings",
".",
"executor",
";",
"}"
] | Returns the Executor used by the SDK for non-AsyncTask background work.
By default this uses AsyncTask Executor via reflection if the API level is high enough.
Otherwise this creates a new Executor with defaults similar to those used in AsyncTask.
@return an Executor used by the SDK. This will never be null. | [
"Returns",
"the",
"Executor",
"used",
"by",
"the",
"SDK",
"for",
"non",
"-",
"AsyncTask",
"background",
"work",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/Settings.java#L215-L227 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/Settings.java | Settings.setExecutor | public static void setExecutor(Executor executor) {
Validate.notNull(executor, "executor");
synchronized (LOCK) {
Settings.executor = executor;
}
} | java | public static void setExecutor(Executor executor) {
Validate.notNull(executor, "executor");
synchronized (LOCK) {
Settings.executor = executor;
}
} | [
"public",
"static",
"void",
"setExecutor",
"(",
"Executor",
"executor",
")",
"{",
"Validate",
".",
"notNull",
"(",
"executor",
",",
"\"executor\"",
")",
";",
"synchronized",
"(",
"LOCK",
")",
"{",
"Settings",
".",
"executor",
"=",
"executor",
";",
"}",
"}"
] | Sets the Executor used by the SDK for non-AsyncTask background work.
@param executor
the Executor to use; must not be null. | [
"Sets",
"the",
"Executor",
"used",
"by",
"the",
"SDK",
"for",
"non",
"-",
"AsyncTask",
"background",
"work",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/Settings.java#L235-L240 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/Settings.java | Settings.getAttributionId | public static String getAttributionId(ContentResolver contentResolver) {
try {
String [] projection = {ATTRIBUTION_ID_COLUMN_NAME};
Cursor c = contentResolver.query(ATTRIBUTION_ID_CONTENT_URI, projection, null, null, null);
if (c == null || !c.moveToFirst()) {
return null;
}
String attributionId = c.getString(c.getColumnIndex(ATTRIBUTION_ID_COLUMN_NAME));
c.close();
return attributionId;
} catch (Exception e) {
Log.d(TAG, "Caught unexpected exception in getAttributionId(): " + e.toString());
return null;
}
} | java | public static String getAttributionId(ContentResolver contentResolver) {
try {
String [] projection = {ATTRIBUTION_ID_COLUMN_NAME};
Cursor c = contentResolver.query(ATTRIBUTION_ID_CONTENT_URI, projection, null, null, null);
if (c == null || !c.moveToFirst()) {
return null;
}
String attributionId = c.getString(c.getColumnIndex(ATTRIBUTION_ID_COLUMN_NAME));
c.close();
return attributionId;
} catch (Exception e) {
Log.d(TAG, "Caught unexpected exception in getAttributionId(): " + e.toString());
return null;
}
} | [
"public",
"static",
"String",
"getAttributionId",
"(",
"ContentResolver",
"contentResolver",
")",
"{",
"try",
"{",
"String",
"[",
"]",
"projection",
"=",
"{",
"ATTRIBUTION_ID_COLUMN_NAME",
"}",
";",
"Cursor",
"c",
"=",
"contentResolver",
".",
"query",
"(",
"ATTRIBUTION_ID_CONTENT_URI",
",",
"projection",
",",
"null",
",",
"null",
",",
"null",
")",
";",
"if",
"(",
"c",
"==",
"null",
"||",
"!",
"c",
".",
"moveToFirst",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"String",
"attributionId",
"=",
"c",
".",
"getString",
"(",
"c",
".",
"getColumnIndex",
"(",
"ATTRIBUTION_ID_COLUMN_NAME",
")",
")",
";",
"c",
".",
"close",
"(",
")",
";",
"return",
"attributionId",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"Log",
".",
"d",
"(",
"TAG",
",",
"\"Caught unexpected exception in getAttributionId(): \"",
"+",
"e",
".",
"toString",
"(",
")",
")",
";",
"return",
"null",
";",
"}",
"}"
] | Acquire the current attribution id from the facebook app.
@return returns null if the facebook app is not present on the phone. | [
"Acquire",
"the",
"current",
"attribution",
"id",
"from",
"the",
"facebook",
"app",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/Settings.java#L422-L436 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/Settings.java | Settings.getLimitEventAndDataUsage | public static boolean getLimitEventAndDataUsage(Context context) {
SharedPreferences preferences = context.getSharedPreferences(APP_EVENT_PREFERENCES, Context.MODE_PRIVATE);
return preferences.getBoolean("limitEventUsage", false);
} | java | public static boolean getLimitEventAndDataUsage(Context context) {
SharedPreferences preferences = context.getSharedPreferences(APP_EVENT_PREFERENCES, Context.MODE_PRIVATE);
return preferences.getBoolean("limitEventUsage", false);
} | [
"public",
"static",
"boolean",
"getLimitEventAndDataUsage",
"(",
"Context",
"context",
")",
"{",
"SharedPreferences",
"preferences",
"=",
"context",
".",
"getSharedPreferences",
"(",
"APP_EVENT_PREFERENCES",
",",
"Context",
".",
"MODE_PRIVATE",
")",
";",
"return",
"preferences",
".",
"getBoolean",
"(",
"\"limitEventUsage\"",
",",
"false",
")",
";",
"}"
] | Gets whether data such as that generated through AppEventsLogger and sent to Facebook should be restricted from
being used for purposes other than analytics and conversions, such as for targeting ads to this user. Defaults
to false. This value is stored on the device and persists across app launches.
@param context Used to read the value. | [
"Gets",
"whether",
"data",
"such",
"as",
"that",
"generated",
"through",
"AppEventsLogger",
"and",
"sent",
"to",
"Facebook",
"should",
"be",
"restricted",
"from",
"being",
"used",
"for",
"purposes",
"other",
"than",
"analytics",
"and",
"conversions",
"such",
"as",
"for",
"targeting",
"ads",
"to",
"this",
"user",
".",
"Defaults",
"to",
"false",
".",
"This",
"value",
"is",
"stored",
"on",
"the",
"device",
"and",
"persists",
"across",
"app",
"launches",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/Settings.java#L473-L476 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/Settings.java | Settings.setLimitEventAndDataUsage | public static void setLimitEventAndDataUsage(Context context, boolean limitEventUsage) {
SharedPreferences preferences = context.getSharedPreferences(APP_EVENT_PREFERENCES, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("limitEventUsage", limitEventUsage);
editor.commit();
} | java | public static void setLimitEventAndDataUsage(Context context, boolean limitEventUsage) {
SharedPreferences preferences = context.getSharedPreferences(APP_EVENT_PREFERENCES, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("limitEventUsage", limitEventUsage);
editor.commit();
} | [
"public",
"static",
"void",
"setLimitEventAndDataUsage",
"(",
"Context",
"context",
",",
"boolean",
"limitEventUsage",
")",
"{",
"SharedPreferences",
"preferences",
"=",
"context",
".",
"getSharedPreferences",
"(",
"APP_EVENT_PREFERENCES",
",",
"Context",
".",
"MODE_PRIVATE",
")",
";",
"SharedPreferences",
".",
"Editor",
"editor",
"=",
"preferences",
".",
"edit",
"(",
")",
";",
"editor",
".",
"putBoolean",
"(",
"\"limitEventUsage\"",
",",
"limitEventUsage",
")",
";",
"editor",
".",
"commit",
"(",
")",
";",
"}"
] | Sets whether data such as that generated through AppEventsLogger and sent to Facebook should be restricted from
being used for purposes other than analytics and conversions, such as for targeting ads to this user. Defaults
to false. This value is stored on the device and persists across app launches. Changes to this setting will
apply to app events currently queued to be flushed.
@param context Used to persist this value across app runs. | [
"Sets",
"whether",
"data",
"such",
"as",
"that",
"generated",
"through",
"AppEventsLogger",
"and",
"sent",
"to",
"Facebook",
"should",
"be",
"restricted",
"from",
"being",
"used",
"for",
"purposes",
"other",
"than",
"analytics",
"and",
"conversions",
"such",
"as",
"for",
"targeting",
"ads",
"to",
"this",
"user",
".",
"Defaults",
"to",
"false",
".",
"This",
"value",
"is",
"stored",
"on",
"the",
"device",
"and",
"persists",
"across",
"app",
"launches",
".",
"Changes",
"to",
"this",
"setting",
"will",
"apply",
"to",
"app",
"events",
"currently",
"queued",
"to",
"be",
"flushed",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/Settings.java#L486-L491 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/widget/ToolTipPopup.java | ToolTipPopup.show | public void show() {
if (mAnchorViewRef.get() != null) {
mPopupContent = new PopupContentView(mContext);
TextView body = (TextView) mPopupContent.findViewById(
R.id.com_facebook_tooltip_bubble_view_text_body);
body.setText(mText);
if (mStyle == Style.BLUE) {
mPopupContent.bodyFrame.setBackgroundResource(
R.drawable.com_facebook_tooltip_blue_background);
mPopupContent.bottomArrow.setImageResource(
R.drawable.com_facebook_tooltip_blue_bottomnub);
mPopupContent.topArrow.setImageResource(
R.drawable.com_facebook_tooltip_blue_topnub);
mPopupContent.xOut.setImageResource(R.drawable.com_facebook_tooltip_blue_xout);
} else {
mPopupContent.bodyFrame.setBackgroundResource(
R.drawable.com_facebook_tooltip_black_background);
mPopupContent.bottomArrow.setImageResource(
R.drawable.com_facebook_tooltip_black_bottomnub);
mPopupContent.topArrow.setImageResource(
R.drawable.com_facebook_tooltip_black_topnub);
mPopupContent.xOut.setImageResource(R.drawable.com_facebook_tooltip_black_xout);
}
final Window window = ((Activity) mContext).getWindow();
final View decorView = window.getDecorView();
final int decorWidth = decorView.getWidth();
final int decorHeight = decorView.getHeight();
registerObserver();
mPopupContent.onMeasure(
View.MeasureSpec.makeMeasureSpec(decorWidth, View.MeasureSpec.AT_MOST),
View.MeasureSpec.makeMeasureSpec(decorHeight, View.MeasureSpec.AT_MOST));
mPopupWindow = new PopupWindow(
mPopupContent,
mPopupContent.getMeasuredWidth(),
mPopupContent.getMeasuredHeight());
mPopupWindow.showAsDropDown(mAnchorViewRef.get());
updateArrows();
if (mNuxDisplayTime > 0) {
mPopupContent.postDelayed(new Runnable() {
@Override
public void run() {
dismiss();
}
}, mNuxDisplayTime);
}
mPopupWindow.setTouchable(true);
mPopupContent.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
}
} | java | public void show() {
if (mAnchorViewRef.get() != null) {
mPopupContent = new PopupContentView(mContext);
TextView body = (TextView) mPopupContent.findViewById(
R.id.com_facebook_tooltip_bubble_view_text_body);
body.setText(mText);
if (mStyle == Style.BLUE) {
mPopupContent.bodyFrame.setBackgroundResource(
R.drawable.com_facebook_tooltip_blue_background);
mPopupContent.bottomArrow.setImageResource(
R.drawable.com_facebook_tooltip_blue_bottomnub);
mPopupContent.topArrow.setImageResource(
R.drawable.com_facebook_tooltip_blue_topnub);
mPopupContent.xOut.setImageResource(R.drawable.com_facebook_tooltip_blue_xout);
} else {
mPopupContent.bodyFrame.setBackgroundResource(
R.drawable.com_facebook_tooltip_black_background);
mPopupContent.bottomArrow.setImageResource(
R.drawable.com_facebook_tooltip_black_bottomnub);
mPopupContent.topArrow.setImageResource(
R.drawable.com_facebook_tooltip_black_topnub);
mPopupContent.xOut.setImageResource(R.drawable.com_facebook_tooltip_black_xout);
}
final Window window = ((Activity) mContext).getWindow();
final View decorView = window.getDecorView();
final int decorWidth = decorView.getWidth();
final int decorHeight = decorView.getHeight();
registerObserver();
mPopupContent.onMeasure(
View.MeasureSpec.makeMeasureSpec(decorWidth, View.MeasureSpec.AT_MOST),
View.MeasureSpec.makeMeasureSpec(decorHeight, View.MeasureSpec.AT_MOST));
mPopupWindow = new PopupWindow(
mPopupContent,
mPopupContent.getMeasuredWidth(),
mPopupContent.getMeasuredHeight());
mPopupWindow.showAsDropDown(mAnchorViewRef.get());
updateArrows();
if (mNuxDisplayTime > 0) {
mPopupContent.postDelayed(new Runnable() {
@Override
public void run() {
dismiss();
}
}, mNuxDisplayTime);
}
mPopupWindow.setTouchable(true);
mPopupContent.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
}
} | [
"public",
"void",
"show",
"(",
")",
"{",
"if",
"(",
"mAnchorViewRef",
".",
"get",
"(",
")",
"!=",
"null",
")",
"{",
"mPopupContent",
"=",
"new",
"PopupContentView",
"(",
"mContext",
")",
";",
"TextView",
"body",
"=",
"(",
"TextView",
")",
"mPopupContent",
".",
"findViewById",
"(",
"R",
".",
"id",
".",
"com_facebook_tooltip_bubble_view_text_body",
")",
";",
"body",
".",
"setText",
"(",
"mText",
")",
";",
"if",
"(",
"mStyle",
"==",
"Style",
".",
"BLUE",
")",
"{",
"mPopupContent",
".",
"bodyFrame",
".",
"setBackgroundResource",
"(",
"R",
".",
"drawable",
".",
"com_facebook_tooltip_blue_background",
")",
";",
"mPopupContent",
".",
"bottomArrow",
".",
"setImageResource",
"(",
"R",
".",
"drawable",
".",
"com_facebook_tooltip_blue_bottomnub",
")",
";",
"mPopupContent",
".",
"topArrow",
".",
"setImageResource",
"(",
"R",
".",
"drawable",
".",
"com_facebook_tooltip_blue_topnub",
")",
";",
"mPopupContent",
".",
"xOut",
".",
"setImageResource",
"(",
"R",
".",
"drawable",
".",
"com_facebook_tooltip_blue_xout",
")",
";",
"}",
"else",
"{",
"mPopupContent",
".",
"bodyFrame",
".",
"setBackgroundResource",
"(",
"R",
".",
"drawable",
".",
"com_facebook_tooltip_black_background",
")",
";",
"mPopupContent",
".",
"bottomArrow",
".",
"setImageResource",
"(",
"R",
".",
"drawable",
".",
"com_facebook_tooltip_black_bottomnub",
")",
";",
"mPopupContent",
".",
"topArrow",
".",
"setImageResource",
"(",
"R",
".",
"drawable",
".",
"com_facebook_tooltip_black_topnub",
")",
";",
"mPopupContent",
".",
"xOut",
".",
"setImageResource",
"(",
"R",
".",
"drawable",
".",
"com_facebook_tooltip_black_xout",
")",
";",
"}",
"final",
"Window",
"window",
"=",
"(",
"(",
"Activity",
")",
"mContext",
")",
".",
"getWindow",
"(",
")",
";",
"final",
"View",
"decorView",
"=",
"window",
".",
"getDecorView",
"(",
")",
";",
"final",
"int",
"decorWidth",
"=",
"decorView",
".",
"getWidth",
"(",
")",
";",
"final",
"int",
"decorHeight",
"=",
"decorView",
".",
"getHeight",
"(",
")",
";",
"registerObserver",
"(",
")",
";",
"mPopupContent",
".",
"onMeasure",
"(",
"View",
".",
"MeasureSpec",
".",
"makeMeasureSpec",
"(",
"decorWidth",
",",
"View",
".",
"MeasureSpec",
".",
"AT_MOST",
")",
",",
"View",
".",
"MeasureSpec",
".",
"makeMeasureSpec",
"(",
"decorHeight",
",",
"View",
".",
"MeasureSpec",
".",
"AT_MOST",
")",
")",
";",
"mPopupWindow",
"=",
"new",
"PopupWindow",
"(",
"mPopupContent",
",",
"mPopupContent",
".",
"getMeasuredWidth",
"(",
")",
",",
"mPopupContent",
".",
"getMeasuredHeight",
"(",
")",
")",
";",
"mPopupWindow",
".",
"showAsDropDown",
"(",
"mAnchorViewRef",
".",
"get",
"(",
")",
")",
";",
"updateArrows",
"(",
")",
";",
"if",
"(",
"mNuxDisplayTime",
">",
"0",
")",
"{",
"mPopupContent",
".",
"postDelayed",
"(",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"dismiss",
"(",
")",
";",
"}",
"}",
",",
"mNuxDisplayTime",
")",
";",
"}",
"mPopupWindow",
".",
"setTouchable",
"(",
"true",
")",
";",
"mPopupContent",
".",
"setOnClickListener",
"(",
"new",
"View",
".",
"OnClickListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onClick",
"(",
"View",
"v",
")",
"{",
"dismiss",
"(",
")",
";",
"}",
"}",
")",
";",
"}",
"}"
] | Display this tool tip to the user | [
"Display",
"this",
"tool",
"tip",
"to",
"the",
"user"
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/widget/ToolTipPopup.java#L100-L154 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/UiLifecycleHelper.java | UiLifecycleHelper.onCreate | public void onCreate(Bundle savedInstanceState) {
Session session = Session.getActiveSession();
if (session == null) {
if (savedInstanceState != null) {
session = Session.restoreSession(activity, null, callback, savedInstanceState);
}
if (session == null) {
session = new Session(activity);
}
Session.setActiveSession(session);
}
if (savedInstanceState != null) {
pendingFacebookDialogCall = savedInstanceState.getParcelable(DIALOG_CALL_BUNDLE_SAVE_KEY);
}
} | java | public void onCreate(Bundle savedInstanceState) {
Session session = Session.getActiveSession();
if (session == null) {
if (savedInstanceState != null) {
session = Session.restoreSession(activity, null, callback, savedInstanceState);
}
if (session == null) {
session = new Session(activity);
}
Session.setActiveSession(session);
}
if (savedInstanceState != null) {
pendingFacebookDialogCall = savedInstanceState.getParcelable(DIALOG_CALL_BUNDLE_SAVE_KEY);
}
} | [
"public",
"void",
"onCreate",
"(",
"Bundle",
"savedInstanceState",
")",
"{",
"Session",
"session",
"=",
"Session",
".",
"getActiveSession",
"(",
")",
";",
"if",
"(",
"session",
"==",
"null",
")",
"{",
"if",
"(",
"savedInstanceState",
"!=",
"null",
")",
"{",
"session",
"=",
"Session",
".",
"restoreSession",
"(",
"activity",
",",
"null",
",",
"callback",
",",
"savedInstanceState",
")",
";",
"}",
"if",
"(",
"session",
"==",
"null",
")",
"{",
"session",
"=",
"new",
"Session",
"(",
"activity",
")",
";",
"}",
"Session",
".",
"setActiveSession",
"(",
"session",
")",
";",
"}",
"if",
"(",
"savedInstanceState",
"!=",
"null",
")",
"{",
"pendingFacebookDialogCall",
"=",
"savedInstanceState",
".",
"getParcelable",
"(",
"DIALOG_CALL_BUNDLE_SAVE_KEY",
")",
";",
"}",
"}"
] | To be called from an Activity or Fragment's onCreate method.
@param savedInstanceState the previously saved state | [
"To",
"be",
"called",
"from",
"an",
"Activity",
"or",
"Fragment",
"s",
"onCreate",
"method",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/UiLifecycleHelper.java#L85-L99 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/UiLifecycleHelper.java | UiLifecycleHelper.onResume | public void onResume() {
Session session = Session.getActiveSession();
if (session != null) {
if (callback != null) {
session.addCallback(callback);
}
if (SessionState.CREATED_TOKEN_LOADED.equals(session.getState())) {
session.openForRead(null);
}
}
// add the broadcast receiver
IntentFilter filter = new IntentFilter();
filter.addAction(Session.ACTION_ACTIVE_SESSION_SET);
filter.addAction(Session.ACTION_ACTIVE_SESSION_UNSET);
// Add a broadcast receiver to listen to when the active Session
// is set or unset, and add/remove our callback as appropriate
broadcastManager.registerReceiver(receiver, filter);
} | java | public void onResume() {
Session session = Session.getActiveSession();
if (session != null) {
if (callback != null) {
session.addCallback(callback);
}
if (SessionState.CREATED_TOKEN_LOADED.equals(session.getState())) {
session.openForRead(null);
}
}
// add the broadcast receiver
IntentFilter filter = new IntentFilter();
filter.addAction(Session.ACTION_ACTIVE_SESSION_SET);
filter.addAction(Session.ACTION_ACTIVE_SESSION_UNSET);
// Add a broadcast receiver to listen to when the active Session
// is set or unset, and add/remove our callback as appropriate
broadcastManager.registerReceiver(receiver, filter);
} | [
"public",
"void",
"onResume",
"(",
")",
"{",
"Session",
"session",
"=",
"Session",
".",
"getActiveSession",
"(",
")",
";",
"if",
"(",
"session",
"!=",
"null",
")",
"{",
"if",
"(",
"callback",
"!=",
"null",
")",
"{",
"session",
".",
"addCallback",
"(",
"callback",
")",
";",
"}",
"if",
"(",
"SessionState",
".",
"CREATED_TOKEN_LOADED",
".",
"equals",
"(",
"session",
".",
"getState",
"(",
")",
")",
")",
"{",
"session",
".",
"openForRead",
"(",
"null",
")",
";",
"}",
"}",
"// add the broadcast receiver",
"IntentFilter",
"filter",
"=",
"new",
"IntentFilter",
"(",
")",
";",
"filter",
".",
"addAction",
"(",
"Session",
".",
"ACTION_ACTIVE_SESSION_SET",
")",
";",
"filter",
".",
"addAction",
"(",
"Session",
".",
"ACTION_ACTIVE_SESSION_UNSET",
")",
";",
"// Add a broadcast receiver to listen to when the active Session",
"// is set or unset, and add/remove our callback as appropriate",
"broadcastManager",
".",
"registerReceiver",
"(",
"receiver",
",",
"filter",
")",
";",
"}"
] | To be called from an Activity or Fragment's onResume method. | [
"To",
"be",
"called",
"from",
"an",
"Activity",
"or",
"Fragment",
"s",
"onResume",
"method",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/UiLifecycleHelper.java#L104-L123 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/UiLifecycleHelper.java | UiLifecycleHelper.onActivityResult | public void onActivityResult(int requestCode, int resultCode, Intent data) {
onActivityResult(requestCode, resultCode, data, null);
} | java | public void onActivityResult(int requestCode, int resultCode, Intent data) {
onActivityResult(requestCode, resultCode, data, null);
} | [
"public",
"void",
"onActivityResult",
"(",
"int",
"requestCode",
",",
"int",
"resultCode",
",",
"Intent",
"data",
")",
"{",
"onActivityResult",
"(",
"requestCode",
",",
"resultCode",
",",
"data",
",",
"null",
")",
";",
"}"
] | To be called from an Activity or Fragment's onActivityResult method.
@param requestCode the request code
@param resultCode the result code
@param data the result data | [
"To",
"be",
"called",
"from",
"an",
"Activity",
"or",
"Fragment",
"s",
"onActivityResult",
"method",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/UiLifecycleHelper.java#L132-L134 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/UiLifecycleHelper.java | UiLifecycleHelper.onActivityResult | public void onActivityResult(int requestCode, int resultCode, Intent data,
FacebookDialog.Callback facebookDialogCallback) {
Session session = Session.getActiveSession();
if (session != null) {
session.onActivityResult(activity, requestCode, resultCode, data);
}
handleFacebookDialogActivityResult(requestCode, resultCode, data, facebookDialogCallback);
} | java | public void onActivityResult(int requestCode, int resultCode, Intent data,
FacebookDialog.Callback facebookDialogCallback) {
Session session = Session.getActiveSession();
if (session != null) {
session.onActivityResult(activity, requestCode, resultCode, data);
}
handleFacebookDialogActivityResult(requestCode, resultCode, data, facebookDialogCallback);
} | [
"public",
"void",
"onActivityResult",
"(",
"int",
"requestCode",
",",
"int",
"resultCode",
",",
"Intent",
"data",
",",
"FacebookDialog",
".",
"Callback",
"facebookDialogCallback",
")",
"{",
"Session",
"session",
"=",
"Session",
".",
"getActiveSession",
"(",
")",
";",
"if",
"(",
"session",
"!=",
"null",
")",
"{",
"session",
".",
"onActivityResult",
"(",
"activity",
",",
"requestCode",
",",
"resultCode",
",",
"data",
")",
";",
"}",
"handleFacebookDialogActivityResult",
"(",
"requestCode",
",",
"resultCode",
",",
"data",
",",
"facebookDialogCallback",
")",
";",
"}"
] | To be called from an Activity or Fragment's onActivityResult method, when the results of a FacebookDialog
call are expected.
@param requestCode the request code
@param resultCode the result code
@param data the result data
@param dialogCallback the callback for handling FacebookDialog results, can be null | [
"To",
"be",
"called",
"from",
"an",
"Activity",
"or",
"Fragment",
"s",
"onActivityResult",
"method",
"when",
"the",
"results",
"of",
"a",
"FacebookDialog",
"call",
"are",
"expected",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/UiLifecycleHelper.java#L145-L153 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/UiLifecycleHelper.java | UiLifecycleHelper.onSaveInstanceState | public void onSaveInstanceState(Bundle outState) {
Session.saveSession(Session.getActiveSession(), outState);
outState.putParcelable(DIALOG_CALL_BUNDLE_SAVE_KEY, pendingFacebookDialogCall);
} | java | public void onSaveInstanceState(Bundle outState) {
Session.saveSession(Session.getActiveSession(), outState);
outState.putParcelable(DIALOG_CALL_BUNDLE_SAVE_KEY, pendingFacebookDialogCall);
} | [
"public",
"void",
"onSaveInstanceState",
"(",
"Bundle",
"outState",
")",
"{",
"Session",
".",
"saveSession",
"(",
"Session",
".",
"getActiveSession",
"(",
")",
",",
"outState",
")",
";",
"outState",
".",
"putParcelable",
"(",
"DIALOG_CALL_BUNDLE_SAVE_KEY",
",",
"pendingFacebookDialogCall",
")",
";",
"}"
] | To be called from an Activity or Fragment's onSaveInstanceState method.
@param outState the bundle to save state in | [
"To",
"be",
"called",
"from",
"an",
"Activity",
"or",
"Fragment",
"s",
"onSaveInstanceState",
"method",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/UiLifecycleHelper.java#L160-L163 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/UiLifecycleHelper.java | UiLifecycleHelper.onPause | public void onPause() {
// remove the broadcast receiver
broadcastManager.unregisterReceiver(receiver);
if (callback != null) {
Session session = Session.getActiveSession();
if (session != null) {
session.removeCallback(callback);
}
}
} | java | public void onPause() {
// remove the broadcast receiver
broadcastManager.unregisterReceiver(receiver);
if (callback != null) {
Session session = Session.getActiveSession();
if (session != null) {
session.removeCallback(callback);
}
}
} | [
"public",
"void",
"onPause",
"(",
")",
"{",
"// remove the broadcast receiver",
"broadcastManager",
".",
"unregisterReceiver",
"(",
"receiver",
")",
";",
"if",
"(",
"callback",
"!=",
"null",
")",
"{",
"Session",
"session",
"=",
"Session",
".",
"getActiveSession",
"(",
")",
";",
"if",
"(",
"session",
"!=",
"null",
")",
"{",
"session",
".",
"removeCallback",
"(",
"callback",
")",
";",
"}",
"}",
"}"
] | To be called from an Activity or Fragment's onPause method. | [
"To",
"be",
"called",
"from",
"an",
"Activity",
"or",
"Fragment",
"s",
"onPause",
"method",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/UiLifecycleHelper.java#L168-L178 | train |
mnlipp/jgrapes | org.jgrapes.core/src/org/jgrapes/core/internal/CoreUtils.java | CoreUtils.definitionEvaluator | public static Evaluator definitionEvaluator(
HandlerDefinition hda) {
return definitionEvaluators.computeIfAbsent(hda.evaluator(), key -> {
try {
return hda.evaluator().getConstructor().newInstance();
} catch (InstantiationException | IllegalAccessException
| IllegalArgumentException | InvocationTargetException
| NoSuchMethodException | SecurityException e) {
throw new IllegalStateException(e);
}
});
} | java | public static Evaluator definitionEvaluator(
HandlerDefinition hda) {
return definitionEvaluators.computeIfAbsent(hda.evaluator(), key -> {
try {
return hda.evaluator().getConstructor().newInstance();
} catch (InstantiationException | IllegalAccessException
| IllegalArgumentException | InvocationTargetException
| NoSuchMethodException | SecurityException e) {
throw new IllegalStateException(e);
}
});
} | [
"public",
"static",
"Evaluator",
"definitionEvaluator",
"(",
"HandlerDefinition",
"hda",
")",
"{",
"return",
"definitionEvaluators",
".",
"computeIfAbsent",
"(",
"hda",
".",
"evaluator",
"(",
")",
",",
"key",
"->",
"{",
"try",
"{",
"return",
"hda",
".",
"evaluator",
"(",
")",
".",
"getConstructor",
"(",
")",
".",
"newInstance",
"(",
")",
";",
"}",
"catch",
"(",
"InstantiationException",
"|",
"IllegalAccessException",
"|",
"IllegalArgumentException",
"|",
"InvocationTargetException",
"|",
"NoSuchMethodException",
"|",
"SecurityException",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"e",
")",
";",
"}",
"}",
")",
";",
"}"
] | Create a new definition evaluator.
@param hda the handler definition annotation
@return the evaluator | [
"Create",
"a",
"new",
"definition",
"evaluator",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.core/src/org/jgrapes/core/internal/CoreUtils.java#L65-L76 | train |
ologolo/streamline-api | src/org/daisy/streamline/api/tasks/TaskGroupSpecification.java | TaskGroupSpecification.matches | public boolean matches(TaskGroupInformation info) {
return getActivity().equals(info.getActivity()) &&
getInputType().equals(info.getInputType()) &&
getOutputType().equals(info.getOutputType()) &&
info.matchesLocale(getLocale());
} | java | public boolean matches(TaskGroupInformation info) {
return getActivity().equals(info.getActivity()) &&
getInputType().equals(info.getInputType()) &&
getOutputType().equals(info.getOutputType()) &&
info.matchesLocale(getLocale());
} | [
"public",
"boolean",
"matches",
"(",
"TaskGroupInformation",
"info",
")",
"{",
"return",
"getActivity",
"(",
")",
".",
"equals",
"(",
"info",
".",
"getActivity",
"(",
")",
")",
"&&",
"getInputType",
"(",
")",
".",
"equals",
"(",
"info",
".",
"getInputType",
"(",
")",
")",
"&&",
"getOutputType",
"(",
")",
".",
"equals",
"(",
"info",
".",
"getOutputType",
"(",
")",
")",
"&&",
"info",
".",
"matchesLocale",
"(",
"getLocale",
"(",
")",
")",
";",
"}"
] | Returns true if this specification matches the specified
task group information.
@param info the information to test
@return returns true if the specification matches | [
"Returns",
"true",
"if",
"this",
"specification",
"matches",
"the",
"specified",
"task",
"group",
"information",
"."
] | 4934b6da1de06e364ae90d6ea9b0929500da9cdb | https://github.com/ologolo/streamline-api/blob/4934b6da1de06e364ae90d6ea9b0929500da9cdb/src/org/daisy/streamline/api/tasks/TaskGroupSpecification.java#L206-L211 | train |
dmerkushov/log-helper | src/main/java/ru/dmerkushov/loghelper/LoggerWrapper.java | LoggerWrapper.logDomNodeList | public void logDomNodeList (String msg, NodeList nodeList) {
StackTraceElement caller = StackTraceUtils.getCallerStackTraceElement ();
String toLog = (msg != null ? msg + "\n" : "DOM nodelist:\n");
for (int i = 0; i < nodeList.getLength (); i++) {
toLog += domNodeDescription (nodeList.item (i), 0) + "\n";
}
if (caller != null) {
logger.logp (Level.FINER, caller.getClassName (), caller.getMethodName () + "():" + caller.getLineNumber (), toLog);
} else {
logger.logp (Level.FINER, "(UnknownSourceClass)", "(unknownSourceMethod)", toLog);
}
} | java | public void logDomNodeList (String msg, NodeList nodeList) {
StackTraceElement caller = StackTraceUtils.getCallerStackTraceElement ();
String toLog = (msg != null ? msg + "\n" : "DOM nodelist:\n");
for (int i = 0; i < nodeList.getLength (); i++) {
toLog += domNodeDescription (nodeList.item (i), 0) + "\n";
}
if (caller != null) {
logger.logp (Level.FINER, caller.getClassName (), caller.getMethodName () + "():" + caller.getLineNumber (), toLog);
} else {
logger.logp (Level.FINER, "(UnknownSourceClass)", "(unknownSourceMethod)", toLog);
}
} | [
"public",
"void",
"logDomNodeList",
"(",
"String",
"msg",
",",
"NodeList",
"nodeList",
")",
"{",
"StackTraceElement",
"caller",
"=",
"StackTraceUtils",
".",
"getCallerStackTraceElement",
"(",
")",
";",
"String",
"toLog",
"=",
"(",
"msg",
"!=",
"null",
"?",
"msg",
"+",
"\"\\n\"",
":",
"\"DOM nodelist:\\n\"",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"nodeList",
".",
"getLength",
"(",
")",
";",
"i",
"++",
")",
"{",
"toLog",
"+=",
"domNodeDescription",
"(",
"nodeList",
".",
"item",
"(",
"i",
")",
",",
"0",
")",
"+",
"\"\\n\"",
";",
"}",
"if",
"(",
"caller",
"!=",
"null",
")",
"{",
"logger",
".",
"logp",
"(",
"Level",
".",
"FINER",
",",
"caller",
".",
"getClassName",
"(",
")",
",",
"caller",
".",
"getMethodName",
"(",
")",
"+",
"\"():\"",
"+",
"caller",
".",
"getLineNumber",
"(",
")",
",",
"toLog",
")",
";",
"}",
"else",
"{",
"logger",
".",
"logp",
"(",
"Level",
".",
"FINER",
",",
"\"(UnknownSourceClass)\"",
",",
"\"(unknownSourceMethod)\"",
",",
"toLog",
")",
";",
"}",
"}"
] | Log a DOM node list at the FINER level
@param msg The message to show with the list, or null if no message
needed
@param nodeList
@see NodeList | [
"Log",
"a",
"DOM",
"node",
"list",
"at",
"the",
"FINER",
"level"
] | 3b7d3d30faa7f1437b27cd07c10fa579a995de23 | https://github.com/dmerkushov/log-helper/blob/3b7d3d30faa7f1437b27cd07c10fa579a995de23/src/main/java/ru/dmerkushov/loghelper/LoggerWrapper.java#L418-L431 | train |
dmerkushov/log-helper | src/main/java/ru/dmerkushov/loghelper/LoggerWrapper.java | LoggerWrapper.logDomNode | public void logDomNode (String msg, Node node) {
StackTraceElement caller = StackTraceUtils.getCallerStackTraceElement ();
logDomNode (msg, node, Level.FINER, caller);
} | java | public void logDomNode (String msg, Node node) {
StackTraceElement caller = StackTraceUtils.getCallerStackTraceElement ();
logDomNode (msg, node, Level.FINER, caller);
} | [
"public",
"void",
"logDomNode",
"(",
"String",
"msg",
",",
"Node",
"node",
")",
"{",
"StackTraceElement",
"caller",
"=",
"StackTraceUtils",
".",
"getCallerStackTraceElement",
"(",
")",
";",
"logDomNode",
"(",
"msg",
",",
"node",
",",
"Level",
".",
"FINER",
",",
"caller",
")",
";",
"}"
] | Log a DOM node at the FINER level
@param msg The message to show with the node, or null if no message needed
@param node
@see Node | [
"Log",
"a",
"DOM",
"node",
"at",
"the",
"FINER",
"level"
] | 3b7d3d30faa7f1437b27cd07c10fa579a995de23 | https://github.com/dmerkushov/log-helper/blob/3b7d3d30faa7f1437b27cd07c10fa579a995de23/src/main/java/ru/dmerkushov/loghelper/LoggerWrapper.java#L440-L444 | train |
dmerkushov/log-helper | src/main/java/ru/dmerkushov/loghelper/LoggerWrapper.java | LoggerWrapper.logDomNode | public void logDomNode (String msg, Node node, Level level, StackTraceElement caller) {
String toLog = (msg != null ? msg + "\n" : "DOM node:\n") + domNodeDescription (node, 0);
if (caller != null) {
logger.logp (level, caller.getClassName (), caller.getMethodName () + "():" + caller.getLineNumber (), toLog);
} else {
logger.logp (level, "(UnknownSourceClass)", "(unknownSourceMethod)", toLog);
}
} | java | public void logDomNode (String msg, Node node, Level level, StackTraceElement caller) {
String toLog = (msg != null ? msg + "\n" : "DOM node:\n") + domNodeDescription (node, 0);
if (caller != null) {
logger.logp (level, caller.getClassName (), caller.getMethodName () + "():" + caller.getLineNumber (), toLog);
} else {
logger.logp (level, "(UnknownSourceClass)", "(unknownSourceMethod)", toLog);
}
} | [
"public",
"void",
"logDomNode",
"(",
"String",
"msg",
",",
"Node",
"node",
",",
"Level",
"level",
",",
"StackTraceElement",
"caller",
")",
"{",
"String",
"toLog",
"=",
"(",
"msg",
"!=",
"null",
"?",
"msg",
"+",
"\"\\n\"",
":",
"\"DOM node:\\n\"",
")",
"+",
"domNodeDescription",
"(",
"node",
",",
"0",
")",
";",
"if",
"(",
"caller",
"!=",
"null",
")",
"{",
"logger",
".",
"logp",
"(",
"level",
",",
"caller",
".",
"getClassName",
"(",
")",
",",
"caller",
".",
"getMethodName",
"(",
")",
"+",
"\"():\"",
"+",
"caller",
".",
"getLineNumber",
"(",
")",
",",
"toLog",
")",
";",
"}",
"else",
"{",
"logger",
".",
"logp",
"(",
"level",
",",
"\"(UnknownSourceClass)\"",
",",
"\"(unknownSourceMethod)\"",
",",
"toLog",
")",
";",
"}",
"}"
] | Log a DOM node at a given logging level and a specified caller
@param msg The message to show with the node, or null if no message needed
@param node
@param level
@param caller The caller's stack trace element
@see ru.dmerkushov.loghelper.StackTraceUtils#getMyStackTraceElement() | [
"Log",
"a",
"DOM",
"node",
"at",
"a",
"given",
"logging",
"level",
"and",
"a",
"specified",
"caller"
] | 3b7d3d30faa7f1437b27cd07c10fa579a995de23 | https://github.com/dmerkushov/log-helper/blob/3b7d3d30faa7f1437b27cd07c10fa579a995de23/src/main/java/ru/dmerkushov/loghelper/LoggerWrapper.java#L466-L474 | train |
dmerkushov/log-helper | src/main/java/ru/dmerkushov/loghelper/LoggerWrapper.java | LoggerWrapper.domNodeDescription | private String domNodeDescription (Node node, int tablevel) {
String domNodeDescription = null;
String nodeName = node.getNodeName ();
String nodeValue = node.getNodeValue ();
if (!(nodeName.equals ("#text") && nodeValue.replaceAll ("\n", "").trim ().equals (""))) {
domNodeDescription = tabs (tablevel) + node.getNodeName () + "\n";
NamedNodeMap attributes = node.getAttributes ();
if (attributes != null) {
for (int i = 0; i < attributes.getLength (); i++) {
Node attribute = attributes.item (i);
domNodeDescription += tabs (tablevel) + "-" + attribute.getNodeName () + "=" + attribute.getNodeValue () + "\n";
}
}
domNodeDescription += tabs (tablevel) + "=" + node.getNodeValue () + "\n";
NodeList children = node.getChildNodes ();
if (children != null) {
for (int i = 0; i < children.getLength (); i++) {
String childDescription = domNodeDescription (children.item (i), tablevel + 1);
if (childDescription != null) {
domNodeDescription += childDescription;
}
}
}
}
return domNodeDescription;
} | java | private String domNodeDescription (Node node, int tablevel) {
String domNodeDescription = null;
String nodeName = node.getNodeName ();
String nodeValue = node.getNodeValue ();
if (!(nodeName.equals ("#text") && nodeValue.replaceAll ("\n", "").trim ().equals (""))) {
domNodeDescription = tabs (tablevel) + node.getNodeName () + "\n";
NamedNodeMap attributes = node.getAttributes ();
if (attributes != null) {
for (int i = 0; i < attributes.getLength (); i++) {
Node attribute = attributes.item (i);
domNodeDescription += tabs (tablevel) + "-" + attribute.getNodeName () + "=" + attribute.getNodeValue () + "\n";
}
}
domNodeDescription += tabs (tablevel) + "=" + node.getNodeValue () + "\n";
NodeList children = node.getChildNodes ();
if (children != null) {
for (int i = 0; i < children.getLength (); i++) {
String childDescription = domNodeDescription (children.item (i), tablevel + 1);
if (childDescription != null) {
domNodeDescription += childDescription;
}
}
}
}
return domNodeDescription;
} | [
"private",
"String",
"domNodeDescription",
"(",
"Node",
"node",
",",
"int",
"tablevel",
")",
"{",
"String",
"domNodeDescription",
"=",
"null",
";",
"String",
"nodeName",
"=",
"node",
".",
"getNodeName",
"(",
")",
";",
"String",
"nodeValue",
"=",
"node",
".",
"getNodeValue",
"(",
")",
";",
"if",
"(",
"!",
"(",
"nodeName",
".",
"equals",
"(",
"\"#text\"",
")",
"&&",
"nodeValue",
".",
"replaceAll",
"(",
"\"\\n\"",
",",
"\"\"",
")",
".",
"trim",
"(",
")",
".",
"equals",
"(",
"\"\"",
")",
")",
")",
"{",
"domNodeDescription",
"=",
"tabs",
"(",
"tablevel",
")",
"+",
"node",
".",
"getNodeName",
"(",
")",
"+",
"\"\\n\"",
";",
"NamedNodeMap",
"attributes",
"=",
"node",
".",
"getAttributes",
"(",
")",
";",
"if",
"(",
"attributes",
"!=",
"null",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"attributes",
".",
"getLength",
"(",
")",
";",
"i",
"++",
")",
"{",
"Node",
"attribute",
"=",
"attributes",
".",
"item",
"(",
"i",
")",
";",
"domNodeDescription",
"+=",
"tabs",
"(",
"tablevel",
")",
"+",
"\"-\"",
"+",
"attribute",
".",
"getNodeName",
"(",
")",
"+",
"\"=\"",
"+",
"attribute",
".",
"getNodeValue",
"(",
")",
"+",
"\"\\n\"",
";",
"}",
"}",
"domNodeDescription",
"+=",
"tabs",
"(",
"tablevel",
")",
"+",
"\"=\"",
"+",
"node",
".",
"getNodeValue",
"(",
")",
"+",
"\"\\n\"",
";",
"NodeList",
"children",
"=",
"node",
".",
"getChildNodes",
"(",
")",
";",
"if",
"(",
"children",
"!=",
"null",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"children",
".",
"getLength",
"(",
")",
";",
"i",
"++",
")",
"{",
"String",
"childDescription",
"=",
"domNodeDescription",
"(",
"children",
".",
"item",
"(",
"i",
")",
",",
"tablevel",
"+",
"1",
")",
";",
"if",
"(",
"childDescription",
"!=",
"null",
")",
"{",
"domNodeDescription",
"+=",
"childDescription",
";",
"}",
"}",
"}",
"}",
"return",
"domNodeDescription",
";",
"}"
] | Form a DOM node textual representation recursively
@param node
@param tablevel
@return | [
"Form",
"a",
"DOM",
"node",
"textual",
"representation",
"recursively"
] | 3b7d3d30faa7f1437b27cd07c10fa579a995de23 | https://github.com/dmerkushov/log-helper/blob/3b7d3d30faa7f1437b27cd07c10fa579a995de23/src/main/java/ru/dmerkushov/loghelper/LoggerWrapper.java#L483-L513 | train |
dmerkushov/log-helper | src/main/java/ru/dmerkushov/loghelper/LoggerWrapper.java | LoggerWrapper.setLevel | public void setLevel (Level level) {
this.defaultLevel = level;
logger.setLevel (level);
for (Handler handler : logger.getHandlers ()) {
handler.setLevel (level);
}
} | java | public void setLevel (Level level) {
this.defaultLevel = level;
logger.setLevel (level);
for (Handler handler : logger.getHandlers ()) {
handler.setLevel (level);
}
} | [
"public",
"void",
"setLevel",
"(",
"Level",
"level",
")",
"{",
"this",
".",
"defaultLevel",
"=",
"level",
";",
"logger",
".",
"setLevel",
"(",
"level",
")",
";",
"for",
"(",
"Handler",
"handler",
":",
"logger",
".",
"getHandlers",
"(",
")",
")",
"{",
"handler",
".",
"setLevel",
"(",
"level",
")",
";",
"}",
"}"
] | Set this level for all configured loggers
@param level | [
"Set",
"this",
"level",
"for",
"all",
"configured",
"loggers"
] | 3b7d3d30faa7f1437b27cd07c10fa579a995de23 | https://github.com/dmerkushov/log-helper/blob/3b7d3d30faa7f1437b27cd07c10fa579a995de23/src/main/java/ru/dmerkushov/loghelper/LoggerWrapper.java#L541-L548 | train |
mnlipp/jgrapes | org.jgrapes.io/src/org/jgrapes/net/TcpServer.java | TcpServer.onRegistered | @Handler(channels = Self.class)
public void onRegistered(NioRegistration.Completed event)
throws InterruptedException, IOException {
NioHandler handler = event.event().handler();
if (handler == this) {
if (event.event().get() == null) {
fire(new Error(event,
"Registration failed, no NioDispatcher?"));
return;
}
registration = event.event().get();
purger = new Purger();
purger.start();
fire(new Ready(serverSocketChannel.getLocalAddress()));
return;
}
if (handler instanceof TcpChannelImpl) {
TcpChannelImpl channel = (TcpChannelImpl) handler;
channel.downPipeline()
.fire(new Accepted(channel.nioChannel().getLocalAddress(),
channel.nioChannel().getRemoteAddress(), false,
Collections.emptyList()), channel);
channel.registrationComplete(event.event());
}
} | java | @Handler(channels = Self.class)
public void onRegistered(NioRegistration.Completed event)
throws InterruptedException, IOException {
NioHandler handler = event.event().handler();
if (handler == this) {
if (event.event().get() == null) {
fire(new Error(event,
"Registration failed, no NioDispatcher?"));
return;
}
registration = event.event().get();
purger = new Purger();
purger.start();
fire(new Ready(serverSocketChannel.getLocalAddress()));
return;
}
if (handler instanceof TcpChannelImpl) {
TcpChannelImpl channel = (TcpChannelImpl) handler;
channel.downPipeline()
.fire(new Accepted(channel.nioChannel().getLocalAddress(),
channel.nioChannel().getRemoteAddress(), false,
Collections.emptyList()), channel);
channel.registrationComplete(event.event());
}
} | [
"@",
"Handler",
"(",
"channels",
"=",
"Self",
".",
"class",
")",
"public",
"void",
"onRegistered",
"(",
"NioRegistration",
".",
"Completed",
"event",
")",
"throws",
"InterruptedException",
",",
"IOException",
"{",
"NioHandler",
"handler",
"=",
"event",
".",
"event",
"(",
")",
".",
"handler",
"(",
")",
";",
"if",
"(",
"handler",
"==",
"this",
")",
"{",
"if",
"(",
"event",
".",
"event",
"(",
")",
".",
"get",
"(",
")",
"==",
"null",
")",
"{",
"fire",
"(",
"new",
"Error",
"(",
"event",
",",
"\"Registration failed, no NioDispatcher?\"",
")",
")",
";",
"return",
";",
"}",
"registration",
"=",
"event",
".",
"event",
"(",
")",
".",
"get",
"(",
")",
";",
"purger",
"=",
"new",
"Purger",
"(",
")",
";",
"purger",
".",
"start",
"(",
")",
";",
"fire",
"(",
"new",
"Ready",
"(",
"serverSocketChannel",
".",
"getLocalAddress",
"(",
")",
")",
")",
";",
"return",
";",
"}",
"if",
"(",
"handler",
"instanceof",
"TcpChannelImpl",
")",
"{",
"TcpChannelImpl",
"channel",
"=",
"(",
"TcpChannelImpl",
")",
"handler",
";",
"channel",
".",
"downPipeline",
"(",
")",
".",
"fire",
"(",
"new",
"Accepted",
"(",
"channel",
".",
"nioChannel",
"(",
")",
".",
"getLocalAddress",
"(",
")",
",",
"channel",
".",
"nioChannel",
"(",
")",
".",
"getRemoteAddress",
"(",
")",
",",
"false",
",",
"Collections",
".",
"emptyList",
"(",
")",
")",
",",
"channel",
")",
";",
"channel",
".",
"registrationComplete",
"(",
"event",
".",
"event",
"(",
")",
")",
";",
"}",
"}"
] | Handles the successful channel registration.
@param event the event
@throws InterruptedException the interrupted exception
@throws IOException Signals that an I/O exception has occurred. | [
"Handles",
"the",
"successful",
"channel",
"registration",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.io/src/org/jgrapes/net/TcpServer.java#L380-L404 | train |
mnlipp/jgrapes | org.jgrapes.io/src/org/jgrapes/net/TcpServer.java | TcpServer.onClose | @Handler
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
public void onClose(Close event) throws IOException, InterruptedException {
boolean subOnly = true;
for (Channel channel : event.channels()) {
if (channel instanceof TcpChannelImpl) {
if (channels.contains(channel)) {
((TcpChannelImpl) channel).close();
}
} else {
subOnly = false;
}
}
if (subOnly || !serverSocketChannel.isOpen()) {
// Closed already
fire(new Closed());
return;
}
synchronized (channels) {
closing = true;
// Copy to avoid concurrent modification exception
Set<TcpChannelImpl> conns = new HashSet<>(channels);
for (TcpChannelImpl conn : conns) {
conn.close();
}
while (!channels.isEmpty()) {
channels.wait();
}
}
serverSocketChannel.close();
purger.interrupt();
closing = false;
fire(new Closed());
} | java | @Handler
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
public void onClose(Close event) throws IOException, InterruptedException {
boolean subOnly = true;
for (Channel channel : event.channels()) {
if (channel instanceof TcpChannelImpl) {
if (channels.contains(channel)) {
((TcpChannelImpl) channel).close();
}
} else {
subOnly = false;
}
}
if (subOnly || !serverSocketChannel.isOpen()) {
// Closed already
fire(new Closed());
return;
}
synchronized (channels) {
closing = true;
// Copy to avoid concurrent modification exception
Set<TcpChannelImpl> conns = new HashSet<>(channels);
for (TcpChannelImpl conn : conns) {
conn.close();
}
while (!channels.isEmpty()) {
channels.wait();
}
}
serverSocketChannel.close();
purger.interrupt();
closing = false;
fire(new Closed());
} | [
"@",
"Handler",
"@",
"SuppressWarnings",
"(",
"\"PMD.DataflowAnomalyAnalysis\"",
")",
"public",
"void",
"onClose",
"(",
"Close",
"event",
")",
"throws",
"IOException",
",",
"InterruptedException",
"{",
"boolean",
"subOnly",
"=",
"true",
";",
"for",
"(",
"Channel",
"channel",
":",
"event",
".",
"channels",
"(",
")",
")",
"{",
"if",
"(",
"channel",
"instanceof",
"TcpChannelImpl",
")",
"{",
"if",
"(",
"channels",
".",
"contains",
"(",
"channel",
")",
")",
"{",
"(",
"(",
"TcpChannelImpl",
")",
"channel",
")",
".",
"close",
"(",
")",
";",
"}",
"}",
"else",
"{",
"subOnly",
"=",
"false",
";",
"}",
"}",
"if",
"(",
"subOnly",
"||",
"!",
"serverSocketChannel",
".",
"isOpen",
"(",
")",
")",
"{",
"// Closed already",
"fire",
"(",
"new",
"Closed",
"(",
")",
")",
";",
"return",
";",
"}",
"synchronized",
"(",
"channels",
")",
"{",
"closing",
"=",
"true",
";",
"// Copy to avoid concurrent modification exception",
"Set",
"<",
"TcpChannelImpl",
">",
"conns",
"=",
"new",
"HashSet",
"<>",
"(",
"channels",
")",
";",
"for",
"(",
"TcpChannelImpl",
"conn",
":",
"conns",
")",
"{",
"conn",
".",
"close",
"(",
")",
";",
"}",
"while",
"(",
"!",
"channels",
".",
"isEmpty",
"(",
")",
")",
"{",
"channels",
".",
"wait",
"(",
")",
";",
"}",
"}",
"serverSocketChannel",
".",
"close",
"(",
")",
";",
"purger",
".",
"interrupt",
"(",
")",
";",
"closing",
"=",
"false",
";",
"fire",
"(",
"new",
"Closed",
"(",
")",
")",
";",
"}"
] | Shuts down the server or one of the connections to the server.
@param event the event
@throws IOException if an I/O exception occurred
@throws InterruptedException if the execution was interrupted | [
"Shuts",
"down",
"the",
"server",
"or",
"one",
"of",
"the",
"connections",
"to",
"the",
"server",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.io/src/org/jgrapes/net/TcpServer.java#L459-L492 | train |
anotheria/configureme | src/main/java/org/configureme/util/StringUtils.java | StringUtils.tokenize2vector | public static Vector<String> tokenize2vector(final String source, final char delimiter) {
final Vector<String> v = new Vector<>();
StringBuilder currentS = new StringBuilder();
char c;
for (int i = 0; i < source.length(); i++) {
c = source.charAt(i);
if (c == delimiter) {
v.addElement(currentS.length() > 0 ? currentS.toString() : "");
currentS = new StringBuilder(); //TODO: should be use one SB and not create another one
} else {
currentS.append(c);
}
}
if (currentS.length() > 0)
v.addElement(currentS.toString());
return v;
} | java | public static Vector<String> tokenize2vector(final String source, final char delimiter) {
final Vector<String> v = new Vector<>();
StringBuilder currentS = new StringBuilder();
char c;
for (int i = 0; i < source.length(); i++) {
c = source.charAt(i);
if (c == delimiter) {
v.addElement(currentS.length() > 0 ? currentS.toString() : "");
currentS = new StringBuilder(); //TODO: should be use one SB and not create another one
} else {
currentS.append(c);
}
}
if (currentS.length() > 0)
v.addElement(currentS.toString());
return v;
} | [
"public",
"static",
"Vector",
"<",
"String",
">",
"tokenize2vector",
"(",
"final",
"String",
"source",
",",
"final",
"char",
"delimiter",
")",
"{",
"final",
"Vector",
"<",
"String",
">",
"v",
"=",
"new",
"Vector",
"<>",
"(",
")",
";",
"StringBuilder",
"currentS",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"char",
"c",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"source",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"c",
"=",
"source",
".",
"charAt",
"(",
"i",
")",
";",
"if",
"(",
"c",
"==",
"delimiter",
")",
"{",
"v",
".",
"addElement",
"(",
"currentS",
".",
"length",
"(",
")",
">",
"0",
"?",
"currentS",
".",
"toString",
"(",
")",
":",
"\"\"",
")",
";",
"currentS",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"//TODO: should be use one SB and not create another one",
"}",
"else",
"{",
"currentS",
".",
"append",
"(",
"c",
")",
";",
"}",
"}",
"if",
"(",
"currentS",
".",
"length",
"(",
")",
">",
"0",
")",
"v",
".",
"addElement",
"(",
"currentS",
".",
"toString",
"(",
")",
")",
";",
"return",
"v",
";",
"}"
] | Return a Vector with tokens from the source string tokenized using the delimiter char.
@param source
source string
@param delimiter
token delimiter
@return {@link java.util.Vector} with {@link java.lang.String} | [
"Return",
"a",
"Vector",
"with",
"tokens",
"from",
"the",
"source",
"string",
"tokenized",
"using",
"the",
"delimiter",
"char",
"."
] | 1f52dd9109349623190586bdf5a592de8016e1fa | https://github.com/anotheria/configureme/blob/1f52dd9109349623190586bdf5a592de8016e1fa/src/main/java/org/configureme/util/StringUtils.java#L59-L75 | train |
anotheria/configureme | src/main/java/org/configureme/util/StringUtils.java | StringUtils.removeCComments | public static String removeCComments(final String src) {
final StringBuilder ret = new StringBuilder();
boolean inComments = false;
for (int i = 0; i < src.length(); i++) {
char c = src.charAt(i);
if (inComments) {
if (c == '*' && src.charAt(i + 1) == '/') {
inComments = false;
i++;
}
} else {
if (c == '/') {
if (src.charAt(i + 1) == '*') {
inComments = true;
i++;
} else {
ret.append(c);
}
} else
ret.append(c);
}
}
return ret.toString();
} | java | public static String removeCComments(final String src) {
final StringBuilder ret = new StringBuilder();
boolean inComments = false;
for (int i = 0; i < src.length(); i++) {
char c = src.charAt(i);
if (inComments) {
if (c == '*' && src.charAt(i + 1) == '/') {
inComments = false;
i++;
}
} else {
if (c == '/') {
if (src.charAt(i + 1) == '*') {
inComments = true;
i++;
} else {
ret.append(c);
}
} else
ret.append(c);
}
}
return ret.toString();
} | [
"public",
"static",
"String",
"removeCComments",
"(",
"final",
"String",
"src",
")",
"{",
"final",
"StringBuilder",
"ret",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"boolean",
"inComments",
"=",
"false",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"src",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"char",
"c",
"=",
"src",
".",
"charAt",
"(",
"i",
")",
";",
"if",
"(",
"inComments",
")",
"{",
"if",
"(",
"c",
"==",
"'",
"'",
"&&",
"src",
".",
"charAt",
"(",
"i",
"+",
"1",
")",
"==",
"'",
"'",
")",
"{",
"inComments",
"=",
"false",
";",
"i",
"++",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"c",
"==",
"'",
"'",
")",
"{",
"if",
"(",
"src",
".",
"charAt",
"(",
"i",
"+",
"1",
")",
"==",
"'",
"'",
")",
"{",
"inComments",
"=",
"true",
";",
"i",
"++",
";",
"}",
"else",
"{",
"ret",
".",
"append",
"(",
"c",
")",
";",
"}",
"}",
"else",
"ret",
".",
"append",
"(",
"c",
")",
";",
"}",
"}",
"return",
"ret",
".",
"toString",
"(",
")",
";",
"}"
] | Remove 'C' commentaries.
@param src
source string
@return processed {@link java.lang.String} | [
"Remove",
"C",
"commentaries",
"."
] | 1f52dd9109349623190586bdf5a592de8016e1fa | https://github.com/anotheria/configureme/blob/1f52dd9109349623190586bdf5a592de8016e1fa/src/main/java/org/configureme/util/StringUtils.java#L166-L190 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/NativeAppCallAttachmentStore.java | NativeAppCallAttachmentStore.cleanupAttachmentsForCall | public void cleanupAttachmentsForCall(Context context, UUID callId) {
File dir = getAttachmentsDirectoryForCall(callId, false);
Utility.deleteDirectory(dir);
} | java | public void cleanupAttachmentsForCall(Context context, UUID callId) {
File dir = getAttachmentsDirectoryForCall(callId, false);
Utility.deleteDirectory(dir);
} | [
"public",
"void",
"cleanupAttachmentsForCall",
"(",
"Context",
"context",
",",
"UUID",
"callId",
")",
"{",
"File",
"dir",
"=",
"getAttachmentsDirectoryForCall",
"(",
"callId",
",",
"false",
")",
";",
"Utility",
".",
"deleteDirectory",
"(",
"dir",
")",
";",
"}"
] | Removes any temporary files associated with a particular native app call.
@param context the Context the call is being made from
@param callId the unique ID of the call | [
"Removes",
"any",
"temporary",
"files",
"associated",
"with",
"a",
"particular",
"native",
"app",
"call",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/NativeAppCallAttachmentStore.java#L164-L167 | train |
mnlipp/jgrapes | org.jgrapes.io/src/org/jgrapes/io/util/ManagedBuffer.java | ManagedBuffer.duplicate | @SuppressWarnings("unchecked")
public final T duplicate() {
if (backing instanceof ByteBuffer) {
return (T) ((ByteBuffer) backing).duplicate();
}
if (backing instanceof CharBuffer) {
return (T) ((CharBuffer) backing).duplicate();
}
throw new IllegalArgumentException("Backing buffer of unknown type.");
} | java | @SuppressWarnings("unchecked")
public final T duplicate() {
if (backing instanceof ByteBuffer) {
return (T) ((ByteBuffer) backing).duplicate();
}
if (backing instanceof CharBuffer) {
return (T) ((CharBuffer) backing).duplicate();
}
throw new IllegalArgumentException("Backing buffer of unknown type.");
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"final",
"T",
"duplicate",
"(",
")",
"{",
"if",
"(",
"backing",
"instanceof",
"ByteBuffer",
")",
"{",
"return",
"(",
"T",
")",
"(",
"(",
"ByteBuffer",
")",
"backing",
")",
".",
"duplicate",
"(",
")",
";",
"}",
"if",
"(",
"backing",
"instanceof",
"CharBuffer",
")",
"{",
"return",
"(",
"T",
")",
"(",
"(",
"CharBuffer",
")",
"backing",
")",
".",
"duplicate",
"(",
")",
";",
"}",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Backing buffer of unknown type.\"",
")",
";",
"}"
] | Duplicate the buffer.
@return the t | [
"Duplicate",
"the",
"buffer",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.io/src/org/jgrapes/io/util/ManagedBuffer.java#L258-L267 | train |
mnlipp/jgrapes | org.jgrapes.core/src/org/jgrapes/core/internal/HandlerList.java | HandlerList.process | public void process(EventPipeline eventPipeline, EventBase<?> event) {
try {
for (HandlerReference hdlr : this) {
try {
hdlr.invoke(event);
if (event.isStopped()) {
break;
}
} catch (AssertionError t) {
// JUnit support
CoreUtils.setAssertionError(t);
event.handlingError(eventPipeline, t);
} catch (Error e) { // NOPMD
// Wouldn't have caught it, if it was possible.
throw e;
} catch (Throwable t) { // NOPMD
// Errors have been rethrown, so this should work.
event.handlingError(eventPipeline, t);
}
}
} finally { // NOPMD
try {
event.handled();
} catch (AssertionError t) {
// JUnit support
CoreUtils.setAssertionError(t);
event.handlingError(eventPipeline, t);
} catch (Error e) { // NOPMD
// Wouldn't have caught it, if it was possible.
throw e;
} catch (Throwable t) { // NOPMD
// Errors have been rethrown, so this should work.
event.handlingError(eventPipeline, t);
}
}
} | java | public void process(EventPipeline eventPipeline, EventBase<?> event) {
try {
for (HandlerReference hdlr : this) {
try {
hdlr.invoke(event);
if (event.isStopped()) {
break;
}
} catch (AssertionError t) {
// JUnit support
CoreUtils.setAssertionError(t);
event.handlingError(eventPipeline, t);
} catch (Error e) { // NOPMD
// Wouldn't have caught it, if it was possible.
throw e;
} catch (Throwable t) { // NOPMD
// Errors have been rethrown, so this should work.
event.handlingError(eventPipeline, t);
}
}
} finally { // NOPMD
try {
event.handled();
} catch (AssertionError t) {
// JUnit support
CoreUtils.setAssertionError(t);
event.handlingError(eventPipeline, t);
} catch (Error e) { // NOPMD
// Wouldn't have caught it, if it was possible.
throw e;
} catch (Throwable t) { // NOPMD
// Errors have been rethrown, so this should work.
event.handlingError(eventPipeline, t);
}
}
} | [
"public",
"void",
"process",
"(",
"EventPipeline",
"eventPipeline",
",",
"EventBase",
"<",
"?",
">",
"event",
")",
"{",
"try",
"{",
"for",
"(",
"HandlerReference",
"hdlr",
":",
"this",
")",
"{",
"try",
"{",
"hdlr",
".",
"invoke",
"(",
"event",
")",
";",
"if",
"(",
"event",
".",
"isStopped",
"(",
")",
")",
"{",
"break",
";",
"}",
"}",
"catch",
"(",
"AssertionError",
"t",
")",
"{",
"// JUnit support",
"CoreUtils",
".",
"setAssertionError",
"(",
"t",
")",
";",
"event",
".",
"handlingError",
"(",
"eventPipeline",
",",
"t",
")",
";",
"}",
"catch",
"(",
"Error",
"e",
")",
"{",
"// NOPMD",
"// Wouldn't have caught it, if it was possible.",
"throw",
"e",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"// NOPMD",
"// Errors have been rethrown, so this should work.",
"event",
".",
"handlingError",
"(",
"eventPipeline",
",",
"t",
")",
";",
"}",
"}",
"}",
"finally",
"{",
"// NOPMD",
"try",
"{",
"event",
".",
"handled",
"(",
")",
";",
"}",
"catch",
"(",
"AssertionError",
"t",
")",
"{",
"// JUnit support",
"CoreUtils",
".",
"setAssertionError",
"(",
"t",
")",
";",
"event",
".",
"handlingError",
"(",
"eventPipeline",
",",
"t",
")",
";",
"}",
"catch",
"(",
"Error",
"e",
")",
"{",
"// NOPMD",
"// Wouldn't have caught it, if it was possible.",
"throw",
"e",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"// NOPMD",
"// Errors have been rethrown, so this should work.",
"event",
".",
"handlingError",
"(",
"eventPipeline",
",",
"t",
")",
";",
"}",
"}",
"}"
] | Invoke all handlers with the given event as parameter.
@param eventProcessor
@param event the event | [
"Invoke",
"all",
"handlers",
"with",
"the",
"given",
"event",
"as",
"parameter",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.core/src/org/jgrapes/core/internal/HandlerList.java#L37-L72 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/internal/SessionTracker.java | SessionTracker.getOpenSession | public Session getOpenSession() {
Session openSession = getSession();
if (openSession != null && openSession.isOpened()) {
return openSession;
}
return null;
} | java | public Session getOpenSession() {
Session openSession = getSession();
if (openSession != null && openSession.isOpened()) {
return openSession;
}
return null;
} | [
"public",
"Session",
"getOpenSession",
"(",
")",
"{",
"Session",
"openSession",
"=",
"getSession",
"(",
")",
";",
"if",
"(",
"openSession",
"!=",
"null",
"&&",
"openSession",
".",
"isOpened",
"(",
")",
")",
"{",
"return",
"openSession",
";",
"}",
"return",
"null",
";",
"}"
] | Returns the current Session that's being tracked if it's open,
otherwise returns null.
@return the current Session if it's open, otherwise returns null | [
"Returns",
"the",
"current",
"Session",
"that",
"s",
"being",
"tracked",
"if",
"it",
"s",
"open",
"otherwise",
"returns",
"null",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/internal/SessionTracker.java#L98-L104 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/internal/SessionTracker.java | SessionTracker.setSession | public void setSession(Session newSession) {
if (newSession == null) {
if (session != null) {
// We're current tracking a Session. Remove the callback
// and start tracking the active Session.
session.removeCallback(callback);
session = null;
addBroadcastReceiver();
if (getSession() != null) {
getSession().addCallback(callback);
}
}
} else {
if (session == null) {
// We're currently tracking the active Session, but will be
// switching to tracking a different Session object.
Session activeSession = Session.getActiveSession();
if (activeSession != null) {
activeSession.removeCallback(callback);
}
broadcastManager.unregisterReceiver(receiver);
} else {
// We're currently tracking a Session, but are now switching
// to a new Session, so we remove the callback from the old
// Session, and add it to the new one.
session.removeCallback(callback);
}
session = newSession;
session.addCallback(callback);
}
} | java | public void setSession(Session newSession) {
if (newSession == null) {
if (session != null) {
// We're current tracking a Session. Remove the callback
// and start tracking the active Session.
session.removeCallback(callback);
session = null;
addBroadcastReceiver();
if (getSession() != null) {
getSession().addCallback(callback);
}
}
} else {
if (session == null) {
// We're currently tracking the active Session, but will be
// switching to tracking a different Session object.
Session activeSession = Session.getActiveSession();
if (activeSession != null) {
activeSession.removeCallback(callback);
}
broadcastManager.unregisterReceiver(receiver);
} else {
// We're currently tracking a Session, but are now switching
// to a new Session, so we remove the callback from the old
// Session, and add it to the new one.
session.removeCallback(callback);
}
session = newSession;
session.addCallback(callback);
}
} | [
"public",
"void",
"setSession",
"(",
"Session",
"newSession",
")",
"{",
"if",
"(",
"newSession",
"==",
"null",
")",
"{",
"if",
"(",
"session",
"!=",
"null",
")",
"{",
"// We're current tracking a Session. Remove the callback",
"// and start tracking the active Session.",
"session",
".",
"removeCallback",
"(",
"callback",
")",
";",
"session",
"=",
"null",
";",
"addBroadcastReceiver",
"(",
")",
";",
"if",
"(",
"getSession",
"(",
")",
"!=",
"null",
")",
"{",
"getSession",
"(",
")",
".",
"addCallback",
"(",
"callback",
")",
";",
"}",
"}",
"}",
"else",
"{",
"if",
"(",
"session",
"==",
"null",
")",
"{",
"// We're currently tracking the active Session, but will be",
"// switching to tracking a different Session object.",
"Session",
"activeSession",
"=",
"Session",
".",
"getActiveSession",
"(",
")",
";",
"if",
"(",
"activeSession",
"!=",
"null",
")",
"{",
"activeSession",
".",
"removeCallback",
"(",
"callback",
")",
";",
"}",
"broadcastManager",
".",
"unregisterReceiver",
"(",
"receiver",
")",
";",
"}",
"else",
"{",
"// We're currently tracking a Session, but are now switching ",
"// to a new Session, so we remove the callback from the old ",
"// Session, and add it to the new one.",
"session",
".",
"removeCallback",
"(",
"callback",
")",
";",
"}",
"session",
"=",
"newSession",
";",
"session",
".",
"addCallback",
"(",
"callback",
")",
";",
"}",
"}"
] | Set the Session object to track.
@param newSession the new Session object to track | [
"Set",
"the",
"Session",
"object",
"to",
"track",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/internal/SessionTracker.java#L111-L141 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/internal/SessionTracker.java | SessionTracker.stopTracking | public void stopTracking() {
if (!isTracking) {
return;
}
Session session = getSession();
if (session != null) {
session.removeCallback(callback);
}
broadcastManager.unregisterReceiver(receiver);
isTracking = false;
} | java | public void stopTracking() {
if (!isTracking) {
return;
}
Session session = getSession();
if (session != null) {
session.removeCallback(callback);
}
broadcastManager.unregisterReceiver(receiver);
isTracking = false;
} | [
"public",
"void",
"stopTracking",
"(",
")",
"{",
"if",
"(",
"!",
"isTracking",
")",
"{",
"return",
";",
"}",
"Session",
"session",
"=",
"getSession",
"(",
")",
";",
"if",
"(",
"session",
"!=",
"null",
")",
"{",
"session",
".",
"removeCallback",
"(",
"callback",
")",
";",
"}",
"broadcastManager",
".",
"unregisterReceiver",
"(",
"receiver",
")",
";",
"isTracking",
"=",
"false",
";",
"}"
] | Stop tracking the Session and remove any callbacks attached
to those sessions. | [
"Stop",
"tracking",
"the",
"Session",
"and",
"remove",
"any",
"callbacks",
"attached",
"to",
"those",
"sessions",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/internal/SessionTracker.java#L164-L174 | train |
mnlipp/jgrapes | org.jgrapes.io/src/org/jgrapes/io/util/LinkedIOSubchannel.java | LinkedIOSubchannel.associated | @Override
@SuppressWarnings("PMD.ShortVariable")
public <V> Optional<V> associated(Object by, Class<V> type) {
Optional<V> result = super.associated(by, type);
if (!result.isPresent()) {
IOSubchannel upstream = upstreamChannel();
if (upstream != null) {
return upstream.associated(by, type);
}
}
return result;
} | java | @Override
@SuppressWarnings("PMD.ShortVariable")
public <V> Optional<V> associated(Object by, Class<V> type) {
Optional<V> result = super.associated(by, type);
if (!result.isPresent()) {
IOSubchannel upstream = upstreamChannel();
if (upstream != null) {
return upstream.associated(by, type);
}
}
return result;
} | [
"@",
"Override",
"@",
"SuppressWarnings",
"(",
"\"PMD.ShortVariable\"",
")",
"public",
"<",
"V",
">",
"Optional",
"<",
"V",
">",
"associated",
"(",
"Object",
"by",
",",
"Class",
"<",
"V",
">",
"type",
")",
"{",
"Optional",
"<",
"V",
">",
"result",
"=",
"super",
".",
"associated",
"(",
"by",
",",
"type",
")",
";",
"if",
"(",
"!",
"result",
".",
"isPresent",
"(",
")",
")",
"{",
"IOSubchannel",
"upstream",
"=",
"upstreamChannel",
"(",
")",
";",
"if",
"(",
"upstream",
"!=",
"null",
")",
"{",
"return",
"upstream",
".",
"associated",
"(",
"by",
",",
"type",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] | Delegates the invocation to the upstream channel
if no associated data is found for this channel.
@param <V> the value type
@param by the associator
@param type the type
@return the optional | [
"Delegates",
"the",
"invocation",
"to",
"the",
"upstream",
"channel",
"if",
"no",
"associated",
"data",
"is",
"found",
"for",
"this",
"channel",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.io/src/org/jgrapes/io/util/LinkedIOSubchannel.java#L150-L161 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/FacebookAppLinkResolver.java | FacebookAppLinkResolver.getAppLinkFromUrlInBackground | public Task<AppLink> getAppLinkFromUrlInBackground(final Uri uri) {
ArrayList<Uri> uris = new ArrayList<Uri>();
uris.add(uri);
Task<Map<Uri, AppLink>> resolveTask = getAppLinkFromUrlsInBackground(uris);
return resolveTask.onSuccess(new Continuation<Map<Uri, AppLink>, AppLink>() {
@Override
public AppLink then(Task<Map<Uri, AppLink>> resolveUrisTask) throws Exception {
return resolveUrisTask.getResult().get(uri);
}
});
} | java | public Task<AppLink> getAppLinkFromUrlInBackground(final Uri uri) {
ArrayList<Uri> uris = new ArrayList<Uri>();
uris.add(uri);
Task<Map<Uri, AppLink>> resolveTask = getAppLinkFromUrlsInBackground(uris);
return resolveTask.onSuccess(new Continuation<Map<Uri, AppLink>, AppLink>() {
@Override
public AppLink then(Task<Map<Uri, AppLink>> resolveUrisTask) throws Exception {
return resolveUrisTask.getResult().get(uri);
}
});
} | [
"public",
"Task",
"<",
"AppLink",
">",
"getAppLinkFromUrlInBackground",
"(",
"final",
"Uri",
"uri",
")",
"{",
"ArrayList",
"<",
"Uri",
">",
"uris",
"=",
"new",
"ArrayList",
"<",
"Uri",
">",
"(",
")",
";",
"uris",
".",
"add",
"(",
"uri",
")",
";",
"Task",
"<",
"Map",
"<",
"Uri",
",",
"AppLink",
">",
">",
"resolveTask",
"=",
"getAppLinkFromUrlsInBackground",
"(",
"uris",
")",
";",
"return",
"resolveTask",
".",
"onSuccess",
"(",
"new",
"Continuation",
"<",
"Map",
"<",
"Uri",
",",
"AppLink",
">",
",",
"AppLink",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"AppLink",
"then",
"(",
"Task",
"<",
"Map",
"<",
"Uri",
",",
"AppLink",
">",
">",
"resolveUrisTask",
")",
"throws",
"Exception",
"{",
"return",
"resolveUrisTask",
".",
"getResult",
"(",
")",
".",
"get",
"(",
"uri",
")",
";",
"}",
"}",
")",
";",
"}"
] | Asynchronously resolves App Link data for the passed in Uri
@param uri Uri to be resolved into an App Link
@return A Task that, when successful, will return an AppLink for the passed in Uri. This may be null if no App
Link data was found for this Uri.
In the case of general server errors, the task will be completed with the corresponding error. | [
"Asynchronously",
"resolves",
"App",
"Link",
"data",
"for",
"the",
"passed",
"in",
"Uri"
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/FacebookAppLinkResolver.java#L58-L70 | train |
spotify/netty-batch-flusher | src/main/java/com/spotify/netty/util/BatchFlusher.java | BatchFlusher.flush | public void flush() {
if (eventLoop.inEventLoop()) {
pending++;
if (pending >= maxPending) {
pending = 0;
channel.flush();
}
}
if (woken == 0 && WOKEN.compareAndSet(this, 0, 1)) {
woken = 1;
eventLoop.execute(wakeup);
}
} | java | public void flush() {
if (eventLoop.inEventLoop()) {
pending++;
if (pending >= maxPending) {
pending = 0;
channel.flush();
}
}
if (woken == 0 && WOKEN.compareAndSet(this, 0, 1)) {
woken = 1;
eventLoop.execute(wakeup);
}
} | [
"public",
"void",
"flush",
"(",
")",
"{",
"if",
"(",
"eventLoop",
".",
"inEventLoop",
"(",
")",
")",
"{",
"pending",
"++",
";",
"if",
"(",
"pending",
">=",
"maxPending",
")",
"{",
"pending",
"=",
"0",
";",
"channel",
".",
"flush",
"(",
")",
";",
"}",
"}",
"if",
"(",
"woken",
"==",
"0",
"&&",
"WOKEN",
".",
"compareAndSet",
"(",
"this",
",",
"0",
",",
"1",
")",
")",
"{",
"woken",
"=",
"1",
";",
"eventLoop",
".",
"execute",
"(",
"wakeup",
")",
";",
"}",
"}"
] | Schedule an asynchronous opportunistically batching flush. | [
"Schedule",
"an",
"asynchronous",
"opportunistically",
"batching",
"flush",
"."
] | 795a7f42817258d6c1a68a3fe3fba0847ce08757 | https://github.com/spotify/netty-batch-flusher/blob/795a7f42817258d6c1a68a3fe3fba0847ce08757/src/main/java/com/spotify/netty/util/BatchFlusher.java#L77-L89 | train |
mnlipp/jgrapes | org.jgrapes.io/src/org/jgrapes/io/InputStreamMonitor.java | InputStreamMonitor.onStart | @Handler
public void onStart(Start event) {
synchronized (this) {
if (runner != null) {
return;
}
buffers = new ManagedBufferPool<>(ManagedBuffer::new,
() -> {
return ByteBuffer.allocateDirect(bufferSize);
}, 2);
runner = new Thread(this, Components.simpleObjectName(this));
// Because this cannot reliably be stopped, it doesn't prevent
// shutdown.
runner.setDaemon(true);
runner.start();
}
} | java | @Handler
public void onStart(Start event) {
synchronized (this) {
if (runner != null) {
return;
}
buffers = new ManagedBufferPool<>(ManagedBuffer::new,
() -> {
return ByteBuffer.allocateDirect(bufferSize);
}, 2);
runner = new Thread(this, Components.simpleObjectName(this));
// Because this cannot reliably be stopped, it doesn't prevent
// shutdown.
runner.setDaemon(true);
runner.start();
}
} | [
"@",
"Handler",
"public",
"void",
"onStart",
"(",
"Start",
"event",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"runner",
"!=",
"null",
")",
"{",
"return",
";",
"}",
"buffers",
"=",
"new",
"ManagedBufferPool",
"<>",
"(",
"ManagedBuffer",
"::",
"new",
",",
"(",
")",
"->",
"{",
"return",
"ByteBuffer",
".",
"allocateDirect",
"(",
"bufferSize",
")",
";",
"}",
",",
"2",
")",
";",
"runner",
"=",
"new",
"Thread",
"(",
"this",
",",
"Components",
".",
"simpleObjectName",
"(",
"this",
")",
")",
";",
"// Because this cannot reliably be stopped, it doesn't prevent",
"// shutdown.",
"runner",
".",
"setDaemon",
"(",
"true",
")",
";",
"runner",
".",
"start",
"(",
")",
";",
"}",
"}"
] | Starts a thread that continuously reads available
data from the input stream.
@param event the event | [
"Starts",
"a",
"thread",
"that",
"continuously",
"reads",
"available",
"data",
"from",
"the",
"input",
"stream",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.io/src/org/jgrapes/io/InputStreamMonitor.java#L135-L151 | train |
mnlipp/jgrapes | org.jgrapes.io/src/org/jgrapes/io/InputStreamMonitor.java | InputStreamMonitor.onStop | @Handler(priority = -10000)
public void onStop(Stop event) throws InterruptedException {
synchronized (this) {
if (runner == null) {
return;
}
runner.interrupt();
synchronized (this) {
if (registered) {
unregisterAsGenerator();
registered = false;
}
}
runner = null;
}
} | java | @Handler(priority = -10000)
public void onStop(Stop event) throws InterruptedException {
synchronized (this) {
if (runner == null) {
return;
}
runner.interrupt();
synchronized (this) {
if (registered) {
unregisterAsGenerator();
registered = false;
}
}
runner = null;
}
} | [
"@",
"Handler",
"(",
"priority",
"=",
"-",
"10000",
")",
"public",
"void",
"onStop",
"(",
"Stop",
"event",
")",
"throws",
"InterruptedException",
"{",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"runner",
"==",
"null",
")",
"{",
"return",
";",
"}",
"runner",
".",
"interrupt",
"(",
")",
";",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"registered",
")",
"{",
"unregisterAsGenerator",
"(",
")",
";",
"registered",
"=",
"false",
";",
"}",
"}",
"runner",
"=",
"null",
";",
"}",
"}"
] | Stops the thread that reads data from the input stream.
Note that the input stream is not closed.
@param event the event
@throws InterruptedException the interrupted exception | [
"Stops",
"the",
"thread",
"that",
"reads",
"data",
"from",
"the",
"input",
"stream",
".",
"Note",
"that",
"the",
"input",
"stream",
"is",
"not",
"closed",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.io/src/org/jgrapes/io/InputStreamMonitor.java#L160-L175 | train |
mnlipp/jgrapes | org.jgrapes.core/src/org/jgrapes/core/internal/ComponentVertex.java | ComponentVertex.componentVertex | public static ComponentVertex componentVertex(
ComponentType component, Channel componentChannel) {
if (component instanceof ComponentVertex) {
return (ComponentVertex) component;
}
return ComponentProxy.getComponentProxy(component, componentChannel);
} | java | public static ComponentVertex componentVertex(
ComponentType component, Channel componentChannel) {
if (component instanceof ComponentVertex) {
return (ComponentVertex) component;
}
return ComponentProxy.getComponentProxy(component, componentChannel);
} | [
"public",
"static",
"ComponentVertex",
"componentVertex",
"(",
"ComponentType",
"component",
",",
"Channel",
"componentChannel",
")",
"{",
"if",
"(",
"component",
"instanceof",
"ComponentVertex",
")",
"{",
"return",
"(",
"ComponentVertex",
")",
"component",
";",
"}",
"return",
"ComponentProxy",
".",
"getComponentProxy",
"(",
"component",
",",
"componentChannel",
")",
";",
"}"
] | Return the component node for a given component.
@param component the component
@param componentChannel the component's channel
@return the node representing the component in the tree | [
"Return",
"the",
"component",
"node",
"for",
"a",
"given",
"component",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.core/src/org/jgrapes/core/internal/ComponentVertex.java#L163-L169 | train |
mnlipp/jgrapes | org.jgrapes.core/src/org/jgrapes/core/internal/ComponentVertex.java | ComponentVertex.setTree | private void setTree(ComponentTree tree) {
synchronized (this) {
this.tree = tree;
for (ComponentVertex child : children) {
child.setTree(tree);
}
}
} | java | private void setTree(ComponentTree tree) {
synchronized (this) {
this.tree = tree;
for (ComponentVertex child : children) {
child.setTree(tree);
}
}
} | [
"private",
"void",
"setTree",
"(",
"ComponentTree",
"tree",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"this",
".",
"tree",
"=",
"tree",
";",
"for",
"(",
"ComponentVertex",
"child",
":",
"children",
")",
"{",
"child",
".",
"setTree",
"(",
"tree",
")",
";",
"}",
"}",
"}"
] | Set the reference to the common properties of this component
and all its children to the given value.
@param comp the new root | [
"Set",
"the",
"reference",
"to",
"the",
"common",
"properties",
"of",
"this",
"component",
"and",
"all",
"its",
"children",
"to",
"the",
"given",
"value",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.core/src/org/jgrapes/core/internal/ComponentVertex.java#L243-L250 | train |
mnlipp/jgrapes | org.jgrapes.core/src/org/jgrapes/core/internal/ComponentVertex.java | ComponentVertex.collectHandlers | @SuppressWarnings("PMD.UseVarargs")
/* default */ void collectHandlers(Collection<HandlerReference> hdlrs,
EventBase<?> event, Channel[] channels) {
for (HandlerReference hdlr : handlers) {
if (hdlr.handles(event, channels)) {
hdlrs.add(hdlr);
}
}
for (ComponentVertex child : children) {
child.collectHandlers(hdlrs, event, channels);
}
} | java | @SuppressWarnings("PMD.UseVarargs")
/* default */ void collectHandlers(Collection<HandlerReference> hdlrs,
EventBase<?> event, Channel[] channels) {
for (HandlerReference hdlr : handlers) {
if (hdlr.handles(event, channels)) {
hdlrs.add(hdlr);
}
}
for (ComponentVertex child : children) {
child.collectHandlers(hdlrs, event, channels);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"PMD.UseVarargs\"",
")",
"/* default */",
"void",
"collectHandlers",
"(",
"Collection",
"<",
"HandlerReference",
">",
"hdlrs",
",",
"EventBase",
"<",
"?",
">",
"event",
",",
"Channel",
"[",
"]",
"channels",
")",
"{",
"for",
"(",
"HandlerReference",
"hdlr",
":",
"handlers",
")",
"{",
"if",
"(",
"hdlr",
".",
"handles",
"(",
"event",
",",
"channels",
")",
")",
"{",
"hdlrs",
".",
"add",
"(",
"hdlr",
")",
";",
"}",
"}",
"for",
"(",
"ComponentVertex",
"child",
":",
"children",
")",
"{",
"child",
".",
"collectHandlers",
"(",
"hdlrs",
",",
"event",
",",
"channels",
")",
";",
"}",
"}"
] | Collects all handlers. Iterates over the tree with this object
as root and for all child components adds the matching handlers to
the result set recursively.
@param hdlrs the result set
@param event the event to match
@param channels the channels to match | [
"Collects",
"all",
"handlers",
".",
"Iterates",
"over",
"the",
"tree",
"with",
"this",
"object",
"as",
"root",
"and",
"for",
"all",
"child",
"components",
"adds",
"the",
"matching",
"handlers",
"to",
"the",
"result",
"set",
"recursively",
"."
] | 8b5d874935d84c34a52d3e3d3745e869b5203fa0 | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.core/src/org/jgrapes/core/internal/ComponentVertex.java#L518-L529 | train |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/widget/PlacePickerFragment.java | PlacePickerFragment.getSelection | public GraphPlace getSelection() {
Collection<GraphPlace> selection = getSelectedGraphObjects();
return (selection != null && !selection.isEmpty()) ? selection.iterator().next() : null;
} | java | public GraphPlace getSelection() {
Collection<GraphPlace> selection = getSelectedGraphObjects();
return (selection != null && !selection.isEmpty()) ? selection.iterator().next() : null;
} | [
"public",
"GraphPlace",
"getSelection",
"(",
")",
"{",
"Collection",
"<",
"GraphPlace",
">",
"selection",
"=",
"getSelectedGraphObjects",
"(",
")",
";",
"return",
"(",
"selection",
"!=",
"null",
"&&",
"!",
"selection",
".",
"isEmpty",
"(",
")",
")",
"?",
"selection",
".",
"iterator",
"(",
")",
".",
"next",
"(",
")",
":",
"null",
";",
"}"
] | Gets the currently-selected place.
@return the currently-selected place, or null if there is none | [
"Gets",
"the",
"currently",
"-",
"selected",
"place",
"."
] | ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/widget/PlacePickerFragment.java#L234-L237 | train |
A-pZ/struts2-thymeleaf3-plugin | src/main/java/serendip/struts/plugins/thymeleaf/diarect/FieldErrorAttributeProcessor.java | FieldErrorAttributeProcessor.hasFieldError | protected boolean hasFieldError(String fieldname) {
if ( StringUtils.isEmpty(fieldname)) {
return false;
}
Object action = ActionContext.getContext().getActionInvocation().getAction();
// check action instance 'ActionSupport'.
if (!(action instanceof ActionSupport)) {
return false;
}
ActionSupport asupport = (ActionSupport) action;
Map<String, List<String>> fieldErrors = asupport.getFieldErrors();
if (CollectionUtils.isEmpty(fieldErrors)) {
return false;
}
List<String> targetFieldErrors = fieldErrors.get(fieldname);
if (CollectionUtils.isEmpty(targetFieldErrors)) {
return false;
}
return true;
} | java | protected boolean hasFieldError(String fieldname) {
if ( StringUtils.isEmpty(fieldname)) {
return false;
}
Object action = ActionContext.getContext().getActionInvocation().getAction();
// check action instance 'ActionSupport'.
if (!(action instanceof ActionSupport)) {
return false;
}
ActionSupport asupport = (ActionSupport) action;
Map<String, List<String>> fieldErrors = asupport.getFieldErrors();
if (CollectionUtils.isEmpty(fieldErrors)) {
return false;
}
List<String> targetFieldErrors = fieldErrors.get(fieldname);
if (CollectionUtils.isEmpty(targetFieldErrors)) {
return false;
}
return true;
} | [
"protected",
"boolean",
"hasFieldError",
"(",
"String",
"fieldname",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isEmpty",
"(",
"fieldname",
")",
")",
"{",
"return",
"false",
";",
"}",
"Object",
"action",
"=",
"ActionContext",
".",
"getContext",
"(",
")",
".",
"getActionInvocation",
"(",
")",
".",
"getAction",
"(",
")",
";",
"// check action instance 'ActionSupport'.\r",
"if",
"(",
"!",
"(",
"action",
"instanceof",
"ActionSupport",
")",
")",
"{",
"return",
"false",
";",
"}",
"ActionSupport",
"asupport",
"=",
"(",
"ActionSupport",
")",
"action",
";",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"fieldErrors",
"=",
"asupport",
".",
"getFieldErrors",
"(",
")",
";",
"if",
"(",
"CollectionUtils",
".",
"isEmpty",
"(",
"fieldErrors",
")",
")",
"{",
"return",
"false",
";",
"}",
"List",
"<",
"String",
">",
"targetFieldErrors",
"=",
"fieldErrors",
".",
"get",
"(",
"fieldname",
")",
";",
"if",
"(",
"CollectionUtils",
".",
"isEmpty",
"(",
"targetFieldErrors",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | If Struts2 has field-error for request parameter name , return true.
@param fieldname request-parameter name
@return if field-error has target field name, return true. | [
"If",
"Struts2",
"has",
"field",
"-",
"error",
"for",
"request",
"parameter",
"name",
"return",
"true",
"."
] | 36a4609c1d0a36019784c6dba951c9b27dcc8802 | https://github.com/A-pZ/struts2-thymeleaf3-plugin/blob/36a4609c1d0a36019784c6dba951c9b27dcc8802/src/main/java/serendip/struts/plugins/thymeleaf/diarect/FieldErrorAttributeProcessor.java#L102-L124 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.