repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
sequencelengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
sequencelengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
ronmamo/reflections | src/main/java/org/reflections/Reflections.java | Reflections.save | public File save(final String filename, final Serializer serializer) {
"""
serialize to a given directory and filename using given serializer
<p>* it is preferred to specify a designated directory (for example META-INF/reflections),
so that it could be found later much faster using the load method
"""
File file = serializer.save(this, filename);
if (log != null) //noinspection ConstantConditions
log.info("Reflections successfully saved in " + file.getAbsolutePath() + " using " + serializer.getClass().getSimpleName());
return file;
} | java | public File save(final String filename, final Serializer serializer) {
File file = serializer.save(this, filename);
if (log != null) //noinspection ConstantConditions
log.info("Reflections successfully saved in " + file.getAbsolutePath() + " using " + serializer.getClass().getSimpleName());
return file;
} | [
"public",
"File",
"save",
"(",
"final",
"String",
"filename",
",",
"final",
"Serializer",
"serializer",
")",
"{",
"File",
"file",
"=",
"serializer",
".",
"save",
"(",
"this",
",",
"filename",
")",
";",
"if",
"(",
"log",
"!=",
"null",
")",
"//noinspection ConstantConditions",
"log",
".",
"info",
"(",
"\"Reflections successfully saved in \"",
"+",
"file",
".",
"getAbsolutePath",
"(",
")",
"+",
"\" using \"",
"+",
"serializer",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
")",
";",
"return",
"file",
";",
"}"
] | serialize to a given directory and filename using given serializer
<p>* it is preferred to specify a designated directory (for example META-INF/reflections),
so that it could be found later much faster using the load method | [
"serialize",
"to",
"a",
"given",
"directory",
"and",
"filename",
"using",
"given",
"serializer",
"<p",
">",
"*",
"it",
"is",
"preferred",
"to",
"specify",
"a",
"designated",
"directory",
"(",
"for",
"example",
"META",
"-",
"INF",
"/",
"reflections",
")",
"so",
"that",
"it",
"could",
"be",
"found",
"later",
"much",
"faster",
"using",
"the",
"load",
"method"
] | train | https://github.com/ronmamo/reflections/blob/084cf4a759a06d88e88753ac00397478c2e0ed52/src/main/java/org/reflections/Reflections.java#L669-L674 |
khuxtable/seaglass | src/main/java/com/seaglasslookandfeel/painter/AbstractRegionPainter.java | AbstractRegionPainter.deriveARGB | public static int deriveARGB(Color color1, Color color2, float midPoint) {
"""
Derives the ARGB value for a color based on an offset between two other
colors.
@param color1 The first color
@param color2 The second color
@param midPoint The offset between color 1 and color 2, a value of 0.0
is color 1 and 1.0 is color 2;
@return the ARGB value for a new color based on this derivation
"""
int r = color1.getRed() + (int) ((color2.getRed() - color1.getRed()) * midPoint + 0.5f);
int g = color1.getGreen() + (int) ((color2.getGreen() - color1.getGreen()) * midPoint + 0.5f);
int b = color1.getBlue() + (int) ((color2.getBlue() - color1.getBlue()) * midPoint + 0.5f);
int a = color1.getAlpha() + (int) ((color2.getAlpha() - color1.getAlpha()) * midPoint + 0.5f);
return ((a & 0xFF) << 24) | ((r & 0xFF) << 16) | ((g & 0xFF) << 8) | (b & 0xFF);
} | java | public static int deriveARGB(Color color1, Color color2, float midPoint) {
int r = color1.getRed() + (int) ((color2.getRed() - color1.getRed()) * midPoint + 0.5f);
int g = color1.getGreen() + (int) ((color2.getGreen() - color1.getGreen()) * midPoint + 0.5f);
int b = color1.getBlue() + (int) ((color2.getBlue() - color1.getBlue()) * midPoint + 0.5f);
int a = color1.getAlpha() + (int) ((color2.getAlpha() - color1.getAlpha()) * midPoint + 0.5f);
return ((a & 0xFF) << 24) | ((r & 0xFF) << 16) | ((g & 0xFF) << 8) | (b & 0xFF);
} | [
"public",
"static",
"int",
"deriveARGB",
"(",
"Color",
"color1",
",",
"Color",
"color2",
",",
"float",
"midPoint",
")",
"{",
"int",
"r",
"=",
"color1",
".",
"getRed",
"(",
")",
"+",
"(",
"int",
")",
"(",
"(",
"color2",
".",
"getRed",
"(",
")",
"-",
"color1",
".",
"getRed",
"(",
")",
")",
"*",
"midPoint",
"+",
"0.5f",
")",
";",
"int",
"g",
"=",
"color1",
".",
"getGreen",
"(",
")",
"+",
"(",
"int",
")",
"(",
"(",
"color2",
".",
"getGreen",
"(",
")",
"-",
"color1",
".",
"getGreen",
"(",
")",
")",
"*",
"midPoint",
"+",
"0.5f",
")",
";",
"int",
"b",
"=",
"color1",
".",
"getBlue",
"(",
")",
"+",
"(",
"int",
")",
"(",
"(",
"color2",
".",
"getBlue",
"(",
")",
"-",
"color1",
".",
"getBlue",
"(",
")",
")",
"*",
"midPoint",
"+",
"0.5f",
")",
";",
"int",
"a",
"=",
"color1",
".",
"getAlpha",
"(",
")",
"+",
"(",
"int",
")",
"(",
"(",
"color2",
".",
"getAlpha",
"(",
")",
"-",
"color1",
".",
"getAlpha",
"(",
")",
")",
"*",
"midPoint",
"+",
"0.5f",
")",
";",
"return",
"(",
"(",
"a",
"&",
"0xFF",
")",
"<<",
"24",
")",
"|",
"(",
"(",
"r",
"&",
"0xFF",
")",
"<<",
"16",
")",
"|",
"(",
"(",
"g",
"&",
"0xFF",
")",
"<<",
"8",
")",
"|",
"(",
"b",
"&",
"0xFF",
")",
";",
"}"
] | Derives the ARGB value for a color based on an offset between two other
colors.
@param color1 The first color
@param color2 The second color
@param midPoint The offset between color 1 and color 2, a value of 0.0
is color 1 and 1.0 is color 2;
@return the ARGB value for a new color based on this derivation | [
"Derives",
"the",
"ARGB",
"value",
"for",
"a",
"color",
"based",
"on",
"an",
"offset",
"between",
"two",
"other",
"colors",
"."
] | train | https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/painter/AbstractRegionPainter.java#L311-L318 |
tzaeschke/zoodb | src/org/zoodb/jdo/spi/PersistenceCapableImpl.java | PersistenceCapableImpl.jdoCopyKeyFieldsFromObjectId | @Override
public void jdoCopyKeyFieldsFromObjectId (ObjectIdFieldConsumer fc, Object oid) {
"""
The generated methods copy key fields from the object id instance to the PersistenceCapable
instance or to the ObjectIdFieldConsumer.
"""
fc.storeIntField (2, ((IntIdentity)oid).getKey());
} | java | @Override
public void jdoCopyKeyFieldsFromObjectId (ObjectIdFieldConsumer fc, Object oid) {
fc.storeIntField (2, ((IntIdentity)oid).getKey());
} | [
"@",
"Override",
"public",
"void",
"jdoCopyKeyFieldsFromObjectId",
"(",
"ObjectIdFieldConsumer",
"fc",
",",
"Object",
"oid",
")",
"{",
"fc",
".",
"storeIntField",
"(",
"2",
",",
"(",
"(",
"IntIdentity",
")",
"oid",
")",
".",
"getKey",
"(",
")",
")",
";",
"}"
] | The generated methods copy key fields from the object id instance to the PersistenceCapable
instance or to the ObjectIdFieldConsumer. | [
"The",
"generated",
"methods",
"copy",
"key",
"fields",
"from",
"the",
"object",
"id",
"instance",
"to",
"the",
"PersistenceCapable",
"instance",
"or",
"to",
"the",
"ObjectIdFieldConsumer",
"."
] | train | https://github.com/tzaeschke/zoodb/blob/058d0ff161a8ee9d53244c433aca97ee9c654410/src/org/zoodb/jdo/spi/PersistenceCapableImpl.java#L514-L517 |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/util/PathTokenizer.java | PathTokenizer.getRemainingPath | protected static String getRemainingPath(List<String> tokens, int i, int end) {
"""
Get the remaining path from some tokens
@param tokens the tokens
@param i the current location
@param end the end index
@return the remaining path
@throws IllegalArgumentException for null tokens or i is out of range
"""
if (tokens == null) {
throw MESSAGES.nullArgument("tokens");
}
if (i < 0 || i >= end) { throw new IllegalArgumentException("i is not in the range of tokens: 0-" + (end - 1)); }
if (i == end - 1) { return tokens.get(end - 1); }
StringBuilder buffer = new StringBuilder();
for (; i < end - 1; ++i) {
buffer.append(tokens.get(i));
buffer.append("/");
}
buffer.append(tokens.get(end - 1));
return buffer.toString();
} | java | protected static String getRemainingPath(List<String> tokens, int i, int end) {
if (tokens == null) {
throw MESSAGES.nullArgument("tokens");
}
if (i < 0 || i >= end) { throw new IllegalArgumentException("i is not in the range of tokens: 0-" + (end - 1)); }
if (i == end - 1) { return tokens.get(end - 1); }
StringBuilder buffer = new StringBuilder();
for (; i < end - 1; ++i) {
buffer.append(tokens.get(i));
buffer.append("/");
}
buffer.append(tokens.get(end - 1));
return buffer.toString();
} | [
"protected",
"static",
"String",
"getRemainingPath",
"(",
"List",
"<",
"String",
">",
"tokens",
",",
"int",
"i",
",",
"int",
"end",
")",
"{",
"if",
"(",
"tokens",
"==",
"null",
")",
"{",
"throw",
"MESSAGES",
".",
"nullArgument",
"(",
"\"tokens\"",
")",
";",
"}",
"if",
"(",
"i",
"<",
"0",
"||",
"i",
">=",
"end",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"i is not in the range of tokens: 0-\"",
"+",
"(",
"end",
"-",
"1",
")",
")",
";",
"}",
"if",
"(",
"i",
"==",
"end",
"-",
"1",
")",
"{",
"return",
"tokens",
".",
"get",
"(",
"end",
"-",
"1",
")",
";",
"}",
"StringBuilder",
"buffer",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
";",
"i",
"<",
"end",
"-",
"1",
";",
"++",
"i",
")",
"{",
"buffer",
".",
"append",
"(",
"tokens",
".",
"get",
"(",
"i",
")",
")",
";",
"buffer",
".",
"append",
"(",
"\"/\"",
")",
";",
"}",
"buffer",
".",
"append",
"(",
"tokens",
".",
"get",
"(",
"end",
"-",
"1",
")",
")",
";",
"return",
"buffer",
".",
"toString",
"(",
")",
";",
"}"
] | Get the remaining path from some tokens
@param tokens the tokens
@param i the current location
@param end the end index
@return the remaining path
@throws IllegalArgumentException for null tokens or i is out of range | [
"Get",
"the",
"remaining",
"path",
"from",
"some",
"tokens"
] | train | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/util/PathTokenizer.java#L71-L84 |
google/error-prone | core/src/main/java/com/google/errorprone/bugpatterns/argumentselectiondefects/CreatesDuplicateCallHeuristic.java | CreatesDuplicateCallHeuristic.isAcceptableChange | @Override
public boolean isAcceptableChange(
Changes changes, Tree node, MethodSymbol symbol, VisitorState state) {
"""
Returns true if there are no other calls to this method which already have an actual parameter
in the position we are moving this one too.
"""
return findArgumentsForOtherInstances(symbol, node, state).stream()
.allMatch(arguments -> !anyArgumentsMatch(changes.changedPairs(), arguments));
} | java | @Override
public boolean isAcceptableChange(
Changes changes, Tree node, MethodSymbol symbol, VisitorState state) {
return findArgumentsForOtherInstances(symbol, node, state).stream()
.allMatch(arguments -> !anyArgumentsMatch(changes.changedPairs(), arguments));
} | [
"@",
"Override",
"public",
"boolean",
"isAcceptableChange",
"(",
"Changes",
"changes",
",",
"Tree",
"node",
",",
"MethodSymbol",
"symbol",
",",
"VisitorState",
"state",
")",
"{",
"return",
"findArgumentsForOtherInstances",
"(",
"symbol",
",",
"node",
",",
"state",
")",
".",
"stream",
"(",
")",
".",
"allMatch",
"(",
"arguments",
"->",
"!",
"anyArgumentsMatch",
"(",
"changes",
".",
"changedPairs",
"(",
")",
",",
"arguments",
")",
")",
";",
"}"
] | Returns true if there are no other calls to this method which already have an actual parameter
in the position we are moving this one too. | [
"Returns",
"true",
"if",
"there",
"are",
"no",
"other",
"calls",
"to",
"this",
"method",
"which",
"already",
"have",
"an",
"actual",
"parameter",
"in",
"the",
"position",
"we",
"are",
"moving",
"this",
"one",
"too",
"."
] | train | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/argumentselectiondefects/CreatesDuplicateCallHeuristic.java#L44-L49 |
EdwardRaff/JSAT | JSAT/src/jsat/classifiers/boosting/Bagging.java | Bagging.getWeightSampledDataSet | public static RegressionDataSet getWeightSampledDataSet(RegressionDataSet dataSet, int[] sampledCounts) {
"""
Creates a new data set from the given sample counts. Points sampled
multiple times will be added once to the data set with their weight
multiplied by the number of times it was sampled.
@param dataSet the data set that was sampled from
@param sampledCounts the sampling values obtained from
{@link #sampleWithReplacement(int[], int, java.util.Random) }
@return a new sampled classification data set
"""
RegressionDataSet destination = new RegressionDataSet(dataSet.getNumNumericalVars(), dataSet.getCategories());
for (int i = 0; i < sampledCounts.length; i++)
{
if(sampledCounts[i] <= 0)
continue;
DataPoint dp = dataSet.getDataPoint(i);
destination.addDataPoint(dp, dataSet.getTargetValue(i), dataSet.getWeight(i)*sampledCounts[i]);
}
return destination;
} | java | public static RegressionDataSet getWeightSampledDataSet(RegressionDataSet dataSet, int[] sampledCounts)
{
RegressionDataSet destination = new RegressionDataSet(dataSet.getNumNumericalVars(), dataSet.getCategories());
for (int i = 0; i < sampledCounts.length; i++)
{
if(sampledCounts[i] <= 0)
continue;
DataPoint dp = dataSet.getDataPoint(i);
destination.addDataPoint(dp, dataSet.getTargetValue(i), dataSet.getWeight(i)*sampledCounts[i]);
}
return destination;
} | [
"public",
"static",
"RegressionDataSet",
"getWeightSampledDataSet",
"(",
"RegressionDataSet",
"dataSet",
",",
"int",
"[",
"]",
"sampledCounts",
")",
"{",
"RegressionDataSet",
"destination",
"=",
"new",
"RegressionDataSet",
"(",
"dataSet",
".",
"getNumNumericalVars",
"(",
")",
",",
"dataSet",
".",
"getCategories",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"sampledCounts",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"sampledCounts",
"[",
"i",
"]",
"<=",
"0",
")",
"continue",
";",
"DataPoint",
"dp",
"=",
"dataSet",
".",
"getDataPoint",
"(",
"i",
")",
";",
"destination",
".",
"addDataPoint",
"(",
"dp",
",",
"dataSet",
".",
"getTargetValue",
"(",
"i",
")",
",",
"dataSet",
".",
"getWeight",
"(",
"i",
")",
"*",
"sampledCounts",
"[",
"i",
"]",
")",
";",
"}",
"return",
"destination",
";",
"}"
] | Creates a new data set from the given sample counts. Points sampled
multiple times will be added once to the data set with their weight
multiplied by the number of times it was sampled.
@param dataSet the data set that was sampled from
@param sampledCounts the sampling values obtained from
{@link #sampleWithReplacement(int[], int, java.util.Random) }
@return a new sampled classification data set | [
"Creates",
"a",
"new",
"data",
"set",
"from",
"the",
"given",
"sample",
"counts",
".",
"Points",
"sampled",
"multiple",
"times",
"will",
"be",
"added",
"once",
"to",
"the",
"data",
"set",
"with",
"their",
"weight",
"multiplied",
"by",
"the",
"number",
"of",
"times",
"it",
"was",
"sampled",
"."
] | train | https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/boosting/Bagging.java#L345-L358 |
elki-project/elki | addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java | SVGPlot.svgRect | public Element svgRect(double x, double y, double w, double h) {
"""
Create a SVG rectangle
@param x X coordinate
@param y Y coordinate
@param w Width
@param h Height
@return new element
"""
return SVGUtil.svgRect(document, x, y, w, h);
} | java | public Element svgRect(double x, double y, double w, double h) {
return SVGUtil.svgRect(document, x, y, w, h);
} | [
"public",
"Element",
"svgRect",
"(",
"double",
"x",
",",
"double",
"y",
",",
"double",
"w",
",",
"double",
"h",
")",
"{",
"return",
"SVGUtil",
".",
"svgRect",
"(",
"document",
",",
"x",
",",
"y",
",",
"w",
",",
"h",
")",
";",
"}"
] | Create a SVG rectangle
@param x X coordinate
@param y Y coordinate
@param w Width
@param h Height
@return new element | [
"Create",
"a",
"SVG",
"rectangle"
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGPlot.java#L254-L256 |
milaboratory/milib | src/main/java/com/milaboratory/core/alignment/AlignmentUtils.java | AlignmentUtils.calculateScore | public static <S extends Sequence<S>> int calculateScore(S seq1, Mutations<S> mutations,
AlignmentScoring<S> scoring) {
"""
Calculates score of alignment
@param seq1 target sequence
@param mutations mutations (alignment)
@param scoring scoring
@param <S> sequence type
@return score
"""
return calculateScore(seq1, new Range(0, seq1.size()), mutations, scoring);
} | java | public static <S extends Sequence<S>> int calculateScore(S seq1, Mutations<S> mutations,
AlignmentScoring<S> scoring) {
return calculateScore(seq1, new Range(0, seq1.size()), mutations, scoring);
} | [
"public",
"static",
"<",
"S",
"extends",
"Sequence",
"<",
"S",
">",
">",
"int",
"calculateScore",
"(",
"S",
"seq1",
",",
"Mutations",
"<",
"S",
">",
"mutations",
",",
"AlignmentScoring",
"<",
"S",
">",
"scoring",
")",
"{",
"return",
"calculateScore",
"(",
"seq1",
",",
"new",
"Range",
"(",
"0",
",",
"seq1",
".",
"size",
"(",
")",
")",
",",
"mutations",
",",
"scoring",
")",
";",
"}"
] | Calculates score of alignment
@param seq1 target sequence
@param mutations mutations (alignment)
@param scoring scoring
@param <S> sequence type
@return score | [
"Calculates",
"score",
"of",
"alignment"
] | train | https://github.com/milaboratory/milib/blob/2349b3dccdd3c7948643760e570238d6e30d5a34/src/main/java/com/milaboratory/core/alignment/AlignmentUtils.java#L44-L47 |
alkacon/opencms-core | src/org/opencms/ui/apps/resourcetypes/CmsNewResourceTypeDialog.java | CmsNewResourceTypeDialog.lockTemporary | private void lockTemporary(CmsResource resource) throws CmsException {
"""
Locks the given resource temporarily.<p>
@param resource the resource to lock
@throws CmsException if locking fails
"""
CmsUser user = m_cms.getRequestContext().getCurrentUser();
CmsLock lock = m_cms.getLock(resource);
if (!lock.isOwnedBy(user)) {
m_cms.lockResourceTemporary(resource);
} else if (!lock.isOwnedInProjectBy(user, m_cms.getRequestContext().getCurrentProject())) {
m_cms.changeLock(resource);
}
} | java | private void lockTemporary(CmsResource resource) throws CmsException {
CmsUser user = m_cms.getRequestContext().getCurrentUser();
CmsLock lock = m_cms.getLock(resource);
if (!lock.isOwnedBy(user)) {
m_cms.lockResourceTemporary(resource);
} else if (!lock.isOwnedInProjectBy(user, m_cms.getRequestContext().getCurrentProject())) {
m_cms.changeLock(resource);
}
} | [
"private",
"void",
"lockTemporary",
"(",
"CmsResource",
"resource",
")",
"throws",
"CmsException",
"{",
"CmsUser",
"user",
"=",
"m_cms",
".",
"getRequestContext",
"(",
")",
".",
"getCurrentUser",
"(",
")",
";",
"CmsLock",
"lock",
"=",
"m_cms",
".",
"getLock",
"(",
"resource",
")",
";",
"if",
"(",
"!",
"lock",
".",
"isOwnedBy",
"(",
"user",
")",
")",
"{",
"m_cms",
".",
"lockResourceTemporary",
"(",
"resource",
")",
";",
"}",
"else",
"if",
"(",
"!",
"lock",
".",
"isOwnedInProjectBy",
"(",
"user",
",",
"m_cms",
".",
"getRequestContext",
"(",
")",
".",
"getCurrentProject",
"(",
")",
")",
")",
"{",
"m_cms",
".",
"changeLock",
"(",
"resource",
")",
";",
"}",
"}"
] | Locks the given resource temporarily.<p>
@param resource the resource to lock
@throws CmsException if locking fails | [
"Locks",
"the",
"given",
"resource",
"temporarily",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/apps/resourcetypes/CmsNewResourceTypeDialog.java#L1031-L1040 |
HadoopGenomics/Hadoop-BAM | src/main/java/org/seqdoop/hadoop_bam/KeyIgnoringVCFOutputFormat.java | KeyIgnoringVCFOutputFormat.getRecordWriter | @Override public RecordWriter<K,VariantContextWritable> getRecordWriter(
TaskAttemptContext ctx)
throws IOException {
"""
<code>setHeader</code> or <code>readHeaderFrom</code> must have been
called first.
"""
Configuration conf = ctx.getConfiguration();
boolean isCompressed = getCompressOutput(ctx);
CompressionCodec codec = null;
String extension = "";
if (isCompressed) {
Class<? extends CompressionCodec> codecClass =
getOutputCompressorClass(ctx, BGZFCodec.class);
codec = ReflectionUtils.newInstance(codecClass, conf);
extension = codec.getDefaultExtension();
}
Path file = getDefaultWorkFile(ctx, extension);
if (!isCompressed) {
return getRecordWriter(ctx, file);
} else {
FileSystem fs = file.getFileSystem(conf);
return getRecordWriter(ctx, codec.createOutputStream(fs.create(file)));
}
} | java | @Override public RecordWriter<K,VariantContextWritable> getRecordWriter(
TaskAttemptContext ctx)
throws IOException
{
Configuration conf = ctx.getConfiguration();
boolean isCompressed = getCompressOutput(ctx);
CompressionCodec codec = null;
String extension = "";
if (isCompressed) {
Class<? extends CompressionCodec> codecClass =
getOutputCompressorClass(ctx, BGZFCodec.class);
codec = ReflectionUtils.newInstance(codecClass, conf);
extension = codec.getDefaultExtension();
}
Path file = getDefaultWorkFile(ctx, extension);
if (!isCompressed) {
return getRecordWriter(ctx, file);
} else {
FileSystem fs = file.getFileSystem(conf);
return getRecordWriter(ctx, codec.createOutputStream(fs.create(file)));
}
} | [
"@",
"Override",
"public",
"RecordWriter",
"<",
"K",
",",
"VariantContextWritable",
">",
"getRecordWriter",
"(",
"TaskAttemptContext",
"ctx",
")",
"throws",
"IOException",
"{",
"Configuration",
"conf",
"=",
"ctx",
".",
"getConfiguration",
"(",
")",
";",
"boolean",
"isCompressed",
"=",
"getCompressOutput",
"(",
"ctx",
")",
";",
"CompressionCodec",
"codec",
"=",
"null",
";",
"String",
"extension",
"=",
"\"\"",
";",
"if",
"(",
"isCompressed",
")",
"{",
"Class",
"<",
"?",
"extends",
"CompressionCodec",
">",
"codecClass",
"=",
"getOutputCompressorClass",
"(",
"ctx",
",",
"BGZFCodec",
".",
"class",
")",
";",
"codec",
"=",
"ReflectionUtils",
".",
"newInstance",
"(",
"codecClass",
",",
"conf",
")",
";",
"extension",
"=",
"codec",
".",
"getDefaultExtension",
"(",
")",
";",
"}",
"Path",
"file",
"=",
"getDefaultWorkFile",
"(",
"ctx",
",",
"extension",
")",
";",
"if",
"(",
"!",
"isCompressed",
")",
"{",
"return",
"getRecordWriter",
"(",
"ctx",
",",
"file",
")",
";",
"}",
"else",
"{",
"FileSystem",
"fs",
"=",
"file",
".",
"getFileSystem",
"(",
"conf",
")",
";",
"return",
"getRecordWriter",
"(",
"ctx",
",",
"codec",
".",
"createOutputStream",
"(",
"fs",
".",
"create",
"(",
"file",
")",
")",
")",
";",
"}",
"}"
] | <code>setHeader</code> or <code>readHeaderFrom</code> must have been
called first. | [
"<code",
">",
"setHeader<",
"/",
"code",
">",
"or",
"<code",
">",
"readHeaderFrom<",
"/",
"code",
">",
"must",
"have",
"been",
"called",
"first",
"."
] | train | https://github.com/HadoopGenomics/Hadoop-BAM/blob/9f974cf635a8d72f69604021cc3d5f3469d38d2f/src/main/java/org/seqdoop/hadoop_bam/KeyIgnoringVCFOutputFormat.java#L93-L114 |
minio/minio-java | api/src/main/java/io/minio/MinioClient.java | MinioClient.setAppInfo | @SuppressWarnings("unused")
public void setAppInfo(String name, String version) {
"""
Sets application's name/version to user agent. For more information about user agent
refer <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html">#rfc2616</a>.
@param name Your application name.
@param version Your application version.
"""
if (name == null || version == null) {
// nothing to do
return;
}
this.userAgent = DEFAULT_USER_AGENT + " " + name.trim() + "/" + version.trim();
} | java | @SuppressWarnings("unused")
public void setAppInfo(String name, String version) {
if (name == null || version == null) {
// nothing to do
return;
}
this.userAgent = DEFAULT_USER_AGENT + " " + name.trim() + "/" + version.trim();
} | [
"@",
"SuppressWarnings",
"(",
"\"unused\"",
")",
"public",
"void",
"setAppInfo",
"(",
"String",
"name",
",",
"String",
"version",
")",
"{",
"if",
"(",
"name",
"==",
"null",
"||",
"version",
"==",
"null",
")",
"{",
"// nothing to do",
"return",
";",
"}",
"this",
".",
"userAgent",
"=",
"DEFAULT_USER_AGENT",
"+",
"\" \"",
"+",
"name",
".",
"trim",
"(",
")",
"+",
"\"/\"",
"+",
"version",
".",
"trim",
"(",
")",
";",
"}"
] | Sets application's name/version to user agent. For more information about user agent
refer <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html">#rfc2616</a>.
@param name Your application name.
@param version Your application version. | [
"Sets",
"application",
"s",
"name",
"/",
"version",
"to",
"user",
"agent",
".",
"For",
"more",
"information",
"about",
"user",
"agent",
"refer",
"<a",
"href",
"=",
"http",
":",
"//",
"www",
".",
"w3",
".",
"org",
"/",
"Protocols",
"/",
"rfc2616",
"/",
"rfc2616",
"-",
"sec14",
".",
"html",
">",
"#rfc2616<",
"/",
"a",
">",
"."
] | train | https://github.com/minio/minio-java/blob/b2028f56403c89ce2d5900ae813bc1314c87bc7f/api/src/main/java/io/minio/MinioClient.java#L1438-L1446 |
matthewhorridge/owlapi-gwt | owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLNegativeDataPropertyAssertionAxiomImpl_CustomFieldSerializer.java | OWLNegativeDataPropertyAssertionAxiomImpl_CustomFieldSerializer.deserializeInstance | @Override
public void deserializeInstance(SerializationStreamReader streamReader, OWLNegativeDataPropertyAssertionAxiomImpl instance) throws SerializationException {
"""
Deserializes the content of the object from the
{@link com.google.gwt.user.client.rpc.SerializationStreamReader}.
@param streamReader the {@link com.google.gwt.user.client.rpc.SerializationStreamReader} to read the
object's content from
@param instance the object instance to deserialize
@throws com.google.gwt.user.client.rpc.SerializationException
if the deserialization operation is not
successful
"""
deserialize(streamReader, instance);
} | java | @Override
public void deserializeInstance(SerializationStreamReader streamReader, OWLNegativeDataPropertyAssertionAxiomImpl instance) throws SerializationException {
deserialize(streamReader, instance);
} | [
"@",
"Override",
"public",
"void",
"deserializeInstance",
"(",
"SerializationStreamReader",
"streamReader",
",",
"OWLNegativeDataPropertyAssertionAxiomImpl",
"instance",
")",
"throws",
"SerializationException",
"{",
"deserialize",
"(",
"streamReader",
",",
"instance",
")",
";",
"}"
] | Deserializes the content of the object from the
{@link com.google.gwt.user.client.rpc.SerializationStreamReader}.
@param streamReader the {@link com.google.gwt.user.client.rpc.SerializationStreamReader} to read the
object's content from
@param instance the object instance to deserialize
@throws com.google.gwt.user.client.rpc.SerializationException
if the deserialization operation is not
successful | [
"Deserializes",
"the",
"content",
"of",
"the",
"object",
"from",
"the",
"{",
"@link",
"com",
".",
"google",
".",
"gwt",
".",
"user",
".",
"client",
".",
"rpc",
".",
"SerializationStreamReader",
"}",
"."
] | train | https://github.com/matthewhorridge/owlapi-gwt/blob/7ab975fb6cef3c8947099983551672a3b5d4e2fd/owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLNegativeDataPropertyAssertionAxiomImpl_CustomFieldSerializer.java#L101-L104 |
landawn/AbacusUtil | src/com/landawn/abacus/dataSource/PoolablePreparedStatement.java | PoolablePreparedStatement.setBlob | @Override
public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException {
"""
Method setBlob.
@param parameterIndex
@param inputStream
@param length
@throws SQLException
@see java.sql.PreparedStatement#setBlob(int, InputStream, long)
"""
internalStmt.setBlob(parameterIndex, inputStream, length);
} | java | @Override
public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException {
internalStmt.setBlob(parameterIndex, inputStream, length);
} | [
"@",
"Override",
"public",
"void",
"setBlob",
"(",
"int",
"parameterIndex",
",",
"InputStream",
"inputStream",
",",
"long",
"length",
")",
"throws",
"SQLException",
"{",
"internalStmt",
".",
"setBlob",
"(",
"parameterIndex",
",",
"inputStream",
",",
"length",
")",
";",
"}"
] | Method setBlob.
@param parameterIndex
@param inputStream
@param length
@throws SQLException
@see java.sql.PreparedStatement#setBlob(int, InputStream, long) | [
"Method",
"setBlob",
"."
] | train | https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/dataSource/PoolablePreparedStatement.java#L578-L581 |
geomajas/geomajas-project-client-gwt | client/src/main/java/org/geomajas/gwt/client/controller/FeatureInfoController.java | FeatureInfoController.onMouseUp | public void onMouseUp(MouseUpEvent event) {
"""
On mouse up, execute the search by location, and display a
{@link org.geomajas.gwt.client.widget.FeatureAttributeWindow} if a result is found.
"""
Coordinate worldPosition = getWorldPosition(event);
Point point = mapWidget.getMapModel().getGeometryFactory().createPoint(worldPosition);
SearchByLocationRequest request = new SearchByLocationRequest();
request.setLocation(GeometryConverter.toDto(point));
request.setCrs(mapWidget.getMapModel().getCrs());
request.setQueryType(SearchByLocationRequest.QUERY_INTERSECTS);
request.setSearchType(SearchByLocationRequest.SEARCH_FIRST_LAYER);
request.setBuffer(calculateBufferFromPixelTolerance());
request.setFeatureIncludes(GwtCommandDispatcher.getInstance().getLazyFeatureIncludesSelect());
request.setLayerIds(getServerLayerIds(mapWidget.getMapModel()));
for (Layer<?> layer : mapWidget.getMapModel().getLayers()) {
if (layer.isShowing() && layer instanceof VectorLayer) {
request.setFilter(layer.getServerLayerId(), ((VectorLayer) layer).getFilter());
}
}
GwtCommand commandRequest = new GwtCommand(SearchByLocationRequest.COMMAND);
commandRequest.setCommandRequest(request);
GwtCommandDispatcher.getInstance().execute(commandRequest,
new AbstractCommandCallback<SearchByLocationResponse>() {
public void execute(SearchByLocationResponse response) {
Map<String, List<org.geomajas.layer.feature.Feature>> featureMap = response.getFeatureMap();
for (String serverLayerId : featureMap.keySet()) {
List<VectorLayer> layers = mapWidget.getMapModel().getVectorLayersByServerId(serverLayerId);
for (VectorLayer vectorLayer : layers) {
List<org.geomajas.layer.feature.Feature> orgFeatures = featureMap.get(serverLayerId);
if (orgFeatures.size() > 0) {
Feature feature = new Feature(orgFeatures.get(0), vectorLayer);
vectorLayer.getFeatureStore().addFeature(feature);
FeatureAttributeWindow window = new FeatureAttributeWindow(feature, false);
window.setPageTop(mapWidget.getAbsoluteTop() + 10);
window.setPageLeft(mapWidget.getAbsoluteLeft() + 10);
window.draw();
}
}
}
}
});
} | java | public void onMouseUp(MouseUpEvent event) {
Coordinate worldPosition = getWorldPosition(event);
Point point = mapWidget.getMapModel().getGeometryFactory().createPoint(worldPosition);
SearchByLocationRequest request = new SearchByLocationRequest();
request.setLocation(GeometryConverter.toDto(point));
request.setCrs(mapWidget.getMapModel().getCrs());
request.setQueryType(SearchByLocationRequest.QUERY_INTERSECTS);
request.setSearchType(SearchByLocationRequest.SEARCH_FIRST_LAYER);
request.setBuffer(calculateBufferFromPixelTolerance());
request.setFeatureIncludes(GwtCommandDispatcher.getInstance().getLazyFeatureIncludesSelect());
request.setLayerIds(getServerLayerIds(mapWidget.getMapModel()));
for (Layer<?> layer : mapWidget.getMapModel().getLayers()) {
if (layer.isShowing() && layer instanceof VectorLayer) {
request.setFilter(layer.getServerLayerId(), ((VectorLayer) layer).getFilter());
}
}
GwtCommand commandRequest = new GwtCommand(SearchByLocationRequest.COMMAND);
commandRequest.setCommandRequest(request);
GwtCommandDispatcher.getInstance().execute(commandRequest,
new AbstractCommandCallback<SearchByLocationResponse>() {
public void execute(SearchByLocationResponse response) {
Map<String, List<org.geomajas.layer.feature.Feature>> featureMap = response.getFeatureMap();
for (String serverLayerId : featureMap.keySet()) {
List<VectorLayer> layers = mapWidget.getMapModel().getVectorLayersByServerId(serverLayerId);
for (VectorLayer vectorLayer : layers) {
List<org.geomajas.layer.feature.Feature> orgFeatures = featureMap.get(serverLayerId);
if (orgFeatures.size() > 0) {
Feature feature = new Feature(orgFeatures.get(0), vectorLayer);
vectorLayer.getFeatureStore().addFeature(feature);
FeatureAttributeWindow window = new FeatureAttributeWindow(feature, false);
window.setPageTop(mapWidget.getAbsoluteTop() + 10);
window.setPageLeft(mapWidget.getAbsoluteLeft() + 10);
window.draw();
}
}
}
}
});
} | [
"public",
"void",
"onMouseUp",
"(",
"MouseUpEvent",
"event",
")",
"{",
"Coordinate",
"worldPosition",
"=",
"getWorldPosition",
"(",
"event",
")",
";",
"Point",
"point",
"=",
"mapWidget",
".",
"getMapModel",
"(",
")",
".",
"getGeometryFactory",
"(",
")",
".",
"createPoint",
"(",
"worldPosition",
")",
";",
"SearchByLocationRequest",
"request",
"=",
"new",
"SearchByLocationRequest",
"(",
")",
";",
"request",
".",
"setLocation",
"(",
"GeometryConverter",
".",
"toDto",
"(",
"point",
")",
")",
";",
"request",
".",
"setCrs",
"(",
"mapWidget",
".",
"getMapModel",
"(",
")",
".",
"getCrs",
"(",
")",
")",
";",
"request",
".",
"setQueryType",
"(",
"SearchByLocationRequest",
".",
"QUERY_INTERSECTS",
")",
";",
"request",
".",
"setSearchType",
"(",
"SearchByLocationRequest",
".",
"SEARCH_FIRST_LAYER",
")",
";",
"request",
".",
"setBuffer",
"(",
"calculateBufferFromPixelTolerance",
"(",
")",
")",
";",
"request",
".",
"setFeatureIncludes",
"(",
"GwtCommandDispatcher",
".",
"getInstance",
"(",
")",
".",
"getLazyFeatureIncludesSelect",
"(",
")",
")",
";",
"request",
".",
"setLayerIds",
"(",
"getServerLayerIds",
"(",
"mapWidget",
".",
"getMapModel",
"(",
")",
")",
")",
";",
"for",
"(",
"Layer",
"<",
"?",
">",
"layer",
":",
"mapWidget",
".",
"getMapModel",
"(",
")",
".",
"getLayers",
"(",
")",
")",
"{",
"if",
"(",
"layer",
".",
"isShowing",
"(",
")",
"&&",
"layer",
"instanceof",
"VectorLayer",
")",
"{",
"request",
".",
"setFilter",
"(",
"layer",
".",
"getServerLayerId",
"(",
")",
",",
"(",
"(",
"VectorLayer",
")",
"layer",
")",
".",
"getFilter",
"(",
")",
")",
";",
"}",
"}",
"GwtCommand",
"commandRequest",
"=",
"new",
"GwtCommand",
"(",
"SearchByLocationRequest",
".",
"COMMAND",
")",
";",
"commandRequest",
".",
"setCommandRequest",
"(",
"request",
")",
";",
"GwtCommandDispatcher",
".",
"getInstance",
"(",
")",
".",
"execute",
"(",
"commandRequest",
",",
"new",
"AbstractCommandCallback",
"<",
"SearchByLocationResponse",
">",
"(",
")",
"{",
"public",
"void",
"execute",
"(",
"SearchByLocationResponse",
"response",
")",
"{",
"Map",
"<",
"String",
",",
"List",
"<",
"org",
".",
"geomajas",
".",
"layer",
".",
"feature",
".",
"Feature",
">",
">",
"featureMap",
"=",
"response",
".",
"getFeatureMap",
"(",
")",
";",
"for",
"(",
"String",
"serverLayerId",
":",
"featureMap",
".",
"keySet",
"(",
")",
")",
"{",
"List",
"<",
"VectorLayer",
">",
"layers",
"=",
"mapWidget",
".",
"getMapModel",
"(",
")",
".",
"getVectorLayersByServerId",
"(",
"serverLayerId",
")",
";",
"for",
"(",
"VectorLayer",
"vectorLayer",
":",
"layers",
")",
"{",
"List",
"<",
"org",
".",
"geomajas",
".",
"layer",
".",
"feature",
".",
"Feature",
">",
"orgFeatures",
"=",
"featureMap",
".",
"get",
"(",
"serverLayerId",
")",
";",
"if",
"(",
"orgFeatures",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"Feature",
"feature",
"=",
"new",
"Feature",
"(",
"orgFeatures",
".",
"get",
"(",
"0",
")",
",",
"vectorLayer",
")",
";",
"vectorLayer",
".",
"getFeatureStore",
"(",
")",
".",
"addFeature",
"(",
"feature",
")",
";",
"FeatureAttributeWindow",
"window",
"=",
"new",
"FeatureAttributeWindow",
"(",
"feature",
",",
"false",
")",
";",
"window",
".",
"setPageTop",
"(",
"mapWidget",
".",
"getAbsoluteTop",
"(",
")",
"+",
"10",
")",
";",
"window",
".",
"setPageLeft",
"(",
"mapWidget",
".",
"getAbsoluteLeft",
"(",
")",
"+",
"10",
")",
";",
"window",
".",
"draw",
"(",
")",
";",
"}",
"}",
"}",
"}",
"}",
")",
";",
"}"
] | On mouse up, execute the search by location, and display a
{@link org.geomajas.gwt.client.widget.FeatureAttributeWindow} if a result is found. | [
"On",
"mouse",
"up",
"execute",
"the",
"search",
"by",
"location",
"and",
"display",
"a",
"{"
] | train | https://github.com/geomajas/geomajas-project-client-gwt/blob/1c1adc48deb192ed825265eebcc74d70bbf45670/client/src/main/java/org/geomajas/gwt/client/controller/FeatureInfoController.java#L57-L98 |
kiswanij/jk-util | src/main/java/com/jk/util/JKConversionUtil.java | JKConversionUtil.toInteger | public static int toInteger(Object value, int defaultValue) {
"""
To integer.
@param value the value
@param defaultValue the default value
@return the int
"""
if (value == null || value.toString().trim().equals("")) {
return defaultValue;
}
if (value instanceof Integer) {
return (Integer) value;
}
return (int) JKConversionUtil.toDouble(value);
} | java | public static int toInteger(Object value, int defaultValue) {
if (value == null || value.toString().trim().equals("")) {
return defaultValue;
}
if (value instanceof Integer) {
return (Integer) value;
}
return (int) JKConversionUtil.toDouble(value);
} | [
"public",
"static",
"int",
"toInteger",
"(",
"Object",
"value",
",",
"int",
"defaultValue",
")",
"{",
"if",
"(",
"value",
"==",
"null",
"||",
"value",
".",
"toString",
"(",
")",
".",
"trim",
"(",
")",
".",
"equals",
"(",
"\"\"",
")",
")",
"{",
"return",
"defaultValue",
";",
"}",
"if",
"(",
"value",
"instanceof",
"Integer",
")",
"{",
"return",
"(",
"Integer",
")",
"value",
";",
"}",
"return",
"(",
"int",
")",
"JKConversionUtil",
".",
"toDouble",
"(",
"value",
")",
";",
"}"
] | To integer.
@param value the value
@param defaultValue the default value
@return the int | [
"To",
"integer",
"."
] | train | https://github.com/kiswanij/jk-util/blob/8e0c85818423406f769444c76194a748e0a0fc0a/src/main/java/com/jk/util/JKConversionUtil.java#L179-L187 |
groupe-sii/ogham | ogham-core/src/main/java/fr/sii/ogham/core/sender/MultiImplementationSender.java | MultiImplementationSender.addImplementation | public final MultiImplementationSender<M> addImplementation(Condition<Message> condition, MessageSender implementation) {
"""
Register a new possible implementation with the associated condition. The
implementation is added at the end so any other possible implementation
will be used before this one if the associated condition allow it.
@param condition
the condition that indicates if the implementation can be used
at runtime
@param implementation
the implementation to register
@return this instance for fluent chaining
"""
implementations.add(new Implementation(condition, implementation));
return this;
} | java | public final MultiImplementationSender<M> addImplementation(Condition<Message> condition, MessageSender implementation) {
implementations.add(new Implementation(condition, implementation));
return this;
} | [
"public",
"final",
"MultiImplementationSender",
"<",
"M",
">",
"addImplementation",
"(",
"Condition",
"<",
"Message",
">",
"condition",
",",
"MessageSender",
"implementation",
")",
"{",
"implementations",
".",
"add",
"(",
"new",
"Implementation",
"(",
"condition",
",",
"implementation",
")",
")",
";",
"return",
"this",
";",
"}"
] | Register a new possible implementation with the associated condition. The
implementation is added at the end so any other possible implementation
will be used before this one if the associated condition allow it.
@param condition
the condition that indicates if the implementation can be used
at runtime
@param implementation
the implementation to register
@return this instance for fluent chaining | [
"Register",
"a",
"new",
"possible",
"implementation",
"with",
"the",
"associated",
"condition",
".",
"The",
"implementation",
"is",
"added",
"at",
"the",
"end",
"so",
"any",
"other",
"possible",
"implementation",
"will",
"be",
"used",
"before",
"this",
"one",
"if",
"the",
"associated",
"condition",
"allow",
"it",
"."
] | train | https://github.com/groupe-sii/ogham/blob/e273b845604add74b5a25dfd931cb3c166b1008f/ogham-core/src/main/java/fr/sii/ogham/core/sender/MultiImplementationSender.java#L90-L93 |
h2oai/h2o-2 | src/main/java/water/exec/Env.java | Env.subRef | public Futures subRef( Vec vec, Futures fs ) {
"""
Subtract reference count.
@param vec vector to handle
@param fs future, cannot be null
@return returns given Future
"""
assert fs != null : "Future should not be null!";
if ( vec.masterVec() != null ) subRef(vec.masterVec(), fs);
int cnt = _refcnt.get(vec)._val-1;
if ( cnt > 0 ) {
_refcnt.put(vec,new IcedInt(cnt));
} else {
UKV.remove(vec._key,fs);
_refcnt.remove(vec);
}
return fs;
} | java | public Futures subRef( Vec vec, Futures fs ) {
assert fs != null : "Future should not be null!";
if ( vec.masterVec() != null ) subRef(vec.masterVec(), fs);
int cnt = _refcnt.get(vec)._val-1;
if ( cnt > 0 ) {
_refcnt.put(vec,new IcedInt(cnt));
} else {
UKV.remove(vec._key,fs);
_refcnt.remove(vec);
}
return fs;
} | [
"public",
"Futures",
"subRef",
"(",
"Vec",
"vec",
",",
"Futures",
"fs",
")",
"{",
"assert",
"fs",
"!=",
"null",
":",
"\"Future should not be null!\"",
";",
"if",
"(",
"vec",
".",
"masterVec",
"(",
")",
"!=",
"null",
")",
"subRef",
"(",
"vec",
".",
"masterVec",
"(",
")",
",",
"fs",
")",
";",
"int",
"cnt",
"=",
"_refcnt",
".",
"get",
"(",
"vec",
")",
".",
"_val",
"-",
"1",
";",
"if",
"(",
"cnt",
">",
"0",
")",
"{",
"_refcnt",
".",
"put",
"(",
"vec",
",",
"new",
"IcedInt",
"(",
"cnt",
")",
")",
";",
"}",
"else",
"{",
"UKV",
".",
"remove",
"(",
"vec",
".",
"_key",
",",
"fs",
")",
";",
"_refcnt",
".",
"remove",
"(",
"vec",
")",
";",
"}",
"return",
"fs",
";",
"}"
] | Subtract reference count.
@param vec vector to handle
@param fs future, cannot be null
@return returns given Future | [
"Subtract",
"reference",
"count",
"."
] | train | https://github.com/h2oai/h2o-2/blob/be350f3f2c2fb6f135cc07c41f83fd0e4f521ac1/src/main/java/water/exec/Env.java#L279-L290 |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/util/Properties.java | Properties.getProperty | public double getProperty(String propName, double defaultValue) {
"""
Returns the double value of the property associated with {@code propName},
or {@code defaultValue} if there is no property.
"""
String propValue = props.getProperty(propName);
return (propValue == null) ? defaultValue : Double.parseDouble(propValue);
} | java | public double getProperty(String propName, double defaultValue) {
String propValue = props.getProperty(propName);
return (propValue == null) ? defaultValue : Double.parseDouble(propValue);
} | [
"public",
"double",
"getProperty",
"(",
"String",
"propName",
",",
"double",
"defaultValue",
")",
"{",
"String",
"propValue",
"=",
"props",
".",
"getProperty",
"(",
"propName",
")",
";",
"return",
"(",
"propValue",
"==",
"null",
")",
"?",
"defaultValue",
":",
"Double",
".",
"parseDouble",
"(",
"propValue",
")",
";",
"}"
] | Returns the double value of the property associated with {@code propName},
or {@code defaultValue} if there is no property. | [
"Returns",
"the",
"double",
"value",
"of",
"the",
"property",
"associated",
"with",
"{"
] | train | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/util/Properties.java#L82-L85 |
apache/incubator-gobblin | gobblin-utility/src/main/java/org/apache/gobblin/util/AvroUtils.java | AvroUtils.getObjectFromMap | private static Object getObjectFromMap(Map map, String key) {
"""
This method is to get object from map given a key as string.
Avro persists string as Utf8
@param map passed from {@link #getFieldHelper(Map, Object, List, int)}
@param key passed from {@link #getFieldHelper(Map, Object, List, int)}
@return This could again be a GenericRecord
"""
Utf8 utf8Key = new Utf8(key);
return map.get(utf8Key);
} | java | private static Object getObjectFromMap(Map map, String key) {
Utf8 utf8Key = new Utf8(key);
return map.get(utf8Key);
} | [
"private",
"static",
"Object",
"getObjectFromMap",
"(",
"Map",
"map",
",",
"String",
"key",
")",
"{",
"Utf8",
"utf8Key",
"=",
"new",
"Utf8",
"(",
"key",
")",
";",
"return",
"map",
".",
"get",
"(",
"utf8Key",
")",
";",
"}"
] | This method is to get object from map given a key as string.
Avro persists string as Utf8
@param map passed from {@link #getFieldHelper(Map, Object, List, int)}
@param key passed from {@link #getFieldHelper(Map, Object, List, int)}
@return This could again be a GenericRecord | [
"This",
"method",
"is",
"to",
"get",
"object",
"from",
"map",
"given",
"a",
"key",
"as",
"string",
".",
"Avro",
"persists",
"string",
"as",
"Utf8"
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/AvroUtils.java#L353-L356 |
threerings/narya | core/src/main/java/com/threerings/presents/server/InvocationException.java | InvocationException.requireAccess | public static void requireAccess (ClientObject clobj, Permission perm)
throws InvocationException {
"""
A version of {@link #requireAccess(ClientObject,Permission,Object)} that takes no context.
"""
requireAccess(clobj, perm, null);
} | java | public static void requireAccess (ClientObject clobj, Permission perm)
throws InvocationException
{
requireAccess(clobj, perm, null);
} | [
"public",
"static",
"void",
"requireAccess",
"(",
"ClientObject",
"clobj",
",",
"Permission",
"perm",
")",
"throws",
"InvocationException",
"{",
"requireAccess",
"(",
"clobj",
",",
"perm",
",",
"null",
")",
";",
"}"
] | A version of {@link #requireAccess(ClientObject,Permission,Object)} that takes no context. | [
"A",
"version",
"of",
"{"
] | train | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/server/InvocationException.java#L51-L55 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/javax/crypto/SealedObject.java | SealedObject.getObject | public final Object getObject(Key key)
throws IOException, ClassNotFoundException, NoSuchAlgorithmException,
InvalidKeyException {
"""
Retrieves the original (encapsulated) object.
<p>This method creates a cipher for the algorithm that had been used in
the sealing operation.
If the default provider package provides an implementation of that
algorithm, an instance of Cipher containing that implementation is used.
If the algorithm is not available in the default package, other
packages are searched.
The Cipher object is initialized for decryption, using the given
<code>key</code> and the parameters (if any) that had been used in the
sealing operation.
<p>The encapsulated object is unsealed and de-serialized, before it is
returned.
@param key the key used to unseal the object.
@return the original object.
@exception IOException if an error occurs during de-serialiazation.
@exception ClassNotFoundException if an error occurs during
de-serialiazation.
@exception NoSuchAlgorithmException if the algorithm to unseal the
object is not available.
@exception InvalidKeyException if the given key cannot be used to unseal
the object (e.g., it has the wrong algorithm).
@exception NullPointerException if <code>key</code> is null.
"""
if (key == null) {
throw new NullPointerException("key is null");
}
try {
return unseal(key, null);
} catch (NoSuchProviderException nspe) {
// we've already caught NoSuchProviderException's and converted
// them into NoSuchAlgorithmException's with details about
// the failing algorithm
throw new NoSuchAlgorithmException("algorithm not found");
} catch (IllegalBlockSizeException ibse) {
throw new InvalidKeyException(ibse.getMessage());
} catch (BadPaddingException bpe) {
throw new InvalidKeyException(bpe.getMessage());
}
} | java | public final Object getObject(Key key)
throws IOException, ClassNotFoundException, NoSuchAlgorithmException,
InvalidKeyException
{
if (key == null) {
throw new NullPointerException("key is null");
}
try {
return unseal(key, null);
} catch (NoSuchProviderException nspe) {
// we've already caught NoSuchProviderException's and converted
// them into NoSuchAlgorithmException's with details about
// the failing algorithm
throw new NoSuchAlgorithmException("algorithm not found");
} catch (IllegalBlockSizeException ibse) {
throw new InvalidKeyException(ibse.getMessage());
} catch (BadPaddingException bpe) {
throw new InvalidKeyException(bpe.getMessage());
}
} | [
"public",
"final",
"Object",
"getObject",
"(",
"Key",
"key",
")",
"throws",
"IOException",
",",
"ClassNotFoundException",
",",
"NoSuchAlgorithmException",
",",
"InvalidKeyException",
"{",
"if",
"(",
"key",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"key is null\"",
")",
";",
"}",
"try",
"{",
"return",
"unseal",
"(",
"key",
",",
"null",
")",
";",
"}",
"catch",
"(",
"NoSuchProviderException",
"nspe",
")",
"{",
"// we've already caught NoSuchProviderException's and converted",
"// them into NoSuchAlgorithmException's with details about",
"// the failing algorithm",
"throw",
"new",
"NoSuchAlgorithmException",
"(",
"\"algorithm not found\"",
")",
";",
"}",
"catch",
"(",
"IllegalBlockSizeException",
"ibse",
")",
"{",
"throw",
"new",
"InvalidKeyException",
"(",
"ibse",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"catch",
"(",
"BadPaddingException",
"bpe",
")",
"{",
"throw",
"new",
"InvalidKeyException",
"(",
"bpe",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Retrieves the original (encapsulated) object.
<p>This method creates a cipher for the algorithm that had been used in
the sealing operation.
If the default provider package provides an implementation of that
algorithm, an instance of Cipher containing that implementation is used.
If the algorithm is not available in the default package, other
packages are searched.
The Cipher object is initialized for decryption, using the given
<code>key</code> and the parameters (if any) that had been used in the
sealing operation.
<p>The encapsulated object is unsealed and de-serialized, before it is
returned.
@param key the key used to unseal the object.
@return the original object.
@exception IOException if an error occurs during de-serialiazation.
@exception ClassNotFoundException if an error occurs during
de-serialiazation.
@exception NoSuchAlgorithmException if the algorithm to unseal the
object is not available.
@exception InvalidKeyException if the given key cannot be used to unseal
the object (e.g., it has the wrong algorithm).
@exception NullPointerException if <code>key</code> is null. | [
"Retrieves",
"the",
"original",
"(",
"encapsulated",
")",
"object",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/javax/crypto/SealedObject.java#L242-L262 |
javagl/Common | src/main/java/de/javagl/common/beans/FullPersistenceDelegate.java | FullPersistenceDelegate.initializeProperty | private void initializeProperty(
Class<?> type, PropertyDescriptor pd, Object oldInstance, Encoder encoder)
throws Exception {
"""
Write the statement to initialize the specified property of the given
Java Bean Type, based on the given instance, using the given
encoder
@param type The Java Bean Type
@param pd The property descriptor
@param oldInstance The base instance
@param encoder The encoder
@throws Exception If the value can not be obtained
"""
Method getter = pd.getReadMethod();
Method setter = pd.getWriteMethod();
if (getter != null && setter != null)
{
Expression oldGetExpression =
new Expression(oldInstance, getter.getName(), new Object[] {});
Object oldValue = oldGetExpression.getValue();
Statement setStatement =
new Statement(oldInstance, setter.getName(),
new Object[] { oldValue });
encoder.writeStatement(setStatement);
}
} | java | private void initializeProperty(
Class<?> type, PropertyDescriptor pd, Object oldInstance, Encoder encoder)
throws Exception
{
Method getter = pd.getReadMethod();
Method setter = pd.getWriteMethod();
if (getter != null && setter != null)
{
Expression oldGetExpression =
new Expression(oldInstance, getter.getName(), new Object[] {});
Object oldValue = oldGetExpression.getValue();
Statement setStatement =
new Statement(oldInstance, setter.getName(),
new Object[] { oldValue });
encoder.writeStatement(setStatement);
}
} | [
"private",
"void",
"initializeProperty",
"(",
"Class",
"<",
"?",
">",
"type",
",",
"PropertyDescriptor",
"pd",
",",
"Object",
"oldInstance",
",",
"Encoder",
"encoder",
")",
"throws",
"Exception",
"{",
"Method",
"getter",
"=",
"pd",
".",
"getReadMethod",
"(",
")",
";",
"Method",
"setter",
"=",
"pd",
".",
"getWriteMethod",
"(",
")",
";",
"if",
"(",
"getter",
"!=",
"null",
"&&",
"setter",
"!=",
"null",
")",
"{",
"Expression",
"oldGetExpression",
"=",
"new",
"Expression",
"(",
"oldInstance",
",",
"getter",
".",
"getName",
"(",
")",
",",
"new",
"Object",
"[",
"]",
"{",
"}",
")",
";",
"Object",
"oldValue",
"=",
"oldGetExpression",
".",
"getValue",
"(",
")",
";",
"Statement",
"setStatement",
"=",
"new",
"Statement",
"(",
"oldInstance",
",",
"setter",
".",
"getName",
"(",
")",
",",
"new",
"Object",
"[",
"]",
"{",
"oldValue",
"}",
")",
";",
"encoder",
".",
"writeStatement",
"(",
"setStatement",
")",
";",
"}",
"}"
] | Write the statement to initialize the specified property of the given
Java Bean Type, based on the given instance, using the given
encoder
@param type The Java Bean Type
@param pd The property descriptor
@param oldInstance The base instance
@param encoder The encoder
@throws Exception If the value can not be obtained | [
"Write",
"the",
"statement",
"to",
"initialize",
"the",
"specified",
"property",
"of",
"the",
"given",
"Java",
"Bean",
"Type",
"based",
"on",
"the",
"given",
"instance",
"using",
"the",
"given",
"encoder"
] | train | https://github.com/javagl/Common/blob/5a4876b48c3a2dc61d21324733cf37512d721c33/src/main/java/de/javagl/common/beans/FullPersistenceDelegate.java#L124-L140 |
pwheel/spring-security-oauth2-client | src/main/java/com/racquettrack/security/oauth/OAuth2AuthenticationFilter.java | OAuth2AuthenticationFilter.attemptAuthentication | @Override
public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException, IOException, ServletException {
"""
Performs actual authentication.
<p>
The implementation should do one of the following:
<ol>
<li>Return a populated authentication token for the authenticated user, indicating successful authentication</li>
<li>Return null, indicating that the authentication process is still in progress. Before returning, the
implementation should perform any additional work required to complete the process.</li>
<li>Throw an <tt>AuthenticationException</tt> if the authentication process fails</li>
</ol>
@param request from which to extract parameters and perform the authentication
@param response the response, which may be needed if the implementation has to do a redirect as part of a
multi-stage authentication process (such as OpenID).
@return the authenticated user token, or null if authentication is incomplete.
@throws org.springframework.security.core.AuthenticationException
if authentication fails.
"""
String code = null;
if (LOG.isDebugEnabled()) {
String url = request.getRequestURI();
String queryString = request.getQueryString();
LOG.debug("attemptAuthentication on url {}?{}", url, queryString);
}
// request parameters
final Map<String, String[]> parameters = request.getParameterMap();
LOG.debug("Got Parameters: {}", parameters);
// Check to see if there was an error response from the OAuth Provider
checkForErrors(parameters);
// Check state parameter to avoid cross-site-scripting attacks
checkStateParameter(request.getSession(), parameters);
final String codeValues[] = parameters.get(oAuth2ServiceProperties.getCodeParamName());
if (codeValues != null && codeValues.length > 0) {
code = codeValues[0];
LOG.debug("Got code {}", code);
}
OAuth2AuthenticationToken authRequest = new OAuth2AuthenticationToken(code);
// Allow subclasses to set the "details" property
setDetails(request, authRequest);
return this.getAuthenticationManager().authenticate(authRequest);
} | java | @Override
public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException, IOException, ServletException {
String code = null;
if (LOG.isDebugEnabled()) {
String url = request.getRequestURI();
String queryString = request.getQueryString();
LOG.debug("attemptAuthentication on url {}?{}", url, queryString);
}
// request parameters
final Map<String, String[]> parameters = request.getParameterMap();
LOG.debug("Got Parameters: {}", parameters);
// Check to see if there was an error response from the OAuth Provider
checkForErrors(parameters);
// Check state parameter to avoid cross-site-scripting attacks
checkStateParameter(request.getSession(), parameters);
final String codeValues[] = parameters.get(oAuth2ServiceProperties.getCodeParamName());
if (codeValues != null && codeValues.length > 0) {
code = codeValues[0];
LOG.debug("Got code {}", code);
}
OAuth2AuthenticationToken authRequest = new OAuth2AuthenticationToken(code);
// Allow subclasses to set the "details" property
setDetails(request, authRequest);
return this.getAuthenticationManager().authenticate(authRequest);
} | [
"@",
"Override",
"public",
"Authentication",
"attemptAuthentication",
"(",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
")",
"throws",
"AuthenticationException",
",",
"IOException",
",",
"ServletException",
"{",
"String",
"code",
"=",
"null",
";",
"if",
"(",
"LOG",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"String",
"url",
"=",
"request",
".",
"getRequestURI",
"(",
")",
";",
"String",
"queryString",
"=",
"request",
".",
"getQueryString",
"(",
")",
";",
"LOG",
".",
"debug",
"(",
"\"attemptAuthentication on url {}?{}\"",
",",
"url",
",",
"queryString",
")",
";",
"}",
"// request parameters",
"final",
"Map",
"<",
"String",
",",
"String",
"[",
"]",
">",
"parameters",
"=",
"request",
".",
"getParameterMap",
"(",
")",
";",
"LOG",
".",
"debug",
"(",
"\"Got Parameters: {}\"",
",",
"parameters",
")",
";",
"// Check to see if there was an error response from the OAuth Provider",
"checkForErrors",
"(",
"parameters",
")",
";",
"// Check state parameter to avoid cross-site-scripting attacks",
"checkStateParameter",
"(",
"request",
".",
"getSession",
"(",
")",
",",
"parameters",
")",
";",
"final",
"String",
"codeValues",
"[",
"]",
"=",
"parameters",
".",
"get",
"(",
"oAuth2ServiceProperties",
".",
"getCodeParamName",
"(",
")",
")",
";",
"if",
"(",
"codeValues",
"!=",
"null",
"&&",
"codeValues",
".",
"length",
">",
"0",
")",
"{",
"code",
"=",
"codeValues",
"[",
"0",
"]",
";",
"LOG",
".",
"debug",
"(",
"\"Got code {}\"",
",",
"code",
")",
";",
"}",
"OAuth2AuthenticationToken",
"authRequest",
"=",
"new",
"OAuth2AuthenticationToken",
"(",
"code",
")",
";",
"// Allow subclasses to set the \"details\" property",
"setDetails",
"(",
"request",
",",
"authRequest",
")",
";",
"return",
"this",
".",
"getAuthenticationManager",
"(",
")",
".",
"authenticate",
"(",
"authRequest",
")",
";",
"}"
] | Performs actual authentication.
<p>
The implementation should do one of the following:
<ol>
<li>Return a populated authentication token for the authenticated user, indicating successful authentication</li>
<li>Return null, indicating that the authentication process is still in progress. Before returning, the
implementation should perform any additional work required to complete the process.</li>
<li>Throw an <tt>AuthenticationException</tt> if the authentication process fails</li>
</ol>
@param request from which to extract parameters and perform the authentication
@param response the response, which may be needed if the implementation has to do a redirect as part of a
multi-stage authentication process (such as OpenID).
@return the authenticated user token, or null if authentication is incomplete.
@throws org.springframework.security.core.AuthenticationException
if authentication fails. | [
"Performs",
"actual",
"authentication",
".",
"<p",
">",
"The",
"implementation",
"should",
"do",
"one",
"of",
"the",
"following",
":",
"<ol",
">",
"<li",
">",
"Return",
"a",
"populated",
"authentication",
"token",
"for",
"the",
"authenticated",
"user",
"indicating",
"successful",
"authentication<",
"/",
"li",
">",
"<li",
">",
"Return",
"null",
"indicating",
"that",
"the",
"authentication",
"process",
"is",
"still",
"in",
"progress",
".",
"Before",
"returning",
"the",
"implementation",
"should",
"perform",
"any",
"additional",
"work",
"required",
"to",
"complete",
"the",
"process",
".",
"<",
"/",
"li",
">",
"<li",
">",
"Throw",
"an",
"<tt",
">",
"AuthenticationException<",
"/",
"tt",
">",
"if",
"the",
"authentication",
"process",
"fails<",
"/",
"li",
">",
"<",
"/",
"ol",
">"
] | train | https://github.com/pwheel/spring-security-oauth2-client/blob/c0258823493e268495c9752c5d752f74c6809c6b/src/main/java/com/racquettrack/security/oauth/OAuth2AuthenticationFilter.java#L64-L97 |
ist-dresden/composum | sling/core/commons/src/main/java/com/composum/sling/core/util/LinkUtil.java | LinkUtil.getUrl | public static String getUrl(SlingHttpServletRequest request, String url,
String selectors, String extension) {
"""
Builds a mapped link to the path (resource path) with optional selectors and extension.
@param request the request context for path mapping (the result is always mapped)
@param url the URL to use (complete) or the path to an addressed resource (without any extension)
@param selectors an optional selector string with all necessary selectors (can be 'null')
@param extension an optional extension (can be 'null' for extension determination)
@return the mapped url for the referenced resource
"""
LinkMapper mapper = (LinkMapper) request.getAttribute(LinkMapper.LINK_MAPPER_REQUEST_ATTRIBUTE);
return getUrl(request, url, selectors, extension, mapper != null ? mapper : LinkMapper.RESOLVER);
} | java | public static String getUrl(SlingHttpServletRequest request, String url,
String selectors, String extension) {
LinkMapper mapper = (LinkMapper) request.getAttribute(LinkMapper.LINK_MAPPER_REQUEST_ATTRIBUTE);
return getUrl(request, url, selectors, extension, mapper != null ? mapper : LinkMapper.RESOLVER);
} | [
"public",
"static",
"String",
"getUrl",
"(",
"SlingHttpServletRequest",
"request",
",",
"String",
"url",
",",
"String",
"selectors",
",",
"String",
"extension",
")",
"{",
"LinkMapper",
"mapper",
"=",
"(",
"LinkMapper",
")",
"request",
".",
"getAttribute",
"(",
"LinkMapper",
".",
"LINK_MAPPER_REQUEST_ATTRIBUTE",
")",
";",
"return",
"getUrl",
"(",
"request",
",",
"url",
",",
"selectors",
",",
"extension",
",",
"mapper",
"!=",
"null",
"?",
"mapper",
":",
"LinkMapper",
".",
"RESOLVER",
")",
";",
"}"
] | Builds a mapped link to the path (resource path) with optional selectors and extension.
@param request the request context for path mapping (the result is always mapped)
@param url the URL to use (complete) or the path to an addressed resource (without any extension)
@param selectors an optional selector string with all necessary selectors (can be 'null')
@param extension an optional extension (can be 'null' for extension determination)
@return the mapped url for the referenced resource | [
"Builds",
"a",
"mapped",
"link",
"to",
"the",
"path",
"(",
"resource",
"path",
")",
"with",
"optional",
"selectors",
"and",
"extension",
"."
] | train | https://github.com/ist-dresden/composum/blob/ebc79f559f6022c935240c19102539bdfb1bd1e2/sling/core/commons/src/main/java/com/composum/sling/core/util/LinkUtil.java#L101-L105 |
OpenLiberty/open-liberty | dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/internal/HttpChannelConfig.java | HttpChannelConfig.parseLimitMessageSize | private void parseLimitMessageSize(Map<Object, Object> props) {
"""
Parse the possible configuration limit on the incoming message body.
size.
@param props
"""
Object value = props.get(HttpConfigConstants.PROPNAME_MSG_SIZE_LIMIT);
if (null != value) {
try {
this.limitMessageSize = convertLong(value);
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Config: Message size limit is " + getMessageSizeLimit());
}
} catch (NumberFormatException nfe) {
FFDCFilter.processException(nfe, getClass().getName() + ".parseLimitMessageSize", "1");
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Config: Invalid message size limit; " + value);
}
}
}
} | java | private void parseLimitMessageSize(Map<Object, Object> props) {
Object value = props.get(HttpConfigConstants.PROPNAME_MSG_SIZE_LIMIT);
if (null != value) {
try {
this.limitMessageSize = convertLong(value);
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Config: Message size limit is " + getMessageSizeLimit());
}
} catch (NumberFormatException nfe) {
FFDCFilter.processException(nfe, getClass().getName() + ".parseLimitMessageSize", "1");
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Config: Invalid message size limit; " + value);
}
}
}
} | [
"private",
"void",
"parseLimitMessageSize",
"(",
"Map",
"<",
"Object",
",",
"Object",
">",
"props",
")",
"{",
"Object",
"value",
"=",
"props",
".",
"get",
"(",
"HttpConfigConstants",
".",
"PROPNAME_MSG_SIZE_LIMIT",
")",
";",
"if",
"(",
"null",
"!=",
"value",
")",
"{",
"try",
"{",
"this",
".",
"limitMessageSize",
"=",
"convertLong",
"(",
"value",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEventEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"event",
"(",
"tc",
",",
"\"Config: Message size limit is \"",
"+",
"getMessageSizeLimit",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"NumberFormatException",
"nfe",
")",
"{",
"FFDCFilter",
".",
"processException",
"(",
"nfe",
",",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\".parseLimitMessageSize\"",
",",
"\"1\"",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEventEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"event",
"(",
"tc",
",",
"\"Config: Invalid message size limit; \"",
"+",
"value",
")",
";",
"}",
"}",
"}",
"}"
] | Parse the possible configuration limit on the incoming message body.
size.
@param props | [
"Parse",
"the",
"possible",
"configuration",
"limit",
"on",
"the",
"incoming",
"message",
"body",
".",
"size",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/internal/HttpChannelConfig.java#L886-L901 |
play1-maven-plugin/play1-maven-plugin | surefire-play-junit4/src/main/java/com/google/code/play/surefire/junit4/PlayJUnit4Provider.java | PlayJUnit4Provider.getPlayHome | private File getPlayHome( File applicationPath )
throws TestSetFailedException {
"""
Copy of AbstractPlayMojo.getPlayHome() method (with getCanonicalPath() changed to getAbsolutePath() )
"""
File targetDir = new File( applicationPath, "target" );
File playTmpDir = new File( targetDir, "play" );
File playTmpHomeDir = new File( playTmpDir, "home" );
if ( !playTmpHomeDir.exists() )
{
throw new TestSetFailedException( String.format( "Play! home directory \"%s\" does not exist",
playTmpHomeDir.getAbsolutePath() ) );
}
if ( !playTmpHomeDir.isDirectory() )
{
throw new TestSetFailedException( String.format( "Play! home directory \"%s\" is not a directory",
playTmpHomeDir.getAbsolutePath() ) );
}
// Additional check whether the temporary Play! home directory is created by this plugin
File warningFile = new File( playTmpHomeDir, "WARNING.txt" );
if ( warningFile.exists() )
{
if ( !warningFile.isFile() )
{
throw new TestSetFailedException( String.format( "Play! home directory warning file \"%s\" is not a file",
warningFile.getAbsolutePath() ) );
}
}
else
{
throw new TestSetFailedException( String.format( "Play! home directory warning file \"%s\" does not exist",
warningFile.getAbsolutePath() ) );
}
return playTmpHomeDir;
} | java | private File getPlayHome( File applicationPath )
throws TestSetFailedException
{
File targetDir = new File( applicationPath, "target" );
File playTmpDir = new File( targetDir, "play" );
File playTmpHomeDir = new File( playTmpDir, "home" );
if ( !playTmpHomeDir.exists() )
{
throw new TestSetFailedException( String.format( "Play! home directory \"%s\" does not exist",
playTmpHomeDir.getAbsolutePath() ) );
}
if ( !playTmpHomeDir.isDirectory() )
{
throw new TestSetFailedException( String.format( "Play! home directory \"%s\" is not a directory",
playTmpHomeDir.getAbsolutePath() ) );
}
// Additional check whether the temporary Play! home directory is created by this plugin
File warningFile = new File( playTmpHomeDir, "WARNING.txt" );
if ( warningFile.exists() )
{
if ( !warningFile.isFile() )
{
throw new TestSetFailedException( String.format( "Play! home directory warning file \"%s\" is not a file",
warningFile.getAbsolutePath() ) );
}
}
else
{
throw new TestSetFailedException( String.format( "Play! home directory warning file \"%s\" does not exist",
warningFile.getAbsolutePath() ) );
}
return playTmpHomeDir;
} | [
"private",
"File",
"getPlayHome",
"(",
"File",
"applicationPath",
")",
"throws",
"TestSetFailedException",
"{",
"File",
"targetDir",
"=",
"new",
"File",
"(",
"applicationPath",
",",
"\"target\"",
")",
";",
"File",
"playTmpDir",
"=",
"new",
"File",
"(",
"targetDir",
",",
"\"play\"",
")",
";",
"File",
"playTmpHomeDir",
"=",
"new",
"File",
"(",
"playTmpDir",
",",
"\"home\"",
")",
";",
"if",
"(",
"!",
"playTmpHomeDir",
".",
"exists",
"(",
")",
")",
"{",
"throw",
"new",
"TestSetFailedException",
"(",
"String",
".",
"format",
"(",
"\"Play! home directory \\\"%s\\\" does not exist\"",
",",
"playTmpHomeDir",
".",
"getAbsolutePath",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"!",
"playTmpHomeDir",
".",
"isDirectory",
"(",
")",
")",
"{",
"throw",
"new",
"TestSetFailedException",
"(",
"String",
".",
"format",
"(",
"\"Play! home directory \\\"%s\\\" is not a directory\"",
",",
"playTmpHomeDir",
".",
"getAbsolutePath",
"(",
")",
")",
")",
";",
"}",
"// Additional check whether the temporary Play! home directory is created by this plugin",
"File",
"warningFile",
"=",
"new",
"File",
"(",
"playTmpHomeDir",
",",
"\"WARNING.txt\"",
")",
";",
"if",
"(",
"warningFile",
".",
"exists",
"(",
")",
")",
"{",
"if",
"(",
"!",
"warningFile",
".",
"isFile",
"(",
")",
")",
"{",
"throw",
"new",
"TestSetFailedException",
"(",
"String",
".",
"format",
"(",
"\"Play! home directory warning file \\\"%s\\\" is not a file\"",
",",
"warningFile",
".",
"getAbsolutePath",
"(",
")",
")",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"TestSetFailedException",
"(",
"String",
".",
"format",
"(",
"\"Play! home directory warning file \\\"%s\\\" does not exist\"",
",",
"warningFile",
".",
"getAbsolutePath",
"(",
")",
")",
")",
";",
"}",
"return",
"playTmpHomeDir",
";",
"}"
] | Copy of AbstractPlayMojo.getPlayHome() method (with getCanonicalPath() changed to getAbsolutePath() ) | [
"Copy",
"of",
"AbstractPlayMojo",
".",
"getPlayHome",
"()",
"method",
"(",
"with",
"getCanonicalPath",
"()",
"changed",
"to",
"getAbsolutePath",
"()",
")"
] | train | https://github.com/play1-maven-plugin/play1-maven-plugin/blob/d5b2c29f4eb911e605a41529bf0aa0f83ec0aded/surefire-play-junit4/src/main/java/com/google/code/play/surefire/junit4/PlayJUnit4Provider.java#L134-L166 |
biojava/biojava | biojava-protein-disorder/src/main/java/org/biojava/nbio/ronn/Jronn.java | Jronn.scoresToRanges | public static Range[] scoresToRanges(float[] scores, float probability) {
"""
Convert raw scores to ranges. Gives ranges for given probability of disorder value
@param scores the raw probability of disorder scores for each residue in the sequence.
@param probability the cut off threshold. Include all residues with the probability of disorder greater then this value
@return the array of ranges if there are any residues predicted to have the
probability of disorder greater then {@code probability}, null otherwise.
"""
assert scores!=null && scores.length>0;
assert probability>0 && probability<1;
int count=0;
int regionLen=0;
List<Range> ranges = new ArrayList<Range>();
for(float score: scores) {
count++;
// Round to 2 decimal points before comparison
score = (float) (Math.round(score*100.0)/100.0);
if(score>probability) {
regionLen++;
} else {
if(regionLen>0) {
ranges.add(new Range(count-regionLen, count-1,score));
}
regionLen=0;
}
}
// In case of the range to boundary runs to the very end of the sequence
if(regionLen>1) {
ranges.add(new Range(count-regionLen+1, count,scores[scores.length-1]));
}
return ranges.toArray(new Range[ranges.size()]);
} | java | public static Range[] scoresToRanges(float[] scores, float probability) {
assert scores!=null && scores.length>0;
assert probability>0 && probability<1;
int count=0;
int regionLen=0;
List<Range> ranges = new ArrayList<Range>();
for(float score: scores) {
count++;
// Round to 2 decimal points before comparison
score = (float) (Math.round(score*100.0)/100.0);
if(score>probability) {
regionLen++;
} else {
if(regionLen>0) {
ranges.add(new Range(count-regionLen, count-1,score));
}
regionLen=0;
}
}
// In case of the range to boundary runs to the very end of the sequence
if(regionLen>1) {
ranges.add(new Range(count-regionLen+1, count,scores[scores.length-1]));
}
return ranges.toArray(new Range[ranges.size()]);
} | [
"public",
"static",
"Range",
"[",
"]",
"scoresToRanges",
"(",
"float",
"[",
"]",
"scores",
",",
"float",
"probability",
")",
"{",
"assert",
"scores",
"!=",
"null",
"&&",
"scores",
".",
"length",
">",
"0",
";",
"assert",
"probability",
">",
"0",
"&&",
"probability",
"<",
"1",
";",
"int",
"count",
"=",
"0",
";",
"int",
"regionLen",
"=",
"0",
";",
"List",
"<",
"Range",
">",
"ranges",
"=",
"new",
"ArrayList",
"<",
"Range",
">",
"(",
")",
";",
"for",
"(",
"float",
"score",
":",
"scores",
")",
"{",
"count",
"++",
";",
"// Round to 2 decimal points before comparison",
"score",
"=",
"(",
"float",
")",
"(",
"Math",
".",
"round",
"(",
"score",
"*",
"100.0",
")",
"/",
"100.0",
")",
";",
"if",
"(",
"score",
">",
"probability",
")",
"{",
"regionLen",
"++",
";",
"}",
"else",
"{",
"if",
"(",
"regionLen",
">",
"0",
")",
"{",
"ranges",
".",
"add",
"(",
"new",
"Range",
"(",
"count",
"-",
"regionLen",
",",
"count",
"-",
"1",
",",
"score",
")",
")",
";",
"}",
"regionLen",
"=",
"0",
";",
"}",
"}",
"// In case of the range to boundary runs to the very end of the sequence",
"if",
"(",
"regionLen",
">",
"1",
")",
"{",
"ranges",
".",
"add",
"(",
"new",
"Range",
"(",
"count",
"-",
"regionLen",
"+",
"1",
",",
"count",
",",
"scores",
"[",
"scores",
".",
"length",
"-",
"1",
"]",
")",
")",
";",
"}",
"return",
"ranges",
".",
"toArray",
"(",
"new",
"Range",
"[",
"ranges",
".",
"size",
"(",
")",
"]",
")",
";",
"}"
] | Convert raw scores to ranges. Gives ranges for given probability of disorder value
@param scores the raw probability of disorder scores for each residue in the sequence.
@param probability the cut off threshold. Include all residues with the probability of disorder greater then this value
@return the array of ranges if there are any residues predicted to have the
probability of disorder greater then {@code probability}, null otherwise. | [
"Convert",
"raw",
"scores",
"to",
"ranges",
".",
"Gives",
"ranges",
"for",
"given",
"probability",
"of",
"disorder",
"value"
] | train | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-protein-disorder/src/main/java/org/biojava/nbio/ronn/Jronn.java#L212-L238 |
thrau/jarchivelib | src/main/java/org/rauschig/jarchivelib/CommonsArchiver.java | CommonsArchiver.createNewArchiveFile | protected File createNewArchiveFile(String archive, String extension, File destination) throws IOException {
"""
Creates a new File in the given destination. The resulting name will always be "archive"."fileExtension". If the
archive name parameter already ends with the given file name extension, it is not additionally appended.
@param archive the name of the archive
@param extension the file extension (e.g. ".tar")
@param destination the parent path
@return the newly created file
@throws IOException if an I/O error occurred while creating the file
"""
if (!archive.endsWith(extension)) {
archive += extension;
}
File file = new File(destination, archive);
file.createNewFile();
return file;
} | java | protected File createNewArchiveFile(String archive, String extension, File destination) throws IOException {
if (!archive.endsWith(extension)) {
archive += extension;
}
File file = new File(destination, archive);
file.createNewFile();
return file;
} | [
"protected",
"File",
"createNewArchiveFile",
"(",
"String",
"archive",
",",
"String",
"extension",
",",
"File",
"destination",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"archive",
".",
"endsWith",
"(",
"extension",
")",
")",
"{",
"archive",
"+=",
"extension",
";",
"}",
"File",
"file",
"=",
"new",
"File",
"(",
"destination",
",",
"archive",
")",
";",
"file",
".",
"createNewFile",
"(",
")",
";",
"return",
"file",
";",
"}"
] | Creates a new File in the given destination. The resulting name will always be "archive"."fileExtension". If the
archive name parameter already ends with the given file name extension, it is not additionally appended.
@param archive the name of the archive
@param extension the file extension (e.g. ".tar")
@param destination the parent path
@return the newly created file
@throws IOException if an I/O error occurred while creating the file | [
"Creates",
"a",
"new",
"File",
"in",
"the",
"given",
"destination",
".",
"The",
"resulting",
"name",
"will",
"always",
"be",
"archive",
".",
"fileExtension",
".",
"If",
"the",
"archive",
"name",
"parameter",
"already",
"ends",
"with",
"the",
"given",
"file",
"name",
"extension",
"it",
"is",
"not",
"additionally",
"appended",
"."
] | train | https://github.com/thrau/jarchivelib/blob/8afee5124c588f589306796985b722d63572bbfa/src/main/java/org/rauschig/jarchivelib/CommonsArchiver.java#L195-L204 |
sarl/sarl | main/internalmaven/sarl-maven-plugin/src/main/java/io/sarl/maven/compiler/MavenHelper.java | MavenHelper.toXpp3Dom | @SuppressWarnings("static-method")
public Xpp3Dom toXpp3Dom(String content, Log logger) {
"""
Parse the given string for extracting an XML tree.
@param content the text to parse.
@param logger the logger to use for printing out the parsing errors. May be {@code null}.
@return the XML tree, or {@code null} if empty.
@since 0.8
"""
if (content != null && !content.isEmpty()) {
try (StringReader sr = new StringReader(content)) {
return Xpp3DomBuilder.build(sr);
} catch (Exception exception) {
if (logger != null) {
logger.debug(exception);
}
}
}
return null;
} | java | @SuppressWarnings("static-method")
public Xpp3Dom toXpp3Dom(String content, Log logger) {
if (content != null && !content.isEmpty()) {
try (StringReader sr = new StringReader(content)) {
return Xpp3DomBuilder.build(sr);
} catch (Exception exception) {
if (logger != null) {
logger.debug(exception);
}
}
}
return null;
} | [
"@",
"SuppressWarnings",
"(",
"\"static-method\"",
")",
"public",
"Xpp3Dom",
"toXpp3Dom",
"(",
"String",
"content",
",",
"Log",
"logger",
")",
"{",
"if",
"(",
"content",
"!=",
"null",
"&&",
"!",
"content",
".",
"isEmpty",
"(",
")",
")",
"{",
"try",
"(",
"StringReader",
"sr",
"=",
"new",
"StringReader",
"(",
"content",
")",
")",
"{",
"return",
"Xpp3DomBuilder",
".",
"build",
"(",
"sr",
")",
";",
"}",
"catch",
"(",
"Exception",
"exception",
")",
"{",
"if",
"(",
"logger",
"!=",
"null",
")",
"{",
"logger",
".",
"debug",
"(",
"exception",
")",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] | Parse the given string for extracting an XML tree.
@param content the text to parse.
@param logger the logger to use for printing out the parsing errors. May be {@code null}.
@return the XML tree, or {@code null} if empty.
@since 0.8 | [
"Parse",
"the",
"given",
"string",
"for",
"extracting",
"an",
"XML",
"tree",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/internalmaven/sarl-maven-plugin/src/main/java/io/sarl/maven/compiler/MavenHelper.java#L391-L403 |
radkovo/Pdf2Dom | src/main/java/org/fit/cssbox/pdf/CSSBoxTree.java | CSSBoxTree.createRectangleStyle | protected NodeData createRectangleStyle(float x, float y, float width, float height, boolean stroke, boolean fill) {
"""
Creates the style definition used for a rectangle element based on the given properties of the rectangle
@param x The X coordinate of the rectangle.
@param y The Y coordinate of the rectangle.
@param width The width of the rectangle.
@param height The height of the rectangle.
@param stroke Should there be a stroke around?
@param fill Should the rectangle be filled?
@return The resulting element style definition.
"""
float lineWidth = transformLength((float) getGraphicsState().getLineWidth());
float lw = (lineWidth < 1f) ? 1f : lineWidth;
float wcor = stroke ? lw : 0.0f;
NodeData ret = CSSFactory.createNodeData();
TermFactory tf = CSSFactory.getTermFactory();
ret.push(createDeclaration("position", tf.createIdent("absolute")));
ret.push(createDeclaration("left", tf.createLength(x, unit)));
ret.push(createDeclaration("top", tf.createLength(y, unit)));
ret.push(createDeclaration("width", tf.createLength(width - wcor, unit)));
ret.push(createDeclaration("height", tf.createLength(height - wcor, unit)));
if (stroke)
{
ret.push(createDeclaration("border-width", tf.createLength(lw, unit)));
ret.push(createDeclaration("border-style", tf.createIdent("solid")));
String color = colorString(getGraphicsState().getStrokingColor());
ret.push(createDeclaration("border-color", tf.createColor(color)));
}
if (fill)
{
String color = colorString(getGraphicsState().getNonStrokingColor());
if (color != null)
ret.push(createDeclaration("background-color", tf.createColor(color)));
}
return ret;
} | java | protected NodeData createRectangleStyle(float x, float y, float width, float height, boolean stroke, boolean fill)
{
float lineWidth = transformLength((float) getGraphicsState().getLineWidth());
float lw = (lineWidth < 1f) ? 1f : lineWidth;
float wcor = stroke ? lw : 0.0f;
NodeData ret = CSSFactory.createNodeData();
TermFactory tf = CSSFactory.getTermFactory();
ret.push(createDeclaration("position", tf.createIdent("absolute")));
ret.push(createDeclaration("left", tf.createLength(x, unit)));
ret.push(createDeclaration("top", tf.createLength(y, unit)));
ret.push(createDeclaration("width", tf.createLength(width - wcor, unit)));
ret.push(createDeclaration("height", tf.createLength(height - wcor, unit)));
if (stroke)
{
ret.push(createDeclaration("border-width", tf.createLength(lw, unit)));
ret.push(createDeclaration("border-style", tf.createIdent("solid")));
String color = colorString(getGraphicsState().getStrokingColor());
ret.push(createDeclaration("border-color", tf.createColor(color)));
}
if (fill)
{
String color = colorString(getGraphicsState().getNonStrokingColor());
if (color != null)
ret.push(createDeclaration("background-color", tf.createColor(color)));
}
return ret;
} | [
"protected",
"NodeData",
"createRectangleStyle",
"(",
"float",
"x",
",",
"float",
"y",
",",
"float",
"width",
",",
"float",
"height",
",",
"boolean",
"stroke",
",",
"boolean",
"fill",
")",
"{",
"float",
"lineWidth",
"=",
"transformLength",
"(",
"(",
"float",
")",
"getGraphicsState",
"(",
")",
".",
"getLineWidth",
"(",
")",
")",
";",
"float",
"lw",
"=",
"(",
"lineWidth",
"<",
"1f",
")",
"?",
"1f",
":",
"lineWidth",
";",
"float",
"wcor",
"=",
"stroke",
"?",
"lw",
":",
"0.0f",
";",
"NodeData",
"ret",
"=",
"CSSFactory",
".",
"createNodeData",
"(",
")",
";",
"TermFactory",
"tf",
"=",
"CSSFactory",
".",
"getTermFactory",
"(",
")",
";",
"ret",
".",
"push",
"(",
"createDeclaration",
"(",
"\"position\"",
",",
"tf",
".",
"createIdent",
"(",
"\"absolute\"",
")",
")",
")",
";",
"ret",
".",
"push",
"(",
"createDeclaration",
"(",
"\"left\"",
",",
"tf",
".",
"createLength",
"(",
"x",
",",
"unit",
")",
")",
")",
";",
"ret",
".",
"push",
"(",
"createDeclaration",
"(",
"\"top\"",
",",
"tf",
".",
"createLength",
"(",
"y",
",",
"unit",
")",
")",
")",
";",
"ret",
".",
"push",
"(",
"createDeclaration",
"(",
"\"width\"",
",",
"tf",
".",
"createLength",
"(",
"width",
"-",
"wcor",
",",
"unit",
")",
")",
")",
";",
"ret",
".",
"push",
"(",
"createDeclaration",
"(",
"\"height\"",
",",
"tf",
".",
"createLength",
"(",
"height",
"-",
"wcor",
",",
"unit",
")",
")",
")",
";",
"if",
"(",
"stroke",
")",
"{",
"ret",
".",
"push",
"(",
"createDeclaration",
"(",
"\"border-width\"",
",",
"tf",
".",
"createLength",
"(",
"lw",
",",
"unit",
")",
")",
")",
";",
"ret",
".",
"push",
"(",
"createDeclaration",
"(",
"\"border-style\"",
",",
"tf",
".",
"createIdent",
"(",
"\"solid\"",
")",
")",
")",
";",
"String",
"color",
"=",
"colorString",
"(",
"getGraphicsState",
"(",
")",
".",
"getStrokingColor",
"(",
")",
")",
";",
"ret",
".",
"push",
"(",
"createDeclaration",
"(",
"\"border-color\"",
",",
"tf",
".",
"createColor",
"(",
"color",
")",
")",
")",
";",
"}",
"if",
"(",
"fill",
")",
"{",
"String",
"color",
"=",
"colorString",
"(",
"getGraphicsState",
"(",
")",
".",
"getNonStrokingColor",
"(",
")",
")",
";",
"if",
"(",
"color",
"!=",
"null",
")",
"ret",
".",
"push",
"(",
"createDeclaration",
"(",
"\"background-color\"",
",",
"tf",
".",
"createColor",
"(",
"color",
")",
")",
")",
";",
"}",
"return",
"ret",
";",
"}"
] | Creates the style definition used for a rectangle element based on the given properties of the rectangle
@param x The X coordinate of the rectangle.
@param y The Y coordinate of the rectangle.
@param width The width of the rectangle.
@param height The height of the rectangle.
@param stroke Should there be a stroke around?
@param fill Should the rectangle be filled?
@return The resulting element style definition. | [
"Creates",
"the",
"style",
"definition",
"used",
"for",
"a",
"rectangle",
"element",
"based",
"on",
"the",
"given",
"properties",
"of",
"the",
"rectangle"
] | train | https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/cssbox/pdf/CSSBoxTree.java#L464-L494 |
crnk-project/crnk-framework | crnk-operations/src/main/java/io/crnk/operations/server/OperationsModule.java | OperationsModule.checkAccess | private void checkAccess(List<Operation> operations, QueryContext queryContext) {
"""
This is not strictly necessary, but allows to catch security issues early before accessing the individual repositories
"""
for (Operation operation : operations) {
checkAccess(operation, queryContext);
}
} | java | private void checkAccess(List<Operation> operations, QueryContext queryContext) {
for (Operation operation : operations) {
checkAccess(operation, queryContext);
}
} | [
"private",
"void",
"checkAccess",
"(",
"List",
"<",
"Operation",
">",
"operations",
",",
"QueryContext",
"queryContext",
")",
"{",
"for",
"(",
"Operation",
"operation",
":",
"operations",
")",
"{",
"checkAccess",
"(",
"operation",
",",
"queryContext",
")",
";",
"}",
"}"
] | This is not strictly necessary, but allows to catch security issues early before accessing the individual repositories | [
"This",
"is",
"not",
"strictly",
"necessary",
"but",
"allows",
"to",
"catch",
"security",
"issues",
"early",
"before",
"accessing",
"the",
"individual",
"repositories"
] | train | https://github.com/crnk-project/crnk-framework/blob/2fd3ef9a991788d46fd2e83b43c8ea37cbaf8681/crnk-operations/src/main/java/io/crnk/operations/server/OperationsModule.java#L117-L121 |
xcesco/kripton | kripton-processor/src/main/java/com/abubusoft/kripton/processor/sqlite/grammars/jql/JQLChecker.java | JQLChecker.extractPlaceHoldersFromVariableStatementAsSet | public Set<JQLPlaceHolder> extractPlaceHoldersFromVariableStatementAsSet(JQLContext jqlContext, String jql) {
"""
Extract all bind parameters and dynamic part used in query.
@param jqlContext
the jql context
@param jql
the jql
@return the sets the
"""
return extractPlaceHoldersFromVariableStatement(jqlContext, jql, new LinkedHashSet<JQLPlaceHolder>());
} | java | public Set<JQLPlaceHolder> extractPlaceHoldersFromVariableStatementAsSet(JQLContext jqlContext, String jql) {
return extractPlaceHoldersFromVariableStatement(jqlContext, jql, new LinkedHashSet<JQLPlaceHolder>());
} | [
"public",
"Set",
"<",
"JQLPlaceHolder",
">",
"extractPlaceHoldersFromVariableStatementAsSet",
"(",
"JQLContext",
"jqlContext",
",",
"String",
"jql",
")",
"{",
"return",
"extractPlaceHoldersFromVariableStatement",
"(",
"jqlContext",
",",
"jql",
",",
"new",
"LinkedHashSet",
"<",
"JQLPlaceHolder",
">",
"(",
")",
")",
";",
"}"
] | Extract all bind parameters and dynamic part used in query.
@param jqlContext
the jql context
@param jql
the jql
@return the sets the | [
"Extract",
"all",
"bind",
"parameters",
"and",
"dynamic",
"part",
"used",
"in",
"query",
"."
] | train | https://github.com/xcesco/kripton/blob/90de2c0523d39b99e81b8d38aa996898762f594a/kripton-processor/src/main/java/com/abubusoft/kripton/processor/sqlite/grammars/jql/JQLChecker.java#L846-L848 |
grails/grails-core | grails-core/src/main/groovy/grails/util/GrailsClassUtils.java | GrailsClassUtils.getPropertyValueOfNewInstance | @SuppressWarnings( {
"""
Returns the value of the specified property and type from an instance of the specified Grails class
@param clazz The name of the class which contains the property
@param propertyName The property name
@param propertyType The property type
@return The value of the property or null if none exists
""" "unchecked", "rawtypes" })
public static Object getPropertyValueOfNewInstance(Class clazz, String propertyName, Class<?> propertyType) {
// validate
if (clazz == null || !StringUtils.hasText(propertyName)) {
return null;
}
try {
return getPropertyOrStaticPropertyOrFieldValue(BeanUtils.instantiateClass(clazz), propertyName);
}
catch (BeanInstantiationException e) {
return null;
}
} | java | @SuppressWarnings({ "unchecked", "rawtypes" })
public static Object getPropertyValueOfNewInstance(Class clazz, String propertyName, Class<?> propertyType) {
// validate
if (clazz == null || !StringUtils.hasText(propertyName)) {
return null;
}
try {
return getPropertyOrStaticPropertyOrFieldValue(BeanUtils.instantiateClass(clazz), propertyName);
}
catch (BeanInstantiationException e) {
return null;
}
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unchecked\"",
",",
"\"rawtypes\"",
"}",
")",
"public",
"static",
"Object",
"getPropertyValueOfNewInstance",
"(",
"Class",
"clazz",
",",
"String",
"propertyName",
",",
"Class",
"<",
"?",
">",
"propertyType",
")",
"{",
"// validate",
"if",
"(",
"clazz",
"==",
"null",
"||",
"!",
"StringUtils",
".",
"hasText",
"(",
"propertyName",
")",
")",
"{",
"return",
"null",
";",
"}",
"try",
"{",
"return",
"getPropertyOrStaticPropertyOrFieldValue",
"(",
"BeanUtils",
".",
"instantiateClass",
"(",
"clazz",
")",
",",
"propertyName",
")",
";",
"}",
"catch",
"(",
"BeanInstantiationException",
"e",
")",
"{",
"return",
"null",
";",
"}",
"}"
] | Returns the value of the specified property and type from an instance of the specified Grails class
@param clazz The name of the class which contains the property
@param propertyName The property name
@param propertyType The property type
@return The value of the property or null if none exists | [
"Returns",
"the",
"value",
"of",
"the",
"specified",
"property",
"and",
"type",
"from",
"an",
"instance",
"of",
"the",
"specified",
"Grails",
"class"
] | train | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/GrailsClassUtils.java#L220-L233 |
jeremybrooks/jinx | src/main/java/net/jeremybrooks/jinx/api/PhotosSuggestionsApi.java | PhotosSuggestionsApi.getList | public Suggestions getList(String photoId, JinxConstants.SuggestionStatus status) throws JinxException {
"""
Return a list of suggestions for a user that are pending approval.
<br>
This method requires authentication with 'read' permission.
@param photoId (Optional) Only show suggestions for this photo.
@param status (Optional) Only show suggestions with a given status. If this is null, the default is pending.
@return object with a list of the suggestions.
@throws JinxException if required parameters are missing or if there are any errors.
@see <a href="https://www.flickr.com/services/api/flickr.photos.suggestions.getList.html">flickr.photos.suggestions.getList</a>
"""
Map<String, String> params = new TreeMap<>();
params.put("method", "flickr.photos.suggestions.getList");
if (!JinxUtils.isNullOrEmpty(photoId)) {
params.put("photo_id", photoId);
}
if (status != null) {
params.put("status_id", JinxUtils.suggestionStatusToFlickrSuggestionStatusId(status).toString());
}
return jinx.flickrPost(params, Suggestions.class);
} | java | public Suggestions getList(String photoId, JinxConstants.SuggestionStatus status) throws JinxException {
Map<String, String> params = new TreeMap<>();
params.put("method", "flickr.photos.suggestions.getList");
if (!JinxUtils.isNullOrEmpty(photoId)) {
params.put("photo_id", photoId);
}
if (status != null) {
params.put("status_id", JinxUtils.suggestionStatusToFlickrSuggestionStatusId(status).toString());
}
return jinx.flickrPost(params, Suggestions.class);
} | [
"public",
"Suggestions",
"getList",
"(",
"String",
"photoId",
",",
"JinxConstants",
".",
"SuggestionStatus",
"status",
")",
"throws",
"JinxException",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"params",
"=",
"new",
"TreeMap",
"<>",
"(",
")",
";",
"params",
".",
"put",
"(",
"\"method\"",
",",
"\"flickr.photos.suggestions.getList\"",
")",
";",
"if",
"(",
"!",
"JinxUtils",
".",
"isNullOrEmpty",
"(",
"photoId",
")",
")",
"{",
"params",
".",
"put",
"(",
"\"photo_id\"",
",",
"photoId",
")",
";",
"}",
"if",
"(",
"status",
"!=",
"null",
")",
"{",
"params",
".",
"put",
"(",
"\"status_id\"",
",",
"JinxUtils",
".",
"suggestionStatusToFlickrSuggestionStatusId",
"(",
"status",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"jinx",
".",
"flickrPost",
"(",
"params",
",",
"Suggestions",
".",
"class",
")",
";",
"}"
] | Return a list of suggestions for a user that are pending approval.
<br>
This method requires authentication with 'read' permission.
@param photoId (Optional) Only show suggestions for this photo.
@param status (Optional) Only show suggestions with a given status. If this is null, the default is pending.
@return object with a list of the suggestions.
@throws JinxException if required parameters are missing or if there are any errors.
@see <a href="https://www.flickr.com/services/api/flickr.photos.suggestions.getList.html">flickr.photos.suggestions.getList</a> | [
"Return",
"a",
"list",
"of",
"suggestions",
"for",
"a",
"user",
"that",
"are",
"pending",
"approval",
".",
"<br",
">",
"This",
"method",
"requires",
"authentication",
"with",
"read",
"permission",
"."
] | train | https://github.com/jeremybrooks/jinx/blob/ab7a4b7462d08bcbfd9b98bd3f5029771c20f6c6/src/main/java/net/jeremybrooks/jinx/api/PhotosSuggestionsApi.java#L75-L85 |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeAlignmentPatternLocator.java | QrCodeAlignmentPatternLocator.process | public boolean process(T image , QrCode qr ) {
"""
Uses the previously detected position patterns to seed the search for the alignment patterns
"""
this.qr = qr;
// this must be cleared before calling setMarker or else the distortion will be messed up
qr.alignment.reset();
reader.setImage(image);
reader.setMarker(qr);
threshold = (float)qr.threshCorner;
initializePatterns(qr);
// version 1 has no alignment patterns
if( qr.version <= 1 )
return true;
return localizePositionPatterns(QrCode.VERSION_INFO[qr.version].alignment);
} | java | public boolean process(T image , QrCode qr ) {
this.qr = qr;
// this must be cleared before calling setMarker or else the distortion will be messed up
qr.alignment.reset();
reader.setImage(image);
reader.setMarker(qr);
threshold = (float)qr.threshCorner;
initializePatterns(qr);
// version 1 has no alignment patterns
if( qr.version <= 1 )
return true;
return localizePositionPatterns(QrCode.VERSION_INFO[qr.version].alignment);
} | [
"public",
"boolean",
"process",
"(",
"T",
"image",
",",
"QrCode",
"qr",
")",
"{",
"this",
".",
"qr",
"=",
"qr",
";",
"// this must be cleared before calling setMarker or else the distortion will be messed up",
"qr",
".",
"alignment",
".",
"reset",
"(",
")",
";",
"reader",
".",
"setImage",
"(",
"image",
")",
";",
"reader",
".",
"setMarker",
"(",
"qr",
")",
";",
"threshold",
"=",
"(",
"float",
")",
"qr",
".",
"threshCorner",
";",
"initializePatterns",
"(",
"qr",
")",
";",
"// version 1 has no alignment patterns",
"if",
"(",
"qr",
".",
"version",
"<=",
"1",
")",
"return",
"true",
";",
"return",
"localizePositionPatterns",
"(",
"QrCode",
".",
"VERSION_INFO",
"[",
"qr",
".",
"version",
"]",
".",
"alignment",
")",
";",
"}"
] | Uses the previously detected position patterns to seed the search for the alignment patterns | [
"Uses",
"the",
"previously",
"detected",
"position",
"patterns",
"to",
"seed",
"the",
"search",
"for",
"the",
"alignment",
"patterns"
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeAlignmentPatternLocator.java#L56-L72 |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java | LostExceptionStackTrace.addCatchBlock | private void addCatchBlock(int start, int finish) {
"""
add a catch block info record for the catch block that is guessed to be in the range of start to finish
@param start
the handler pc
@param finish
the guessed end of the catch block
"""
CatchInfo ci = new CatchInfo(start, finish);
catchInfos.add(ci);
} | java | private void addCatchBlock(int start, int finish) {
CatchInfo ci = new CatchInfo(start, finish);
catchInfos.add(ci);
} | [
"private",
"void",
"addCatchBlock",
"(",
"int",
"start",
",",
"int",
"finish",
")",
"{",
"CatchInfo",
"ci",
"=",
"new",
"CatchInfo",
"(",
"start",
",",
"finish",
")",
";",
"catchInfos",
".",
"add",
"(",
"ci",
")",
";",
"}"
] | add a catch block info record for the catch block that is guessed to be in the range of start to finish
@param start
the handler pc
@param finish
the guessed end of the catch block | [
"add",
"a",
"catch",
"block",
"info",
"record",
"for",
"the",
"catch",
"block",
"that",
"is",
"guessed",
"to",
"be",
"in",
"the",
"range",
"of",
"start",
"to",
"finish"
] | train | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java#L423-L426 |
zxing/zxing | javase/src/main/java/com/google/zxing/client/j2se/MatrixToImageWriter.java | MatrixToImageWriter.writeToStream | public static void writeToStream(BitMatrix matrix, String format, OutputStream stream) throws IOException {
"""
Writes a {@link BitMatrix} to a stream with default configuration.
@param matrix {@link BitMatrix} to write
@param format image format
@param stream {@link OutputStream} to write image to
@throws IOException if writes to the stream fail
@see #toBufferedImage(BitMatrix)
"""
writeToStream(matrix, format, stream, DEFAULT_CONFIG);
} | java | public static void writeToStream(BitMatrix matrix, String format, OutputStream stream) throws IOException {
writeToStream(matrix, format, stream, DEFAULT_CONFIG);
} | [
"public",
"static",
"void",
"writeToStream",
"(",
"BitMatrix",
"matrix",
",",
"String",
"format",
",",
"OutputStream",
"stream",
")",
"throws",
"IOException",
"{",
"writeToStream",
"(",
"matrix",
",",
"format",
",",
"stream",
",",
"DEFAULT_CONFIG",
")",
";",
"}"
] | Writes a {@link BitMatrix} to a stream with default configuration.
@param matrix {@link BitMatrix} to write
@param format image format
@param stream {@link OutputStream} to write image to
@throws IOException if writes to the stream fail
@see #toBufferedImage(BitMatrix) | [
"Writes",
"a",
"{",
"@link",
"BitMatrix",
"}",
"to",
"a",
"stream",
"with",
"default",
"configuration",
"."
] | train | https://github.com/zxing/zxing/blob/653ac2a3beb11481eff82e7d5f2bab8a745f7fac/javase/src/main/java/com/google/zxing/client/j2se/MatrixToImageWriter.java#L143-L145 |
Azure/azure-sdk-for-java | sql/resource-manager/v2017_03_01_preview/src/main/java/com/microsoft/azure/management/sql/v2017_03_01_preview/implementation/LongTermRetentionBackupsInner.java | LongTermRetentionBackupsInner.listByServerAsync | public Observable<Page<LongTermRetentionBackupInner>> listByServerAsync(final String locationName, final String longTermRetentionServerName, final Boolean onlyLatestPerDatabase, final LongTermRetentionDatabaseState databaseState) {
"""
Lists the long term retention backups for a given server.
@param locationName The location of the database
@param longTermRetentionServerName the String value
@param onlyLatestPerDatabase Whether or not to only get the latest backup for each database.
@param databaseState Whether to query against just live databases, just deleted databases, or all databases. Possible values include: 'All', 'Live', 'Deleted'
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<LongTermRetentionBackupInner> object
"""
return listByServerWithServiceResponseAsync(locationName, longTermRetentionServerName, onlyLatestPerDatabase, databaseState)
.map(new Func1<ServiceResponse<Page<LongTermRetentionBackupInner>>, Page<LongTermRetentionBackupInner>>() {
@Override
public Page<LongTermRetentionBackupInner> call(ServiceResponse<Page<LongTermRetentionBackupInner>> response) {
return response.body();
}
});
} | java | public Observable<Page<LongTermRetentionBackupInner>> listByServerAsync(final String locationName, final String longTermRetentionServerName, final Boolean onlyLatestPerDatabase, final LongTermRetentionDatabaseState databaseState) {
return listByServerWithServiceResponseAsync(locationName, longTermRetentionServerName, onlyLatestPerDatabase, databaseState)
.map(new Func1<ServiceResponse<Page<LongTermRetentionBackupInner>>, Page<LongTermRetentionBackupInner>>() {
@Override
public Page<LongTermRetentionBackupInner> call(ServiceResponse<Page<LongTermRetentionBackupInner>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Page",
"<",
"LongTermRetentionBackupInner",
">",
">",
"listByServerAsync",
"(",
"final",
"String",
"locationName",
",",
"final",
"String",
"longTermRetentionServerName",
",",
"final",
"Boolean",
"onlyLatestPerDatabase",
",",
"final",
"LongTermRetentionDatabaseState",
"databaseState",
")",
"{",
"return",
"listByServerWithServiceResponseAsync",
"(",
"locationName",
",",
"longTermRetentionServerName",
",",
"onlyLatestPerDatabase",
",",
"databaseState",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"LongTermRetentionBackupInner",
">",
">",
",",
"Page",
"<",
"LongTermRetentionBackupInner",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Page",
"<",
"LongTermRetentionBackupInner",
">",
"call",
"(",
"ServiceResponse",
"<",
"Page",
"<",
"LongTermRetentionBackupInner",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Lists the long term retention backups for a given server.
@param locationName The location of the database
@param longTermRetentionServerName the String value
@param onlyLatestPerDatabase Whether or not to only get the latest backup for each database.
@param databaseState Whether to query against just live databases, just deleted databases, or all databases. Possible values include: 'All', 'Live', 'Deleted'
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<LongTermRetentionBackupInner> object | [
"Lists",
"the",
"long",
"term",
"retention",
"backups",
"for",
"a",
"given",
"server",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2017_03_01_preview/src/main/java/com/microsoft/azure/management/sql/v2017_03_01_preview/implementation/LongTermRetentionBackupsInner.java#L1057-L1065 |
albfernandez/itext2 | src/main/java/com/lowagie/text/pdf/TrueTypeFont.java | TrueTypeFont.readStandardString | protected String readStandardString(int length) throws IOException {
"""
Reads a <CODE>String</CODE> from the font file as bytes using the Cp1252
encoding.
@param length the length of bytes to read
@return the <CODE>String</CODE> read
@throws IOException the font file could not be read
"""
byte buf[] = new byte[length];
rf.readFully(buf);
try {
return new String(buf, WINANSI);
}
catch (Exception e) {
throw new ExceptionConverter(e);
}
} | java | protected String readStandardString(int length) throws IOException {
byte buf[] = new byte[length];
rf.readFully(buf);
try {
return new String(buf, WINANSI);
}
catch (Exception e) {
throw new ExceptionConverter(e);
}
} | [
"protected",
"String",
"readStandardString",
"(",
"int",
"length",
")",
"throws",
"IOException",
"{",
"byte",
"buf",
"[",
"]",
"=",
"new",
"byte",
"[",
"length",
"]",
";",
"rf",
".",
"readFully",
"(",
"buf",
")",
";",
"try",
"{",
"return",
"new",
"String",
"(",
"buf",
",",
"WINANSI",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"ExceptionConverter",
"(",
"e",
")",
";",
"}",
"}"
] | Reads a <CODE>String</CODE> from the font file as bytes using the Cp1252
encoding.
@param length the length of bytes to read
@return the <CODE>String</CODE> read
@throws IOException the font file could not be read | [
"Reads",
"a",
"<CODE",
">",
"String<",
"/",
"CODE",
">",
"from",
"the",
"font",
"file",
"as",
"bytes",
"using",
"the",
"Cp1252",
"encoding",
"."
] | train | https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/pdf/TrueTypeFont.java#L694-L703 |
UrielCh/ovh-java-sdk | ovh-java-sdk-me/src/main/java/net/minidev/ovh/api/ApiOvhMe.java | ApiOvhMe.bill_billId_debt_GET | public OvhDebt bill_billId_debt_GET(String billId) throws IOException {
"""
Get this object properties
REST: GET /me/bill/{billId}/debt
@param billId [required]
"""
String qPath = "/me/bill/{billId}/debt";
StringBuilder sb = path(qPath, billId);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhDebt.class);
} | java | public OvhDebt bill_billId_debt_GET(String billId) throws IOException {
String qPath = "/me/bill/{billId}/debt";
StringBuilder sb = path(qPath, billId);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhDebt.class);
} | [
"public",
"OvhDebt",
"bill_billId_debt_GET",
"(",
"String",
"billId",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/me/bill/{billId}/debt\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"billId",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhDebt",
".",
"class",
")",
";",
"}"
] | Get this object properties
REST: GET /me/bill/{billId}/debt
@param billId [required] | [
"Get",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-me/src/main/java/net/minidev/ovh/api/ApiOvhMe.java#L2907-L2912 |
rundeck/rundeck | core/src/main/java/com/dtolabs/utils/Mapper.java | Mapper.mapEntries | public static Map mapEntries(Mapper mapper, Map map, boolean includeNull) {
"""
Create a new Map by mapping all values from the original map, and mapping all keys.
@param mapper a Mapper to map both values and keys
@param map Map input
@param includeNull if true, allow null as either key or value after mapping
@return a new Map with both keys and values mapped using the Mapper
"""
HashMap h = new HashMap();
for (Object e : map.entrySet()) {
Map.Entry entry = (Map.Entry) e;
Object k = entry.getKey();
Object v = entry.getValue();
Object nk = mapper.map(k);
Object o = mapper.map(v);
if (includeNull || (o != null && nk != null)) {
h.put(nk, o);
}
}
return h;
} | java | public static Map mapEntries(Mapper mapper, Map map, boolean includeNull){
HashMap h = new HashMap();
for (Object e : map.entrySet()) {
Map.Entry entry = (Map.Entry) e;
Object k = entry.getKey();
Object v = entry.getValue();
Object nk = mapper.map(k);
Object o = mapper.map(v);
if (includeNull || (o != null && nk != null)) {
h.put(nk, o);
}
}
return h;
} | [
"public",
"static",
"Map",
"mapEntries",
"(",
"Mapper",
"mapper",
",",
"Map",
"map",
",",
"boolean",
"includeNull",
")",
"{",
"HashMap",
"h",
"=",
"new",
"HashMap",
"(",
")",
";",
"for",
"(",
"Object",
"e",
":",
"map",
".",
"entrySet",
"(",
")",
")",
"{",
"Map",
".",
"Entry",
"entry",
"=",
"(",
"Map",
".",
"Entry",
")",
"e",
";",
"Object",
"k",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"Object",
"v",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"Object",
"nk",
"=",
"mapper",
".",
"map",
"(",
"k",
")",
";",
"Object",
"o",
"=",
"mapper",
".",
"map",
"(",
"v",
")",
";",
"if",
"(",
"includeNull",
"||",
"(",
"o",
"!=",
"null",
"&&",
"nk",
"!=",
"null",
")",
")",
"{",
"h",
".",
"put",
"(",
"nk",
",",
"o",
")",
";",
"}",
"}",
"return",
"h",
";",
"}"
] | Create a new Map by mapping all values from the original map, and mapping all keys.
@param mapper a Mapper to map both values and keys
@param map Map input
@param includeNull if true, allow null as either key or value after mapping
@return a new Map with both keys and values mapped using the Mapper | [
"Create",
"a",
"new",
"Map",
"by",
"mapping",
"all",
"values",
"from",
"the",
"original",
"map",
"and",
"mapping",
"all",
"keys",
"."
] | train | https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/utils/Mapper.java#L463-L476 |
kuali/kc-s2sgen | coeus-s2sgen-impl/src/main/java/org/kuali/coeus/s2sgen/impl/generate/support/PHS398FellowshipSupplementalV3_1Generator.java | PHS398FellowshipSupplementalV3_1Generator.getSupplementationFromOtherSources | protected void getSupplementationFromOtherSources(Budget budget, Map<Integer, String> hmBudgetQuestions) {
"""
/*
This method is used to set data to SupplementationFromOtherSources XMLObject from budgetMap data for Budget
"""
if (!hmBudgetQuestions.isEmpty()) {
if (hmBudgetQuestions.get(OTHER_SUPP_SOURCE) != null) {
if (hmBudgetQuestions.get(OTHER_SUPP_SOURCE).toString().toUpperCase().equals("Y")) {
SupplementationFromOtherSources supplementationFromOtherSources = budget
.addNewSupplementationFromOtherSources();
if (hmBudgetQuestions.get(SUPP_SOURCE) != null) {
supplementationFromOtherSources.setSource(hmBudgetQuestions.get(SUPP_SOURCE).toString());
supplementationFromOtherSources.setAmount(new BigDecimal(hmBudgetQuestions.get(SUPP_FUNDING_AMT).toString()));
try {
supplementationFromOtherSources.setNumberOfMonths(new BigDecimal(hmBudgetQuestions.get(SUPP_MONTHS).toString()));
} catch (Exception ex) {
}
supplementationFromOtherSources.setType(hmBudgetQuestions.get(SUPP_TYPE).toString());
}
}
}
}
} | java | protected void getSupplementationFromOtherSources(Budget budget, Map<Integer, String> hmBudgetQuestions) {
if (!hmBudgetQuestions.isEmpty()) {
if (hmBudgetQuestions.get(OTHER_SUPP_SOURCE) != null) {
if (hmBudgetQuestions.get(OTHER_SUPP_SOURCE).toString().toUpperCase().equals("Y")) {
SupplementationFromOtherSources supplementationFromOtherSources = budget
.addNewSupplementationFromOtherSources();
if (hmBudgetQuestions.get(SUPP_SOURCE) != null) {
supplementationFromOtherSources.setSource(hmBudgetQuestions.get(SUPP_SOURCE).toString());
supplementationFromOtherSources.setAmount(new BigDecimal(hmBudgetQuestions.get(SUPP_FUNDING_AMT).toString()));
try {
supplementationFromOtherSources.setNumberOfMonths(new BigDecimal(hmBudgetQuestions.get(SUPP_MONTHS).toString()));
} catch (Exception ex) {
}
supplementationFromOtherSources.setType(hmBudgetQuestions.get(SUPP_TYPE).toString());
}
}
}
}
} | [
"protected",
"void",
"getSupplementationFromOtherSources",
"(",
"Budget",
"budget",
",",
"Map",
"<",
"Integer",
",",
"String",
">",
"hmBudgetQuestions",
")",
"{",
"if",
"(",
"!",
"hmBudgetQuestions",
".",
"isEmpty",
"(",
")",
")",
"{",
"if",
"(",
"hmBudgetQuestions",
".",
"get",
"(",
"OTHER_SUPP_SOURCE",
")",
"!=",
"null",
")",
"{",
"if",
"(",
"hmBudgetQuestions",
".",
"get",
"(",
"OTHER_SUPP_SOURCE",
")",
".",
"toString",
"(",
")",
".",
"toUpperCase",
"(",
")",
".",
"equals",
"(",
"\"Y\"",
")",
")",
"{",
"SupplementationFromOtherSources",
"supplementationFromOtherSources",
"=",
"budget",
".",
"addNewSupplementationFromOtherSources",
"(",
")",
";",
"if",
"(",
"hmBudgetQuestions",
".",
"get",
"(",
"SUPP_SOURCE",
")",
"!=",
"null",
")",
"{",
"supplementationFromOtherSources",
".",
"setSource",
"(",
"hmBudgetQuestions",
".",
"get",
"(",
"SUPP_SOURCE",
")",
".",
"toString",
"(",
")",
")",
";",
"supplementationFromOtherSources",
".",
"setAmount",
"(",
"new",
"BigDecimal",
"(",
"hmBudgetQuestions",
".",
"get",
"(",
"SUPP_FUNDING_AMT",
")",
".",
"toString",
"(",
")",
")",
")",
";",
"try",
"{",
"supplementationFromOtherSources",
".",
"setNumberOfMonths",
"(",
"new",
"BigDecimal",
"(",
"hmBudgetQuestions",
".",
"get",
"(",
"SUPP_MONTHS",
")",
".",
"toString",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"}",
"supplementationFromOtherSources",
".",
"setType",
"(",
"hmBudgetQuestions",
".",
"get",
"(",
"SUPP_TYPE",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"}",
"}",
"}"
] | /*
This method is used to set data to SupplementationFromOtherSources XMLObject from budgetMap data for Budget | [
"/",
"*",
"This",
"method",
"is",
"used",
"to",
"set",
"data",
"to",
"SupplementationFromOtherSources",
"XMLObject",
"from",
"budgetMap",
"data",
"for",
"Budget"
] | train | https://github.com/kuali/kc-s2sgen/blob/2886380e1e3cb8bdd732ba99b2afa6ffc630bb37/coeus-s2sgen-impl/src/main/java/org/kuali/coeus/s2sgen/impl/generate/support/PHS398FellowshipSupplementalV3_1Generator.java#L639-L659 |
mapcode-foundation/mapcode-java | src/main/java/com/mapcode/Mapcode.java | Mapcode.convertStringToAlphabet | @Nonnull
static String convertStringToAlphabet(@Nonnull final String string, @Nullable final Alphabet alphabet) throws IllegalArgumentException {
"""
Convert a string into the same string using a different (or the same) alphabet.
@param string Any string.
@param alphabet Alphabet to convert to, may contain Unicode characters.
@return Converted mapcode.
@throws IllegalArgumentException Thrown if string has incorrect syntax or if the string cannot be encoded in
the specified alphabet.
"""
return (alphabet != null) ? Decoder.encodeUTF16(string.toUpperCase(), alphabet.getNumber()) :
string.toUpperCase();
} | java | @Nonnull
static String convertStringToAlphabet(@Nonnull final String string, @Nullable final Alphabet alphabet) throws IllegalArgumentException {
return (alphabet != null) ? Decoder.encodeUTF16(string.toUpperCase(), alphabet.getNumber()) :
string.toUpperCase();
} | [
"@",
"Nonnull",
"static",
"String",
"convertStringToAlphabet",
"(",
"@",
"Nonnull",
"final",
"String",
"string",
",",
"@",
"Nullable",
"final",
"Alphabet",
"alphabet",
")",
"throws",
"IllegalArgumentException",
"{",
"return",
"(",
"alphabet",
"!=",
"null",
")",
"?",
"Decoder",
".",
"encodeUTF16",
"(",
"string",
".",
"toUpperCase",
"(",
")",
",",
"alphabet",
".",
"getNumber",
"(",
")",
")",
":",
"string",
".",
"toUpperCase",
"(",
")",
";",
"}"
] | Convert a string into the same string using a different (or the same) alphabet.
@param string Any string.
@param alphabet Alphabet to convert to, may contain Unicode characters.
@return Converted mapcode.
@throws IllegalArgumentException Thrown if string has incorrect syntax or if the string cannot be encoded in
the specified alphabet. | [
"Convert",
"a",
"string",
"into",
"the",
"same",
"string",
"using",
"a",
"different",
"(",
"or",
"the",
"same",
")",
"alphabet",
"."
] | train | https://github.com/mapcode-foundation/mapcode-java/blob/f12d4d9fbd460472ac0fff1f702f2ac716bc0ab8/src/main/java/com/mapcode/Mapcode.java#L393-L397 |
forge/core | parser-java/api/src/main/java/org/jboss/forge/addon/parser/java/beans/FieldOperations.java | FieldOperations.removeField | public void removeField(final JavaClassSource targetClass, final Field<JavaClassSource> field) {
"""
Removes the field, including its getters and setters and updating toString()
@param targetClass The class, which field will be removed
@param field The field to be removed
"""
PropertySource<JavaClassSource> property = targetClass.getProperty(field.getName());
property.setMutable(false).setAccessible(false);
targetClass.removeProperty(property);
updateToString(targetClass);
} | java | public void removeField(final JavaClassSource targetClass, final Field<JavaClassSource> field)
{
PropertySource<JavaClassSource> property = targetClass.getProperty(field.getName());
property.setMutable(false).setAccessible(false);
targetClass.removeProperty(property);
updateToString(targetClass);
} | [
"public",
"void",
"removeField",
"(",
"final",
"JavaClassSource",
"targetClass",
",",
"final",
"Field",
"<",
"JavaClassSource",
">",
"field",
")",
"{",
"PropertySource",
"<",
"JavaClassSource",
">",
"property",
"=",
"targetClass",
".",
"getProperty",
"(",
"field",
".",
"getName",
"(",
")",
")",
";",
"property",
".",
"setMutable",
"(",
"false",
")",
".",
"setAccessible",
"(",
"false",
")",
";",
"targetClass",
".",
"removeProperty",
"(",
"property",
")",
";",
"updateToString",
"(",
"targetClass",
")",
";",
"}"
] | Removes the field, including its getters and setters and updating toString()
@param targetClass The class, which field will be removed
@param field The field to be removed | [
"Removes",
"the",
"field",
"including",
"its",
"getters",
"and",
"setters",
"and",
"updating",
"toString",
"()"
] | train | https://github.com/forge/core/blob/e140eb03bbe2b3409478ad70c86c3edbef6d9a0c/parser-java/api/src/main/java/org/jboss/forge/addon/parser/java/beans/FieldOperations.java#L39-L45 |
OpenLiberty/open-liberty | dev/com.ibm.ws.security.social/src/com/ibm/ws/security/social/twitter/TwitterTokenServices.java | TwitterTokenServices.isMissingParameter | protected boolean isMissingParameter(Map<String, String[]> requestParams, String endpoint) {
"""
Checks for required parameters depending on the endpoint type.
- oauth/access_token: Must have oauth_token and oauth_verifier parameters in order to continue
@param requestParams
@param endpoint
@return
"""
if (TwitterConstants.TWITTER_ENDPOINT_ACCESS_TOKEN.equals(endpoint)) {
// Must have oauth_token and oauth_verifier parameters in order to send request to oauth/access_token endpoint
if (!requestParams.containsKey(TwitterConstants.PARAM_OAUTH_TOKEN)) {
Tr.error(tc, "TWITTER_REQUEST_MISSING_PARAMETER", new Object[] { TwitterConstants.TWITTER_ENDPOINT_ACCESS_TOKEN, TwitterConstants.PARAM_OAUTH_TOKEN });
return true;
}
if (!requestParams.containsKey(TwitterConstants.PARAM_OAUTH_VERIFIER)) {
Tr.error(tc, "TWITTER_REQUEST_MISSING_PARAMETER", new Object[] { TwitterConstants.TWITTER_ENDPOINT_ACCESS_TOKEN, TwitterConstants.PARAM_OAUTH_VERIFIER });
return true;
}
}
return false;
} | java | protected boolean isMissingParameter(Map<String, String[]> requestParams, String endpoint) {
if (TwitterConstants.TWITTER_ENDPOINT_ACCESS_TOKEN.equals(endpoint)) {
// Must have oauth_token and oauth_verifier parameters in order to send request to oauth/access_token endpoint
if (!requestParams.containsKey(TwitterConstants.PARAM_OAUTH_TOKEN)) {
Tr.error(tc, "TWITTER_REQUEST_MISSING_PARAMETER", new Object[] { TwitterConstants.TWITTER_ENDPOINT_ACCESS_TOKEN, TwitterConstants.PARAM_OAUTH_TOKEN });
return true;
}
if (!requestParams.containsKey(TwitterConstants.PARAM_OAUTH_VERIFIER)) {
Tr.error(tc, "TWITTER_REQUEST_MISSING_PARAMETER", new Object[] { TwitterConstants.TWITTER_ENDPOINT_ACCESS_TOKEN, TwitterConstants.PARAM_OAUTH_VERIFIER });
return true;
}
}
return false;
} | [
"protected",
"boolean",
"isMissingParameter",
"(",
"Map",
"<",
"String",
",",
"String",
"[",
"]",
">",
"requestParams",
",",
"String",
"endpoint",
")",
"{",
"if",
"(",
"TwitterConstants",
".",
"TWITTER_ENDPOINT_ACCESS_TOKEN",
".",
"equals",
"(",
"endpoint",
")",
")",
"{",
"// Must have oauth_token and oauth_verifier parameters in order to send request to oauth/access_token endpoint",
"if",
"(",
"!",
"requestParams",
".",
"containsKey",
"(",
"TwitterConstants",
".",
"PARAM_OAUTH_TOKEN",
")",
")",
"{",
"Tr",
".",
"error",
"(",
"tc",
",",
"\"TWITTER_REQUEST_MISSING_PARAMETER\"",
",",
"new",
"Object",
"[",
"]",
"{",
"TwitterConstants",
".",
"TWITTER_ENDPOINT_ACCESS_TOKEN",
",",
"TwitterConstants",
".",
"PARAM_OAUTH_TOKEN",
"}",
")",
";",
"return",
"true",
";",
"}",
"if",
"(",
"!",
"requestParams",
".",
"containsKey",
"(",
"TwitterConstants",
".",
"PARAM_OAUTH_VERIFIER",
")",
")",
"{",
"Tr",
".",
"error",
"(",
"tc",
",",
"\"TWITTER_REQUEST_MISSING_PARAMETER\"",
",",
"new",
"Object",
"[",
"]",
"{",
"TwitterConstants",
".",
"TWITTER_ENDPOINT_ACCESS_TOKEN",
",",
"TwitterConstants",
".",
"PARAM_OAUTH_VERIFIER",
"}",
")",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Checks for required parameters depending on the endpoint type.
- oauth/access_token: Must have oauth_token and oauth_verifier parameters in order to continue
@param requestParams
@param endpoint
@return | [
"Checks",
"for",
"required",
"parameters",
"depending",
"on",
"the",
"endpoint",
"type",
".",
"-",
"oauth",
"/",
"access_token",
":",
"Must",
"have",
"oauth_token",
"and",
"oauth_verifier",
"parameters",
"in",
"order",
"to",
"continue"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.social/src/com/ibm/ws/security/social/twitter/TwitterTokenServices.java#L210-L223 |
apache/groovy | src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java | DefaultGroovyMethods.groupBy | public static Map groupBy(Iterable self, Object... closures) {
"""
Sorts all Iterable members into (sub)groups determined by the supplied
mapping closures. Each closure should return the key that this item
should be grouped by. The returned LinkedHashMap will have an entry for each
distinct 'key path' returned from the closures, with each value being a list
of items for that 'group path'.
Example usage:
<pre class="groovyTestCase">def result = [1,2,3,4,5,6].groupBy({ it % 2 }, { it {@code <} 4 })
assert result == [1:[(true):[1, 3], (false):[5]], 0:[(true):[2], (false):[4, 6]]]</pre>
Another example:
<pre>def sql = groovy.sql.Sql.newInstance(/* ... */)
def data = sql.rows("SELECT * FROM a_table").groupBy({ it.column1 }, { it.column2 }, { it.column3 })
if (data.val1.val2.val3) {
// there exists a record where:
// a_table.column1 == val1
// a_table.column2 == val2, and
// a_table.column3 == val3
} else {
// there is no such record
}</pre>
If an empty array of closures is supplied the IDENTITY Closure will be used.
@param self a collection to group
@param closures an array of closures, each mapping entries on keys
@return a new Map grouped by keys on each criterion
@since 2.2.0
@see Closure#IDENTITY
"""
final Closure head = closures.length == 0 ? Closure.IDENTITY : (Closure) closures[0];
@SuppressWarnings("unchecked")
Map<Object, List> first = groupBy(self, head);
if (closures.length < 2)
return first;
final Object[] tail = new Object[closures.length - 1];
System.arraycopy(closures, 1, tail, 0, closures.length - 1); // Arrays.copyOfRange only since JDK 1.6
// inject([:]) { a,e {@code ->} a {@code <<} [(e.key): e.value.groupBy(tail)] }
Map<Object, Map> acc = new LinkedHashMap<Object, Map>();
for (Map.Entry<Object, List> item : first.entrySet()) {
acc.put(item.getKey(), groupBy((Iterable)item.getValue(), tail));
}
return acc;
} | java | public static Map groupBy(Iterable self, Object... closures) {
final Closure head = closures.length == 0 ? Closure.IDENTITY : (Closure) closures[0];
@SuppressWarnings("unchecked")
Map<Object, List> first = groupBy(self, head);
if (closures.length < 2)
return first;
final Object[] tail = new Object[closures.length - 1];
System.arraycopy(closures, 1, tail, 0, closures.length - 1); // Arrays.copyOfRange only since JDK 1.6
// inject([:]) { a,e {@code ->} a {@code <<} [(e.key): e.value.groupBy(tail)] }
Map<Object, Map> acc = new LinkedHashMap<Object, Map>();
for (Map.Entry<Object, List> item : first.entrySet()) {
acc.put(item.getKey(), groupBy((Iterable)item.getValue(), tail));
}
return acc;
} | [
"public",
"static",
"Map",
"groupBy",
"(",
"Iterable",
"self",
",",
"Object",
"...",
"closures",
")",
"{",
"final",
"Closure",
"head",
"=",
"closures",
".",
"length",
"==",
"0",
"?",
"Closure",
".",
"IDENTITY",
":",
"(",
"Closure",
")",
"closures",
"[",
"0",
"]",
";",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"Map",
"<",
"Object",
",",
"List",
">",
"first",
"=",
"groupBy",
"(",
"self",
",",
"head",
")",
";",
"if",
"(",
"closures",
".",
"length",
"<",
"2",
")",
"return",
"first",
";",
"final",
"Object",
"[",
"]",
"tail",
"=",
"new",
"Object",
"[",
"closures",
".",
"length",
"-",
"1",
"]",
";",
"System",
".",
"arraycopy",
"(",
"closures",
",",
"1",
",",
"tail",
",",
"0",
",",
"closures",
".",
"length",
"-",
"1",
")",
";",
"// Arrays.copyOfRange only since JDK 1.6",
"// inject([:]) { a,e {@code ->} a {@code <<} [(e.key): e.value.groupBy(tail)] }",
"Map",
"<",
"Object",
",",
"Map",
">",
"acc",
"=",
"new",
"LinkedHashMap",
"<",
"Object",
",",
"Map",
">",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Object",
",",
"List",
">",
"item",
":",
"first",
".",
"entrySet",
"(",
")",
")",
"{",
"acc",
".",
"put",
"(",
"item",
".",
"getKey",
"(",
")",
",",
"groupBy",
"(",
"(",
"Iterable",
")",
"item",
".",
"getValue",
"(",
")",
",",
"tail",
")",
")",
";",
"}",
"return",
"acc",
";",
"}"
] | Sorts all Iterable members into (sub)groups determined by the supplied
mapping closures. Each closure should return the key that this item
should be grouped by. The returned LinkedHashMap will have an entry for each
distinct 'key path' returned from the closures, with each value being a list
of items for that 'group path'.
Example usage:
<pre class="groovyTestCase">def result = [1,2,3,4,5,6].groupBy({ it % 2 }, { it {@code <} 4 })
assert result == [1:[(true):[1, 3], (false):[5]], 0:[(true):[2], (false):[4, 6]]]</pre>
Another example:
<pre>def sql = groovy.sql.Sql.newInstance(/* ... */)
def data = sql.rows("SELECT * FROM a_table").groupBy({ it.column1 }, { it.column2 }, { it.column3 })
if (data.val1.val2.val3) {
// there exists a record where:
// a_table.column1 == val1
// a_table.column2 == val2, and
// a_table.column3 == val3
} else {
// there is no such record
}</pre>
If an empty array of closures is supplied the IDENTITY Closure will be used.
@param self a collection to group
@param closures an array of closures, each mapping entries on keys
@return a new Map grouped by keys on each criterion
@since 2.2.0
@see Closure#IDENTITY | [
"Sorts",
"all",
"Iterable",
"members",
"into",
"(",
"sub",
")",
"groups",
"determined",
"by",
"the",
"supplied",
"mapping",
"closures",
".",
"Each",
"closure",
"should",
"return",
"the",
"key",
"that",
"this",
"item",
"should",
"be",
"grouped",
"by",
".",
"The",
"returned",
"LinkedHashMap",
"will",
"have",
"an",
"entry",
"for",
"each",
"distinct",
"key",
"path",
"returned",
"from",
"the",
"closures",
"with",
"each",
"value",
"being",
"a",
"list",
"of",
"items",
"for",
"that",
"group",
"path",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L5583-L5601 |
operasoftware/operaprestodriver | src/com/opera/core/systems/OperaDesktopDriver.java | OperaDesktopDriver.keyPress | public void keyPress(String key, List<ModifierPressed> modifiers) {
"""
Press Key with modifiers held down.
@param key key to press
@param modifiers modifiers held
"""
systemInputManager.keyPress(key, modifiers);
} | java | public void keyPress(String key, List<ModifierPressed> modifiers) {
systemInputManager.keyPress(key, modifiers);
} | [
"public",
"void",
"keyPress",
"(",
"String",
"key",
",",
"List",
"<",
"ModifierPressed",
">",
"modifiers",
")",
"{",
"systemInputManager",
".",
"keyPress",
"(",
"key",
",",
"modifiers",
")",
";",
"}"
] | Press Key with modifiers held down.
@param key key to press
@param modifiers modifiers held | [
"Press",
"Key",
"with",
"modifiers",
"held",
"down",
"."
] | train | https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/OperaDesktopDriver.java#L600-L602 |
hazelcast/hazelcast | hazelcast/src/main/java/com/hazelcast/map/impl/MapKeyLoader.java | MapKeyLoader.trackLoading | public void trackLoading(boolean lastBatch, Throwable exception) {
"""
Advances the state of this map key loader and sets the {@link #keyLoadFinished}
result if the {@code lastBatch} is {@code true}.
<p>
If there was an exception during key loading, you may pass it as the
{@code exception} paramter and it will be set as the result of the future.
@param lastBatch if the last key batch was sent
@param exception an exception that occurred during key loading
"""
if (lastBatch) {
state.nextOrStay(State.LOADED);
if (exception != null) {
keyLoadFinished.setResult(exception);
} else {
keyLoadFinished.setResult(true);
}
} else if (state.is(State.LOADED)) {
state.next(State.LOADING);
}
} | java | public void trackLoading(boolean lastBatch, Throwable exception) {
if (lastBatch) {
state.nextOrStay(State.LOADED);
if (exception != null) {
keyLoadFinished.setResult(exception);
} else {
keyLoadFinished.setResult(true);
}
} else if (state.is(State.LOADED)) {
state.next(State.LOADING);
}
} | [
"public",
"void",
"trackLoading",
"(",
"boolean",
"lastBatch",
",",
"Throwable",
"exception",
")",
"{",
"if",
"(",
"lastBatch",
")",
"{",
"state",
".",
"nextOrStay",
"(",
"State",
".",
"LOADED",
")",
";",
"if",
"(",
"exception",
"!=",
"null",
")",
"{",
"keyLoadFinished",
".",
"setResult",
"(",
"exception",
")",
";",
"}",
"else",
"{",
"keyLoadFinished",
".",
"setResult",
"(",
"true",
")",
";",
"}",
"}",
"else",
"if",
"(",
"state",
".",
"is",
"(",
"State",
".",
"LOADED",
")",
")",
"{",
"state",
".",
"next",
"(",
"State",
".",
"LOADING",
")",
";",
"}",
"}"
] | Advances the state of this map key loader and sets the {@link #keyLoadFinished}
result if the {@code lastBatch} is {@code true}.
<p>
If there was an exception during key loading, you may pass it as the
{@code exception} paramter and it will be set as the result of the future.
@param lastBatch if the last key batch was sent
@param exception an exception that occurred during key loading | [
"Advances",
"the",
"state",
"of",
"this",
"map",
"key",
"loader",
"and",
"sets",
"the",
"{",
"@link",
"#keyLoadFinished",
"}",
"result",
"if",
"the",
"{",
"@code",
"lastBatch",
"}",
"is",
"{",
"@code",
"true",
"}",
".",
"<p",
">",
"If",
"there",
"was",
"an",
"exception",
"during",
"key",
"loading",
"you",
"may",
"pass",
"it",
"as",
"the",
"{",
"@code",
"exception",
"}",
"paramter",
"and",
"it",
"will",
"be",
"set",
"as",
"the",
"result",
"of",
"the",
"future",
"."
] | train | https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/map/impl/MapKeyLoader.java#L346-L357 |
Azure/azure-sdk-for-java | sql/resource-manager/v2017_10_01_preview/src/main/java/com/microsoft/azure/management/sql/v2017_10_01_preview/implementation/TdeCertificatesInner.java | TdeCertificatesInner.createAsync | public Observable<Void> createAsync(String resourceGroupName, String serverName, TdeCertificateInner parameters) {
"""
Creates a TDE certificate for a given server.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param parameters The requested TDE certificate to be created or updated.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request
"""
return createWithServiceResponseAsync(resourceGroupName, serverName, parameters).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | java | public Observable<Void> createAsync(String resourceGroupName, String serverName, TdeCertificateInner parameters) {
return createWithServiceResponseAsync(resourceGroupName, serverName, parameters).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Void",
">",
"createAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"TdeCertificateInner",
"parameters",
")",
"{",
"return",
"createWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
",",
"parameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Void",
">",
",",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
"ServiceResponse",
"<",
"Void",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Creates a TDE certificate for a given server.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param parameters The requested TDE certificate to be created or updated.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request | [
"Creates",
"a",
"TDE",
"certificate",
"for",
"a",
"given",
"server",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2017_10_01_preview/src/main/java/com/microsoft/azure/management/sql/v2017_10_01_preview/implementation/TdeCertificatesInner.java#L103-L110 |
liferay/com-liferay-commerce | commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPAttachmentFileEntryPersistenceImpl.java | CPAttachmentFileEntryPersistenceImpl.countByC_C_F | @Override
public int countByC_C_F(long classNameId, long classPK, long fileEntryId) {
"""
Returns the number of cp attachment file entries where classNameId = ? and classPK = ? and fileEntryId = ?.
@param classNameId the class name ID
@param classPK the class pk
@param fileEntryId the file entry ID
@return the number of matching cp attachment file entries
"""
FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C_F;
Object[] finderArgs = new Object[] { classNameId, classPK, fileEntryId };
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(4);
query.append(_SQL_COUNT_CPATTACHMENTFILEENTRY_WHERE);
query.append(_FINDER_COLUMN_C_C_F_CLASSNAMEID_2);
query.append(_FINDER_COLUMN_C_C_F_CLASSPK_2);
query.append(_FINDER_COLUMN_C_C_F_FILEENTRYID_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(classNameId);
qPos.add(classPK);
qPos.add(fileEntryId);
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
} | java | @Override
public int countByC_C_F(long classNameId, long classPK, long fileEntryId) {
FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C_F;
Object[] finderArgs = new Object[] { classNameId, classPK, fileEntryId };
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler query = new StringBundler(4);
query.append(_SQL_COUNT_CPATTACHMENTFILEENTRY_WHERE);
query.append(_FINDER_COLUMN_C_C_F_CLASSNAMEID_2);
query.append(_FINDER_COLUMN_C_C_F_CLASSPK_2);
query.append(_FINDER_COLUMN_C_C_F_FILEENTRYID_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(classNameId);
qPos.add(classPK);
qPos.add(fileEntryId);
count = (Long)q.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
}
finally {
closeSession(session);
}
}
return count.intValue();
} | [
"@",
"Override",
"public",
"int",
"countByC_C_F",
"(",
"long",
"classNameId",
",",
"long",
"classPK",
",",
"long",
"fileEntryId",
")",
"{",
"FinderPath",
"finderPath",
"=",
"FINDER_PATH_COUNT_BY_C_C_F",
";",
"Object",
"[",
"]",
"finderArgs",
"=",
"new",
"Object",
"[",
"]",
"{",
"classNameId",
",",
"classPK",
",",
"fileEntryId",
"}",
";",
"Long",
"count",
"=",
"(",
"Long",
")",
"finderCache",
".",
"getResult",
"(",
"finderPath",
",",
"finderArgs",
",",
"this",
")",
";",
"if",
"(",
"count",
"==",
"null",
")",
"{",
"StringBundler",
"query",
"=",
"new",
"StringBundler",
"(",
"4",
")",
";",
"query",
".",
"append",
"(",
"_SQL_COUNT_CPATTACHMENTFILEENTRY_WHERE",
")",
";",
"query",
".",
"append",
"(",
"_FINDER_COLUMN_C_C_F_CLASSNAMEID_2",
")",
";",
"query",
".",
"append",
"(",
"_FINDER_COLUMN_C_C_F_CLASSPK_2",
")",
";",
"query",
".",
"append",
"(",
"_FINDER_COLUMN_C_C_F_FILEENTRYID_2",
")",
";",
"String",
"sql",
"=",
"query",
".",
"toString",
"(",
")",
";",
"Session",
"session",
"=",
"null",
";",
"try",
"{",
"session",
"=",
"openSession",
"(",
")",
";",
"Query",
"q",
"=",
"session",
".",
"createQuery",
"(",
"sql",
")",
";",
"QueryPos",
"qPos",
"=",
"QueryPos",
".",
"getInstance",
"(",
"q",
")",
";",
"qPos",
".",
"add",
"(",
"classNameId",
")",
";",
"qPos",
".",
"add",
"(",
"classPK",
")",
";",
"qPos",
".",
"add",
"(",
"fileEntryId",
")",
";",
"count",
"=",
"(",
"Long",
")",
"q",
".",
"uniqueResult",
"(",
")",
";",
"finderCache",
".",
"putResult",
"(",
"finderPath",
",",
"finderArgs",
",",
"count",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"finderCache",
".",
"removeResult",
"(",
"finderPath",
",",
"finderArgs",
")",
";",
"throw",
"processException",
"(",
"e",
")",
";",
"}",
"finally",
"{",
"closeSession",
"(",
"session",
")",
";",
"}",
"}",
"return",
"count",
".",
"intValue",
"(",
")",
";",
"}"
] | Returns the number of cp attachment file entries where classNameId = ? and classPK = ? and fileEntryId = ?.
@param classNameId the class name ID
@param classPK the class pk
@param fileEntryId the file entry ID
@return the number of matching cp attachment file entries | [
"Returns",
"the",
"number",
"of",
"cp",
"attachment",
"file",
"entries",
"where",
"classNameId",
"=",
"?",
";",
"and",
"classPK",
"=",
"?",
";",
"and",
"fileEntryId",
"=",
"?",
";",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPAttachmentFileEntryPersistenceImpl.java#L2802-L2853 |
Javacord/Javacord | javacord-core/src/main/java/org/javacord/core/entity/server/ServerImpl.java | ServerImpl.getOrCreateServerVoiceChannel | public ServerVoiceChannel getOrCreateServerVoiceChannel(JsonNode data) {
"""
Gets or creates a server voice channel.
@param data The json data of the channel.
@return The server voice channel.
"""
long id = Long.parseLong(data.get("id").asText());
ChannelType type = ChannelType.fromId(data.get("type").asInt());
synchronized (this) {
if (type == ChannelType.SERVER_VOICE_CHANNEL) {
return getVoiceChannelById(id).orElseGet(() -> new ServerVoiceChannelImpl(api, this, data));
}
}
// Invalid channel type
return null;
} | java | public ServerVoiceChannel getOrCreateServerVoiceChannel(JsonNode data) {
long id = Long.parseLong(data.get("id").asText());
ChannelType type = ChannelType.fromId(data.get("type").asInt());
synchronized (this) {
if (type == ChannelType.SERVER_VOICE_CHANNEL) {
return getVoiceChannelById(id).orElseGet(() -> new ServerVoiceChannelImpl(api, this, data));
}
}
// Invalid channel type
return null;
} | [
"public",
"ServerVoiceChannel",
"getOrCreateServerVoiceChannel",
"(",
"JsonNode",
"data",
")",
"{",
"long",
"id",
"=",
"Long",
".",
"parseLong",
"(",
"data",
".",
"get",
"(",
"\"id\"",
")",
".",
"asText",
"(",
")",
")",
";",
"ChannelType",
"type",
"=",
"ChannelType",
".",
"fromId",
"(",
"data",
".",
"get",
"(",
"\"type\"",
")",
".",
"asInt",
"(",
")",
")",
";",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"type",
"==",
"ChannelType",
".",
"SERVER_VOICE_CHANNEL",
")",
"{",
"return",
"getVoiceChannelById",
"(",
"id",
")",
".",
"orElseGet",
"(",
"(",
")",
"->",
"new",
"ServerVoiceChannelImpl",
"(",
"api",
",",
"this",
",",
"data",
")",
")",
";",
"}",
"}",
"// Invalid channel type",
"return",
"null",
";",
"}"
] | Gets or creates a server voice channel.
@param data The json data of the channel.
@return The server voice channel. | [
"Gets",
"or",
"creates",
"a",
"server",
"voice",
"channel",
"."
] | train | https://github.com/Javacord/Javacord/blob/915aad084dc5e863284267529d0dccd625fc6886/javacord-core/src/main/java/org/javacord/core/entity/server/ServerImpl.java#L637-L647 |
hypercube1024/firefly | firefly-common/src/main/java/com/firefly/utils/io/BufferUtils.java | BufferUtils.toBuffer | public static ByteBuffer toBuffer(byte[] array) {
"""
Create a new ByteBuffer using provided byte array.
@param array the byte array to back buffer with.
@return ByteBuffer with provided byte array, in flush mode
"""
if (array == null)
return EMPTY_BUFFER;
return toBuffer(array, 0, array.length);
} | java | public static ByteBuffer toBuffer(byte[] array) {
if (array == null)
return EMPTY_BUFFER;
return toBuffer(array, 0, array.length);
} | [
"public",
"static",
"ByteBuffer",
"toBuffer",
"(",
"byte",
"[",
"]",
"array",
")",
"{",
"if",
"(",
"array",
"==",
"null",
")",
"return",
"EMPTY_BUFFER",
";",
"return",
"toBuffer",
"(",
"array",
",",
"0",
",",
"array",
".",
"length",
")",
";",
"}"
] | Create a new ByteBuffer using provided byte array.
@param array the byte array to back buffer with.
@return ByteBuffer with provided byte array, in flush mode | [
"Create",
"a",
"new",
"ByteBuffer",
"using",
"provided",
"byte",
"array",
"."
] | train | https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/io/BufferUtils.java#L795-L799 |
googleads/googleads-java-lib | modules/ads_lib/src/main/java/com/google/api/ads/common/lib/utils/CsvFiles.java | CsvFiles.writeCsv | public static void writeCsv(List<String[]> csvData, String fileName) throws IOException {
"""
Writes the CSV data located in {@code csvData} to the file located at
{@code fileName}.
@param csvData the CSV data including the header
@param fileName the file to write the CSV data to
@throws IOException if there was an error writing to the file
@throws NullPointerException if {@code csvData == null} or {@code fileName == null}
"""
Preconditions.checkNotNull(csvData, "Null CSV data");
Preconditions.checkNotNull(fileName, "Null file name");
CSVWriter writer = null;
try {
writer = new CSVWriter(Files.newWriter(new File(fileName), StandardCharsets.UTF_8));
for (String[] line : csvData) {
writer.writeNext(line);
}
} finally {
if (writer != null) {
writer.close();
}
}
} | java | public static void writeCsv(List<String[]> csvData, String fileName) throws IOException {
Preconditions.checkNotNull(csvData, "Null CSV data");
Preconditions.checkNotNull(fileName, "Null file name");
CSVWriter writer = null;
try {
writer = new CSVWriter(Files.newWriter(new File(fileName), StandardCharsets.UTF_8));
for (String[] line : csvData) {
writer.writeNext(line);
}
} finally {
if (writer != null) {
writer.close();
}
}
} | [
"public",
"static",
"void",
"writeCsv",
"(",
"List",
"<",
"String",
"[",
"]",
">",
"csvData",
",",
"String",
"fileName",
")",
"throws",
"IOException",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"csvData",
",",
"\"Null CSV data\"",
")",
";",
"Preconditions",
".",
"checkNotNull",
"(",
"fileName",
",",
"\"Null file name\"",
")",
";",
"CSVWriter",
"writer",
"=",
"null",
";",
"try",
"{",
"writer",
"=",
"new",
"CSVWriter",
"(",
"Files",
".",
"newWriter",
"(",
"new",
"File",
"(",
"fileName",
")",
",",
"StandardCharsets",
".",
"UTF_8",
")",
")",
";",
"for",
"(",
"String",
"[",
"]",
"line",
":",
"csvData",
")",
"{",
"writer",
".",
"writeNext",
"(",
"line",
")",
";",
"}",
"}",
"finally",
"{",
"if",
"(",
"writer",
"!=",
"null",
")",
"{",
"writer",
".",
"close",
"(",
")",
";",
"}",
"}",
"}"
] | Writes the CSV data located in {@code csvData} to the file located at
{@code fileName}.
@param csvData the CSV data including the header
@param fileName the file to write the CSV data to
@throws IOException if there was an error writing to the file
@throws NullPointerException if {@code csvData == null} or {@code fileName == null} | [
"Writes",
"the",
"CSV",
"data",
"located",
"in",
"{",
"@code",
"csvData",
"}",
"to",
"the",
"file",
"located",
"at",
"{",
"@code",
"fileName",
"}",
"."
] | train | https://github.com/googleads/googleads-java-lib/blob/967957cc4f6076514e3a7926fe653e4f1f7cc9c9/modules/ads_lib/src/main/java/com/google/api/ads/common/lib/utils/CsvFiles.java#L202-L217 |
jeremiehuchet/nominatim-java-api | src/main/java/fr/dudie/nominatim/client/request/NominatimSearchRequest.java | NominatimSearchRequest.setViewBox | public void setViewBox(final double west, final double north, final double east, final double south) {
"""
Sets the preferred area to find search results;
@param west
the west bound
@param north
the north bound
@param east
the east bound
@param south
the south bound
"""
this.viewBox = new BoundingBox();
this.viewBox.setWest(west);
this.viewBox.setNorth(north);
this.viewBox.setEast(east);
this.viewBox.setSouth(south);
} | java | public void setViewBox(final double west, final double north, final double east, final double south) {
this.viewBox = new BoundingBox();
this.viewBox.setWest(west);
this.viewBox.setNorth(north);
this.viewBox.setEast(east);
this.viewBox.setSouth(south);
} | [
"public",
"void",
"setViewBox",
"(",
"final",
"double",
"west",
",",
"final",
"double",
"north",
",",
"final",
"double",
"east",
",",
"final",
"double",
"south",
")",
"{",
"this",
".",
"viewBox",
"=",
"new",
"BoundingBox",
"(",
")",
";",
"this",
".",
"viewBox",
".",
"setWest",
"(",
"west",
")",
";",
"this",
".",
"viewBox",
".",
"setNorth",
"(",
"north",
")",
";",
"this",
".",
"viewBox",
".",
"setEast",
"(",
"east",
")",
";",
"this",
".",
"viewBox",
".",
"setSouth",
"(",
"south",
")",
";",
"}"
] | Sets the preferred area to find search results;
@param west
the west bound
@param north
the north bound
@param east
the east bound
@param south
the south bound | [
"Sets",
"the",
"preferred",
"area",
"to",
"find",
"search",
"results",
";"
] | train | https://github.com/jeremiehuchet/nominatim-java-api/blob/faf3ff1003a9989eb5cc48f449b3a22c567843bf/src/main/java/fr/dudie/nominatim/client/request/NominatimSearchRequest.java#L215-L221 |
google/closure-compiler | src/com/google/javascript/jscomp/JSModuleGraph.java | JSModuleGraph.getSmallestCoveringSubtree | public JSModule getSmallestCoveringSubtree(JSModule parentTree, BitSet dependentModules) {
"""
Finds the module with the fewest transitive dependents on which all of the given modules depend
and that is a subtree of the given parent module tree.
<p>If no such subtree can be found, the parent module is returned.
<p>If multiple candidates have the same number of dependents, the module farthest down in the
total ordering of modules will be chosen.
@param parentTree module on which the result must depend
@param dependentModules indices of modules to consider
@return A module on which all of the argument modules depend
"""
checkState(!dependentModules.isEmpty());
// Candidate modules are those that all of the given dependent modules depend on, including
// themselves. The dependent module with the smallest index might be our answer, if all
// the other modules depend on it.
int minDependentModuleIndex = modules.length;
final BitSet candidates = new BitSet(modules.length);
candidates.set(0, modules.length, true);
for (int dependentIndex = dependentModules.nextSetBit(0);
dependentIndex >= 0;
dependentIndex = dependentModules.nextSetBit(dependentIndex + 1)) {
minDependentModuleIndex = Math.min(minDependentModuleIndex, dependentIndex);
candidates.and(selfPlusTransitiveDeps[dependentIndex]);
}
checkState(
!candidates.isEmpty(), "No common dependency found for %s", dependentModules);
// All candidates must have an index <= the smallest dependent module index.
// Work backwards through the candidates starting with the dependent module with the smallest
// index. For each candidate, we'll remove all of the modules it depends on from consideration,
// since they must all have larger subtrees than the one we're considering.
int parentTreeIndex = parentTree.getIndex();
// default to parent tree if we don't find anything better
int bestCandidateIndex = parentTreeIndex;
for (int candidateIndex = candidates.previousSetBit(minDependentModuleIndex);
candidateIndex >= 0;
candidateIndex = candidates.previousSetBit(candidateIndex - 1)) {
BitSet candidatePlusTransitiveDeps = selfPlusTransitiveDeps[candidateIndex];
if (candidatePlusTransitiveDeps.get(parentTreeIndex)) {
// candidate is a subtree of parentTree
candidates.andNot(candidatePlusTransitiveDeps);
if (subtreeSize[candidateIndex] < subtreeSize[bestCandidateIndex]) {
bestCandidateIndex = candidateIndex;
}
} // eliminate candidates that are not a subtree of parentTree
}
return modules[bestCandidateIndex];
} | java | public JSModule getSmallestCoveringSubtree(JSModule parentTree, BitSet dependentModules) {
checkState(!dependentModules.isEmpty());
// Candidate modules are those that all of the given dependent modules depend on, including
// themselves. The dependent module with the smallest index might be our answer, if all
// the other modules depend on it.
int minDependentModuleIndex = modules.length;
final BitSet candidates = new BitSet(modules.length);
candidates.set(0, modules.length, true);
for (int dependentIndex = dependentModules.nextSetBit(0);
dependentIndex >= 0;
dependentIndex = dependentModules.nextSetBit(dependentIndex + 1)) {
minDependentModuleIndex = Math.min(minDependentModuleIndex, dependentIndex);
candidates.and(selfPlusTransitiveDeps[dependentIndex]);
}
checkState(
!candidates.isEmpty(), "No common dependency found for %s", dependentModules);
// All candidates must have an index <= the smallest dependent module index.
// Work backwards through the candidates starting with the dependent module with the smallest
// index. For each candidate, we'll remove all of the modules it depends on from consideration,
// since they must all have larger subtrees than the one we're considering.
int parentTreeIndex = parentTree.getIndex();
// default to parent tree if we don't find anything better
int bestCandidateIndex = parentTreeIndex;
for (int candidateIndex = candidates.previousSetBit(minDependentModuleIndex);
candidateIndex >= 0;
candidateIndex = candidates.previousSetBit(candidateIndex - 1)) {
BitSet candidatePlusTransitiveDeps = selfPlusTransitiveDeps[candidateIndex];
if (candidatePlusTransitiveDeps.get(parentTreeIndex)) {
// candidate is a subtree of parentTree
candidates.andNot(candidatePlusTransitiveDeps);
if (subtreeSize[candidateIndex] < subtreeSize[bestCandidateIndex]) {
bestCandidateIndex = candidateIndex;
}
} // eliminate candidates that are not a subtree of parentTree
}
return modules[bestCandidateIndex];
} | [
"public",
"JSModule",
"getSmallestCoveringSubtree",
"(",
"JSModule",
"parentTree",
",",
"BitSet",
"dependentModules",
")",
"{",
"checkState",
"(",
"!",
"dependentModules",
".",
"isEmpty",
"(",
")",
")",
";",
"// Candidate modules are those that all of the given dependent modules depend on, including",
"// themselves. The dependent module with the smallest index might be our answer, if all",
"// the other modules depend on it.",
"int",
"minDependentModuleIndex",
"=",
"modules",
".",
"length",
";",
"final",
"BitSet",
"candidates",
"=",
"new",
"BitSet",
"(",
"modules",
".",
"length",
")",
";",
"candidates",
".",
"set",
"(",
"0",
",",
"modules",
".",
"length",
",",
"true",
")",
";",
"for",
"(",
"int",
"dependentIndex",
"=",
"dependentModules",
".",
"nextSetBit",
"(",
"0",
")",
";",
"dependentIndex",
">=",
"0",
";",
"dependentIndex",
"=",
"dependentModules",
".",
"nextSetBit",
"(",
"dependentIndex",
"+",
"1",
")",
")",
"{",
"minDependentModuleIndex",
"=",
"Math",
".",
"min",
"(",
"minDependentModuleIndex",
",",
"dependentIndex",
")",
";",
"candidates",
".",
"and",
"(",
"selfPlusTransitiveDeps",
"[",
"dependentIndex",
"]",
")",
";",
"}",
"checkState",
"(",
"!",
"candidates",
".",
"isEmpty",
"(",
")",
",",
"\"No common dependency found for %s\"",
",",
"dependentModules",
")",
";",
"// All candidates must have an index <= the smallest dependent module index.",
"// Work backwards through the candidates starting with the dependent module with the smallest",
"// index. For each candidate, we'll remove all of the modules it depends on from consideration,",
"// since they must all have larger subtrees than the one we're considering.",
"int",
"parentTreeIndex",
"=",
"parentTree",
".",
"getIndex",
"(",
")",
";",
"// default to parent tree if we don't find anything better",
"int",
"bestCandidateIndex",
"=",
"parentTreeIndex",
";",
"for",
"(",
"int",
"candidateIndex",
"=",
"candidates",
".",
"previousSetBit",
"(",
"minDependentModuleIndex",
")",
";",
"candidateIndex",
">=",
"0",
";",
"candidateIndex",
"=",
"candidates",
".",
"previousSetBit",
"(",
"candidateIndex",
"-",
"1",
")",
")",
"{",
"BitSet",
"candidatePlusTransitiveDeps",
"=",
"selfPlusTransitiveDeps",
"[",
"candidateIndex",
"]",
";",
"if",
"(",
"candidatePlusTransitiveDeps",
".",
"get",
"(",
"parentTreeIndex",
")",
")",
"{",
"// candidate is a subtree of parentTree",
"candidates",
".",
"andNot",
"(",
"candidatePlusTransitiveDeps",
")",
";",
"if",
"(",
"subtreeSize",
"[",
"candidateIndex",
"]",
"<",
"subtreeSize",
"[",
"bestCandidateIndex",
"]",
")",
"{",
"bestCandidateIndex",
"=",
"candidateIndex",
";",
"}",
"}",
"// eliminate candidates that are not a subtree of parentTree",
"}",
"return",
"modules",
"[",
"bestCandidateIndex",
"]",
";",
"}"
] | Finds the module with the fewest transitive dependents on which all of the given modules depend
and that is a subtree of the given parent module tree.
<p>If no such subtree can be found, the parent module is returned.
<p>If multiple candidates have the same number of dependents, the module farthest down in the
total ordering of modules will be chosen.
@param parentTree module on which the result must depend
@param dependentModules indices of modules to consider
@return A module on which all of the argument modules depend | [
"Finds",
"the",
"module",
"with",
"the",
"fewest",
"transitive",
"dependents",
"on",
"which",
"all",
"of",
"the",
"given",
"modules",
"depend",
"and",
"that",
"is",
"a",
"subtree",
"of",
"the",
"given",
"parent",
"module",
"tree",
"."
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/JSModuleGraph.java#L356-L395 |
google/error-prone | core/src/main/java/com/google/errorprone/bugpatterns/AbstractMustBeClosedChecker.java | AbstractMustBeClosedChecker.matchNewClassOrMethodInvocation | protected Description matchNewClassOrMethodInvocation(ExpressionTree tree, VisitorState state) {
"""
Check that constructors and methods annotated with {@link MustBeClosed} occur within the
resource variable initializer of a try-with-resources statement.
"""
Description description = checkClosed(tree, state);
if (description == NO_MATCH) {
return NO_MATCH;
}
if (AbstractReturnValueIgnored.expectedExceptionTest(tree, state)
|| MOCKITO_MATCHER.matches(state.getPath().getParentPath().getLeaf(), state)) {
return NO_MATCH;
}
return description;
} | java | protected Description matchNewClassOrMethodInvocation(ExpressionTree tree, VisitorState state) {
Description description = checkClosed(tree, state);
if (description == NO_MATCH) {
return NO_MATCH;
}
if (AbstractReturnValueIgnored.expectedExceptionTest(tree, state)
|| MOCKITO_MATCHER.matches(state.getPath().getParentPath().getLeaf(), state)) {
return NO_MATCH;
}
return description;
} | [
"protected",
"Description",
"matchNewClassOrMethodInvocation",
"(",
"ExpressionTree",
"tree",
",",
"VisitorState",
"state",
")",
"{",
"Description",
"description",
"=",
"checkClosed",
"(",
"tree",
",",
"state",
")",
";",
"if",
"(",
"description",
"==",
"NO_MATCH",
")",
"{",
"return",
"NO_MATCH",
";",
"}",
"if",
"(",
"AbstractReturnValueIgnored",
".",
"expectedExceptionTest",
"(",
"tree",
",",
"state",
")",
"||",
"MOCKITO_MATCHER",
".",
"matches",
"(",
"state",
".",
"getPath",
"(",
")",
".",
"getParentPath",
"(",
")",
".",
"getLeaf",
"(",
")",
",",
"state",
")",
")",
"{",
"return",
"NO_MATCH",
";",
"}",
"return",
"description",
";",
"}"
] | Check that constructors and methods annotated with {@link MustBeClosed} occur within the
resource variable initializer of a try-with-resources statement. | [
"Check",
"that",
"constructors",
"and",
"methods",
"annotated",
"with",
"{"
] | train | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/AbstractMustBeClosedChecker.java#L75-L85 |
lightblueseas/file-worker | src/main/java/de/alpharogroup/file/read/ReadFileExtensions.java | ReadFileExtensions.readLinesInList | public static List<String> readLinesInList(final InputStream input, final Charset encoding,
final boolean trim) throws IOException {
"""
Reads every line from the given InputStream and puts them to the List.
@param input
The InputStream from where the input comes.
@param encoding
the charset for read
@param trim
the flag trim if the lines shell be trimed.
@return The List with all lines from the file.
@throws IOException
When a io-problem occurs.
"""
// The List where the lines from the File to save.
final List<String> output = new ArrayList<>();
try (
InputStreamReader isr = encoding == null
? new InputStreamReader(input)
: new InputStreamReader(input, encoding);
BufferedReader reader = new BufferedReader(isr);)
{
// the line.
String line = null;
// read all lines from the file
do
{
line = reader.readLine();
// if null break the loop
if (line == null)
{
break;
}
if (trim)
{
line.trim();
}
// add the line to the list
output.add(line);
}
while (true);
}
// return the list with all lines from the file.
return output;
} | java | public static List<String> readLinesInList(final InputStream input, final Charset encoding,
final boolean trim) throws IOException
{
// The List where the lines from the File to save.
final List<String> output = new ArrayList<>();
try (
InputStreamReader isr = encoding == null
? new InputStreamReader(input)
: new InputStreamReader(input, encoding);
BufferedReader reader = new BufferedReader(isr);)
{
// the line.
String line = null;
// read all lines from the file
do
{
line = reader.readLine();
// if null break the loop
if (line == null)
{
break;
}
if (trim)
{
line.trim();
}
// add the line to the list
output.add(line);
}
while (true);
}
// return the list with all lines from the file.
return output;
} | [
"public",
"static",
"List",
"<",
"String",
">",
"readLinesInList",
"(",
"final",
"InputStream",
"input",
",",
"final",
"Charset",
"encoding",
",",
"final",
"boolean",
"trim",
")",
"throws",
"IOException",
"{",
"// The List where the lines from the File to save.",
"final",
"List",
"<",
"String",
">",
"output",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"try",
"(",
"InputStreamReader",
"isr",
"=",
"encoding",
"==",
"null",
"?",
"new",
"InputStreamReader",
"(",
"input",
")",
":",
"new",
"InputStreamReader",
"(",
"input",
",",
"encoding",
")",
";",
"BufferedReader",
"reader",
"=",
"new",
"BufferedReader",
"(",
"isr",
")",
";",
")",
"{",
"// the line.",
"String",
"line",
"=",
"null",
";",
"// read all lines from the file",
"do",
"{",
"line",
"=",
"reader",
".",
"readLine",
"(",
")",
";",
"// if null break the loop",
"if",
"(",
"line",
"==",
"null",
")",
"{",
"break",
";",
"}",
"if",
"(",
"trim",
")",
"{",
"line",
".",
"trim",
"(",
")",
";",
"}",
"// add the line to the list",
"output",
".",
"add",
"(",
"line",
")",
";",
"}",
"while",
"(",
"true",
")",
";",
"}",
"// return the list with all lines from the file.",
"return",
"output",
";",
"}"
] | Reads every line from the given InputStream and puts them to the List.
@param input
The InputStream from where the input comes.
@param encoding
the charset for read
@param trim
the flag trim if the lines shell be trimed.
@return The List with all lines from the file.
@throws IOException
When a io-problem occurs. | [
"Reads",
"every",
"line",
"from",
"the",
"given",
"InputStream",
"and",
"puts",
"them",
"to",
"the",
"List",
"."
] | train | https://github.com/lightblueseas/file-worker/blob/2c81de10fb5d68de64c1abc3ed64ca681ce76da8/src/main/java/de/alpharogroup/file/read/ReadFileExtensions.java#L332-L365 |
cdk/cdk | tool/sdg/src/main/java/org/openscience/cdk/layout/StructureDiagramGenerator.java | StructureDiagramGenerator.getRingSystemOfAtom | private IRingSet getRingSystemOfAtom(List ringSystems, IAtom ringAtom) {
"""
Get the ring system of which the given atom is part of
@param ringSystems a List of ring systems to be searched
@param ringAtom the ring atom to be search in the ring system.
@return the ring system the given atom is part of
"""
IRingSet ringSet = null;
for (int f = 0; f < ringSystems.size(); f++) {
ringSet = (IRingSet) ringSystems.get(f);
if (ringSet.contains(ringAtom)) {
return ringSet;
}
}
return null;
} | java | private IRingSet getRingSystemOfAtom(List ringSystems, IAtom ringAtom) {
IRingSet ringSet = null;
for (int f = 0; f < ringSystems.size(); f++) {
ringSet = (IRingSet) ringSystems.get(f);
if (ringSet.contains(ringAtom)) {
return ringSet;
}
}
return null;
} | [
"private",
"IRingSet",
"getRingSystemOfAtom",
"(",
"List",
"ringSystems",
",",
"IAtom",
"ringAtom",
")",
"{",
"IRingSet",
"ringSet",
"=",
"null",
";",
"for",
"(",
"int",
"f",
"=",
"0",
";",
"f",
"<",
"ringSystems",
".",
"size",
"(",
")",
";",
"f",
"++",
")",
"{",
"ringSet",
"=",
"(",
"IRingSet",
")",
"ringSystems",
".",
"get",
"(",
"f",
")",
";",
"if",
"(",
"ringSet",
".",
"contains",
"(",
"ringAtom",
")",
")",
"{",
"return",
"ringSet",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Get the ring system of which the given atom is part of
@param ringSystems a List of ring systems to be searched
@param ringAtom the ring atom to be search in the ring system.
@return the ring system the given atom is part of | [
"Get",
"the",
"ring",
"system",
"of",
"which",
"the",
"given",
"atom",
"is",
"part",
"of"
] | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/tool/sdg/src/main/java/org/openscience/cdk/layout/StructureDiagramGenerator.java#L2101-L2110 |
citrusframework/citrus | modules/citrus-core/src/main/java/com/consol/citrus/report/JUnitReporter.java | JUnitReporter.createReportContent | private String createReportContent(String suiteName, List<TestResult> results, ReportTemplates templates) throws IOException {
"""
Create report file for test class.
@param suiteName
@param results
@param templates
@return
"""
final StringBuilder reportDetails = new StringBuilder();
for (TestResult result: results) {
Properties detailProps = new Properties();
detailProps.put("test.class", result.getClassName());
detailProps.put("test.name", StringEscapeUtils.escapeXml(result.getTestName()));
detailProps.put("test.duration", "0.0");
if (result.isFailed()) {
detailProps.put("test.error.cause", Optional.ofNullable(result.getCause()).map(Object::getClass).map(Class::getName).orElse(result.getFailureType()));
detailProps.put("test.error.msg", StringEscapeUtils.escapeXml(result.getErrorMessage()));
detailProps.put("test.error.stackTrace", Optional.ofNullable(result.getCause()).map(cause -> {
StringWriter writer = new StringWriter();
cause.printStackTrace(new PrintWriter(writer));
return writer.toString();
}).orElse(result.getFailureStack()));
reportDetails.append(PropertyUtils.replacePropertiesInString(templates.getFailedTemplate(), detailProps));
} else {
reportDetails.append(PropertyUtils.replacePropertiesInString(templates.getSuccessTemplate(), detailProps));
}
}
Properties reportProps = new Properties();
reportProps.put("test.suite", suiteName);
reportProps.put("test.cnt", Integer.toString(results.size()));
reportProps.put("test.skipped.cnt", Long.toString(results.stream().filter(TestResult::isSkipped).count()));
reportProps.put("test.failed.cnt", Long.toString(results.stream().filter(TestResult::isFailed).count()));
reportProps.put("test.success.cnt", Long.toString(results.stream().filter(TestResult::isSuccess).count()));
reportProps.put("test.error.cnt", "0");
reportProps.put("test.duration", "0.0");
reportProps.put("tests", reportDetails.toString());
return PropertyUtils.replacePropertiesInString(templates.getReportTemplate(), reportProps);
} | java | private String createReportContent(String suiteName, List<TestResult> results, ReportTemplates templates) throws IOException {
final StringBuilder reportDetails = new StringBuilder();
for (TestResult result: results) {
Properties detailProps = new Properties();
detailProps.put("test.class", result.getClassName());
detailProps.put("test.name", StringEscapeUtils.escapeXml(result.getTestName()));
detailProps.put("test.duration", "0.0");
if (result.isFailed()) {
detailProps.put("test.error.cause", Optional.ofNullable(result.getCause()).map(Object::getClass).map(Class::getName).orElse(result.getFailureType()));
detailProps.put("test.error.msg", StringEscapeUtils.escapeXml(result.getErrorMessage()));
detailProps.put("test.error.stackTrace", Optional.ofNullable(result.getCause()).map(cause -> {
StringWriter writer = new StringWriter();
cause.printStackTrace(new PrintWriter(writer));
return writer.toString();
}).orElse(result.getFailureStack()));
reportDetails.append(PropertyUtils.replacePropertiesInString(templates.getFailedTemplate(), detailProps));
} else {
reportDetails.append(PropertyUtils.replacePropertiesInString(templates.getSuccessTemplate(), detailProps));
}
}
Properties reportProps = new Properties();
reportProps.put("test.suite", suiteName);
reportProps.put("test.cnt", Integer.toString(results.size()));
reportProps.put("test.skipped.cnt", Long.toString(results.stream().filter(TestResult::isSkipped).count()));
reportProps.put("test.failed.cnt", Long.toString(results.stream().filter(TestResult::isFailed).count()));
reportProps.put("test.success.cnt", Long.toString(results.stream().filter(TestResult::isSuccess).count()));
reportProps.put("test.error.cnt", "0");
reportProps.put("test.duration", "0.0");
reportProps.put("tests", reportDetails.toString());
return PropertyUtils.replacePropertiesInString(templates.getReportTemplate(), reportProps);
} | [
"private",
"String",
"createReportContent",
"(",
"String",
"suiteName",
",",
"List",
"<",
"TestResult",
">",
"results",
",",
"ReportTemplates",
"templates",
")",
"throws",
"IOException",
"{",
"final",
"StringBuilder",
"reportDetails",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"TestResult",
"result",
":",
"results",
")",
"{",
"Properties",
"detailProps",
"=",
"new",
"Properties",
"(",
")",
";",
"detailProps",
".",
"put",
"(",
"\"test.class\"",
",",
"result",
".",
"getClassName",
"(",
")",
")",
";",
"detailProps",
".",
"put",
"(",
"\"test.name\"",
",",
"StringEscapeUtils",
".",
"escapeXml",
"(",
"result",
".",
"getTestName",
"(",
")",
")",
")",
";",
"detailProps",
".",
"put",
"(",
"\"test.duration\"",
",",
"\"0.0\"",
")",
";",
"if",
"(",
"result",
".",
"isFailed",
"(",
")",
")",
"{",
"detailProps",
".",
"put",
"(",
"\"test.error.cause\"",
",",
"Optional",
".",
"ofNullable",
"(",
"result",
".",
"getCause",
"(",
")",
")",
".",
"map",
"(",
"Object",
"::",
"getClass",
")",
".",
"map",
"(",
"Class",
"::",
"getName",
")",
".",
"orElse",
"(",
"result",
".",
"getFailureType",
"(",
")",
")",
")",
";",
"detailProps",
".",
"put",
"(",
"\"test.error.msg\"",
",",
"StringEscapeUtils",
".",
"escapeXml",
"(",
"result",
".",
"getErrorMessage",
"(",
")",
")",
")",
";",
"detailProps",
".",
"put",
"(",
"\"test.error.stackTrace\"",
",",
"Optional",
".",
"ofNullable",
"(",
"result",
".",
"getCause",
"(",
")",
")",
".",
"map",
"(",
"cause",
"->",
"{",
"StringWriter",
"writer",
"=",
"new",
"StringWriter",
"(",
")",
";",
"cause",
".",
"printStackTrace",
"(",
"new",
"PrintWriter",
"(",
"writer",
")",
")",
";",
"return",
"writer",
".",
"toString",
"(",
")",
";",
"}",
")",
".",
"orElse",
"(",
"result",
".",
"getFailureStack",
"(",
")",
")",
")",
";",
"reportDetails",
".",
"append",
"(",
"PropertyUtils",
".",
"replacePropertiesInString",
"(",
"templates",
".",
"getFailedTemplate",
"(",
")",
",",
"detailProps",
")",
")",
";",
"}",
"else",
"{",
"reportDetails",
".",
"append",
"(",
"PropertyUtils",
".",
"replacePropertiesInString",
"(",
"templates",
".",
"getSuccessTemplate",
"(",
")",
",",
"detailProps",
")",
")",
";",
"}",
"}",
"Properties",
"reportProps",
"=",
"new",
"Properties",
"(",
")",
";",
"reportProps",
".",
"put",
"(",
"\"test.suite\"",
",",
"suiteName",
")",
";",
"reportProps",
".",
"put",
"(",
"\"test.cnt\"",
",",
"Integer",
".",
"toString",
"(",
"results",
".",
"size",
"(",
")",
")",
")",
";",
"reportProps",
".",
"put",
"(",
"\"test.skipped.cnt\"",
",",
"Long",
".",
"toString",
"(",
"results",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"TestResult",
"::",
"isSkipped",
")",
".",
"count",
"(",
")",
")",
")",
";",
"reportProps",
".",
"put",
"(",
"\"test.failed.cnt\"",
",",
"Long",
".",
"toString",
"(",
"results",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"TestResult",
"::",
"isFailed",
")",
".",
"count",
"(",
")",
")",
")",
";",
"reportProps",
".",
"put",
"(",
"\"test.success.cnt\"",
",",
"Long",
".",
"toString",
"(",
"results",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"TestResult",
"::",
"isSuccess",
")",
".",
"count",
"(",
")",
")",
")",
";",
"reportProps",
".",
"put",
"(",
"\"test.error.cnt\"",
",",
"\"0\"",
")",
";",
"reportProps",
".",
"put",
"(",
"\"test.duration\"",
",",
"\"0.0\"",
")",
";",
"reportProps",
".",
"put",
"(",
"\"tests\"",
",",
"reportDetails",
".",
"toString",
"(",
")",
")",
";",
"return",
"PropertyUtils",
".",
"replacePropertiesInString",
"(",
"templates",
".",
"getReportTemplate",
"(",
")",
",",
"reportProps",
")",
";",
"}"
] | Create report file for test class.
@param suiteName
@param results
@param templates
@return | [
"Create",
"report",
"file",
"for",
"test",
"class",
"."
] | train | https://github.com/citrusframework/citrus/blob/55c58ef74c01d511615e43646ca25c1b2301c56d/modules/citrus-core/src/main/java/com/consol/citrus/report/JUnitReporter.java#L116-L149 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java | FileUtil.appendLines | public static <T> File appendLines(Collection<T> list, File file, String charset) throws IORuntimeException {
"""
将列表写入文件,追加模式
@param <T> 集合元素类型
@param list 列表
@param file 文件
@param charset 字符集
@return 目标文件
@throws IORuntimeException IO异常
@since 3.1.2
"""
return writeLines(list, file, charset, true);
} | java | public static <T> File appendLines(Collection<T> list, File file, String charset) throws IORuntimeException {
return writeLines(list, file, charset, true);
} | [
"public",
"static",
"<",
"T",
">",
"File",
"appendLines",
"(",
"Collection",
"<",
"T",
">",
"list",
",",
"File",
"file",
",",
"String",
"charset",
")",
"throws",
"IORuntimeException",
"{",
"return",
"writeLines",
"(",
"list",
",",
"file",
",",
"charset",
",",
"true",
")",
";",
"}"
] | 将列表写入文件,追加模式
@param <T> 集合元素类型
@param list 列表
@param file 文件
@param charset 字符集
@return 目标文件
@throws IORuntimeException IO异常
@since 3.1.2 | [
"将列表写入文件,追加模式"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java#L2982-L2984 |
gresrun/jesque | src/main/java/net/greghaines/jesque/utils/ReflectionUtils.java | ReflectionUtils.invokeSetters | public static <T> T invokeSetters(final T instance, final Map<String,Object> vars)
throws ReflectiveOperationException {
"""
Invoke the setters for the given variables on the given instance.
@param <T> the instance type
@param instance the instance to inject with the variables
@param vars the variables to inject
@return the instance
@throws ReflectiveOperationException if there was a problem finding or invoking a setter method
"""
if (instance != null && vars != null) {
final Class<?> clazz = instance.getClass();
final Method[] methods = clazz.getMethods();
for (final Entry<String,Object> entry : vars.entrySet()) {
final String methodName = "set" + entry.getKey().substring(0, 1).toUpperCase(Locale.US)
+ entry.getKey().substring(1);
boolean found = false;
for (final Method method : methods) {
if (methodName.equals(method.getName()) && method.getParameterTypes().length == 1) {
method.invoke(instance, entry.getValue());
found = true;
break;
}
}
if (!found) {
throw new NoSuchMethodException("Expected setter named '" + methodName
+ "' for var '" + entry.getKey() + "'");
}
}
}
return instance;
} | java | public static <T> T invokeSetters(final T instance, final Map<String,Object> vars)
throws ReflectiveOperationException {
if (instance != null && vars != null) {
final Class<?> clazz = instance.getClass();
final Method[] methods = clazz.getMethods();
for (final Entry<String,Object> entry : vars.entrySet()) {
final String methodName = "set" + entry.getKey().substring(0, 1).toUpperCase(Locale.US)
+ entry.getKey().substring(1);
boolean found = false;
for (final Method method : methods) {
if (methodName.equals(method.getName()) && method.getParameterTypes().length == 1) {
method.invoke(instance, entry.getValue());
found = true;
break;
}
}
if (!found) {
throw new NoSuchMethodException("Expected setter named '" + methodName
+ "' for var '" + entry.getKey() + "'");
}
}
}
return instance;
} | [
"public",
"static",
"<",
"T",
">",
"T",
"invokeSetters",
"(",
"final",
"T",
"instance",
",",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"vars",
")",
"throws",
"ReflectiveOperationException",
"{",
"if",
"(",
"instance",
"!=",
"null",
"&&",
"vars",
"!=",
"null",
")",
"{",
"final",
"Class",
"<",
"?",
">",
"clazz",
"=",
"instance",
".",
"getClass",
"(",
")",
";",
"final",
"Method",
"[",
"]",
"methods",
"=",
"clazz",
".",
"getMethods",
"(",
")",
";",
"for",
"(",
"final",
"Entry",
"<",
"String",
",",
"Object",
">",
"entry",
":",
"vars",
".",
"entrySet",
"(",
")",
")",
"{",
"final",
"String",
"methodName",
"=",
"\"set\"",
"+",
"entry",
".",
"getKey",
"(",
")",
".",
"substring",
"(",
"0",
",",
"1",
")",
".",
"toUpperCase",
"(",
"Locale",
".",
"US",
")",
"+",
"entry",
".",
"getKey",
"(",
")",
".",
"substring",
"(",
"1",
")",
";",
"boolean",
"found",
"=",
"false",
";",
"for",
"(",
"final",
"Method",
"method",
":",
"methods",
")",
"{",
"if",
"(",
"methodName",
".",
"equals",
"(",
"method",
".",
"getName",
"(",
")",
")",
"&&",
"method",
".",
"getParameterTypes",
"(",
")",
".",
"length",
"==",
"1",
")",
"{",
"method",
".",
"invoke",
"(",
"instance",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"found",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"found",
")",
"{",
"throw",
"new",
"NoSuchMethodException",
"(",
"\"Expected setter named '\"",
"+",
"methodName",
"+",
"\"' for var '\"",
"+",
"entry",
".",
"getKey",
"(",
")",
"+",
"\"'\"",
")",
";",
"}",
"}",
"}",
"return",
"instance",
";",
"}"
] | Invoke the setters for the given variables on the given instance.
@param <T> the instance type
@param instance the instance to inject with the variables
@param vars the variables to inject
@return the instance
@throws ReflectiveOperationException if there was a problem finding or invoking a setter method | [
"Invoke",
"the",
"setters",
"for",
"the",
"given",
"variables",
"on",
"the",
"given",
"instance",
"."
] | train | https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/utils/ReflectionUtils.java#L462-L485 |
katjahahn/PortEx | src/main/java/com/github/katjahahn/parser/ByteArrayUtil.java | ByteArrayUtil.byteToHex | public static String byteToHex(byte[] array, String separator) {
"""
Converts a byte array to a hex string.
<p>
Every single byte is shown in the string, also prepended zero bytes.
Single bytes are delimited with the separator.
@param array
byte array to convert
@param separator
the delimiter of the bytes
@return hexadecimal string representation of the byte array
"""
assert array != null;
StringBuilder buffer = new StringBuilder();
for (int i = 0; i < array.length; i++) {
// add separator in between, not before the first byte
if (i != 0) {
buffer.append(separator);
}
// (b & 0xff) treats b as unsigned byte
// first nibble is 0 if byte is less than 0x10
if ((array[i] & 0xff) < 0x10) {
buffer.append("0");
}
// use java's hex conversion for the rest
buffer.append(Integer.toString(array[i] & 0xff, 16));
}
return buffer.toString();
} | java | public static String byteToHex(byte[] array, String separator) {
assert array != null;
StringBuilder buffer = new StringBuilder();
for (int i = 0; i < array.length; i++) {
// add separator in between, not before the first byte
if (i != 0) {
buffer.append(separator);
}
// (b & 0xff) treats b as unsigned byte
// first nibble is 0 if byte is less than 0x10
if ((array[i] & 0xff) < 0x10) {
buffer.append("0");
}
// use java's hex conversion for the rest
buffer.append(Integer.toString(array[i] & 0xff, 16));
}
return buffer.toString();
} | [
"public",
"static",
"String",
"byteToHex",
"(",
"byte",
"[",
"]",
"array",
",",
"String",
"separator",
")",
"{",
"assert",
"array",
"!=",
"null",
";",
"StringBuilder",
"buffer",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"array",
".",
"length",
";",
"i",
"++",
")",
"{",
"// add separator in between, not before the first byte",
"if",
"(",
"i",
"!=",
"0",
")",
"{",
"buffer",
".",
"append",
"(",
"separator",
")",
";",
"}",
"// (b & 0xff) treats b as unsigned byte",
"// first nibble is 0 if byte is less than 0x10",
"if",
"(",
"(",
"array",
"[",
"i",
"]",
"&",
"0xff",
")",
"<",
"0x10",
")",
"{",
"buffer",
".",
"append",
"(",
"\"0\"",
")",
";",
"}",
"// use java's hex conversion for the rest",
"buffer",
".",
"append",
"(",
"Integer",
".",
"toString",
"(",
"array",
"[",
"i",
"]",
"&",
"0xff",
",",
"16",
")",
")",
";",
"}",
"return",
"buffer",
".",
"toString",
"(",
")",
";",
"}"
] | Converts a byte array to a hex string.
<p>
Every single byte is shown in the string, also prepended zero bytes.
Single bytes are delimited with the separator.
@param array
byte array to convert
@param separator
the delimiter of the bytes
@return hexadecimal string representation of the byte array | [
"Converts",
"a",
"byte",
"array",
"to",
"a",
"hex",
"string",
".",
"<p",
">",
"Every",
"single",
"byte",
"is",
"shown",
"in",
"the",
"string",
"also",
"prepended",
"zero",
"bytes",
".",
"Single",
"bytes",
"are",
"delimited",
"with",
"the",
"separator",
"."
] | train | https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/parser/ByteArrayUtil.java#L168-L185 |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/fixed/CommonOps_DDF6.java | CommonOps_DDF6.elementDiv | public static void elementDiv( DMatrix6x6 a , DMatrix6x6 b , DMatrix6x6 c ) {
"""
<p>Performs an element by element division operation:<br>
<br>
c<sub>ij</sub> = a<sub>ij</sub> / b<sub>ij</sub> <br>
</p>
@param a The left matrix in the division operation. Not modified.
@param b The right matrix in the division operation. Not modified.
@param c Where the results of the operation are stored. Modified.
"""
c.a11 = a.a11/b.a11; c.a12 = a.a12/b.a12; c.a13 = a.a13/b.a13; c.a14 = a.a14/b.a14; c.a15 = a.a15/b.a15; c.a16 = a.a16/b.a16;
c.a21 = a.a21/b.a21; c.a22 = a.a22/b.a22; c.a23 = a.a23/b.a23; c.a24 = a.a24/b.a24; c.a25 = a.a25/b.a25; c.a26 = a.a26/b.a26;
c.a31 = a.a31/b.a31; c.a32 = a.a32/b.a32; c.a33 = a.a33/b.a33; c.a34 = a.a34/b.a34; c.a35 = a.a35/b.a35; c.a36 = a.a36/b.a36;
c.a41 = a.a41/b.a41; c.a42 = a.a42/b.a42; c.a43 = a.a43/b.a43; c.a44 = a.a44/b.a44; c.a45 = a.a45/b.a45; c.a46 = a.a46/b.a46;
c.a51 = a.a51/b.a51; c.a52 = a.a52/b.a52; c.a53 = a.a53/b.a53; c.a54 = a.a54/b.a54; c.a55 = a.a55/b.a55; c.a56 = a.a56/b.a56;
c.a61 = a.a61/b.a61; c.a62 = a.a62/b.a62; c.a63 = a.a63/b.a63; c.a64 = a.a64/b.a64; c.a65 = a.a65/b.a65; c.a66 = a.a66/b.a66;
} | java | public static void elementDiv( DMatrix6x6 a , DMatrix6x6 b , DMatrix6x6 c ) {
c.a11 = a.a11/b.a11; c.a12 = a.a12/b.a12; c.a13 = a.a13/b.a13; c.a14 = a.a14/b.a14; c.a15 = a.a15/b.a15; c.a16 = a.a16/b.a16;
c.a21 = a.a21/b.a21; c.a22 = a.a22/b.a22; c.a23 = a.a23/b.a23; c.a24 = a.a24/b.a24; c.a25 = a.a25/b.a25; c.a26 = a.a26/b.a26;
c.a31 = a.a31/b.a31; c.a32 = a.a32/b.a32; c.a33 = a.a33/b.a33; c.a34 = a.a34/b.a34; c.a35 = a.a35/b.a35; c.a36 = a.a36/b.a36;
c.a41 = a.a41/b.a41; c.a42 = a.a42/b.a42; c.a43 = a.a43/b.a43; c.a44 = a.a44/b.a44; c.a45 = a.a45/b.a45; c.a46 = a.a46/b.a46;
c.a51 = a.a51/b.a51; c.a52 = a.a52/b.a52; c.a53 = a.a53/b.a53; c.a54 = a.a54/b.a54; c.a55 = a.a55/b.a55; c.a56 = a.a56/b.a56;
c.a61 = a.a61/b.a61; c.a62 = a.a62/b.a62; c.a63 = a.a63/b.a63; c.a64 = a.a64/b.a64; c.a65 = a.a65/b.a65; c.a66 = a.a66/b.a66;
} | [
"public",
"static",
"void",
"elementDiv",
"(",
"DMatrix6x6",
"a",
",",
"DMatrix6x6",
"b",
",",
"DMatrix6x6",
"c",
")",
"{",
"c",
".",
"a11",
"=",
"a",
".",
"a11",
"/",
"b",
".",
"a11",
";",
"c",
".",
"a12",
"=",
"a",
".",
"a12",
"/",
"b",
".",
"a12",
";",
"c",
".",
"a13",
"=",
"a",
".",
"a13",
"/",
"b",
".",
"a13",
";",
"c",
".",
"a14",
"=",
"a",
".",
"a14",
"/",
"b",
".",
"a14",
";",
"c",
".",
"a15",
"=",
"a",
".",
"a15",
"/",
"b",
".",
"a15",
";",
"c",
".",
"a16",
"=",
"a",
".",
"a16",
"/",
"b",
".",
"a16",
";",
"c",
".",
"a21",
"=",
"a",
".",
"a21",
"/",
"b",
".",
"a21",
";",
"c",
".",
"a22",
"=",
"a",
".",
"a22",
"/",
"b",
".",
"a22",
";",
"c",
".",
"a23",
"=",
"a",
".",
"a23",
"/",
"b",
".",
"a23",
";",
"c",
".",
"a24",
"=",
"a",
".",
"a24",
"/",
"b",
".",
"a24",
";",
"c",
".",
"a25",
"=",
"a",
".",
"a25",
"/",
"b",
".",
"a25",
";",
"c",
".",
"a26",
"=",
"a",
".",
"a26",
"/",
"b",
".",
"a26",
";",
"c",
".",
"a31",
"=",
"a",
".",
"a31",
"/",
"b",
".",
"a31",
";",
"c",
".",
"a32",
"=",
"a",
".",
"a32",
"/",
"b",
".",
"a32",
";",
"c",
".",
"a33",
"=",
"a",
".",
"a33",
"/",
"b",
".",
"a33",
";",
"c",
".",
"a34",
"=",
"a",
".",
"a34",
"/",
"b",
".",
"a34",
";",
"c",
".",
"a35",
"=",
"a",
".",
"a35",
"/",
"b",
".",
"a35",
";",
"c",
".",
"a36",
"=",
"a",
".",
"a36",
"/",
"b",
".",
"a36",
";",
"c",
".",
"a41",
"=",
"a",
".",
"a41",
"/",
"b",
".",
"a41",
";",
"c",
".",
"a42",
"=",
"a",
".",
"a42",
"/",
"b",
".",
"a42",
";",
"c",
".",
"a43",
"=",
"a",
".",
"a43",
"/",
"b",
".",
"a43",
";",
"c",
".",
"a44",
"=",
"a",
".",
"a44",
"/",
"b",
".",
"a44",
";",
"c",
".",
"a45",
"=",
"a",
".",
"a45",
"/",
"b",
".",
"a45",
";",
"c",
".",
"a46",
"=",
"a",
".",
"a46",
"/",
"b",
".",
"a46",
";",
"c",
".",
"a51",
"=",
"a",
".",
"a51",
"/",
"b",
".",
"a51",
";",
"c",
".",
"a52",
"=",
"a",
".",
"a52",
"/",
"b",
".",
"a52",
";",
"c",
".",
"a53",
"=",
"a",
".",
"a53",
"/",
"b",
".",
"a53",
";",
"c",
".",
"a54",
"=",
"a",
".",
"a54",
"/",
"b",
".",
"a54",
";",
"c",
".",
"a55",
"=",
"a",
".",
"a55",
"/",
"b",
".",
"a55",
";",
"c",
".",
"a56",
"=",
"a",
".",
"a56",
"/",
"b",
".",
"a56",
";",
"c",
".",
"a61",
"=",
"a",
".",
"a61",
"/",
"b",
".",
"a61",
";",
"c",
".",
"a62",
"=",
"a",
".",
"a62",
"/",
"b",
".",
"a62",
";",
"c",
".",
"a63",
"=",
"a",
".",
"a63",
"/",
"b",
".",
"a63",
";",
"c",
".",
"a64",
"=",
"a",
".",
"a64",
"/",
"b",
".",
"a64",
";",
"c",
".",
"a65",
"=",
"a",
".",
"a65",
"/",
"b",
".",
"a65",
";",
"c",
".",
"a66",
"=",
"a",
".",
"a66",
"/",
"b",
".",
"a66",
";",
"}"
] | <p>Performs an element by element division operation:<br>
<br>
c<sub>ij</sub> = a<sub>ij</sub> / b<sub>ij</sub> <br>
</p>
@param a The left matrix in the division operation. Not modified.
@param b The right matrix in the division operation. Not modified.
@param c Where the results of the operation are stored. Modified. | [
"<p",
">",
"Performs",
"an",
"element",
"by",
"element",
"division",
"operation",
":",
"<br",
">",
"<br",
">",
"c<sub",
">",
"ij<",
"/",
"sub",
">",
"=",
"a<sub",
">",
"ij<",
"/",
"sub",
">",
"/",
"b<sub",
">",
"ij<",
"/",
"sub",
">",
"<br",
">",
"<",
"/",
"p",
">"
] | train | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/fixed/CommonOps_DDF6.java#L1883-L1890 |
netty/netty | transport/src/main/java/io/netty/channel/embedded/EmbeddedChannel.java | EmbeddedChannel.writeOneInbound | public ChannelFuture writeOneInbound(Object msg, ChannelPromise promise) {
"""
Writes one message to the inbound of this {@link Channel} and does not flush it. This
method is conceptually equivalent to {@link #write(Object, ChannelPromise)}.
@see #writeOneOutbound(Object, ChannelPromise)
"""
if (checkOpen(true)) {
pipeline().fireChannelRead(msg);
}
return checkException(promise);
} | java | public ChannelFuture writeOneInbound(Object msg, ChannelPromise promise) {
if (checkOpen(true)) {
pipeline().fireChannelRead(msg);
}
return checkException(promise);
} | [
"public",
"ChannelFuture",
"writeOneInbound",
"(",
"Object",
"msg",
",",
"ChannelPromise",
"promise",
")",
"{",
"if",
"(",
"checkOpen",
"(",
"true",
")",
")",
"{",
"pipeline",
"(",
")",
".",
"fireChannelRead",
"(",
"msg",
")",
";",
"}",
"return",
"checkException",
"(",
"promise",
")",
";",
"}"
] | Writes one message to the inbound of this {@link Channel} and does not flush it. This
method is conceptually equivalent to {@link #write(Object, ChannelPromise)}.
@see #writeOneOutbound(Object, ChannelPromise) | [
"Writes",
"one",
"message",
"to",
"the",
"inbound",
"of",
"this",
"{",
"@link",
"Channel",
"}",
"and",
"does",
"not",
"flush",
"it",
".",
"This",
"method",
"is",
"conceptually",
"equivalent",
"to",
"{",
"@link",
"#write",
"(",
"Object",
"ChannelPromise",
")",
"}",
"."
] | train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/transport/src/main/java/io/netty/channel/embedded/EmbeddedChannel.java#L348-L353 |
Impetus/Kundera | src/kundera-elastic-search/src/main/java/com/impetus/client/es/ESQuery.java | ESQuery.processGroupByClause | private TermsBuilder processGroupByClause(Expression expression, EntityMetadata entityMetadata, KunderaQuery query) {
"""
Process group by clause.
@param expression
the expression
@param entityMetadata
the entity metadata
@param query
the query
@return the terms builder
"""
MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
entityMetadata.getPersistenceUnit());
Expression groupByClause = ((GroupByClause) expression).getGroupByItems();
if (groupByClause instanceof CollectionExpression)
{
logger.error("More than one item found in group by clause.");
throw new UnsupportedOperationException("Currently, Group By on more than one field is not supported.");
}
SelectStatement selectStatement = query.getSelectStatement();
// To apply terms and tophits aggregation to serve group by
String jPAField = KunderaCoreUtils.getJPAColumnName(groupByClause.toParsedText(), entityMetadata, metaModel);
TermsBuilder termsBuilder = AggregationBuilders.terms(ESConstants.GROUP_BY).field(jPAField).size(0);
// Hard coded value for a max number of record that a group can contain.
TopHitsBuilder topHitsBuilder = getTopHitsAggregation(selectStatement, null, entityMetadata);
termsBuilder.subAggregation(topHitsBuilder);
// To apply the metric aggregations (Min, max... etc) in select clause
buildSelectAggregations(termsBuilder, query.getSelectStatement(), entityMetadata);
if (KunderaQueryUtils.hasHaving(query.getJpqlExpression()))
{
addHavingClause(((HavingClause) selectStatement.getHavingClause()).getConditionalExpression(),
termsBuilder, entityMetadata);
}
if (KunderaQueryUtils.hasOrderBy(query.getJpqlExpression()))
{
processOrderByClause(termsBuilder, KunderaQueryUtils.getOrderByClause(query.getJpqlExpression()),
groupByClause, entityMetadata);
}
return termsBuilder;
} | java | private TermsBuilder processGroupByClause(Expression expression, EntityMetadata entityMetadata, KunderaQuery query)
{
MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
entityMetadata.getPersistenceUnit());
Expression groupByClause = ((GroupByClause) expression).getGroupByItems();
if (groupByClause instanceof CollectionExpression)
{
logger.error("More than one item found in group by clause.");
throw new UnsupportedOperationException("Currently, Group By on more than one field is not supported.");
}
SelectStatement selectStatement = query.getSelectStatement();
// To apply terms and tophits aggregation to serve group by
String jPAField = KunderaCoreUtils.getJPAColumnName(groupByClause.toParsedText(), entityMetadata, metaModel);
TermsBuilder termsBuilder = AggregationBuilders.terms(ESConstants.GROUP_BY).field(jPAField).size(0);
// Hard coded value for a max number of record that a group can contain.
TopHitsBuilder topHitsBuilder = getTopHitsAggregation(selectStatement, null, entityMetadata);
termsBuilder.subAggregation(topHitsBuilder);
// To apply the metric aggregations (Min, max... etc) in select clause
buildSelectAggregations(termsBuilder, query.getSelectStatement(), entityMetadata);
if (KunderaQueryUtils.hasHaving(query.getJpqlExpression()))
{
addHavingClause(((HavingClause) selectStatement.getHavingClause()).getConditionalExpression(),
termsBuilder, entityMetadata);
}
if (KunderaQueryUtils.hasOrderBy(query.getJpqlExpression()))
{
processOrderByClause(termsBuilder, KunderaQueryUtils.getOrderByClause(query.getJpqlExpression()),
groupByClause, entityMetadata);
}
return termsBuilder;
} | [
"private",
"TermsBuilder",
"processGroupByClause",
"(",
"Expression",
"expression",
",",
"EntityMetadata",
"entityMetadata",
",",
"KunderaQuery",
"query",
")",
"{",
"MetamodelImpl",
"metaModel",
"=",
"(",
"MetamodelImpl",
")",
"kunderaMetadata",
".",
"getApplicationMetadata",
"(",
")",
".",
"getMetamodel",
"(",
"entityMetadata",
".",
"getPersistenceUnit",
"(",
")",
")",
";",
"Expression",
"groupByClause",
"=",
"(",
"(",
"GroupByClause",
")",
"expression",
")",
".",
"getGroupByItems",
"(",
")",
";",
"if",
"(",
"groupByClause",
"instanceof",
"CollectionExpression",
")",
"{",
"logger",
".",
"error",
"(",
"\"More than one item found in group by clause.\"",
")",
";",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Currently, Group By on more than one field is not supported.\"",
")",
";",
"}",
"SelectStatement",
"selectStatement",
"=",
"query",
".",
"getSelectStatement",
"(",
")",
";",
"// To apply terms and tophits aggregation to serve group by",
"String",
"jPAField",
"=",
"KunderaCoreUtils",
".",
"getJPAColumnName",
"(",
"groupByClause",
".",
"toParsedText",
"(",
")",
",",
"entityMetadata",
",",
"metaModel",
")",
";",
"TermsBuilder",
"termsBuilder",
"=",
"AggregationBuilders",
".",
"terms",
"(",
"ESConstants",
".",
"GROUP_BY",
")",
".",
"field",
"(",
"jPAField",
")",
".",
"size",
"(",
"0",
")",
";",
"// Hard coded value for a max number of record that a group can contain.",
"TopHitsBuilder",
"topHitsBuilder",
"=",
"getTopHitsAggregation",
"(",
"selectStatement",
",",
"null",
",",
"entityMetadata",
")",
";",
"termsBuilder",
".",
"subAggregation",
"(",
"topHitsBuilder",
")",
";",
"// To apply the metric aggregations (Min, max... etc) in select clause",
"buildSelectAggregations",
"(",
"termsBuilder",
",",
"query",
".",
"getSelectStatement",
"(",
")",
",",
"entityMetadata",
")",
";",
"if",
"(",
"KunderaQueryUtils",
".",
"hasHaving",
"(",
"query",
".",
"getJpqlExpression",
"(",
")",
")",
")",
"{",
"addHavingClause",
"(",
"(",
"(",
"HavingClause",
")",
"selectStatement",
".",
"getHavingClause",
"(",
")",
")",
".",
"getConditionalExpression",
"(",
")",
",",
"termsBuilder",
",",
"entityMetadata",
")",
";",
"}",
"if",
"(",
"KunderaQueryUtils",
".",
"hasOrderBy",
"(",
"query",
".",
"getJpqlExpression",
"(",
")",
")",
")",
"{",
"processOrderByClause",
"(",
"termsBuilder",
",",
"KunderaQueryUtils",
".",
"getOrderByClause",
"(",
"query",
".",
"getJpqlExpression",
"(",
")",
")",
",",
"groupByClause",
",",
"entityMetadata",
")",
";",
"}",
"return",
"termsBuilder",
";",
"}"
] | Process group by clause.
@param expression
the expression
@param entityMetadata
the entity metadata
@param query
the query
@return the terms builder | [
"Process",
"group",
"by",
"clause",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-elastic-search/src/main/java/com/impetus/client/es/ESQuery.java#L308-L346 |
UrielCh/ovh-java-sdk | ovh-java-sdk-core/src/main/java/net/minidev/ovh/core/ApiOvhConfigBasic.java | ApiOvhConfigBasic.gettmpStore | protected File gettmpStore(String nic) {
"""
storage for previous CK
@return File used to store consumer key
"""
if (consumer_key_storage == null || !consumer_key_storage.isDirectory()) {
if (e1 == 0) {
e1++;
log.error(
"No cert directory, can not save consumer_key! please set `consumer_key_storage` variable to a valid directory in your {}, or in your environ variale OVH_CONSUMER_KEY_STORAGE",
configFiles);
}
return null;
}
return new File(consumer_key_storage, nic + ".ck.txt");
} | java | protected File gettmpStore(String nic) {
if (consumer_key_storage == null || !consumer_key_storage.isDirectory()) {
if (e1 == 0) {
e1++;
log.error(
"No cert directory, can not save consumer_key! please set `consumer_key_storage` variable to a valid directory in your {}, or in your environ variale OVH_CONSUMER_KEY_STORAGE",
configFiles);
}
return null;
}
return new File(consumer_key_storage, nic + ".ck.txt");
} | [
"protected",
"File",
"gettmpStore",
"(",
"String",
"nic",
")",
"{",
"if",
"(",
"consumer_key_storage",
"==",
"null",
"||",
"!",
"consumer_key_storage",
".",
"isDirectory",
"(",
")",
")",
"{",
"if",
"(",
"e1",
"==",
"0",
")",
"{",
"e1",
"++",
";",
"log",
".",
"error",
"(",
"\"No cert directory, can not save consumer_key! please set `consumer_key_storage` variable to a valid directory in your {}, or in your environ variale OVH_CONSUMER_KEY_STORAGE\"",
",",
"configFiles",
")",
";",
"}",
"return",
"null",
";",
"}",
"return",
"new",
"File",
"(",
"consumer_key_storage",
",",
"nic",
"+",
"\".ck.txt\"",
")",
";",
"}"
] | storage for previous CK
@return File used to store consumer key | [
"storage",
"for",
"previous",
"CK"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-core/src/main/java/net/minidev/ovh/core/ApiOvhConfigBasic.java#L128-L140 |
Tristan971/EasyFXML | easyfxml/src/main/java/moe/tristan/easyfxml/util/Stages.java | Stages.setStylesheet | public static CompletionStage<Stage> setStylesheet(final Stage stage, final FxmlStylesheet stylesheet) {
"""
See {@link #setStylesheet(Stage, String)}
@param stage The stage to apply the style to
@param stylesheet The {@link FxmlStylesheet} pointing to the stylesheet to apply
@return A {@link CompletionStage} to have monitoring over the state of the asynchronous operation
"""
return setStylesheet(stage, stylesheet.getExternalForm());
} | java | public static CompletionStage<Stage> setStylesheet(final Stage stage, final FxmlStylesheet stylesheet) {
return setStylesheet(stage, stylesheet.getExternalForm());
} | [
"public",
"static",
"CompletionStage",
"<",
"Stage",
">",
"setStylesheet",
"(",
"final",
"Stage",
"stage",
",",
"final",
"FxmlStylesheet",
"stylesheet",
")",
"{",
"return",
"setStylesheet",
"(",
"stage",
",",
"stylesheet",
".",
"getExternalForm",
"(",
")",
")",
";",
"}"
] | See {@link #setStylesheet(Stage, String)}
@param stage The stage to apply the style to
@param stylesheet The {@link FxmlStylesheet} pointing to the stylesheet to apply
@return A {@link CompletionStage} to have monitoring over the state of the asynchronous operation | [
"See",
"{",
"@link",
"#setStylesheet",
"(",
"Stage",
"String",
")",
"}"
] | train | https://github.com/Tristan971/EasyFXML/blob/f82cad1d54e62903ca5e4a250279ad315b028aef/easyfxml/src/main/java/moe/tristan/easyfxml/util/Stages.java#L133-L135 |
OpenTSDB/opentsdb | src/core/Tags.java | Tags.resolveOrCreateAll | static ArrayList<byte[]> resolveOrCreateAll(final TSDB tsdb,
final Map<String, String> tags) {
"""
Resolves (and creates, if necessary) all the tags (name=value) into the a
sorted byte arrays.
@param tsdb The TSDB to use for UniqueId lookups.
@param tags The tags to resolve. If a new tag name or tag value is
seen, it will be assigned an ID.
@return an array of sorted tags (tag id, tag name).
"""
return resolveAllInternal(tsdb, tags, true);
} | java | static ArrayList<byte[]> resolveOrCreateAll(final TSDB tsdb,
final Map<String, String> tags) {
return resolveAllInternal(tsdb, tags, true);
} | [
"static",
"ArrayList",
"<",
"byte",
"[",
"]",
">",
"resolveOrCreateAll",
"(",
"final",
"TSDB",
"tsdb",
",",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"tags",
")",
"{",
"return",
"resolveAllInternal",
"(",
"tsdb",
",",
"tags",
",",
"true",
")",
";",
"}"
] | Resolves (and creates, if necessary) all the tags (name=value) into the a
sorted byte arrays.
@param tsdb The TSDB to use for UniqueId lookups.
@param tags The tags to resolve. If a new tag name or tag value is
seen, it will be assigned an ID.
@return an array of sorted tags (tag id, tag name). | [
"Resolves",
"(",
"and",
"creates",
"if",
"necessary",
")",
"all",
"the",
"tags",
"(",
"name",
"=",
"value",
")",
"into",
"the",
"a",
"sorted",
"byte",
"arrays",
"."
] | train | https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/core/Tags.java#L611-L614 |
alkacon/opencms-core | src/org/opencms/main/CmsStaticResourceHandler.java | CmsStaticResourceHandler.browserHasNewestVersion | private boolean browserHasNewestVersion(HttpServletRequest request, long resourceLastModifiedTimestamp) {
"""
Checks if the browser has an up to date cached version of requested
resource. Currently the check is performed using the "If-Modified-Since"
header. Could be expanded if needed.<p>
@param request the HttpServletRequest from the browser
@param resourceLastModifiedTimestamp the timestamp when the resource was last modified. 0 if the last modification time is unknown
@return true if the If-Modified-Since header tells the cached version in the browser is up to date, false otherwise
"""
if (resourceLastModifiedTimestamp < 1) {
// We do not know when it was modified so the browser cannot have an
// up-to-date version
return false;
}
/*
* The browser can request the resource conditionally using an
* If-Modified-Since header. Check this against the last modification
* time.
*/
try {
// If-Modified-Since represents the timestamp of the version cached
// in the browser
long headerIfModifiedSince = request.getDateHeader("If-Modified-Since");
if (headerIfModifiedSince >= resourceLastModifiedTimestamp) {
// Browser has this an up-to-date version of the resource
return true;
}
} catch (Exception e) {
// Failed to parse header. Fail silently - the browser does not have
// an up-to-date version in its cache.
}
return false;
} | java | private boolean browserHasNewestVersion(HttpServletRequest request, long resourceLastModifiedTimestamp) {
if (resourceLastModifiedTimestamp < 1) {
// We do not know when it was modified so the browser cannot have an
// up-to-date version
return false;
}
/*
* The browser can request the resource conditionally using an
* If-Modified-Since header. Check this against the last modification
* time.
*/
try {
// If-Modified-Since represents the timestamp of the version cached
// in the browser
long headerIfModifiedSince = request.getDateHeader("If-Modified-Since");
if (headerIfModifiedSince >= resourceLastModifiedTimestamp) {
// Browser has this an up-to-date version of the resource
return true;
}
} catch (Exception e) {
// Failed to parse header. Fail silently - the browser does not have
// an up-to-date version in its cache.
}
return false;
} | [
"private",
"boolean",
"browserHasNewestVersion",
"(",
"HttpServletRequest",
"request",
",",
"long",
"resourceLastModifiedTimestamp",
")",
"{",
"if",
"(",
"resourceLastModifiedTimestamp",
"<",
"1",
")",
"{",
"// We do not know when it was modified so the browser cannot have an",
"// up-to-date version",
"return",
"false",
";",
"}",
"/*\n * The browser can request the resource conditionally using an\n * If-Modified-Since header. Check this against the last modification\n * time.\n */",
"try",
"{",
"// If-Modified-Since represents the timestamp of the version cached",
"// in the browser",
"long",
"headerIfModifiedSince",
"=",
"request",
".",
"getDateHeader",
"(",
"\"If-Modified-Since\"",
")",
";",
"if",
"(",
"headerIfModifiedSince",
">=",
"resourceLastModifiedTimestamp",
")",
"{",
"// Browser has this an up-to-date version of the resource",
"return",
"true",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// Failed to parse header. Fail silently - the browser does not have",
"// an up-to-date version in its cache.",
"}",
"return",
"false",
";",
"}"
] | Checks if the browser has an up to date cached version of requested
resource. Currently the check is performed using the "If-Modified-Since"
header. Could be expanded if needed.<p>
@param request the HttpServletRequest from the browser
@param resourceLastModifiedTimestamp the timestamp when the resource was last modified. 0 if the last modification time is unknown
@return true if the If-Modified-Since header tells the cached version in the browser is up to date, false otherwise | [
"Checks",
"if",
"the",
"browser",
"has",
"an",
"up",
"to",
"date",
"cached",
"version",
"of",
"requested",
"resource",
".",
"Currently",
"the",
"check",
"is",
"performed",
"using",
"the",
"If",
"-",
"Modified",
"-",
"Since",
"header",
".",
"Could",
"be",
"expanded",
"if",
"needed",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/main/CmsStaticResourceHandler.java#L402-L428 |
aehrc/snorocket | snorocket-core/src/main/java/au/csiro/snorocket/core/axioms/GCI.java | GCI.rule7 | Inclusion[] rule7(Inclusion[] gcis) {
"""
B ⊑ C ⊓ D → {B ⊑ C, B ⊑ D}
@param gcis
@return
"""
assert isRule7Applicable();
final Conjunction conjunction = (Conjunction) rhs;
final AbstractConcept[] concepts = conjunction.getConcepts();
if (concepts.length > gcis.length) {
gcis = new Inclusion[concepts.length];
}
for (int i = 0; i < concepts.length; i++) {
gcis[i] = new GCI(lhs, concepts[i]);
}
return gcis;
} | java | Inclusion[] rule7(Inclusion[] gcis) {
assert isRule7Applicable();
final Conjunction conjunction = (Conjunction) rhs;
final AbstractConcept[] concepts = conjunction.getConcepts();
if (concepts.length > gcis.length) {
gcis = new Inclusion[concepts.length];
}
for (int i = 0; i < concepts.length; i++) {
gcis[i] = new GCI(lhs, concepts[i]);
}
return gcis;
} | [
"Inclusion",
"[",
"]",
"rule7",
"(",
"Inclusion",
"[",
"]",
"gcis",
")",
"{",
"assert",
"isRule7Applicable",
"(",
")",
";",
"final",
"Conjunction",
"conjunction",
"=",
"(",
"Conjunction",
")",
"rhs",
";",
"final",
"AbstractConcept",
"[",
"]",
"concepts",
"=",
"conjunction",
".",
"getConcepts",
"(",
")",
";",
"if",
"(",
"concepts",
".",
"length",
">",
"gcis",
".",
"length",
")",
"{",
"gcis",
"=",
"new",
"Inclusion",
"[",
"concepts",
".",
"length",
"]",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"concepts",
".",
"length",
";",
"i",
"++",
")",
"{",
"gcis",
"[",
"i",
"]",
"=",
"new",
"GCI",
"(",
"lhs",
",",
"concepts",
"[",
"i",
"]",
")",
";",
"}",
"return",
"gcis",
";",
"}"
] | B ⊑ C ⊓ D → {B ⊑ C, B ⊑ D}
@param gcis
@return | [
"B",
"⊑",
";",
"C",
"⊓",
";",
"D",
"&rarr",
";",
"{",
"B",
"⊑",
";",
"C",
"B",
"⊑",
";",
"D",
"}"
] | train | https://github.com/aehrc/snorocket/blob/e33c1e216f8a66d6502e3a14e80876811feedd8b/snorocket-core/src/main/java/au/csiro/snorocket/core/axioms/GCI.java#L284-L299 |
xdcrafts/flower | flower-tools/src/main/java/com/github/xdcrafts/flower/tools/ListApi.java | ListApi.getMapUnsafe | public static <A, B> Map<A, B> getMapUnsafe(final List list, final Integer... path) {
"""
Get map value by path.
@param <A> map key type
@param <B> map value type
@param list subject
@param path nodes to walk in map
@return value
"""
return getUnsafe(list, Map.class, path);
} | java | public static <A, B> Map<A, B> getMapUnsafe(final List list, final Integer... path) {
return getUnsafe(list, Map.class, path);
} | [
"public",
"static",
"<",
"A",
",",
"B",
">",
"Map",
"<",
"A",
",",
"B",
">",
"getMapUnsafe",
"(",
"final",
"List",
"list",
",",
"final",
"Integer",
"...",
"path",
")",
"{",
"return",
"getUnsafe",
"(",
"list",
",",
"Map",
".",
"class",
",",
"path",
")",
";",
"}"
] | Get map value by path.
@param <A> map key type
@param <B> map value type
@param list subject
@param path nodes to walk in map
@return value | [
"Get",
"map",
"value",
"by",
"path",
"."
] | train | https://github.com/xdcrafts/flower/blob/96a8e49102fea434bd383a3c7852f0ee9545f999/flower-tools/src/main/java/com/github/xdcrafts/flower/tools/ListApi.java#L196-L198 |
liferay/com-liferay-commerce | commerce-service/src/main/java/com/liferay/commerce/service/persistence/impl/CommerceOrderItemPersistenceImpl.java | CommerceOrderItemPersistenceImpl.findByC_I | @Override
public List<CommerceOrderItem> findByC_I(long commerceOrderId,
long CPInstanceId, int start, int end) {
"""
Returns a range of all the commerce order items where commerceOrderId = ? and CPInstanceId = ?.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CommerceOrderItemModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param commerceOrderId the commerce order ID
@param CPInstanceId the cp instance ID
@param start the lower bound of the range of commerce order items
@param end the upper bound of the range of commerce order items (not inclusive)
@return the range of matching commerce order items
"""
return findByC_I(commerceOrderId, CPInstanceId, start, end, null);
} | java | @Override
public List<CommerceOrderItem> findByC_I(long commerceOrderId,
long CPInstanceId, int start, int end) {
return findByC_I(commerceOrderId, CPInstanceId, start, end, null);
} | [
"@",
"Override",
"public",
"List",
"<",
"CommerceOrderItem",
">",
"findByC_I",
"(",
"long",
"commerceOrderId",
",",
"long",
"CPInstanceId",
",",
"int",
"start",
",",
"int",
"end",
")",
"{",
"return",
"findByC_I",
"(",
"commerceOrderId",
",",
"CPInstanceId",
",",
"start",
",",
"end",
",",
"null",
")",
";",
"}"
] | Returns a range of all the commerce order items where commerceOrderId = ? and CPInstanceId = ?.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CommerceOrderItemModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param commerceOrderId the commerce order ID
@param CPInstanceId the cp instance ID
@param start the lower bound of the range of commerce order items
@param end the upper bound of the range of commerce order items (not inclusive)
@return the range of matching commerce order items | [
"Returns",
"a",
"range",
"of",
"all",
"the",
"commerce",
"order",
"items",
"where",
"commerceOrderId",
"=",
"?",
";",
"and",
"CPInstanceId",
"=",
"?",
";",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-service/src/main/java/com/liferay/commerce/service/persistence/impl/CommerceOrderItemPersistenceImpl.java#L1692-L1696 |
Netflix/conductor | mysql-persistence/src/main/java/com/netflix/conductor/dao/mysql/MySQLMetadataDAO.java | MySQLMetadataDAO.getEventHandler | private EventHandler getEventHandler(Connection connection, String name) {
"""
Retrieve a {@link EventHandler} by {@literal name}.
@param connection The {@link Connection} to use for queries.
@param name The {@code EventHandler} name to look for.
@return {@literal null} if nothing is found, otherwise the {@code EventHandler}.
"""
final String READ_ONE_EVENT_HANDLER_QUERY = "SELECT json_data FROM meta_event_handler WHERE name = ?";
return query(connection, READ_ONE_EVENT_HANDLER_QUERY,
q -> q.addParameter(name).executeAndFetchFirst(EventHandler.class));
} | java | private EventHandler getEventHandler(Connection connection, String name) {
final String READ_ONE_EVENT_HANDLER_QUERY = "SELECT json_data FROM meta_event_handler WHERE name = ?";
return query(connection, READ_ONE_EVENT_HANDLER_QUERY,
q -> q.addParameter(name).executeAndFetchFirst(EventHandler.class));
} | [
"private",
"EventHandler",
"getEventHandler",
"(",
"Connection",
"connection",
",",
"String",
"name",
")",
"{",
"final",
"String",
"READ_ONE_EVENT_HANDLER_QUERY",
"=",
"\"SELECT json_data FROM meta_event_handler WHERE name = ?\"",
";",
"return",
"query",
"(",
"connection",
",",
"READ_ONE_EVENT_HANDLER_QUERY",
",",
"q",
"->",
"q",
".",
"addParameter",
"(",
"name",
")",
".",
"executeAndFetchFirst",
"(",
"EventHandler",
".",
"class",
")",
")",
";",
"}"
] | Retrieve a {@link EventHandler} by {@literal name}.
@param connection The {@link Connection} to use for queries.
@param name The {@code EventHandler} name to look for.
@return {@literal null} if nothing is found, otherwise the {@code EventHandler}. | [
"Retrieve",
"a",
"{",
"@link",
"EventHandler",
"}",
"by",
"{",
"@literal",
"name",
"}",
"."
] | train | https://github.com/Netflix/conductor/blob/78fae0ed9ddea22891f9eebb96a2ec0b2783dca0/mysql-persistence/src/main/java/com/netflix/conductor/dao/mysql/MySQLMetadataDAO.java#L292-L297 |
camunda/camunda-bpm-platform | distro/wildfly/subsystem/src/main/java/org/camunda/bpm/container/impl/jboss/util/JBossCompatibilityExtension.java | JBossCompatibilityExtension.addServerExecutorDependency | public static void addServerExecutorDependency(ServiceBuilder<?> serviceBuilder, InjectedValue<ExecutorService> injector, boolean optional) {
"""
Adds the JBoss server executor as a dependency to the given service.
Copied from org.jboss.as.server.Services - JBoss 7.2.0.Final
"""
ServiceBuilder.DependencyType type = optional ? ServiceBuilder.DependencyType.OPTIONAL : ServiceBuilder.DependencyType.REQUIRED;
serviceBuilder.addDependency(type, JBOSS_SERVER_EXECUTOR, ExecutorService.class, injector);
} | java | public static void addServerExecutorDependency(ServiceBuilder<?> serviceBuilder, InjectedValue<ExecutorService> injector, boolean optional) {
ServiceBuilder.DependencyType type = optional ? ServiceBuilder.DependencyType.OPTIONAL : ServiceBuilder.DependencyType.REQUIRED;
serviceBuilder.addDependency(type, JBOSS_SERVER_EXECUTOR, ExecutorService.class, injector);
} | [
"public",
"static",
"void",
"addServerExecutorDependency",
"(",
"ServiceBuilder",
"<",
"?",
">",
"serviceBuilder",
",",
"InjectedValue",
"<",
"ExecutorService",
">",
"injector",
",",
"boolean",
"optional",
")",
"{",
"ServiceBuilder",
".",
"DependencyType",
"type",
"=",
"optional",
"?",
"ServiceBuilder",
".",
"DependencyType",
".",
"OPTIONAL",
":",
"ServiceBuilder",
".",
"DependencyType",
".",
"REQUIRED",
";",
"serviceBuilder",
".",
"addDependency",
"(",
"type",
",",
"JBOSS_SERVER_EXECUTOR",
",",
"ExecutorService",
".",
"class",
",",
"injector",
")",
";",
"}"
] | Adds the JBoss server executor as a dependency to the given service.
Copied from org.jboss.as.server.Services - JBoss 7.2.0.Final | [
"Adds",
"the",
"JBoss",
"server",
"executor",
"as",
"a",
"dependency",
"to",
"the",
"given",
"service",
".",
"Copied",
"from",
"org",
".",
"jboss",
".",
"as",
".",
"server",
".",
"Services",
"-",
"JBoss",
"7",
".",
"2",
".",
"0",
".",
"Final"
] | train | https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/distro/wildfly/subsystem/src/main/java/org/camunda/bpm/container/impl/jboss/util/JBossCompatibilityExtension.java#L47-L50 |
Stratio/stratio-cassandra | src/java/org/apache/cassandra/locator/TokenMetadata.java | TokenMetadata.addMovingEndpoint | public void addMovingEndpoint(Token token, InetAddress endpoint) {
"""
Add a new moving endpoint
@param token token which is node moving to
@param endpoint address of the moving node
"""
assert endpoint != null;
lock.writeLock().lock();
try
{
movingEndpoints.add(Pair.create(token, endpoint));
}
finally
{
lock.writeLock().unlock();
}
} | java | public void addMovingEndpoint(Token token, InetAddress endpoint)
{
assert endpoint != null;
lock.writeLock().lock();
try
{
movingEndpoints.add(Pair.create(token, endpoint));
}
finally
{
lock.writeLock().unlock();
}
} | [
"public",
"void",
"addMovingEndpoint",
"(",
"Token",
"token",
",",
"InetAddress",
"endpoint",
")",
"{",
"assert",
"endpoint",
"!=",
"null",
";",
"lock",
".",
"writeLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"try",
"{",
"movingEndpoints",
".",
"add",
"(",
"Pair",
".",
"create",
"(",
"token",
",",
"endpoint",
")",
")",
";",
"}",
"finally",
"{",
"lock",
".",
"writeLock",
"(",
")",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] | Add a new moving endpoint
@param token token which is node moving to
@param endpoint address of the moving node | [
"Add",
"a",
"new",
"moving",
"endpoint"
] | train | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/locator/TokenMetadata.java#L372-L386 |
alibaba/jstorm | jstorm-utility/jstorm-flux/flux-core/src/main/java/com/alibaba/jstorm/flux/FluxBuilder.java | FluxBuilder.buildTopology | public static StormTopology buildTopology(ExecutionContext context) throws IllegalAccessException,
InstantiationException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException {
"""
Given a topology definition, return a Storm topology that can be run either locally or remotely.
@param context
@return
@throws IllegalAccessException
@throws InstantiationException
@throws ClassNotFoundException
@throws NoSuchMethodException
@throws InvocationTargetException
"""
StormTopology topology = null;
TopologyDef topologyDef = context.getTopologyDef();
if(!topologyDef.validate()){
throw new IllegalArgumentException("Invalid topology config. Spouts, bolts and streams cannot be " +
"defined in the same configuration as a topologySource.");
}
// build components that may be referenced by spouts, bolts, etc.
// the map will be a String --> Object where the object is a fully
// constructed class instance
buildComponents(context);
if(topologyDef.isDslTopology()) {
// This is a DSL (YAML, etc.) topology...
LOG.info("Detected DSL topology...");
TopologyBuilder builder = new TopologyBuilder();
// create spouts
buildSpouts(context, builder);
// we need to be able to lookup bolts by id, then switch based
// on whether they are IBasicBolt or IRichBolt instances
buildBolts(context);
// process stream definitions
buildStreamDefinitions(context, builder);
topology = builder.createTopology();
} else {
// user class supplied...
// this also provides a bridge to Trident...
LOG.info("A topology source has been specified...");
ObjectDef def = topologyDef.getTopologySource();
topology = buildExternalTopology(def, context);
}
return topology;
} | java | public static StormTopology buildTopology(ExecutionContext context) throws IllegalAccessException,
InstantiationException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException {
StormTopology topology = null;
TopologyDef topologyDef = context.getTopologyDef();
if(!topologyDef.validate()){
throw new IllegalArgumentException("Invalid topology config. Spouts, bolts and streams cannot be " +
"defined in the same configuration as a topologySource.");
}
// build components that may be referenced by spouts, bolts, etc.
// the map will be a String --> Object where the object is a fully
// constructed class instance
buildComponents(context);
if(topologyDef.isDslTopology()) {
// This is a DSL (YAML, etc.) topology...
LOG.info("Detected DSL topology...");
TopologyBuilder builder = new TopologyBuilder();
// create spouts
buildSpouts(context, builder);
// we need to be able to lookup bolts by id, then switch based
// on whether they are IBasicBolt or IRichBolt instances
buildBolts(context);
// process stream definitions
buildStreamDefinitions(context, builder);
topology = builder.createTopology();
} else {
// user class supplied...
// this also provides a bridge to Trident...
LOG.info("A topology source has been specified...");
ObjectDef def = topologyDef.getTopologySource();
topology = buildExternalTopology(def, context);
}
return topology;
} | [
"public",
"static",
"StormTopology",
"buildTopology",
"(",
"ExecutionContext",
"context",
")",
"throws",
"IllegalAccessException",
",",
"InstantiationException",
",",
"ClassNotFoundException",
",",
"NoSuchMethodException",
",",
"InvocationTargetException",
"{",
"StormTopology",
"topology",
"=",
"null",
";",
"TopologyDef",
"topologyDef",
"=",
"context",
".",
"getTopologyDef",
"(",
")",
";",
"if",
"(",
"!",
"topologyDef",
".",
"validate",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid topology config. Spouts, bolts and streams cannot be \"",
"+",
"\"defined in the same configuration as a topologySource.\"",
")",
";",
"}",
"// build components that may be referenced by spouts, bolts, etc.",
"// the map will be a String --> Object where the object is a fully",
"// constructed class instance",
"buildComponents",
"(",
"context",
")",
";",
"if",
"(",
"topologyDef",
".",
"isDslTopology",
"(",
")",
")",
"{",
"// This is a DSL (YAML, etc.) topology...",
"LOG",
".",
"info",
"(",
"\"Detected DSL topology...\"",
")",
";",
"TopologyBuilder",
"builder",
"=",
"new",
"TopologyBuilder",
"(",
")",
";",
"// create spouts",
"buildSpouts",
"(",
"context",
",",
"builder",
")",
";",
"// we need to be able to lookup bolts by id, then switch based",
"// on whether they are IBasicBolt or IRichBolt instances",
"buildBolts",
"(",
"context",
")",
";",
"// process stream definitions",
"buildStreamDefinitions",
"(",
"context",
",",
"builder",
")",
";",
"topology",
"=",
"builder",
".",
"createTopology",
"(",
")",
";",
"}",
"else",
"{",
"// user class supplied...",
"// this also provides a bridge to Trident...",
"LOG",
".",
"info",
"(",
"\"A topology source has been specified...\"",
")",
";",
"ObjectDef",
"def",
"=",
"topologyDef",
".",
"getTopologySource",
"(",
")",
";",
"topology",
"=",
"buildExternalTopology",
"(",
"def",
",",
"context",
")",
";",
"}",
"return",
"topology",
";",
"}"
] | Given a topology definition, return a Storm topology that can be run either locally or remotely.
@param context
@return
@throws IllegalAccessException
@throws InstantiationException
@throws ClassNotFoundException
@throws NoSuchMethodException
@throws InvocationTargetException | [
"Given",
"a",
"topology",
"definition",
"return",
"a",
"Storm",
"topology",
"that",
"can",
"be",
"run",
"either",
"locally",
"or",
"remotely",
"."
] | train | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-utility/jstorm-flux/flux-core/src/main/java/com/alibaba/jstorm/flux/FluxBuilder.java#L62-L103 |
ineunetOS/knife-commons | knife-commons-utils/src/main/java/com/ineunet/knife/util/StringUtils.java | StringUtils.startsWithAny | public static boolean startsWithAny(String string, String[] searchStrings) {
"""
<p>Check if a String starts with any of an array of specified strings.</p>
<pre>
StringUtils.startsWithAny(null, null) = false
StringUtils.startsWithAny(null, new String[] {"abc"}) = false
StringUtils.startsWithAny("abcxyz", null) = false
StringUtils.startsWithAny("abcxyz", new String[] {""}) = false
StringUtils.startsWithAny("abcxyz", new String[] {"abc"}) = true
StringUtils.startsWithAny("abcxyz", new String[] {null, "xyz", "abc"}) = true
</pre>
@see #startsWith(String, String)
@param string the String to check, may be null
@param searchStrings the Strings to find, may be null or empty
@return <code>true</code> if the String starts with any of the the prefixes, case insensitive, or
both <code>null</code>
@since 2.5
"""
if (isEmpty(string) || ArrayUtils.isEmpty(searchStrings)) {
return false;
}
for (int i = 0; i < searchStrings.length; i++) {
String searchString = searchStrings[i];
if (StringUtils.startsWith(string, searchString)) {
return true;
}
}
return false;
} | java | public static boolean startsWithAny(String string, String[] searchStrings) {
if (isEmpty(string) || ArrayUtils.isEmpty(searchStrings)) {
return false;
}
for (int i = 0; i < searchStrings.length; i++) {
String searchString = searchStrings[i];
if (StringUtils.startsWith(string, searchString)) {
return true;
}
}
return false;
} | [
"public",
"static",
"boolean",
"startsWithAny",
"(",
"String",
"string",
",",
"String",
"[",
"]",
"searchStrings",
")",
"{",
"if",
"(",
"isEmpty",
"(",
"string",
")",
"||",
"ArrayUtils",
".",
"isEmpty",
"(",
"searchStrings",
")",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"searchStrings",
".",
"length",
";",
"i",
"++",
")",
"{",
"String",
"searchString",
"=",
"searchStrings",
"[",
"i",
"]",
";",
"if",
"(",
"StringUtils",
".",
"startsWith",
"(",
"string",
",",
"searchString",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | <p>Check if a String starts with any of an array of specified strings.</p>
<pre>
StringUtils.startsWithAny(null, null) = false
StringUtils.startsWithAny(null, new String[] {"abc"}) = false
StringUtils.startsWithAny("abcxyz", null) = false
StringUtils.startsWithAny("abcxyz", new String[] {""}) = false
StringUtils.startsWithAny("abcxyz", new String[] {"abc"}) = true
StringUtils.startsWithAny("abcxyz", new String[] {null, "xyz", "abc"}) = true
</pre>
@see #startsWith(String, String)
@param string the String to check, may be null
@param searchStrings the Strings to find, may be null or empty
@return <code>true</code> if the String starts with any of the the prefixes, case insensitive, or
both <code>null</code>
@since 2.5 | [
"<p",
">",
"Check",
"if",
"a",
"String",
"starts",
"with",
"any",
"of",
"an",
"array",
"of",
"specified",
"strings",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/ineunetOS/knife-commons/blob/eae9e59afa020a00ae8977c10d43ac8ae46ae236/knife-commons-utils/src/main/java/com/ineunet/knife/util/StringUtils.java#L6285-L6296 |
alkacon/opencms-core | src/org/opencms/ui/apps/CmsDefaultAppButtonProvider.java | CmsDefaultAppButtonProvider.createIconButton | public static Button createIconButton(String name, String description, Resource icon) {
"""
Creates an icon button.<p>
@param name the name
@param description the description
@param icon the icon
@return the created button
"""
return createIconButton(name, description, icon, I_CmsAppButtonProvider.BUTTON_STYLE_TRANSPARENT);
} | java | public static Button createIconButton(String name, String description, Resource icon) {
return createIconButton(name, description, icon, I_CmsAppButtonProvider.BUTTON_STYLE_TRANSPARENT);
} | [
"public",
"static",
"Button",
"createIconButton",
"(",
"String",
"name",
",",
"String",
"description",
",",
"Resource",
"icon",
")",
"{",
"return",
"createIconButton",
"(",
"name",
",",
"description",
",",
"icon",
",",
"I_CmsAppButtonProvider",
".",
"BUTTON_STYLE_TRANSPARENT",
")",
";",
"}"
] | Creates an icon button.<p>
@param name the name
@param description the description
@param icon the icon
@return the created button | [
"Creates",
"an",
"icon",
"button",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/apps/CmsDefaultAppButtonProvider.java#L195-L198 |
VoltDB/voltdb | src/frontend/org/voltdb/StatsSource.java | StatsSource.populateColumnSchema | protected void populateColumnSchema(ArrayList<ColumnInfo> columns) {
"""
Called from the constructor to generate the column schema at run time.
Derived classes need to override this method in order to specify the
columns they will be adding. The first line must always be a call the
superclasses version of populateColumnSchema
in order to ensure the columns are add to the list in the right order.
@param columns Output list for the column schema.
"""
columns.add(new ColumnInfo("TIMESTAMP", VoltType.BIGINT));
columns.add(new ColumnInfo(VoltSystemProcedure.CNAME_HOST_ID,
VoltSystemProcedure.CTYPE_ID));
columns.add(new ColumnInfo("HOSTNAME", VoltType.STRING));
} | java | protected void populateColumnSchema(ArrayList<ColumnInfo> columns) {
columns.add(new ColumnInfo("TIMESTAMP", VoltType.BIGINT));
columns.add(new ColumnInfo(VoltSystemProcedure.CNAME_HOST_ID,
VoltSystemProcedure.CTYPE_ID));
columns.add(new ColumnInfo("HOSTNAME", VoltType.STRING));
} | [
"protected",
"void",
"populateColumnSchema",
"(",
"ArrayList",
"<",
"ColumnInfo",
">",
"columns",
")",
"{",
"columns",
".",
"add",
"(",
"new",
"ColumnInfo",
"(",
"\"TIMESTAMP\"",
",",
"VoltType",
".",
"BIGINT",
")",
")",
";",
"columns",
".",
"add",
"(",
"new",
"ColumnInfo",
"(",
"VoltSystemProcedure",
".",
"CNAME_HOST_ID",
",",
"VoltSystemProcedure",
".",
"CTYPE_ID",
")",
")",
";",
"columns",
".",
"add",
"(",
"new",
"ColumnInfo",
"(",
"\"HOSTNAME\"",
",",
"VoltType",
".",
"STRING",
")",
")",
";",
"}"
] | Called from the constructor to generate the column schema at run time.
Derived classes need to override this method in order to specify the
columns they will be adding. The first line must always be a call the
superclasses version of populateColumnSchema
in order to ensure the columns are add to the list in the right order.
@param columns Output list for the column schema. | [
"Called",
"from",
"the",
"constructor",
"to",
"generate",
"the",
"column",
"schema",
"at",
"run",
"time",
".",
"Derived",
"classes",
"need",
"to",
"override",
"this",
"method",
"in",
"order",
"to",
"specify",
"the",
"columns",
"they",
"will",
"be",
"adding",
".",
"The",
"first",
"line",
"must",
"always",
"be",
"a",
"call",
"the",
"superclasses",
"version",
"of",
"populateColumnSchema",
"in",
"order",
"to",
"ensure",
"the",
"columns",
"are",
"add",
"to",
"the",
"list",
"in",
"the",
"right",
"order",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/StatsSource.java#L93-L98 |
rwl/CSparseJ | src/main/java/edu/emory/mathcs/csparsej/tfloat/Scs_lsolve.java | Scs_lsolve.cs_lsolve | public static boolean cs_lsolve(Scs L, float[] x) {
"""
Solves a lower triangular system Lx=b where x and b are dense. x=b on
input, solution on output.
@param L
column-compressed, lower triangular matrix
@param x
size n, right hand side on input, solution on output
@return true if successful, false on error
"""
int p, j, n, Lp[], Li[];
float Lx[];
if (!Scs_util.CS_CSC(L) || x == null)
return (false); /* check inputs */
n = L.n;
Lp = L.p;
Li = L.i;
Lx = L.x;
for (j = 0; j < n; j++) {
x[j] /= Lx[Lp[j]];
for (p = Lp[j] + 1; p < Lp[j + 1]; p++) {
x[Li[p]] -= Lx[p] * x[j];
}
}
return true;
} | java | public static boolean cs_lsolve(Scs L, float[] x) {
int p, j, n, Lp[], Li[];
float Lx[];
if (!Scs_util.CS_CSC(L) || x == null)
return (false); /* check inputs */
n = L.n;
Lp = L.p;
Li = L.i;
Lx = L.x;
for (j = 0; j < n; j++) {
x[j] /= Lx[Lp[j]];
for (p = Lp[j] + 1; p < Lp[j + 1]; p++) {
x[Li[p]] -= Lx[p] * x[j];
}
}
return true;
} | [
"public",
"static",
"boolean",
"cs_lsolve",
"(",
"Scs",
"L",
",",
"float",
"[",
"]",
"x",
")",
"{",
"int",
"p",
",",
"j",
",",
"n",
",",
"Lp",
"[",
"]",
",",
"Li",
"[",
"]",
";",
"float",
"Lx",
"[",
"]",
";",
"if",
"(",
"!",
"Scs_util",
".",
"CS_CSC",
"(",
"L",
")",
"||",
"x",
"==",
"null",
")",
"return",
"(",
"false",
")",
";",
"/* check inputs */",
"n",
"=",
"L",
".",
"n",
";",
"Lp",
"=",
"L",
".",
"p",
";",
"Li",
"=",
"L",
".",
"i",
";",
"Lx",
"=",
"L",
".",
"x",
";",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"n",
";",
"j",
"++",
")",
"{",
"x",
"[",
"j",
"]",
"/=",
"Lx",
"[",
"Lp",
"[",
"j",
"]",
"]",
";",
"for",
"(",
"p",
"=",
"Lp",
"[",
"j",
"]",
"+",
"1",
";",
"p",
"<",
"Lp",
"[",
"j",
"+",
"1",
"]",
";",
"p",
"++",
")",
"{",
"x",
"[",
"Li",
"[",
"p",
"]",
"]",
"-=",
"Lx",
"[",
"p",
"]",
"*",
"x",
"[",
"j",
"]",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Solves a lower triangular system Lx=b where x and b are dense. x=b on
input, solution on output.
@param L
column-compressed, lower triangular matrix
@param x
size n, right hand side on input, solution on output
@return true if successful, false on error | [
"Solves",
"a",
"lower",
"triangular",
"system",
"Lx",
"=",
"b",
"where",
"x",
"and",
"b",
"are",
"dense",
".",
"x",
"=",
"b",
"on",
"input",
"solution",
"on",
"output",
"."
] | train | https://github.com/rwl/CSparseJ/blob/6a6f66bccce1558156a961494358952603b0ac84/src/main/java/edu/emory/mathcs/csparsej/tfloat/Scs_lsolve.java#L46-L62 |
UrielCh/ovh-java-sdk | ovh-java-sdk-me/src/main/java/net/minidev/ovh/api/ApiOvhMe.java | ApiOvhMe.task_domain_id_argument_key_GET | public OvhDomainTaskArgument task_domain_id_argument_key_GET(Long id, String key) throws IOException {
"""
Get this object properties
REST: GET /me/task/domain/{id}/argument/{key}
@param id [required] Id of the task
@param key [required] Key of the argument
"""
String qPath = "/me/task/domain/{id}/argument/{key}";
StringBuilder sb = path(qPath, id, key);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhDomainTaskArgument.class);
} | java | public OvhDomainTaskArgument task_domain_id_argument_key_GET(Long id, String key) throws IOException {
String qPath = "/me/task/domain/{id}/argument/{key}";
StringBuilder sb = path(qPath, id, key);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhDomainTaskArgument.class);
} | [
"public",
"OvhDomainTaskArgument",
"task_domain_id_argument_key_GET",
"(",
"Long",
"id",
",",
"String",
"key",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/me/task/domain/{id}/argument/{key}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"id",
",",
"key",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhDomainTaskArgument",
".",
"class",
")",
";",
"}"
] | Get this object properties
REST: GET /me/task/domain/{id}/argument/{key}
@param id [required] Id of the task
@param key [required] Key of the argument | [
"Get",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-me/src/main/java/net/minidev/ovh/api/ApiOvhMe.java#L2374-L2379 |
Azure/azure-sdk-for-java | mysql/resource-manager/v2017_12_01/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01/implementation/DatabasesInner.java | DatabasesInner.createOrUpdateAsync | public Observable<DatabaseInner> createOrUpdateAsync(String resourceGroupName, String serverName, String databaseName, DatabaseInner parameters) {
"""
Creates a new database or updates an existing database.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param databaseName The name of the database.
@param parameters The required parameters for creating or updating a database.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request
"""
return createOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, databaseName, parameters).map(new Func1<ServiceResponse<DatabaseInner>, DatabaseInner>() {
@Override
public DatabaseInner call(ServiceResponse<DatabaseInner> response) {
return response.body();
}
});
} | java | public Observable<DatabaseInner> createOrUpdateAsync(String resourceGroupName, String serverName, String databaseName, DatabaseInner parameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, databaseName, parameters).map(new Func1<ServiceResponse<DatabaseInner>, DatabaseInner>() {
@Override
public DatabaseInner call(ServiceResponse<DatabaseInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"DatabaseInner",
">",
"createOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"String",
"databaseName",
",",
"DatabaseInner",
"parameters",
")",
"{",
"return",
"createOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
",",
"databaseName",
",",
"parameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"DatabaseInner",
">",
",",
"DatabaseInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"DatabaseInner",
"call",
"(",
"ServiceResponse",
"<",
"DatabaseInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Creates a new database or updates an existing database.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param databaseName The name of the database.
@param parameters The required parameters for creating or updating a database.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request | [
"Creates",
"a",
"new",
"database",
"or",
"updates",
"an",
"existing",
"database",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/mysql/resource-manager/v2017_12_01/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01/implementation/DatabasesInner.java#L126-L133 |
kuali/kc-s2sgen | coeus-s2sgen-impl/src/main/java/org/kuali/coeus/s2sgen/impl/generate/support/RRBudget10V1_1Generator.java | RRBudget10V1_1Generator.setOthersForOtherDirectCosts | private void setOthersForOtherDirectCosts(OtherDirectCosts otherDirectCosts, BudgetPeriodDto periodInfo) {
"""
This method is to set Other type description and total cost
OtherDirectCosts details in BudgetYearDataType based on BudgetPeriodInfo
for the RRBudget10.
@param otherDirectCosts otherDirectCosts xmlObject
@param periodInfo
(BudgetPeriodInfo) budget period entry.
"""
if (periodInfo != null && periodInfo.getOtherDirectCosts() != null) {
for (OtherDirectCostInfoDto otherDirectCostInfo : periodInfo.getOtherDirectCosts()) {
gov.grants.apply.forms.rrBudget10V11.BudgetYearDataType.OtherDirectCosts.Other other = otherDirectCosts.addNewOther();
if (otherDirectCostInfo.getOtherCosts() != null
&& otherDirectCostInfo.getOtherCosts().size() > 0) {
other
.setCost(new BigDecimal(otherDirectCostInfo
.getOtherCosts().get(0).get(
CostConstants.KEY_COST)));
}
other.setDescription(OTHERCOST_DESCRIPTION);
}
}
} | java | private void setOthersForOtherDirectCosts(OtherDirectCosts otherDirectCosts, BudgetPeriodDto periodInfo) {
if (periodInfo != null && periodInfo.getOtherDirectCosts() != null) {
for (OtherDirectCostInfoDto otherDirectCostInfo : periodInfo.getOtherDirectCosts()) {
gov.grants.apply.forms.rrBudget10V11.BudgetYearDataType.OtherDirectCosts.Other other = otherDirectCosts.addNewOther();
if (otherDirectCostInfo.getOtherCosts() != null
&& otherDirectCostInfo.getOtherCosts().size() > 0) {
other
.setCost(new BigDecimal(otherDirectCostInfo
.getOtherCosts().get(0).get(
CostConstants.KEY_COST)));
}
other.setDescription(OTHERCOST_DESCRIPTION);
}
}
} | [
"private",
"void",
"setOthersForOtherDirectCosts",
"(",
"OtherDirectCosts",
"otherDirectCosts",
",",
"BudgetPeriodDto",
"periodInfo",
")",
"{",
"if",
"(",
"periodInfo",
"!=",
"null",
"&&",
"periodInfo",
".",
"getOtherDirectCosts",
"(",
")",
"!=",
"null",
")",
"{",
"for",
"(",
"OtherDirectCostInfoDto",
"otherDirectCostInfo",
":",
"periodInfo",
".",
"getOtherDirectCosts",
"(",
")",
")",
"{",
"gov",
".",
"grants",
".",
"apply",
".",
"forms",
".",
"rrBudget10V11",
".",
"BudgetYearDataType",
".",
"OtherDirectCosts",
".",
"Other",
"other",
"=",
"otherDirectCosts",
".",
"addNewOther",
"(",
")",
";",
"if",
"(",
"otherDirectCostInfo",
".",
"getOtherCosts",
"(",
")",
"!=",
"null",
"&&",
"otherDirectCostInfo",
".",
"getOtherCosts",
"(",
")",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"other",
".",
"setCost",
"(",
"new",
"BigDecimal",
"(",
"otherDirectCostInfo",
".",
"getOtherCosts",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"get",
"(",
"CostConstants",
".",
"KEY_COST",
")",
")",
")",
";",
"}",
"other",
".",
"setDescription",
"(",
"OTHERCOST_DESCRIPTION",
")",
";",
"}",
"}",
"}"
] | This method is to set Other type description and total cost
OtherDirectCosts details in BudgetYearDataType based on BudgetPeriodInfo
for the RRBudget10.
@param otherDirectCosts otherDirectCosts xmlObject
@param periodInfo
(BudgetPeriodInfo) budget period entry. | [
"This",
"method",
"is",
"to",
"set",
"Other",
"type",
"description",
"and",
"total",
"cost",
"OtherDirectCosts",
"details",
"in",
"BudgetYearDataType",
"based",
"on",
"BudgetPeriodInfo",
"for",
"the",
"RRBudget10",
"."
] | train | https://github.com/kuali/kc-s2sgen/blob/2886380e1e3cb8bdd732ba99b2afa6ffc630bb37/coeus-s2sgen-impl/src/main/java/org/kuali/coeus/s2sgen/impl/generate/support/RRBudget10V1_1Generator.java#L463-L477 |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/factory/filter/kernel/FactoryKernelGaussian.java | FactoryKernelGaussian.gaussian2D | public static <T extends ImageGray<T>, K extends Kernel2D>
K gaussian2D(Class<T> imageType, double sigma, int radius ) {
"""
Creates a 2D Gaussian kernel of the specified type.
@param imageType The type of image which is to be convolved by this kernel.
@param sigma The distributions stdev. If ≤ 0 then the sigma will be computed from the radius.
@param radius Number of pixels in the kernel's radius. If ≤ 0 then the sigma will be computed from the sigma.
@return The computed Gaussian kernel.
"""
boolean isFloat = GeneralizedImageOps.isFloatingPoint(imageType);
int numBits = Math.max(32, GeneralizedImageOps.getNumBits(imageType));
return gaussian(2,isFloat, numBits, sigma,radius);
} | java | public static <T extends ImageGray<T>, K extends Kernel2D>
K gaussian2D(Class<T> imageType, double sigma, int radius )
{
boolean isFloat = GeneralizedImageOps.isFloatingPoint(imageType);
int numBits = Math.max(32, GeneralizedImageOps.getNumBits(imageType));
return gaussian(2,isFloat, numBits, sigma,radius);
} | [
"public",
"static",
"<",
"T",
"extends",
"ImageGray",
"<",
"T",
">",
",",
"K",
"extends",
"Kernel2D",
">",
"K",
"gaussian2D",
"(",
"Class",
"<",
"T",
">",
"imageType",
",",
"double",
"sigma",
",",
"int",
"radius",
")",
"{",
"boolean",
"isFloat",
"=",
"GeneralizedImageOps",
".",
"isFloatingPoint",
"(",
"imageType",
")",
";",
"int",
"numBits",
"=",
"Math",
".",
"max",
"(",
"32",
",",
"GeneralizedImageOps",
".",
"getNumBits",
"(",
"imageType",
")",
")",
";",
"return",
"gaussian",
"(",
"2",
",",
"isFloat",
",",
"numBits",
",",
"sigma",
",",
"radius",
")",
";",
"}"
] | Creates a 2D Gaussian kernel of the specified type.
@param imageType The type of image which is to be convolved by this kernel.
@param sigma The distributions stdev. If ≤ 0 then the sigma will be computed from the radius.
@param radius Number of pixels in the kernel's radius. If ≤ 0 then the sigma will be computed from the sigma.
@return The computed Gaussian kernel. | [
"Creates",
"a",
"2D",
"Gaussian",
"kernel",
"of",
"the",
"specified",
"type",
"."
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/factory/filter/kernel/FactoryKernelGaussian.java#L95-L101 |
Netflix/conductor | core/src/main/java/com/netflix/conductor/core/execution/WorkflowExecutor.java | WorkflowExecutor.rollbackTasks | @VisibleForTesting
void rollbackTasks(String workflowId, List<Task> createdTasks) {
"""
Rolls back all newly created tasks in a workflow, essentially resetting the workflow state, in case of an exception during task creation or task enqueuing.
@param createdTasks a {@link List} of newly created tasks in the workflow which are to be rolled back
"""
String description = "rolling back task from DAO for " + workflowId;
String operation = "rollbackTasks";
try {
// rollback all newly created tasks in the workflow
createdTasks.forEach(task -> new RetryUtil<>().retryOnException(() ->
{
if (task.getTaskType().equals(SUB_WORKFLOW.name())) {
executionDAOFacade.removeWorkflow((String) task.getOutputData().get(SUB_WORKFLOW_ID), false);
}
executionDAOFacade.removeTask(task.getTaskId());
return null;
}, null, null, 3, description, operation));
} catch (Exception e) {
String errorMsg = String.format("Error scheduling/rolling back tasks for workflow: %s", workflowId);
LOGGER.error(errorMsg, e);
throw new TerminateWorkflowException(errorMsg);
}
} | java | @VisibleForTesting
void rollbackTasks(String workflowId, List<Task> createdTasks) {
String description = "rolling back task from DAO for " + workflowId;
String operation = "rollbackTasks";
try {
// rollback all newly created tasks in the workflow
createdTasks.forEach(task -> new RetryUtil<>().retryOnException(() ->
{
if (task.getTaskType().equals(SUB_WORKFLOW.name())) {
executionDAOFacade.removeWorkflow((String) task.getOutputData().get(SUB_WORKFLOW_ID), false);
}
executionDAOFacade.removeTask(task.getTaskId());
return null;
}, null, null, 3, description, operation));
} catch (Exception e) {
String errorMsg = String.format("Error scheduling/rolling back tasks for workflow: %s", workflowId);
LOGGER.error(errorMsg, e);
throw new TerminateWorkflowException(errorMsg);
}
} | [
"@",
"VisibleForTesting",
"void",
"rollbackTasks",
"(",
"String",
"workflowId",
",",
"List",
"<",
"Task",
">",
"createdTasks",
")",
"{",
"String",
"description",
"=",
"\"rolling back task from DAO for \"",
"+",
"workflowId",
";",
"String",
"operation",
"=",
"\"rollbackTasks\"",
";",
"try",
"{",
"// rollback all newly created tasks in the workflow",
"createdTasks",
".",
"forEach",
"(",
"task",
"->",
"new",
"RetryUtil",
"<>",
"(",
")",
".",
"retryOnException",
"(",
"(",
")",
"->",
"{",
"if",
"(",
"task",
".",
"getTaskType",
"(",
")",
".",
"equals",
"(",
"SUB_WORKFLOW",
".",
"name",
"(",
")",
")",
")",
"{",
"executionDAOFacade",
".",
"removeWorkflow",
"(",
"(",
"String",
")",
"task",
".",
"getOutputData",
"(",
")",
".",
"get",
"(",
"SUB_WORKFLOW_ID",
")",
",",
"false",
")",
";",
"}",
"executionDAOFacade",
".",
"removeTask",
"(",
"task",
".",
"getTaskId",
"(",
")",
")",
";",
"return",
"null",
";",
"}",
",",
"null",
",",
"null",
",",
"3",
",",
"description",
",",
"operation",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"String",
"errorMsg",
"=",
"String",
".",
"format",
"(",
"\"Error scheduling/rolling back tasks for workflow: %s\"",
",",
"workflowId",
")",
";",
"LOGGER",
".",
"error",
"(",
"errorMsg",
",",
"e",
")",
";",
"throw",
"new",
"TerminateWorkflowException",
"(",
"errorMsg",
")",
";",
"}",
"}"
] | Rolls back all newly created tasks in a workflow, essentially resetting the workflow state, in case of an exception during task creation or task enqueuing.
@param createdTasks a {@link List} of newly created tasks in the workflow which are to be rolled back | [
"Rolls",
"back",
"all",
"newly",
"created",
"tasks",
"in",
"a",
"workflow",
"essentially",
"resetting",
"the",
"workflow",
"state",
"in",
"case",
"of",
"an",
"exception",
"during",
"task",
"creation",
"or",
"task",
"enqueuing",
"."
] | train | https://github.com/Netflix/conductor/blob/78fae0ed9ddea22891f9eebb96a2ec0b2783dca0/core/src/main/java/com/netflix/conductor/core/execution/WorkflowExecutor.java#L1194-L1214 |
jbundle/jbundle | thin/base/screen/grid/src/main/java/org/jbundle/thin/base/screen/grid/ThinTableModel.java | ThinTableModel.isCellEditable | public boolean isCellEditable(int iRowIndex, int iColumnIndex) {
"""
Is this cell editable.
@return true unless this is a deleted record.
"""
FieldList fieldList = this.makeRowCurrent(iRowIndex, false);
if (fieldList != null) if (fieldList.getEditMode() == Constants.EDIT_NONE)
if ((m_iLastRecord == RECORD_UNKNOWN) || (iRowIndex != m_iLastRecord + 1))
return false; // Don't allow changes to deleted records
return true; // All my fields are editable
} | java | public boolean isCellEditable(int iRowIndex, int iColumnIndex)
{
FieldList fieldList = this.makeRowCurrent(iRowIndex, false);
if (fieldList != null) if (fieldList.getEditMode() == Constants.EDIT_NONE)
if ((m_iLastRecord == RECORD_UNKNOWN) || (iRowIndex != m_iLastRecord + 1))
return false; // Don't allow changes to deleted records
return true; // All my fields are editable
} | [
"public",
"boolean",
"isCellEditable",
"(",
"int",
"iRowIndex",
",",
"int",
"iColumnIndex",
")",
"{",
"FieldList",
"fieldList",
"=",
"this",
".",
"makeRowCurrent",
"(",
"iRowIndex",
",",
"false",
")",
";",
"if",
"(",
"fieldList",
"!=",
"null",
")",
"if",
"(",
"fieldList",
".",
"getEditMode",
"(",
")",
"==",
"Constants",
".",
"EDIT_NONE",
")",
"if",
"(",
"(",
"m_iLastRecord",
"==",
"RECORD_UNKNOWN",
")",
"||",
"(",
"iRowIndex",
"!=",
"m_iLastRecord",
"+",
"1",
")",
")",
"return",
"false",
";",
"// Don't allow changes to deleted records",
"return",
"true",
";",
"// All my fields are editable",
"}"
] | Is this cell editable.
@return true unless this is a deleted record. | [
"Is",
"this",
"cell",
"editable",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/grid/src/main/java/org/jbundle/thin/base/screen/grid/ThinTableModel.java#L184-L191 |
icode/ameba | src/main/java/ameba/db/ebean/EbeanUtils.java | EbeanUtils.forceUpdateAllProperties | @SuppressWarnings("unchecked")
public static <T> void forceUpdateAllProperties(SpiEbeanServer server, T model) {
"""
<p>forceUpdateAllProperties.</p>
@param server a {@link io.ebeaninternal.api.SpiEbeanServer} object.
@param model a T object.
@param <T> a T object.
"""
forceUpdateAllProperties(server.getBeanDescriptor((Class<T>) model.getClass()), model);
} | java | @SuppressWarnings("unchecked")
public static <T> void forceUpdateAllProperties(SpiEbeanServer server, T model) {
forceUpdateAllProperties(server.getBeanDescriptor((Class<T>) model.getClass()), model);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"T",
">",
"void",
"forceUpdateAllProperties",
"(",
"SpiEbeanServer",
"server",
",",
"T",
"model",
")",
"{",
"forceUpdateAllProperties",
"(",
"server",
".",
"getBeanDescriptor",
"(",
"(",
"Class",
"<",
"T",
">",
")",
"model",
".",
"getClass",
"(",
")",
")",
",",
"model",
")",
";",
"}"
] | <p>forceUpdateAllProperties.</p>
@param server a {@link io.ebeaninternal.api.SpiEbeanServer} object.
@param model a T object.
@param <T> a T object. | [
"<p",
">",
"forceUpdateAllProperties",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/icode/ameba/blob/9d4956e935898e41331b2745e400ef869cd265e0/src/main/java/ameba/db/ebean/EbeanUtils.java#L57-L60 |
datacleaner/AnalyzerBeans | core/src/main/java/org/eobjects/analyzer/util/StringUtils.java | StringUtils.replaceAll | public static String replaceAll(String v, String searchToken, String replacement) {
"""
Utility method that will do replacement multiple times until no more
occurrences are left.
Note that this is NOT the same as
{@link String#replaceAll(String, String)} which will only do one
run-through of the string, and it will use regexes instead of exact
searching.
@param v
@param searchToken
@param replacement
@return
"""
if (v == null) {
return v;
}
while (v.indexOf(searchToken) != -1) {
v = v.replace(searchToken, replacement);
}
return v;
} | java | public static String replaceAll(String v, String searchToken, String replacement) {
if (v == null) {
return v;
}
while (v.indexOf(searchToken) != -1) {
v = v.replace(searchToken, replacement);
}
return v;
} | [
"public",
"static",
"String",
"replaceAll",
"(",
"String",
"v",
",",
"String",
"searchToken",
",",
"String",
"replacement",
")",
"{",
"if",
"(",
"v",
"==",
"null",
")",
"{",
"return",
"v",
";",
"}",
"while",
"(",
"v",
".",
"indexOf",
"(",
"searchToken",
")",
"!=",
"-",
"1",
")",
"{",
"v",
"=",
"v",
".",
"replace",
"(",
"searchToken",
",",
"replacement",
")",
";",
"}",
"return",
"v",
";",
"}"
] | Utility method that will do replacement multiple times until no more
occurrences are left.
Note that this is NOT the same as
{@link String#replaceAll(String, String)} which will only do one
run-through of the string, and it will use regexes instead of exact
searching.
@param v
@param searchToken
@param replacement
@return | [
"Utility",
"method",
"that",
"will",
"do",
"replacement",
"multiple",
"times",
"until",
"no",
"more",
"occurrences",
"are",
"left",
"."
] | train | https://github.com/datacleaner/AnalyzerBeans/blob/f82dae080d80d2a647b706a5fb22b3ea250613b3/core/src/main/java/org/eobjects/analyzer/util/StringUtils.java#L155-L163 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/ValueEnforcer.java | ValueEnforcer.isSame | public static <T> T isSame (final T aValue, final String sName, @Nullable final T aExpectedValue) {
"""
Check that the passed value is the same as the provided expected value
using <code>==</code> to check comparison.
@param <T>
Type to be checked and returned
@param aValue
The value to check.
@param sName
The name of the value (e.g. the parameter name)
@param aExpectedValue
The expected value. May be <code>null</code>.
@return The passed value and maybe <code>null</code> if the expected value
is null.
@throws IllegalArgumentException
if the passed value is not <code>null</code>.
"""
if (isEnabled ())
return isSame (aValue, () -> sName, aExpectedValue);
return aValue;
} | java | public static <T> T isSame (final T aValue, final String sName, @Nullable final T aExpectedValue)
{
if (isEnabled ())
return isSame (aValue, () -> sName, aExpectedValue);
return aValue;
} | [
"public",
"static",
"<",
"T",
">",
"T",
"isSame",
"(",
"final",
"T",
"aValue",
",",
"final",
"String",
"sName",
",",
"@",
"Nullable",
"final",
"T",
"aExpectedValue",
")",
"{",
"if",
"(",
"isEnabled",
"(",
")",
")",
"return",
"isSame",
"(",
"aValue",
",",
"(",
")",
"->",
"sName",
",",
"aExpectedValue",
")",
";",
"return",
"aValue",
";",
"}"
] | Check that the passed value is the same as the provided expected value
using <code>==</code> to check comparison.
@param <T>
Type to be checked and returned
@param aValue
The value to check.
@param sName
The name of the value (e.g. the parameter name)
@param aExpectedValue
The expected value. May be <code>null</code>.
@return The passed value and maybe <code>null</code> if the expected value
is null.
@throws IllegalArgumentException
if the passed value is not <code>null</code>. | [
"Check",
"that",
"the",
"passed",
"value",
"is",
"the",
"same",
"as",
"the",
"provided",
"expected",
"value",
"using",
"<code",
">",
"==",
"<",
"/",
"code",
">",
"to",
"check",
"comparison",
"."
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/ValueEnforcer.java#L1426-L1431 |
line/armeria | examples/annotated-http-service/src/main/java/example/armeria/server/annotated/MessageConverterService.java | MessageConverterService.json2 | @Post("/node/obj")
@ProducesJson
public Response json2(@RequestObject JsonNode input) {
"""
Returns a {@link Response} object. The {@link ProducesJson} annotation makes an object be converted
as JSON string by the {@link JacksonResponseConverterFunction}.
"""
final JsonNode name = input.get("name");
return new Response(Response.SUCCESS, name.textValue());
} | java | @Post("/node/obj")
@ProducesJson
public Response json2(@RequestObject JsonNode input) {
final JsonNode name = input.get("name");
return new Response(Response.SUCCESS, name.textValue());
} | [
"@",
"Post",
"(",
"\"/node/obj\"",
")",
"@",
"ProducesJson",
"public",
"Response",
"json2",
"(",
"@",
"RequestObject",
"JsonNode",
"input",
")",
"{",
"final",
"JsonNode",
"name",
"=",
"input",
".",
"get",
"(",
"\"name\"",
")",
";",
"return",
"new",
"Response",
"(",
"Response",
".",
"SUCCESS",
",",
"name",
".",
"textValue",
"(",
")",
")",
";",
"}"
] | Returns a {@link Response} object. The {@link ProducesJson} annotation makes an object be converted
as JSON string by the {@link JacksonResponseConverterFunction}. | [
"Returns",
"a",
"{"
] | train | https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/examples/annotated-http-service/src/main/java/example/armeria/server/annotated/MessageConverterService.java#L59-L64 |
joniles/mpxj | src/main/java/net/sf/mpxj/Task.java | Task.setBaselineEstimatedDuration | public void setBaselineEstimatedDuration(int baselineNumber, Duration value) {
"""
Set a baseline value.
@param baselineNumber baseline index (1-10)
@param value baseline value
"""
set(selectField(TaskFieldLists.BASELINE_ESTIMATED_DURATIONS, baselineNumber), value);
} | java | public void setBaselineEstimatedDuration(int baselineNumber, Duration value)
{
set(selectField(TaskFieldLists.BASELINE_ESTIMATED_DURATIONS, baselineNumber), value);
} | [
"public",
"void",
"setBaselineEstimatedDuration",
"(",
"int",
"baselineNumber",
",",
"Duration",
"value",
")",
"{",
"set",
"(",
"selectField",
"(",
"TaskFieldLists",
".",
"BASELINE_ESTIMATED_DURATIONS",
",",
"baselineNumber",
")",
",",
"value",
")",
";",
"}"
] | Set a baseline value.
@param baselineNumber baseline index (1-10)
@param value baseline value | [
"Set",
"a",
"baseline",
"value",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L4361-L4364 |
acromusashi/acromusashi-stream | src/main/java/acromusashi/stream/bean/FieldExtractor.java | FieldExtractor.extractKeyTail | public static String extractKeyTail(String key, String delimeter) {
"""
Extract the value of keyTail.
@param key is used to get string.
@param delimeter key delimeter
@return the value of keyTail .
"""
int index = key.indexOf(delimeter);
if (index == -1)
{
return null;
}
String result = key.substring(index + delimeter.length());
return result;
} | java | public static String extractKeyTail(String key, String delimeter)
{
int index = key.indexOf(delimeter);
if (index == -1)
{
return null;
}
String result = key.substring(index + delimeter.length());
return result;
} | [
"public",
"static",
"String",
"extractKeyTail",
"(",
"String",
"key",
",",
"String",
"delimeter",
")",
"{",
"int",
"index",
"=",
"key",
".",
"indexOf",
"(",
"delimeter",
")",
";",
"if",
"(",
"index",
"==",
"-",
"1",
")",
"{",
"return",
"null",
";",
"}",
"String",
"result",
"=",
"key",
".",
"substring",
"(",
"index",
"+",
"delimeter",
".",
"length",
"(",
")",
")",
";",
"return",
"result",
";",
"}"
] | Extract the value of keyTail.
@param key is used to get string.
@param delimeter key delimeter
@return the value of keyTail . | [
"Extract",
"the",
"value",
"of",
"keyTail",
"."
] | train | https://github.com/acromusashi/acromusashi-stream/blob/65b1f335d771d657c5640a2056ab5c8546eddec9/src/main/java/acromusashi/stream/bean/FieldExtractor.java#L106-L115 |
UrielCh/ovh-java-sdk | ovh-java-sdk-cloud/src/main/java/net/minidev/ovh/api/ApiOvhCloud.java | ApiOvhCloud.project_serviceName_user_userId_DELETE | public void project_serviceName_user_userId_DELETE(String serviceName, Long userId) throws IOException {
"""
Delete user
REST: DELETE /cloud/project/{serviceName}/user/{userId}
@param serviceName [required] Service name
@param userId [required] User id
"""
String qPath = "/cloud/project/{serviceName}/user/{userId}";
StringBuilder sb = path(qPath, serviceName, userId);
exec(qPath, "DELETE", sb.toString(), null);
} | java | public void project_serviceName_user_userId_DELETE(String serviceName, Long userId) throws IOException {
String qPath = "/cloud/project/{serviceName}/user/{userId}";
StringBuilder sb = path(qPath, serviceName, userId);
exec(qPath, "DELETE", sb.toString(), null);
} | [
"public",
"void",
"project_serviceName_user_userId_DELETE",
"(",
"String",
"serviceName",
",",
"Long",
"userId",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/cloud/project/{serviceName}/user/{userId}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"userId",
")",
";",
"exec",
"(",
"qPath",
",",
"\"DELETE\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"}"
] | Delete user
REST: DELETE /cloud/project/{serviceName}/user/{userId}
@param serviceName [required] Service name
@param userId [required] User id | [
"Delete",
"user"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-cloud/src/main/java/net/minidev/ovh/api/ApiOvhCloud.java#L432-L436 |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/query/UserAlias.java | UserAlias.initMapping | private void initMapping(String attributePath, String aliasPath) {
"""
generates the mapping from the aliasPath
@param aliasPath the portion of attributePath which should be aliased
"""
Iterator aliasSegmentItr = pathToSegments(aliasPath).iterator();
String currPath = "";
String separator = "";
while (aliasSegmentItr.hasNext())
{
currPath = currPath + separator + (String) aliasSegmentItr.next();
int beginIndex = attributePath.indexOf(currPath);
if (beginIndex == -1)
{
break;
}
int endIndex = beginIndex + currPath.length();
m_mapping.put(attributePath.substring(0, endIndex), m_name);
separator = ".";
}
} | java | private void initMapping(String attributePath, String aliasPath)
{
Iterator aliasSegmentItr = pathToSegments(aliasPath).iterator();
String currPath = "";
String separator = "";
while (aliasSegmentItr.hasNext())
{
currPath = currPath + separator + (String) aliasSegmentItr.next();
int beginIndex = attributePath.indexOf(currPath);
if (beginIndex == -1)
{
break;
}
int endIndex = beginIndex + currPath.length();
m_mapping.put(attributePath.substring(0, endIndex), m_name);
separator = ".";
}
} | [
"private",
"void",
"initMapping",
"(",
"String",
"attributePath",
",",
"String",
"aliasPath",
")",
"{",
"Iterator",
"aliasSegmentItr",
"=",
"pathToSegments",
"(",
"aliasPath",
")",
".",
"iterator",
"(",
")",
";",
"String",
"currPath",
"=",
"\"\"",
";",
"String",
"separator",
"=",
"\"\"",
";",
"while",
"(",
"aliasSegmentItr",
".",
"hasNext",
"(",
")",
")",
"{",
"currPath",
"=",
"currPath",
"+",
"separator",
"+",
"(",
"String",
")",
"aliasSegmentItr",
".",
"next",
"(",
")",
";",
"int",
"beginIndex",
"=",
"attributePath",
".",
"indexOf",
"(",
"currPath",
")",
";",
"if",
"(",
"beginIndex",
"==",
"-",
"1",
")",
"{",
"break",
";",
"}",
"int",
"endIndex",
"=",
"beginIndex",
"+",
"currPath",
".",
"length",
"(",
")",
";",
"m_mapping",
".",
"put",
"(",
"attributePath",
".",
"substring",
"(",
"0",
",",
"endIndex",
")",
",",
"m_name",
")",
";",
"separator",
"=",
"\".\"",
";",
"}",
"}"
] | generates the mapping from the aliasPath
@param aliasPath the portion of attributePath which should be aliased | [
"generates",
"the",
"mapping",
"from",
"the",
"aliasPath",
"@param",
"aliasPath",
"the",
"portion",
"of",
"attributePath",
"which",
"should",
"be",
"aliased"
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/query/UserAlias.java#L94-L111 |
telly/groundy | library/src/main/java/com/telly/groundy/TaskResult.java | TaskResult.add | public TaskResult add(String key, String value) {
"""
Inserts a String value into the mapping of this Bundle, replacing any existing value for the
given key. Either key or value may be null.
@param key a String, or null
@param value a String, or null
"""
mBundle.putString(key, value);
return this;
} | java | public TaskResult add(String key, String value) {
mBundle.putString(key, value);
return this;
} | [
"public",
"TaskResult",
"add",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"mBundle",
".",
"putString",
"(",
"key",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] | Inserts a String value into the mapping of this Bundle, replacing any existing value for the
given key. Either key or value may be null.
@param key a String, or null
@param value a String, or null | [
"Inserts",
"a",
"String",
"value",
"into",
"the",
"mapping",
"of",
"this",
"Bundle",
"replacing",
"any",
"existing",
"value",
"for",
"the",
"given",
"key",
".",
"Either",
"key",
"or",
"value",
"may",
"be",
"null",
"."
] | train | https://github.com/telly/groundy/blob/e90baf9901a8be20b348bd1575d5ad782560cec8/library/src/main/java/com/telly/groundy/TaskResult.java#L155-L158 |
facebook/fresco | imagepipeline-base/src/main/java/com/facebook/imagepipeline/bitmaps/PlatformBitmapFactory.java | PlatformBitmapFactory.createBitmap | public CloseableReference<Bitmap> createBitmap(
Bitmap source,
int x,
int y,
int width,
int height) {
"""
Creates a bitmap from the specified subset of the source
bitmap. It is initialized with the same density as the original bitmap.
@param source The bitmap we are subsetting
@param x The x coordinate of the first pixel in source
@param y The y coordinate of the first pixel in source
@param width The number of pixels in each row
@param height The number of rows
@return a reference to the bitmap
@throws IllegalArgumentException if the x, y, width, height values are
outside of the dimensions of the source bitmap, or width is <= 0,
or height is <= 0
@throws TooManyBitmapsException if the pool is full
@throws java.lang.OutOfMemoryError if the Bitmap cannot be allocated
"""
return createBitmap(source, x, y, width, height, null);
} | java | public CloseableReference<Bitmap> createBitmap(
Bitmap source,
int x,
int y,
int width,
int height) {
return createBitmap(source, x, y, width, height, null);
} | [
"public",
"CloseableReference",
"<",
"Bitmap",
">",
"createBitmap",
"(",
"Bitmap",
"source",
",",
"int",
"x",
",",
"int",
"y",
",",
"int",
"width",
",",
"int",
"height",
")",
"{",
"return",
"createBitmap",
"(",
"source",
",",
"x",
",",
"y",
",",
"width",
",",
"height",
",",
"null",
")",
";",
"}"
] | Creates a bitmap from the specified subset of the source
bitmap. It is initialized with the same density as the original bitmap.
@param source The bitmap we are subsetting
@param x The x coordinate of the first pixel in source
@param y The y coordinate of the first pixel in source
@param width The number of pixels in each row
@param height The number of rows
@return a reference to the bitmap
@throws IllegalArgumentException if the x, y, width, height values are
outside of the dimensions of the source bitmap, or width is <= 0,
or height is <= 0
@throws TooManyBitmapsException if the pool is full
@throws java.lang.OutOfMemoryError if the Bitmap cannot be allocated | [
"Creates",
"a",
"bitmap",
"from",
"the",
"specified",
"subset",
"of",
"the",
"source",
"bitmap",
".",
"It",
"is",
"initialized",
"with",
"the",
"same",
"density",
"as",
"the",
"original",
"bitmap",
"."
] | train | https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline-base/src/main/java/com/facebook/imagepipeline/bitmaps/PlatformBitmapFactory.java#L144-L151 |
Azure/azure-sdk-for-java | keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java | KeyVaultClientBaseImpl.purgeDeletedStorageAccountAsync | public ServiceFuture<Void> purgeDeletedStorageAccountAsync(String vaultBaseUrl, String storageAccountName, final ServiceCallback<Void> serviceCallback) {
"""
Permanently deletes the specified storage account.
The purge deleted storage account operation removes the secret permanently, without the possibility of recovery. This operation can only be performed on a soft-delete enabled vault. This operation requires the storage/purge permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param storageAccountName The name of the storage account.
@param serviceCallback the async ServiceCallback to handle successful and failed responses.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceFuture} object
"""
return ServiceFuture.fromResponse(purgeDeletedStorageAccountWithServiceResponseAsync(vaultBaseUrl, storageAccountName), serviceCallback);
} | java | public ServiceFuture<Void> purgeDeletedStorageAccountAsync(String vaultBaseUrl, String storageAccountName, final ServiceCallback<Void> serviceCallback) {
return ServiceFuture.fromResponse(purgeDeletedStorageAccountWithServiceResponseAsync(vaultBaseUrl, storageAccountName), serviceCallback);
} | [
"public",
"ServiceFuture",
"<",
"Void",
">",
"purgeDeletedStorageAccountAsync",
"(",
"String",
"vaultBaseUrl",
",",
"String",
"storageAccountName",
",",
"final",
"ServiceCallback",
"<",
"Void",
">",
"serviceCallback",
")",
"{",
"return",
"ServiceFuture",
".",
"fromResponse",
"(",
"purgeDeletedStorageAccountWithServiceResponseAsync",
"(",
"vaultBaseUrl",
",",
"storageAccountName",
")",
",",
"serviceCallback",
")",
";",
"}"
] | Permanently deletes the specified storage account.
The purge deleted storage account operation removes the secret permanently, without the possibility of recovery. This operation can only be performed on a soft-delete enabled vault. This operation requires the storage/purge permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param storageAccountName The name of the storage account.
@param serviceCallback the async ServiceCallback to handle successful and failed responses.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceFuture} object | [
"Permanently",
"deletes",
"the",
"specified",
"storage",
"account",
".",
"The",
"purge",
"deleted",
"storage",
"account",
"operation",
"removes",
"the",
"secret",
"permanently",
"without",
"the",
"possibility",
"of",
"recovery",
".",
"This",
"operation",
"can",
"only",
"be",
"performed",
"on",
"a",
"soft",
"-",
"delete",
"enabled",
"vault",
".",
"This",
"operation",
"requires",
"the",
"storage",
"/",
"purge",
"permission",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java#L9358-L9360 |
Esri/geometry-api-java | src/main/java/com/esri/core/geometry/Treap.java | Treap.searchLowerBound | public int searchLowerBound(MonikerComparator moniker, int treap) {
"""
Returns closest smaller (Comparator::compare returns -1) or any equal.
"""
int cur = getRoot(treap);
int bound = -1;
while (cur != nullNode()) {
int res = moniker.compare(this, cur);
if (res == 0)
return cur;
else if (res < 0)
cur = getLeft(cur);
else {
bound = cur;
cur = getRight(cur);
}
}
return bound;
} | java | public int searchLowerBound(MonikerComparator moniker, int treap) {
int cur = getRoot(treap);
int bound = -1;
while (cur != nullNode()) {
int res = moniker.compare(this, cur);
if (res == 0)
return cur;
else if (res < 0)
cur = getLeft(cur);
else {
bound = cur;
cur = getRight(cur);
}
}
return bound;
} | [
"public",
"int",
"searchLowerBound",
"(",
"MonikerComparator",
"moniker",
",",
"int",
"treap",
")",
"{",
"int",
"cur",
"=",
"getRoot",
"(",
"treap",
")",
";",
"int",
"bound",
"=",
"-",
"1",
";",
"while",
"(",
"cur",
"!=",
"nullNode",
"(",
")",
")",
"{",
"int",
"res",
"=",
"moniker",
".",
"compare",
"(",
"this",
",",
"cur",
")",
";",
"if",
"(",
"res",
"==",
"0",
")",
"return",
"cur",
";",
"else",
"if",
"(",
"res",
"<",
"0",
")",
"cur",
"=",
"getLeft",
"(",
"cur",
")",
";",
"else",
"{",
"bound",
"=",
"cur",
";",
"cur",
"=",
"getRight",
"(",
"cur",
")",
";",
"}",
"}",
"return",
"bound",
";",
"}"
] | Returns closest smaller (Comparator::compare returns -1) or any equal. | [
"Returns",
"closest",
"smaller",
"(",
"Comparator",
"::",
"compare",
"returns",
"-",
"1",
")",
"or",
"any",
"equal",
"."
] | train | https://github.com/Esri/geometry-api-java/blob/494da8ec953d76e7c6072afbc081abfe48ff07cf/src/main/java/com/esri/core/geometry/Treap.java#L346-L362 |
Azure/azure-sdk-for-java | automation/resource-manager/v2015_10_31/src/main/java/com/microsoft/azure/management/automation/v2015_10_31/implementation/DscConfigurationsInner.java | DscConfigurationsInner.getContentAsync | public Observable<String> getContentAsync(String resourceGroupName, String automationAccountName, String configurationName) {
"""
Retrieve the configuration script identified by configuration name.
@param resourceGroupName Name of an Azure Resource group.
@param automationAccountName The name of the automation account.
@param configurationName The configuration name.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the String object
"""
return getContentWithServiceResponseAsync(resourceGroupName, automationAccountName, configurationName).map(new Func1<ServiceResponse<String>, String>() {
@Override
public String call(ServiceResponse<String> response) {
return response.body();
}
});
} | java | public Observable<String> getContentAsync(String resourceGroupName, String automationAccountName, String configurationName) {
return getContentWithServiceResponseAsync(resourceGroupName, automationAccountName, configurationName).map(new Func1<ServiceResponse<String>, String>() {
@Override
public String call(ServiceResponse<String> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"String",
">",
"getContentAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"automationAccountName",
",",
"String",
"configurationName",
")",
"{",
"return",
"getContentWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"automationAccountName",
",",
"configurationName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"String",
">",
",",
"String",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"String",
"call",
"(",
"ServiceResponse",
"<",
"String",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Retrieve the configuration script identified by configuration name.
@param resourceGroupName Name of an Azure Resource group.
@param automationAccountName The name of the automation account.
@param configurationName The configuration name.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the String object | [
"Retrieve",
"the",
"configuration",
"script",
"identified",
"by",
"configuration",
"name",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/automation/resource-manager/v2015_10_31/src/main/java/com/microsoft/azure/management/automation/v2015_10_31/implementation/DscConfigurationsInner.java#L598-L605 |
dlemmermann/CalendarFX | CalendarFXRecurrence/src/main/java/com/google/ical/util/TimeUtils.java | TimeUtils.fixedFromGregorian | public static int fixedFromGregorian(int year, int month, int day) {
"""
the number of days since the <em>epoch</em>,
which is the imaginary beginning of year zero in a hypothetical
backward extension of the Gregorian calendar through time.
See "Calendrical Calculations" by Reingold and Dershowitz.
"""
int yearM1 = year - 1;
return 365 * yearM1 +
yearM1 / 4 -
yearM1 / 100 +
yearM1 / 400 +
(367 * month - 362) / 12 +
(month <= 2 ? 0 :
isLeapYear(year) ? -1 :
-2) +
day;
} | java | public static int fixedFromGregorian(int year, int month, int day) {
int yearM1 = year - 1;
return 365 * yearM1 +
yearM1 / 4 -
yearM1 / 100 +
yearM1 / 400 +
(367 * month - 362) / 12 +
(month <= 2 ? 0 :
isLeapYear(year) ? -1 :
-2) +
day;
} | [
"public",
"static",
"int",
"fixedFromGregorian",
"(",
"int",
"year",
",",
"int",
"month",
",",
"int",
"day",
")",
"{",
"int",
"yearM1",
"=",
"year",
"-",
"1",
";",
"return",
"365",
"*",
"yearM1",
"+",
"yearM1",
"/",
"4",
"-",
"yearM1",
"/",
"100",
"+",
"yearM1",
"/",
"400",
"+",
"(",
"367",
"*",
"month",
"-",
"362",
")",
"/",
"12",
"+",
"(",
"month",
"<=",
"2",
"?",
"0",
":",
"isLeapYear",
"(",
"year",
")",
"?",
"-",
"1",
":",
"-",
"2",
")",
"+",
"day",
";",
"}"
] | the number of days since the <em>epoch</em>,
which is the imaginary beginning of year zero in a hypothetical
backward extension of the Gregorian calendar through time.
See "Calendrical Calculations" by Reingold and Dershowitz. | [
"the",
"number",
"of",
"days",
"since",
"the",
"<em",
">",
"epoch<",
"/",
"em",
">",
"which",
"is",
"the",
"imaginary",
"beginning",
"of",
"year",
"zero",
"in",
"a",
"hypothetical",
"backward",
"extension",
"of",
"the",
"Gregorian",
"calendar",
"through",
"time",
".",
"See",
"Calendrical",
"Calculations",
"by",
"Reingold",
"and",
"Dershowitz",
"."
] | train | https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXRecurrence/src/main/java/com/google/ical/util/TimeUtils.java#L148-L159 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.