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
|
---|---|---|---|---|---|---|---|---|---|---|
dickschoeller/gedbrowser | gedbrowser-writer/src/main/java/org/schoellerfamily/gedbrowser/writer/users/UsersWriter.java | UsersWriter.appendRoles | private void appendRoles(final StringBuilder builder, final User user) {
"""
Append roles to the builder.
@param builder the builder
@param user the user whose roles are appended
"""
for (final UserRoleName role : user.getRoles()) {
append(builder, ",", role.name());
}
} | java | private void appendRoles(final StringBuilder builder, final User user) {
for (final UserRoleName role : user.getRoles()) {
append(builder, ",", role.name());
}
} | [
"private",
"void",
"appendRoles",
"(",
"final",
"StringBuilder",
"builder",
",",
"final",
"User",
"user",
")",
"{",
"for",
"(",
"final",
"UserRoleName",
"role",
":",
"user",
".",
"getRoles",
"(",
")",
")",
"{",
"append",
"(",
"builder",
",",
"\",\"",
",",
"role",
".",
"name",
"(",
")",
")",
";",
"}",
"}"
] | Append roles to the builder.
@param builder the builder
@param user the user whose roles are appended | [
"Append",
"roles",
"to",
"the",
"builder",
"."
] | train | https://github.com/dickschoeller/gedbrowser/blob/e3e10b1ff3a34ebde9b7edcbfafcd5fe6fb3b3e1/gedbrowser-writer/src/main/java/org/schoellerfamily/gedbrowser/writer/users/UsersWriter.java#L122-L126 |
googleapis/cloud-bigtable-client | bigtable-client-core-parent/bigtable-client-core/src/main/java/com/google/cloud/bigtable/config/BigtableVeneerSettingsFactory.java | BigtableVeneerSettingsFactory.buildSampleRowKeysSettings | private static void buildSampleRowKeysSettings(Builder builder, BigtableOptions options) {
"""
To build BigtableDataSettings#sampleRowKeysSettings with default Retry settings.
"""
RetrySettings retrySettings =
buildIdempotentRetrySettings(builder.sampleRowKeysSettings().getRetrySettings(), options);
builder.sampleRowKeysSettings()
.setRetrySettings(retrySettings)
.setRetryableCodes(buildRetryCodes(options.getRetryOptions()));
} | java | private static void buildSampleRowKeysSettings(Builder builder, BigtableOptions options) {
RetrySettings retrySettings =
buildIdempotentRetrySettings(builder.sampleRowKeysSettings().getRetrySettings(), options);
builder.sampleRowKeysSettings()
.setRetrySettings(retrySettings)
.setRetryableCodes(buildRetryCodes(options.getRetryOptions()));
} | [
"private",
"static",
"void",
"buildSampleRowKeysSettings",
"(",
"Builder",
"builder",
",",
"BigtableOptions",
"options",
")",
"{",
"RetrySettings",
"retrySettings",
"=",
"buildIdempotentRetrySettings",
"(",
"builder",
".",
"sampleRowKeysSettings",
"(",
")",
".",
"getRetrySettings",
"(",
")",
",",
"options",
")",
";",
"builder",
".",
"sampleRowKeysSettings",
"(",
")",
".",
"setRetrySettings",
"(",
"retrySettings",
")",
".",
"setRetryableCodes",
"(",
"buildRetryCodes",
"(",
"options",
".",
"getRetryOptions",
"(",
")",
")",
")",
";",
"}"
] | To build BigtableDataSettings#sampleRowKeysSettings with default Retry settings. | [
"To",
"build",
"BigtableDataSettings#sampleRowKeysSettings",
"with",
"default",
"Retry",
"settings",
"."
] | train | https://github.com/googleapis/cloud-bigtable-client/blob/53543f36e4d6f9ed1963640d91a35be2a2047656/bigtable-client-core-parent/bigtable-client-core/src/main/java/com/google/cloud/bigtable/config/BigtableVeneerSettingsFactory.java#L204-L211 |
Impetus/Kundera | src/kundera-couchdb/src/main/java/com/impetus/client/couchdb/CouchDBQuery.java | CouchDBQuery.recursivelyPopulateEntities | @Override
protected List recursivelyPopulateEntities(EntityMetadata m, Client client) {
"""
Recursively populate entity.
@param m
the m
@param client
the client
@return the list
"""
List<EnhanceEntity> ls = populateEntities(m, client);
return setRelationEntities(ls, client, m);
} | java | @Override
protected List recursivelyPopulateEntities(EntityMetadata m, Client client)
{
List<EnhanceEntity> ls = populateEntities(m, client);
return setRelationEntities(ls, client, m);
} | [
"@",
"Override",
"protected",
"List",
"recursivelyPopulateEntities",
"(",
"EntityMetadata",
"m",
",",
"Client",
"client",
")",
"{",
"List",
"<",
"EnhanceEntity",
">",
"ls",
"=",
"populateEntities",
"(",
"m",
",",
"client",
")",
";",
"return",
"setRelationEntities",
"(",
"ls",
",",
"client",
",",
"m",
")",
";",
"}"
] | Recursively populate entity.
@param m
the m
@param client
the client
@return the list | [
"Recursively",
"populate",
"entity",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-couchdb/src/main/java/com/impetus/client/couchdb/CouchDBQuery.java#L127-L132 |
michael-rapp/AndroidBottomSheet | library/src/main/java/de/mrapp/android/bottomsheet/adapter/DividableGridAdapter.java | DividableGridAdapter.setItemEnabled | public final void setItemEnabled(final int index, final boolean enabled) {
"""
Sets, whether the item at a specific index should be enabled, or not.
@param index
The index of the item as an {@link Integer} value
@param enabled
True, if the item should be enabled, false otherwise
"""
AbstractItem item = items.get(index);
if (item instanceof Item) {
((Item) item).setEnabled(enabled);
rawItems = null;
notifyOnDataSetChanged();
}
} | java | public final void setItemEnabled(final int index, final boolean enabled) {
AbstractItem item = items.get(index);
if (item instanceof Item) {
((Item) item).setEnabled(enabled);
rawItems = null;
notifyOnDataSetChanged();
}
} | [
"public",
"final",
"void",
"setItemEnabled",
"(",
"final",
"int",
"index",
",",
"final",
"boolean",
"enabled",
")",
"{",
"AbstractItem",
"item",
"=",
"items",
".",
"get",
"(",
"index",
")",
";",
"if",
"(",
"item",
"instanceof",
"Item",
")",
"{",
"(",
"(",
"Item",
")",
"item",
")",
".",
"setEnabled",
"(",
"enabled",
")",
";",
"rawItems",
"=",
"null",
";",
"notifyOnDataSetChanged",
"(",
")",
";",
"}",
"}"
] | Sets, whether the item at a specific index should be enabled, or not.
@param index
The index of the item as an {@link Integer} value
@param enabled
True, if the item should be enabled, false otherwise | [
"Sets",
"whether",
"the",
"item",
"at",
"a",
"specific",
"index",
"should",
"be",
"enabled",
"or",
"not",
"."
] | train | https://github.com/michael-rapp/AndroidBottomSheet/blob/6e4690ee9f63b14a7b143d3a3717b5f8a11ca503/library/src/main/java/de/mrapp/android/bottomsheet/adapter/DividableGridAdapter.java#L599-L607 |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/factory/feature/tracker/FactoryPointTracker.java | FactoryPointTracker.combined_FH_SURF_KLT | public static <I extends ImageGray<I>>
PointTracker<I> combined_FH_SURF_KLT( PkltConfig kltConfig ,
int reactivateThreshold ,
ConfigFastHessian configDetector ,
ConfigSurfDescribe.Stability configDescribe ,
ConfigSlidingIntegral configOrientation ,
Class<I> imageType) {
"""
Creates a tracker which detects Fast-Hessian features, describes them with SURF, nominally tracks them using KLT.
@see DescribePointSurf
@see boofcv.abst.feature.tracker.DdaManagerDetectDescribePoint
@param kltConfig Configuration for KLT tracker
@param reactivateThreshold Tracks are reactivated after this many have been dropped. Try 10% of maxMatches
@param configDetector Configuration for SURF detector
@param configDescribe Configuration for SURF descriptor
@param configOrientation Configuration for region orientation
@param imageType Type of image the input is.
@param <I> Input image type.
@return SURF based tracker.
"""
ScoreAssociation<TupleDesc_F64> score = FactoryAssociation.defaultScore(TupleDesc_F64.class);
AssociateSurfBasic assoc = new AssociateSurfBasic(FactoryAssociation.greedy(score, 100000, true));
AssociateDescription<BrightFeature> generalAssoc = new WrapAssociateSurfBasic(assoc);
DetectDescribePoint<I,BrightFeature> fused =
FactoryDetectDescribe.surfStable(configDetector, configDescribe, configOrientation,imageType);
return combined(fused,generalAssoc, kltConfig,reactivateThreshold, imageType);
} | java | public static <I extends ImageGray<I>>
PointTracker<I> combined_FH_SURF_KLT( PkltConfig kltConfig ,
int reactivateThreshold ,
ConfigFastHessian configDetector ,
ConfigSurfDescribe.Stability configDescribe ,
ConfigSlidingIntegral configOrientation ,
Class<I> imageType) {
ScoreAssociation<TupleDesc_F64> score = FactoryAssociation.defaultScore(TupleDesc_F64.class);
AssociateSurfBasic assoc = new AssociateSurfBasic(FactoryAssociation.greedy(score, 100000, true));
AssociateDescription<BrightFeature> generalAssoc = new WrapAssociateSurfBasic(assoc);
DetectDescribePoint<I,BrightFeature> fused =
FactoryDetectDescribe.surfStable(configDetector, configDescribe, configOrientation,imageType);
return combined(fused,generalAssoc, kltConfig,reactivateThreshold, imageType);
} | [
"public",
"static",
"<",
"I",
"extends",
"ImageGray",
"<",
"I",
">",
">",
"PointTracker",
"<",
"I",
">",
"combined_FH_SURF_KLT",
"(",
"PkltConfig",
"kltConfig",
",",
"int",
"reactivateThreshold",
",",
"ConfigFastHessian",
"configDetector",
",",
"ConfigSurfDescribe",
".",
"Stability",
"configDescribe",
",",
"ConfigSlidingIntegral",
"configOrientation",
",",
"Class",
"<",
"I",
">",
"imageType",
")",
"{",
"ScoreAssociation",
"<",
"TupleDesc_F64",
">",
"score",
"=",
"FactoryAssociation",
".",
"defaultScore",
"(",
"TupleDesc_F64",
".",
"class",
")",
";",
"AssociateSurfBasic",
"assoc",
"=",
"new",
"AssociateSurfBasic",
"(",
"FactoryAssociation",
".",
"greedy",
"(",
"score",
",",
"100000",
",",
"true",
")",
")",
";",
"AssociateDescription",
"<",
"BrightFeature",
">",
"generalAssoc",
"=",
"new",
"WrapAssociateSurfBasic",
"(",
"assoc",
")",
";",
"DetectDescribePoint",
"<",
"I",
",",
"BrightFeature",
">",
"fused",
"=",
"FactoryDetectDescribe",
".",
"surfStable",
"(",
"configDetector",
",",
"configDescribe",
",",
"configOrientation",
",",
"imageType",
")",
";",
"return",
"combined",
"(",
"fused",
",",
"generalAssoc",
",",
"kltConfig",
",",
"reactivateThreshold",
",",
"imageType",
")",
";",
"}"
] | Creates a tracker which detects Fast-Hessian features, describes them with SURF, nominally tracks them using KLT.
@see DescribePointSurf
@see boofcv.abst.feature.tracker.DdaManagerDetectDescribePoint
@param kltConfig Configuration for KLT tracker
@param reactivateThreshold Tracks are reactivated after this many have been dropped. Try 10% of maxMatches
@param configDetector Configuration for SURF detector
@param configDescribe Configuration for SURF descriptor
@param configOrientation Configuration for region orientation
@param imageType Type of image the input is.
@param <I> Input image type.
@return SURF based tracker. | [
"Creates",
"a",
"tracker",
"which",
"detects",
"Fast",
"-",
"Hessian",
"features",
"describes",
"them",
"with",
"SURF",
"nominally",
"tracks",
"them",
"using",
"KLT",
"."
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/factory/feature/tracker/FactoryPointTracker.java#L387-L404 |
icode/ameba | src/main/java/ameba/container/server/Connector.java | Connector.createDefaultConnectors | public static List<Connector> createDefaultConnectors(Map<String, Object> properties) {
"""
<p>createDefaultConnectors.</p>
@param properties a {@link java.util.Map} object.
@return a {@link java.util.List} object.
"""
List<Connector> connectors = Lists.newArrayList();
Map<String, Map<String, String>> propertiesMap = Maps.newLinkedHashMap();
for (String key : properties.keySet()) {
if (key.startsWith(Connector.CONNECTOR_CONF_PREFIX)) {
String oKey = key;
key = key.substring(Connector.CONNECTOR_CONF_PREFIX.length());
int index = key.indexOf(".");
if (index == -1) {
throw new ConfigErrorException("connector configure error, format connector.{connectorName}.{property}");
}
String name = key.substring(0, index);
Map<String, String> pr = propertiesMap.get(name);
if (pr == null) {
pr = Maps.newLinkedHashMap();
propertiesMap.put(name, pr);
pr.put("name", name);
}
pr.put(key.substring(index + 1), String.valueOf(properties.get(oKey)));
}
}
connectors.addAll(propertiesMap.values().stream().map(Connector::createDefault).collect(Collectors.toList()));
return connectors;
} | java | public static List<Connector> createDefaultConnectors(Map<String, Object> properties) {
List<Connector> connectors = Lists.newArrayList();
Map<String, Map<String, String>> propertiesMap = Maps.newLinkedHashMap();
for (String key : properties.keySet()) {
if (key.startsWith(Connector.CONNECTOR_CONF_PREFIX)) {
String oKey = key;
key = key.substring(Connector.CONNECTOR_CONF_PREFIX.length());
int index = key.indexOf(".");
if (index == -1) {
throw new ConfigErrorException("connector configure error, format connector.{connectorName}.{property}");
}
String name = key.substring(0, index);
Map<String, String> pr = propertiesMap.get(name);
if (pr == null) {
pr = Maps.newLinkedHashMap();
propertiesMap.put(name, pr);
pr.put("name", name);
}
pr.put(key.substring(index + 1), String.valueOf(properties.get(oKey)));
}
}
connectors.addAll(propertiesMap.values().stream().map(Connector::createDefault).collect(Collectors.toList()));
return connectors;
} | [
"public",
"static",
"List",
"<",
"Connector",
">",
"createDefaultConnectors",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"properties",
")",
"{",
"List",
"<",
"Connector",
">",
"connectors",
"=",
"Lists",
".",
"newArrayList",
"(",
")",
";",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"String",
">",
">",
"propertiesMap",
"=",
"Maps",
".",
"newLinkedHashMap",
"(",
")",
";",
"for",
"(",
"String",
"key",
":",
"properties",
".",
"keySet",
"(",
")",
")",
"{",
"if",
"(",
"key",
".",
"startsWith",
"(",
"Connector",
".",
"CONNECTOR_CONF_PREFIX",
")",
")",
"{",
"String",
"oKey",
"=",
"key",
";",
"key",
"=",
"key",
".",
"substring",
"(",
"Connector",
".",
"CONNECTOR_CONF_PREFIX",
".",
"length",
"(",
")",
")",
";",
"int",
"index",
"=",
"key",
".",
"indexOf",
"(",
"\".\"",
")",
";",
"if",
"(",
"index",
"==",
"-",
"1",
")",
"{",
"throw",
"new",
"ConfigErrorException",
"(",
"\"connector configure error, format connector.{connectorName}.{property}\"",
")",
";",
"}",
"String",
"name",
"=",
"key",
".",
"substring",
"(",
"0",
",",
"index",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"pr",
"=",
"propertiesMap",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"pr",
"==",
"null",
")",
"{",
"pr",
"=",
"Maps",
".",
"newLinkedHashMap",
"(",
")",
";",
"propertiesMap",
".",
"put",
"(",
"name",
",",
"pr",
")",
";",
"pr",
".",
"put",
"(",
"\"name\"",
",",
"name",
")",
";",
"}",
"pr",
".",
"put",
"(",
"key",
".",
"substring",
"(",
"index",
"+",
"1",
")",
",",
"String",
".",
"valueOf",
"(",
"properties",
".",
"get",
"(",
"oKey",
")",
")",
")",
";",
"}",
"}",
"connectors",
".",
"addAll",
"(",
"propertiesMap",
".",
"values",
"(",
")",
".",
"stream",
"(",
")",
".",
"map",
"(",
"Connector",
"::",
"createDefault",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
")",
";",
"return",
"connectors",
";",
"}"
] | <p>createDefaultConnectors.</p>
@param properties a {@link java.util.Map} object.
@return a {@link java.util.List} object. | [
"<p",
">",
"createDefaultConnectors",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/icode/ameba/blob/9d4956e935898e41331b2745e400ef869cd265e0/src/main/java/ameba/container/server/Connector.java#L121-L145 |
phoenixnap/springmvc-raml-plugin | src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/helpers/NamingHelper.java | NamingHelper.getResourceName | public static String getResourceName(RamlResource resource, boolean singularize) {
"""
Attempts to infer the name of a resource from a resources's relative URL
@param resource
The raml resource being parsed
@param singularize
indicates if the resource name should be singularized or not
@return A name representing this resource or null if one cannot be
inferred
"""
String url = resource.getRelativeUri();
if (StringUtils.hasText(url) && url.contains("/") && (url.lastIndexOf('/') < url.length())) {
return getResourceName(url.substring(url.lastIndexOf('/') + 1), singularize);
}
return null;
} | java | public static String getResourceName(RamlResource resource, boolean singularize) {
String url = resource.getRelativeUri();
if (StringUtils.hasText(url) && url.contains("/") && (url.lastIndexOf('/') < url.length())) {
return getResourceName(url.substring(url.lastIndexOf('/') + 1), singularize);
}
return null;
} | [
"public",
"static",
"String",
"getResourceName",
"(",
"RamlResource",
"resource",
",",
"boolean",
"singularize",
")",
"{",
"String",
"url",
"=",
"resource",
".",
"getRelativeUri",
"(",
")",
";",
"if",
"(",
"StringUtils",
".",
"hasText",
"(",
"url",
")",
"&&",
"url",
".",
"contains",
"(",
"\"/\"",
")",
"&&",
"(",
"url",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
"<",
"url",
".",
"length",
"(",
")",
")",
")",
"{",
"return",
"getResourceName",
"(",
"url",
".",
"substring",
"(",
"url",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
"+",
"1",
")",
",",
"singularize",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Attempts to infer the name of a resource from a resources's relative URL
@param resource
The raml resource being parsed
@param singularize
indicates if the resource name should be singularized or not
@return A name representing this resource or null if one cannot be
inferred | [
"Attempts",
"to",
"infer",
"the",
"name",
"of",
"a",
"resource",
"from",
"a",
"resources",
"s",
"relative",
"URL"
] | train | https://github.com/phoenixnap/springmvc-raml-plugin/blob/6387072317cd771eb7d6f30943f556ac20dd3c84/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/helpers/NamingHelper.java#L242-L250 |
EdwardRaff/JSAT | JSAT/src/jsat/linear/Matrix.java | Matrix.getColumnView | public Vec getColumnView(final int j) {
"""
Obtains a vector that is backed by <i>this</i>, at very little memory
cost. Mutations to this vector will alter the values stored in the
matrix, and vice versa.
@param j the column to obtain a view of
@return a vector backed by the specified row of the matrix
"""
final Matrix M = this;
return new Vec()
{
private static final long serialVersionUID = 7107290189250645384L;
@Override
public int length()
{
return rows();
}
@Override
public double get(int index)
{
return M.get(index, j);
}
@Override
public void set(int index, double val)
{
M.set(index, j, val);
}
@Override
public boolean isSparse()
{
return M.isSparce();
}
@Override
public Vec clone()
{
if(M.isSparce())
return new SparseVector(this);
else
return new DenseVector(this);
}
@Override
public void setLength(int length)
{
throw new UnsupportedOperationException("Vector view can't not extend original matrix");
}
};
} | java | public Vec getColumnView(final int j)
{
final Matrix M = this;
return new Vec()
{
private static final long serialVersionUID = 7107290189250645384L;
@Override
public int length()
{
return rows();
}
@Override
public double get(int index)
{
return M.get(index, j);
}
@Override
public void set(int index, double val)
{
M.set(index, j, val);
}
@Override
public boolean isSparse()
{
return M.isSparce();
}
@Override
public Vec clone()
{
if(M.isSparce())
return new SparseVector(this);
else
return new DenseVector(this);
}
@Override
public void setLength(int length)
{
throw new UnsupportedOperationException("Vector view can't not extend original matrix");
}
};
} | [
"public",
"Vec",
"getColumnView",
"(",
"final",
"int",
"j",
")",
"{",
"final",
"Matrix",
"M",
"=",
"this",
";",
"return",
"new",
"Vec",
"(",
")",
"{",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"7107290189250645384L",
";",
"@",
"Override",
"public",
"int",
"length",
"(",
")",
"{",
"return",
"rows",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"double",
"get",
"(",
"int",
"index",
")",
"{",
"return",
"M",
".",
"get",
"(",
"index",
",",
"j",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"set",
"(",
"int",
"index",
",",
"double",
"val",
")",
"{",
"M",
".",
"set",
"(",
"index",
",",
"j",
",",
"val",
")",
";",
"}",
"@",
"Override",
"public",
"boolean",
"isSparse",
"(",
")",
"{",
"return",
"M",
".",
"isSparce",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"Vec",
"clone",
"(",
")",
"{",
"if",
"(",
"M",
".",
"isSparce",
"(",
")",
")",
"return",
"new",
"SparseVector",
"(",
"this",
")",
";",
"else",
"return",
"new",
"DenseVector",
"(",
"this",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"setLength",
"(",
"int",
"length",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Vector view can't not extend original matrix\"",
")",
";",
"}",
"}",
";",
"}"
] | Obtains a vector that is backed by <i>this</i>, at very little memory
cost. Mutations to this vector will alter the values stored in the
matrix, and vice versa.
@param j the column to obtain a view of
@return a vector backed by the specified row of the matrix | [
"Obtains",
"a",
"vector",
"that",
"is",
"backed",
"by",
"<i",
">",
"this<",
"/",
"i",
">",
"at",
"very",
"little",
"memory",
"cost",
".",
"Mutations",
"to",
"this",
"vector",
"will",
"alter",
"the",
"values",
"stored",
"in",
"the",
"matrix",
"and",
"vice",
"versa",
"."
] | train | https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/linear/Matrix.java#L628-L674 |
Azure/azure-sdk-for-java | keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientCustomImpl.java | KeyVaultClientCustomImpl.getSecretAsync | public ServiceFuture<SecretBundle> getSecretAsync(String vaultBaseUrl, String secretName,
final ServiceCallback<SecretBundle> serviceCallback) {
"""
Get a specified secret from a given key vault.
@param vaultBaseUrl
The vault name, e.g. https://myvault.vault.azure.net
@param secretName
The name of the secret in the given vault
@param serviceCallback
the async ServiceCallback to handle successful and failed
responses.
@return the {@link ServiceFuture} object
"""
return getSecretAsync(vaultBaseUrl, secretName, "", serviceCallback);
} | java | public ServiceFuture<SecretBundle> getSecretAsync(String vaultBaseUrl, String secretName,
final ServiceCallback<SecretBundle> serviceCallback) {
return getSecretAsync(vaultBaseUrl, secretName, "", serviceCallback);
} | [
"public",
"ServiceFuture",
"<",
"SecretBundle",
">",
"getSecretAsync",
"(",
"String",
"vaultBaseUrl",
",",
"String",
"secretName",
",",
"final",
"ServiceCallback",
"<",
"SecretBundle",
">",
"serviceCallback",
")",
"{",
"return",
"getSecretAsync",
"(",
"vaultBaseUrl",
",",
"secretName",
",",
"\"\"",
",",
"serviceCallback",
")",
";",
"}"
] | Get a specified secret from a given key vault.
@param vaultBaseUrl
The vault name, e.g. https://myvault.vault.azure.net
@param secretName
The name of the secret in the given vault
@param serviceCallback
the async ServiceCallback to handle successful and failed
responses.
@return the {@link ServiceFuture} object | [
"Get",
"a",
"specified",
"secret",
"from",
"a",
"given",
"key",
"vault",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientCustomImpl.java#L1157-L1160 |
jmeter-maven-plugin/jmeter-maven-plugin | src/main/java/com/lazerycode/jmeter/mojo/ConfigureJMeterMojo.java | ConfigureJMeterMojo.extractConfigSettings | private void extractConfigSettings(Artifact artifact) throws MojoExecutionException {
"""
Extract the configuration settings (not properties files) from the configuration artifact
and load them into the /bin directory
@param artifact Configuration artifact
@throws MojoExecutionException MojoExecutionException
"""// NOSONAR
try (JarFile configSettings = new JarFile(artifact.getFile())) {
Enumeration<JarEntry> entries = configSettings.entries();
while (entries.hasMoreElements()) {
JarEntry jarFileEntry = entries.nextElement();
// Only interested in files in the /bin directory that are not properties files
if (!jarFileEntry.isDirectory() && jarFileEntry.getName().startsWith("bin")
&& !jarFileEntry.getName().endsWith(".properties")) {
File fileToCreate = new File(jmeterDirectory, jarFileEntry.getName());
copyInputStreamToFile(configSettings.getInputStream(jarFileEntry), fileToCreate);
}
}
} catch (IOException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
} | java | private void extractConfigSettings(Artifact artifact) throws MojoExecutionException {// NOSONAR
try (JarFile configSettings = new JarFile(artifact.getFile())) {
Enumeration<JarEntry> entries = configSettings.entries();
while (entries.hasMoreElements()) {
JarEntry jarFileEntry = entries.nextElement();
// Only interested in files in the /bin directory that are not properties files
if (!jarFileEntry.isDirectory() && jarFileEntry.getName().startsWith("bin")
&& !jarFileEntry.getName().endsWith(".properties")) {
File fileToCreate = new File(jmeterDirectory, jarFileEntry.getName());
copyInputStreamToFile(configSettings.getInputStream(jarFileEntry), fileToCreate);
}
}
} catch (IOException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
} | [
"private",
"void",
"extractConfigSettings",
"(",
"Artifact",
"artifact",
")",
"throws",
"MojoExecutionException",
"{",
"// NOSONAR",
"try",
"(",
"JarFile",
"configSettings",
"=",
"new",
"JarFile",
"(",
"artifact",
".",
"getFile",
"(",
")",
")",
")",
"{",
"Enumeration",
"<",
"JarEntry",
">",
"entries",
"=",
"configSettings",
".",
"entries",
"(",
")",
";",
"while",
"(",
"entries",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"JarEntry",
"jarFileEntry",
"=",
"entries",
".",
"nextElement",
"(",
")",
";",
"// Only interested in files in the /bin directory that are not properties files",
"if",
"(",
"!",
"jarFileEntry",
".",
"isDirectory",
"(",
")",
"&&",
"jarFileEntry",
".",
"getName",
"(",
")",
".",
"startsWith",
"(",
"\"bin\"",
")",
"&&",
"!",
"jarFileEntry",
".",
"getName",
"(",
")",
".",
"endsWith",
"(",
"\".properties\"",
")",
")",
"{",
"File",
"fileToCreate",
"=",
"new",
"File",
"(",
"jmeterDirectory",
",",
"jarFileEntry",
".",
"getName",
"(",
")",
")",
";",
"copyInputStreamToFile",
"(",
"configSettings",
".",
"getInputStream",
"(",
"jarFileEntry",
")",
",",
"fileToCreate",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"MojoExecutionException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] | Extract the configuration settings (not properties files) from the configuration artifact
and load them into the /bin directory
@param artifact Configuration artifact
@throws MojoExecutionException MojoExecutionException | [
"Extract",
"the",
"configuration",
"settings",
"(",
"not",
"properties",
"files",
")",
"from",
"the",
"configuration",
"artifact",
"and",
"load",
"them",
"into",
"the",
"/",
"bin",
"directory"
] | train | https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/blob/63dc8b49cc6b9542deb681e25a2ada6025ddbf6b/src/main/java/com/lazerycode/jmeter/mojo/ConfigureJMeterMojo.java#L674-L689 |
lonnyj/liquibase-spatial | src/main/java/liquibase/ext/spatial/sqlgenerator/AbstractSpatialInsertGenerator.java | AbstractSpatialInsertGenerator.handleColumnValue | protected Object handleColumnValue(final Object oldValue, final Database database) {
"""
If the old value is a geometry or a Well-Known Text, convert it to the appropriate new value.
Otherwise, this method returns the old value.
@param oldValue
the old value.
@param database
the database instance.
@return the new value.
"""
final Object newValue = WktConversionUtils.handleColumnValue(oldValue, database, this);
return newValue;
} | java | protected Object handleColumnValue(final Object oldValue, final Database database) {
final Object newValue = WktConversionUtils.handleColumnValue(oldValue, database, this);
return newValue;
} | [
"protected",
"Object",
"handleColumnValue",
"(",
"final",
"Object",
"oldValue",
",",
"final",
"Database",
"database",
")",
"{",
"final",
"Object",
"newValue",
"=",
"WktConversionUtils",
".",
"handleColumnValue",
"(",
"oldValue",
",",
"database",
",",
"this",
")",
";",
"return",
"newValue",
";",
"}"
] | If the old value is a geometry or a Well-Known Text, convert it to the appropriate new value.
Otherwise, this method returns the old value.
@param oldValue
the old value.
@param database
the database instance.
@return the new value. | [
"If",
"the",
"old",
"value",
"is",
"a",
"geometry",
"or",
"a",
"Well",
"-",
"Known",
"Text",
"convert",
"it",
"to",
"the",
"appropriate",
"new",
"value",
".",
"Otherwise",
"this",
"method",
"returns",
"the",
"old",
"value",
"."
] | train | https://github.com/lonnyj/liquibase-spatial/blob/36ae41b0d3d08bb00a22c856e51ffeed08891c0e/src/main/java/liquibase/ext/spatial/sqlgenerator/AbstractSpatialInsertGenerator.java#L83-L86 |
elki-project/elki | elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/LogisticDistribution.java | LogisticDistribution.logpdf | public static double logpdf(double val, double loc, double scale) {
"""
log Probability density function.
@param val Value
@param loc Location
@param scale Scale
@return log PDF
"""
val = Math.abs((val - loc) / scale);
double f = 1.0 + FastMath.exp(-val);
return -val - FastMath.log(scale * f * f);
} | java | public static double logpdf(double val, double loc, double scale) {
val = Math.abs((val - loc) / scale);
double f = 1.0 + FastMath.exp(-val);
return -val - FastMath.log(scale * f * f);
} | [
"public",
"static",
"double",
"logpdf",
"(",
"double",
"val",
",",
"double",
"loc",
",",
"double",
"scale",
")",
"{",
"val",
"=",
"Math",
".",
"abs",
"(",
"(",
"val",
"-",
"loc",
")",
"/",
"scale",
")",
";",
"double",
"f",
"=",
"1.0",
"+",
"FastMath",
".",
"exp",
"(",
"-",
"val",
")",
";",
"return",
"-",
"val",
"-",
"FastMath",
".",
"log",
"(",
"scale",
"*",
"f",
"*",
"f",
")",
";",
"}"
] | log Probability density function.
@param val Value
@param loc Location
@param scale Scale
@return log PDF | [
"log",
"Probability",
"density",
"function",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/LogisticDistribution.java#L132-L136 |
goldmansachs/gs-collections | collections/src/main/java/com/gs/collections/impl/utility/ArrayListIterate.java | ArrayListIterate.forEach | public static <T> void forEach(ArrayList<T> list, int from, int to, Procedure<? super T> procedure) {
"""
Iterates over the section of the list covered by the specified indexes. The indexes are both inclusive. If the
from is less than the to, the list is iterated in forward order. If the from is greater than the to, then the
list is iterated in the reverse order.
<p>
<pre>e.g.
ArrayList<People> people = new ArrayList<People>(FastList.newListWith(ted, mary, bob, sally));
ArrayListIterate.forEach(people, 0, 1, new Procedure<Person>()
{
public void value(Person person)
{
LOGGER.info(person.getName());
}
});
</pre>
<p>
This code would output ted and mary's names.
"""
ListIterate.rangeCheck(from, to, list.size());
if (ArrayListIterate.isOptimizableArrayList(list, to - from + 1))
{
T[] elements = ArrayListIterate.getInternalArray(list);
InternalArrayIterate.forEachWithoutChecks(elements, from, to, procedure);
}
else
{
RandomAccessListIterate.forEach(list, from, to, procedure);
}
} | java | public static <T> void forEach(ArrayList<T> list, int from, int to, Procedure<? super T> procedure)
{
ListIterate.rangeCheck(from, to, list.size());
if (ArrayListIterate.isOptimizableArrayList(list, to - from + 1))
{
T[] elements = ArrayListIterate.getInternalArray(list);
InternalArrayIterate.forEachWithoutChecks(elements, from, to, procedure);
}
else
{
RandomAccessListIterate.forEach(list, from, to, procedure);
}
} | [
"public",
"static",
"<",
"T",
">",
"void",
"forEach",
"(",
"ArrayList",
"<",
"T",
">",
"list",
",",
"int",
"from",
",",
"int",
"to",
",",
"Procedure",
"<",
"?",
"super",
"T",
">",
"procedure",
")",
"{",
"ListIterate",
".",
"rangeCheck",
"(",
"from",
",",
"to",
",",
"list",
".",
"size",
"(",
")",
")",
";",
"if",
"(",
"ArrayListIterate",
".",
"isOptimizableArrayList",
"(",
"list",
",",
"to",
"-",
"from",
"+",
"1",
")",
")",
"{",
"T",
"[",
"]",
"elements",
"=",
"ArrayListIterate",
".",
"getInternalArray",
"(",
"list",
")",
";",
"InternalArrayIterate",
".",
"forEachWithoutChecks",
"(",
"elements",
",",
"from",
",",
"to",
",",
"procedure",
")",
";",
"}",
"else",
"{",
"RandomAccessListIterate",
".",
"forEach",
"(",
"list",
",",
"from",
",",
"to",
",",
"procedure",
")",
";",
"}",
"}"
] | Iterates over the section of the list covered by the specified indexes. The indexes are both inclusive. If the
from is less than the to, the list is iterated in forward order. If the from is greater than the to, then the
list is iterated in the reverse order.
<p>
<pre>e.g.
ArrayList<People> people = new ArrayList<People>(FastList.newListWith(ted, mary, bob, sally));
ArrayListIterate.forEach(people, 0, 1, new Procedure<Person>()
{
public void value(Person person)
{
LOGGER.info(person.getName());
}
});
</pre>
<p>
This code would output ted and mary's names. | [
"Iterates",
"over",
"the",
"section",
"of",
"the",
"list",
"covered",
"by",
"the",
"specified",
"indexes",
".",
"The",
"indexes",
"are",
"both",
"inclusive",
".",
"If",
"the",
"from",
"is",
"less",
"than",
"the",
"to",
"the",
"list",
"is",
"iterated",
"in",
"forward",
"order",
".",
"If",
"the",
"from",
"is",
"greater",
"than",
"the",
"to",
"then",
"the",
"list",
"is",
"iterated",
"in",
"the",
"reverse",
"order",
".",
"<p",
">",
"<pre",
">",
"e",
".",
"g",
".",
"ArrayList<People",
">",
"people",
"=",
"new",
"ArrayList<People",
">",
"(",
"FastList",
".",
"newListWith",
"(",
"ted",
"mary",
"bob",
"sally",
"))",
";",
"ArrayListIterate",
".",
"forEach",
"(",
"people",
"0",
"1",
"new",
"Procedure<Person",
">",
"()",
"{",
"public",
"void",
"value",
"(",
"Person",
"person",
")",
"{",
"LOGGER",
".",
"info",
"(",
"person",
".",
"getName",
"()",
")",
";",
"}",
"}",
")",
";",
"<",
"/",
"pre",
">",
"<p",
">",
"This",
"code",
"would",
"output",
"ted",
"and",
"mary",
"s",
"names",
"."
] | train | https://github.com/goldmansachs/gs-collections/blob/fa8bf3e103689efa18bca2ab70203e71cde34b52/collections/src/main/java/com/gs/collections/impl/utility/ArrayListIterate.java#L809-L822 |
vipshop/vjtools | vjtop/src/main/java/com/vip/vjtools/vjtop/VMInfo.java | VMInfo.createDeadVM | public static VMInfo createDeadVM(String pid, VMInfoState state) {
"""
Creates a dead VMInfo, representing a jvm in a given state which cannot
be attached or other monitoring issues occurred.
"""
VMInfo vmInfo = new VMInfo();
vmInfo.state = state;
vmInfo.pid = pid;
return vmInfo;
} | java | public static VMInfo createDeadVM(String pid, VMInfoState state) {
VMInfo vmInfo = new VMInfo();
vmInfo.state = state;
vmInfo.pid = pid;
return vmInfo;
} | [
"public",
"static",
"VMInfo",
"createDeadVM",
"(",
"String",
"pid",
",",
"VMInfoState",
"state",
")",
"{",
"VMInfo",
"vmInfo",
"=",
"new",
"VMInfo",
"(",
")",
";",
"vmInfo",
".",
"state",
"=",
"state",
";",
"vmInfo",
".",
"pid",
"=",
"pid",
";",
"return",
"vmInfo",
";",
"}"
] | Creates a dead VMInfo, representing a jvm in a given state which cannot
be attached or other monitoring issues occurred. | [
"Creates",
"a",
"dead",
"VMInfo",
"representing",
"a",
"jvm",
"in",
"a",
"given",
"state",
"which",
"cannot",
"be",
"attached",
"or",
"other",
"monitoring",
"issues",
"occurred",
"."
] | train | https://github.com/vipshop/vjtools/blob/60c743da35913d72f37f2d79afa90ad2bf73cb89/vjtop/src/main/java/com/vip/vjtools/vjtop/VMInfo.java#L151-L156 |
guardtime/ksi-java-sdk | ksi-common/src/main/java/com/guardtime/ksi/hashing/DataHasher.java | DataHasher.addData | public final DataHasher addData(byte[] data, int offset, int length) {
"""
Updates the digest using the specified array of bytes, starting at the specified offset.
@param data the array of bytes.
@param offset the offset to start from in the array of bytes.
@param length the number of bytes to use, starting at the offset.
@return The same {@link DataHasher} object for chaining calls.
@throws IllegalStateException when hash is already been calculated.
"""
if (outputHash != null) {
throw new IllegalStateException("Output hash has already been calculated");
}
messageDigest.update(data, offset, length);
return this;
} | java | public final DataHasher addData(byte[] data, int offset, int length) {
if (outputHash != null) {
throw new IllegalStateException("Output hash has already been calculated");
}
messageDigest.update(data, offset, length);
return this;
} | [
"public",
"final",
"DataHasher",
"addData",
"(",
"byte",
"[",
"]",
"data",
",",
"int",
"offset",
",",
"int",
"length",
")",
"{",
"if",
"(",
"outputHash",
"!=",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Output hash has already been calculated\"",
")",
";",
"}",
"messageDigest",
".",
"update",
"(",
"data",
",",
"offset",
",",
"length",
")",
";",
"return",
"this",
";",
"}"
] | Updates the digest using the specified array of bytes, starting at the specified offset.
@param data the array of bytes.
@param offset the offset to start from in the array of bytes.
@param length the number of bytes to use, starting at the offset.
@return The same {@link DataHasher} object for chaining calls.
@throws IllegalStateException when hash is already been calculated. | [
"Updates",
"the",
"digest",
"using",
"the",
"specified",
"array",
"of",
"bytes",
"starting",
"at",
"the",
"specified",
"offset",
"."
] | train | https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-common/src/main/java/com/guardtime/ksi/hashing/DataHasher.java#L144-L150 |
ocelotds/ocelot | ocelot-web/src/main/java/org/ocelotds/core/services/MethodServices.java | MethodServices.getNonProxiedMethod | public Method getNonProxiedMethod(Class cls, String methodName, Class<?>... parameterTypes) throws NoSuchMethodException {
"""
Get the method on origin class without proxies
@param cls
@param methodName
@param parameterTypes
@throws NoSuchMethodException
@return
"""
return cls.getMethod(methodName, parameterTypes);
} | java | public Method getNonProxiedMethod(Class cls, String methodName, Class<?>... parameterTypes) throws NoSuchMethodException {
return cls.getMethod(methodName, parameterTypes);
} | [
"public",
"Method",
"getNonProxiedMethod",
"(",
"Class",
"cls",
",",
"String",
"methodName",
",",
"Class",
"<",
"?",
">",
"...",
"parameterTypes",
")",
"throws",
"NoSuchMethodException",
"{",
"return",
"cls",
".",
"getMethod",
"(",
"methodName",
",",
"parameterTypes",
")",
";",
"}"
] | Get the method on origin class without proxies
@param cls
@param methodName
@param parameterTypes
@throws NoSuchMethodException
@return | [
"Get",
"the",
"method",
"on",
"origin",
"class",
"without",
"proxies"
] | train | https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-web/src/main/java/org/ocelotds/core/services/MethodServices.java#L79-L81 |
jbossas/jboss-vfs | src/main/java/org/jboss/vfs/TempFileProvider.java | TempFileProvider.createTempDir | public TempDir createTempDir(String originalName) throws IOException {
"""
Create a temp directory, into which temporary files may be placed.
@param originalName the original file name
@return the temp directory
@throws IOException for any error
"""
if (!open.get()) {
throw VFSMessages.MESSAGES.tempFileProviderClosed();
}
final String name = createTempName(originalName + "-", "");
final File f = new File(providerRoot, name);
for (int i = 0; i < RETRIES; i++) {
if (f.mkdirs()) {
return new TempDir(this, f);
}
}
throw VFSMessages.MESSAGES.couldNotCreateDirectory(originalName,RETRIES);
} | java | public TempDir createTempDir(String originalName) throws IOException {
if (!open.get()) {
throw VFSMessages.MESSAGES.tempFileProviderClosed();
}
final String name = createTempName(originalName + "-", "");
final File f = new File(providerRoot, name);
for (int i = 0; i < RETRIES; i++) {
if (f.mkdirs()) {
return new TempDir(this, f);
}
}
throw VFSMessages.MESSAGES.couldNotCreateDirectory(originalName,RETRIES);
} | [
"public",
"TempDir",
"createTempDir",
"(",
"String",
"originalName",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"open",
".",
"get",
"(",
")",
")",
"{",
"throw",
"VFSMessages",
".",
"MESSAGES",
".",
"tempFileProviderClosed",
"(",
")",
";",
"}",
"final",
"String",
"name",
"=",
"createTempName",
"(",
"originalName",
"+",
"\"-\"",
",",
"\"\"",
")",
";",
"final",
"File",
"f",
"=",
"new",
"File",
"(",
"providerRoot",
",",
"name",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"RETRIES",
";",
"i",
"++",
")",
"{",
"if",
"(",
"f",
".",
"mkdirs",
"(",
")",
")",
"{",
"return",
"new",
"TempDir",
"(",
"this",
",",
"f",
")",
";",
"}",
"}",
"throw",
"VFSMessages",
".",
"MESSAGES",
".",
"couldNotCreateDirectory",
"(",
"originalName",
",",
"RETRIES",
")",
";",
"}"
] | Create a temp directory, into which temporary files may be placed.
@param originalName the original file name
@return the temp directory
@throws IOException for any error | [
"Create",
"a",
"temp",
"directory",
"into",
"which",
"temporary",
"files",
"may",
"be",
"placed",
"."
] | train | https://github.com/jbossas/jboss-vfs/blob/420f4b896d6178ee5f6758f3421e9f350d2b8ab5/src/main/java/org/jboss/vfs/TempFileProvider.java#L131-L143 |
httl/httl | httl/src/main/java/httl/Engine.java | Engine.getProperty | public boolean getProperty(String key, boolean defaultValue) {
"""
Get config boolean value.
@param key - config key
@param defaultValue - default boolean value
@return config boolean value
@see #getEngine()
"""
String value = getProperty(key, String.class);
return StringUtils.isEmpty(value) ? defaultValue : Boolean.parseBoolean(value);
} | java | public boolean getProperty(String key, boolean defaultValue) {
String value = getProperty(key, String.class);
return StringUtils.isEmpty(value) ? defaultValue : Boolean.parseBoolean(value);
} | [
"public",
"boolean",
"getProperty",
"(",
"String",
"key",
",",
"boolean",
"defaultValue",
")",
"{",
"String",
"value",
"=",
"getProperty",
"(",
"key",
",",
"String",
".",
"class",
")",
";",
"return",
"StringUtils",
".",
"isEmpty",
"(",
"value",
")",
"?",
"defaultValue",
":",
"Boolean",
".",
"parseBoolean",
"(",
"value",
")",
";",
"}"
] | Get config boolean value.
@param key - config key
@param defaultValue - default boolean value
@return config boolean value
@see #getEngine() | [
"Get",
"config",
"boolean",
"value",
"."
] | train | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/Engine.java#L233-L236 |
headius/invokebinder | src/main/java/com/headius/invokebinder/SmartHandle.java | SmartHandle.returnValue | public SmartHandle returnValue(Class<?> type, Object value) {
"""
Replace the return value with the given value, performing no other
processing of the original value.
@param type the type for the new return value
@param value the new value to return
@return a new SmartHandle that returns the given value
"""
return new SmartHandle(signature.changeReturn(type), MethodHandles.filterReturnValue(handle, MethodHandles.constant(type, value)));
} | java | public SmartHandle returnValue(Class<?> type, Object value) {
return new SmartHandle(signature.changeReturn(type), MethodHandles.filterReturnValue(handle, MethodHandles.constant(type, value)));
} | [
"public",
"SmartHandle",
"returnValue",
"(",
"Class",
"<",
"?",
">",
"type",
",",
"Object",
"value",
")",
"{",
"return",
"new",
"SmartHandle",
"(",
"signature",
".",
"changeReturn",
"(",
"type",
")",
",",
"MethodHandles",
".",
"filterReturnValue",
"(",
"handle",
",",
"MethodHandles",
".",
"constant",
"(",
"type",
",",
"value",
")",
")",
")",
";",
"}"
] | Replace the return value with the given value, performing no other
processing of the original value.
@param type the type for the new return value
@param value the new value to return
@return a new SmartHandle that returns the given value | [
"Replace",
"the",
"return",
"value",
"with",
"the",
"given",
"value",
"performing",
"no",
"other",
"processing",
"of",
"the",
"original",
"value",
"."
] | train | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/SmartHandle.java#L323-L325 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/PersonGroupPersonsImpl.java | PersonGroupPersonsImpl.createAsync | public Observable<Person> createAsync(String personGroupId, CreatePersonGroupPersonsOptionalParameter createOptionalParameter) {
"""
Create a new person in a specified person group.
@param personGroupId Id referencing a particular person group.
@param createOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the Person object
"""
return createWithServiceResponseAsync(personGroupId, createOptionalParameter).map(new Func1<ServiceResponse<Person>, Person>() {
@Override
public Person call(ServiceResponse<Person> response) {
return response.body();
}
});
} | java | public Observable<Person> createAsync(String personGroupId, CreatePersonGroupPersonsOptionalParameter createOptionalParameter) {
return createWithServiceResponseAsync(personGroupId, createOptionalParameter).map(new Func1<ServiceResponse<Person>, Person>() {
@Override
public Person call(ServiceResponse<Person> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Person",
">",
"createAsync",
"(",
"String",
"personGroupId",
",",
"CreatePersonGroupPersonsOptionalParameter",
"createOptionalParameter",
")",
"{",
"return",
"createWithServiceResponseAsync",
"(",
"personGroupId",
",",
"createOptionalParameter",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Person",
">",
",",
"Person",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Person",
"call",
"(",
"ServiceResponse",
"<",
"Person",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Create a new person in a specified person group.
@param personGroupId Id referencing a particular person group.
@param createOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the Person object | [
"Create",
"a",
"new",
"person",
"in",
"a",
"specified",
"person",
"group",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/PersonGroupPersonsImpl.java#L155-L162 |
hazelcast/hazelcast | hazelcast/src/main/java/com/hazelcast/internal/cluster/impl/MemberMap.java | MemberMap.cloneAdding | static MemberMap cloneAdding(MemberMap source, MemberImpl... newMembers) {
"""
Creates clone of source {@code MemberMap} additionally including new members.
@param source source map
@param newMembers new members to add
@return clone map
"""
Map<Address, MemberImpl> addressMap = new LinkedHashMap<>(source.addressToMemberMap);
Map<String, MemberImpl> uuidMap = new LinkedHashMap<>(source.uuidToMemberMap);
for (MemberImpl member : newMembers) {
putMember(addressMap, uuidMap, member);
}
return new MemberMap(source.version + newMembers.length, addressMap, uuidMap);
} | java | static MemberMap cloneAdding(MemberMap source, MemberImpl... newMembers) {
Map<Address, MemberImpl> addressMap = new LinkedHashMap<>(source.addressToMemberMap);
Map<String, MemberImpl> uuidMap = new LinkedHashMap<>(source.uuidToMemberMap);
for (MemberImpl member : newMembers) {
putMember(addressMap, uuidMap, member);
}
return new MemberMap(source.version + newMembers.length, addressMap, uuidMap);
} | [
"static",
"MemberMap",
"cloneAdding",
"(",
"MemberMap",
"source",
",",
"MemberImpl",
"...",
"newMembers",
")",
"{",
"Map",
"<",
"Address",
",",
"MemberImpl",
">",
"addressMap",
"=",
"new",
"LinkedHashMap",
"<>",
"(",
"source",
".",
"addressToMemberMap",
")",
";",
"Map",
"<",
"String",
",",
"MemberImpl",
">",
"uuidMap",
"=",
"new",
"LinkedHashMap",
"<>",
"(",
"source",
".",
"uuidToMemberMap",
")",
";",
"for",
"(",
"MemberImpl",
"member",
":",
"newMembers",
")",
"{",
"putMember",
"(",
"addressMap",
",",
"uuidMap",
",",
"member",
")",
";",
"}",
"return",
"new",
"MemberMap",
"(",
"source",
".",
"version",
"+",
"newMembers",
".",
"length",
",",
"addressMap",
",",
"uuidMap",
")",
";",
"}"
] | Creates clone of source {@code MemberMap} additionally including new members.
@param source source map
@param newMembers new members to add
@return clone map | [
"Creates",
"clone",
"of",
"source",
"{",
"@code",
"MemberMap",
"}",
"additionally",
"including",
"new",
"members",
"."
] | train | https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/cluster/impl/MemberMap.java#L145-L154 |
VoltDB/voltdb | src/frontend/org/voltdb/utils/VoltTypeUtil.java | VoltTypeUtil.getNumericLiteralType | public static VoltType getNumericLiteralType(VoltType vt, String value) {
"""
If the type is NUMERIC from hsqldb, VoltDB has to decide its real type.
It's either INTEGER or DECIMAL according to the SQL Standard.
Thanks for Hsqldb 1.9, FLOAT literal values have been handled well with E sign.
@param vt
@param value
@return
"""
try {
Long.parseLong(value);
} catch (NumberFormatException e) {
// Our DECIMAL may not be bigger/smaller enough to store the constant value
return VoltType.DECIMAL;
}
return vt;
} | java | public static VoltType getNumericLiteralType(VoltType vt, String value) {
try {
Long.parseLong(value);
} catch (NumberFormatException e) {
// Our DECIMAL may not be bigger/smaller enough to store the constant value
return VoltType.DECIMAL;
}
return vt;
} | [
"public",
"static",
"VoltType",
"getNumericLiteralType",
"(",
"VoltType",
"vt",
",",
"String",
"value",
")",
"{",
"try",
"{",
"Long",
".",
"parseLong",
"(",
"value",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"// Our DECIMAL may not be bigger/smaller enough to store the constant value",
"return",
"VoltType",
".",
"DECIMAL",
";",
"}",
"return",
"vt",
";",
"}"
] | If the type is NUMERIC from hsqldb, VoltDB has to decide its real type.
It's either INTEGER or DECIMAL according to the SQL Standard.
Thanks for Hsqldb 1.9, FLOAT literal values have been handled well with E sign.
@param vt
@param value
@return | [
"If",
"the",
"type",
"is",
"NUMERIC",
"from",
"hsqldb",
"VoltDB",
"has",
"to",
"decide",
"its",
"real",
"type",
".",
"It",
"s",
"either",
"INTEGER",
"or",
"DECIMAL",
"according",
"to",
"the",
"SQL",
"Standard",
".",
"Thanks",
"for",
"Hsqldb",
"1",
".",
"9",
"FLOAT",
"literal",
"values",
"have",
"been",
"handled",
"well",
"with",
"E",
"sign",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/utils/VoltTypeUtil.java#L352-L360 |
banq/jdonframework | src/main/java/com/jdon/controller/WebAppUtil.java | WebAppUtil.callService | public static Object callService(String serviceName, String methodName, Object[] methodParams, HttpServletRequest request) throws Exception {
"""
Command pattern for service invoke sample: browser url:
/aaa.do?method=xxxxx
xxxxx is the service's method, such as:
public interface TestService{ void xxxxx(EventModel em); }
@see com.jdon.strutsutil.ServiceMethodAction
@param serviceName
the service name in jdonframework.xml
@param methodName
the method name
@param request
@param model
the method parameter must be packed in a ModelIF object. if no
method parameter, set it to null;
@return return the service dealing result
@throws Exception
"""
Debug.logVerbose("[JdonFramework] call the method: " + methodName + " for the service: " + serviceName, module);
Object result = null;
try {
MethodMetaArgs methodMetaArgs = AppUtil.createDirectMethod(methodName, methodParams);
ServiceFacade serviceFacade = new ServiceFacade();
ServletContext sc = request.getSession().getServletContext();
Service service = serviceFacade.getService(new ServletContextWrapper(sc));
RequestWrapper requestW = RequestWrapperFactory.create(request);
result = service.execute(serviceName, methodMetaArgs, requestW);
} catch (Exception ex) {
Debug.logError("[JdonFramework] serviceAction Error: " + ex, module);
throw new Exception(" serviceAction Error:" + ex);
}
return result;
} | java | public static Object callService(String serviceName, String methodName, Object[] methodParams, HttpServletRequest request) throws Exception {
Debug.logVerbose("[JdonFramework] call the method: " + methodName + " for the service: " + serviceName, module);
Object result = null;
try {
MethodMetaArgs methodMetaArgs = AppUtil.createDirectMethod(methodName, methodParams);
ServiceFacade serviceFacade = new ServiceFacade();
ServletContext sc = request.getSession().getServletContext();
Service service = serviceFacade.getService(new ServletContextWrapper(sc));
RequestWrapper requestW = RequestWrapperFactory.create(request);
result = service.execute(serviceName, methodMetaArgs, requestW);
} catch (Exception ex) {
Debug.logError("[JdonFramework] serviceAction Error: " + ex, module);
throw new Exception(" serviceAction Error:" + ex);
}
return result;
} | [
"public",
"static",
"Object",
"callService",
"(",
"String",
"serviceName",
",",
"String",
"methodName",
",",
"Object",
"[",
"]",
"methodParams",
",",
"HttpServletRequest",
"request",
")",
"throws",
"Exception",
"{",
"Debug",
".",
"logVerbose",
"(",
"\"[JdonFramework] call the method: \"",
"+",
"methodName",
"+",
"\" for the service: \"",
"+",
"serviceName",
",",
"module",
")",
";",
"Object",
"result",
"=",
"null",
";",
"try",
"{",
"MethodMetaArgs",
"methodMetaArgs",
"=",
"AppUtil",
".",
"createDirectMethod",
"(",
"methodName",
",",
"methodParams",
")",
";",
"ServiceFacade",
"serviceFacade",
"=",
"new",
"ServiceFacade",
"(",
")",
";",
"ServletContext",
"sc",
"=",
"request",
".",
"getSession",
"(",
")",
".",
"getServletContext",
"(",
")",
";",
"Service",
"service",
"=",
"serviceFacade",
".",
"getService",
"(",
"new",
"ServletContextWrapper",
"(",
"sc",
")",
")",
";",
"RequestWrapper",
"requestW",
"=",
"RequestWrapperFactory",
".",
"create",
"(",
"request",
")",
";",
"result",
"=",
"service",
".",
"execute",
"(",
"serviceName",
",",
"methodMetaArgs",
",",
"requestW",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"Debug",
".",
"logError",
"(",
"\"[JdonFramework] serviceAction Error: \"",
"+",
"ex",
",",
"module",
")",
";",
"throw",
"new",
"Exception",
"(",
"\" serviceAction Error:\"",
"+",
"ex",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Command pattern for service invoke sample: browser url:
/aaa.do?method=xxxxx
xxxxx is the service's method, such as:
public interface TestService{ void xxxxx(EventModel em); }
@see com.jdon.strutsutil.ServiceMethodAction
@param serviceName
the service name in jdonframework.xml
@param methodName
the method name
@param request
@param model
the method parameter must be packed in a ModelIF object. if no
method parameter, set it to null;
@return return the service dealing result
@throws Exception | [
"Command",
"pattern",
"for",
"service",
"invoke",
"sample",
":",
"browser",
"url",
":",
"/",
"aaa",
".",
"do?method",
"=",
"xxxxx"
] | train | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/controller/WebAppUtil.java#L185-L201 |
jlinn/quartz-redis-jobstore | src/main/java/net/joelinn/quartz/jobstore/AbstractRedisStorage.java | AbstractRedisStorage.retrieveTrigger | public OperableTrigger retrieveTrigger(TriggerKey triggerKey, T jedis) throws JobPersistenceException {
"""
Retrieve a trigger from Redis
@param triggerKey the trigger key
@param jedis a thread-safe Redis connection
@return the requested {@link org.quartz.spi.OperableTrigger} if it exists; null if it does not
@throws JobPersistenceException if the job associated with the retrieved trigger does not exist
"""
final String triggerHashKey = redisSchema.triggerHashKey(triggerKey);
Map<String, String> triggerMap = jedis.hgetAll(triggerHashKey);
if(triggerMap == null || triggerMap.isEmpty()){
logger.debug(String.format("No trigger exists for key %s", triggerHashKey));
return null;
}
Class triggerClass;
try {
triggerClass = Class.forName(triggerMap.get(TRIGGER_CLASS));
} catch (ClassNotFoundException e) {
throw new JobPersistenceException(String.format("Could not find class %s for trigger.", triggerMap.get(TRIGGER_CLASS)), e);
}
triggerMap.remove(TRIGGER_CLASS);
OperableTrigger operableTrigger = (OperableTrigger) mapper.convertValue(triggerMap, triggerClass);
operableTrigger.setFireInstanceId(schedulerInstanceId + "-" + operableTrigger.getKey() + "-" + operableTrigger.getStartTime().getTime());
final Map<String, String> jobData = jedis.hgetAll(redisSchema.triggerDataMapHashKey(triggerKey));
if (jobData != null && !jobData.isEmpty()){
JobDataMap jobDataMap = new JobDataMap();
jobDataMap.putAll(jobData);
operableTrigger.setJobDataMap(jobDataMap);
}
return operableTrigger;
} | java | public OperableTrigger retrieveTrigger(TriggerKey triggerKey, T jedis) throws JobPersistenceException{
final String triggerHashKey = redisSchema.triggerHashKey(triggerKey);
Map<String, String> triggerMap = jedis.hgetAll(triggerHashKey);
if(triggerMap == null || triggerMap.isEmpty()){
logger.debug(String.format("No trigger exists for key %s", triggerHashKey));
return null;
}
Class triggerClass;
try {
triggerClass = Class.forName(triggerMap.get(TRIGGER_CLASS));
} catch (ClassNotFoundException e) {
throw new JobPersistenceException(String.format("Could not find class %s for trigger.", triggerMap.get(TRIGGER_CLASS)), e);
}
triggerMap.remove(TRIGGER_CLASS);
OperableTrigger operableTrigger = (OperableTrigger) mapper.convertValue(triggerMap, triggerClass);
operableTrigger.setFireInstanceId(schedulerInstanceId + "-" + operableTrigger.getKey() + "-" + operableTrigger.getStartTime().getTime());
final Map<String, String> jobData = jedis.hgetAll(redisSchema.triggerDataMapHashKey(triggerKey));
if (jobData != null && !jobData.isEmpty()){
JobDataMap jobDataMap = new JobDataMap();
jobDataMap.putAll(jobData);
operableTrigger.setJobDataMap(jobDataMap);
}
return operableTrigger;
} | [
"public",
"OperableTrigger",
"retrieveTrigger",
"(",
"TriggerKey",
"triggerKey",
",",
"T",
"jedis",
")",
"throws",
"JobPersistenceException",
"{",
"final",
"String",
"triggerHashKey",
"=",
"redisSchema",
".",
"triggerHashKey",
"(",
"triggerKey",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"triggerMap",
"=",
"jedis",
".",
"hgetAll",
"(",
"triggerHashKey",
")",
";",
"if",
"(",
"triggerMap",
"==",
"null",
"||",
"triggerMap",
".",
"isEmpty",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"String",
".",
"format",
"(",
"\"No trigger exists for key %s\"",
",",
"triggerHashKey",
")",
")",
";",
"return",
"null",
";",
"}",
"Class",
"triggerClass",
";",
"try",
"{",
"triggerClass",
"=",
"Class",
".",
"forName",
"(",
"triggerMap",
".",
"get",
"(",
"TRIGGER_CLASS",
")",
")",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"e",
")",
"{",
"throw",
"new",
"JobPersistenceException",
"(",
"String",
".",
"format",
"(",
"\"Could not find class %s for trigger.\"",
",",
"triggerMap",
".",
"get",
"(",
"TRIGGER_CLASS",
")",
")",
",",
"e",
")",
";",
"}",
"triggerMap",
".",
"remove",
"(",
"TRIGGER_CLASS",
")",
";",
"OperableTrigger",
"operableTrigger",
"=",
"(",
"OperableTrigger",
")",
"mapper",
".",
"convertValue",
"(",
"triggerMap",
",",
"triggerClass",
")",
";",
"operableTrigger",
".",
"setFireInstanceId",
"(",
"schedulerInstanceId",
"+",
"\"-\"",
"+",
"operableTrigger",
".",
"getKey",
"(",
")",
"+",
"\"-\"",
"+",
"operableTrigger",
".",
"getStartTime",
"(",
")",
".",
"getTime",
"(",
")",
")",
";",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"jobData",
"=",
"jedis",
".",
"hgetAll",
"(",
"redisSchema",
".",
"triggerDataMapHashKey",
"(",
"triggerKey",
")",
")",
";",
"if",
"(",
"jobData",
"!=",
"null",
"&&",
"!",
"jobData",
".",
"isEmpty",
"(",
")",
")",
"{",
"JobDataMap",
"jobDataMap",
"=",
"new",
"JobDataMap",
"(",
")",
";",
"jobDataMap",
".",
"putAll",
"(",
"jobData",
")",
";",
"operableTrigger",
".",
"setJobDataMap",
"(",
"jobDataMap",
")",
";",
"}",
"return",
"operableTrigger",
";",
"}"
] | Retrieve a trigger from Redis
@param triggerKey the trigger key
@param jedis a thread-safe Redis connection
@return the requested {@link org.quartz.spi.OperableTrigger} if it exists; null if it does not
@throws JobPersistenceException if the job associated with the retrieved trigger does not exist | [
"Retrieve",
"a",
"trigger",
"from",
"Redis"
] | train | https://github.com/jlinn/quartz-redis-jobstore/blob/be9a52ee776d8a09866fe99fd9718bc13a0cb992/src/main/java/net/joelinn/quartz/jobstore/AbstractRedisStorage.java#L278-L301 |
census-instrumentation/opencensus-java | examples/src/main/java/io/opencensus/examples/grpc/helloworld/HelloWorldClient.java | HelloWorldClient.main | public static void main(String[] args) throws IOException, InterruptedException {
"""
Greet server. If provided, the first element of {@code args} is the name to use in the
greeting.
"""
// Add final keyword to pass checkStyle.
final String user = getStringOrDefaultFromArgs(args, 0, "world");
final String host = getStringOrDefaultFromArgs(args, 1, "localhost");
final int serverPort = getPortOrDefaultFromArgs(args, 2, 50051);
final String cloudProjectId = getStringOrDefaultFromArgs(args, 3, null);
final int zPagePort = getPortOrDefaultFromArgs(args, 4, 3001);
// Registers all RPC views. For demonstration all views are registered. You may want to
// start with registering basic views and register other views as needed for your application.
RpcViews.registerAllViews();
// Starts a HTTP server and registers all Zpages to it.
ZPageHandlers.startHttpServerAndRegisterAll(zPagePort);
logger.info("ZPages server starts at localhost:" + zPagePort);
// Registers logging trace exporter.
LoggingTraceExporter.register();
// Registers Stackdriver exporters.
if (cloudProjectId != null) {
StackdriverTraceExporter.createAndRegister(
StackdriverTraceConfiguration.builder().setProjectId(cloudProjectId).build());
StackdriverStatsExporter.createAndRegister(
StackdriverStatsConfiguration.builder()
.setProjectId(cloudProjectId)
.setExportInterval(Duration.create(60, 0))
.build());
}
// Register Prometheus exporters and export metrics to a Prometheus HTTPServer.
PrometheusStatsCollector.createAndRegister();
HelloWorldClient client = new HelloWorldClient(host, serverPort);
try {
client.greet(user);
} finally {
client.shutdown();
}
logger.info("Client sleeping, ^C to exit. Meanwhile you can view stats and spans on zpages.");
while (true) {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
logger.info("Exiting HelloWorldClient...");
}
}
} | java | public static void main(String[] args) throws IOException, InterruptedException {
// Add final keyword to pass checkStyle.
final String user = getStringOrDefaultFromArgs(args, 0, "world");
final String host = getStringOrDefaultFromArgs(args, 1, "localhost");
final int serverPort = getPortOrDefaultFromArgs(args, 2, 50051);
final String cloudProjectId = getStringOrDefaultFromArgs(args, 3, null);
final int zPagePort = getPortOrDefaultFromArgs(args, 4, 3001);
// Registers all RPC views. For demonstration all views are registered. You may want to
// start with registering basic views and register other views as needed for your application.
RpcViews.registerAllViews();
// Starts a HTTP server and registers all Zpages to it.
ZPageHandlers.startHttpServerAndRegisterAll(zPagePort);
logger.info("ZPages server starts at localhost:" + zPagePort);
// Registers logging trace exporter.
LoggingTraceExporter.register();
// Registers Stackdriver exporters.
if (cloudProjectId != null) {
StackdriverTraceExporter.createAndRegister(
StackdriverTraceConfiguration.builder().setProjectId(cloudProjectId).build());
StackdriverStatsExporter.createAndRegister(
StackdriverStatsConfiguration.builder()
.setProjectId(cloudProjectId)
.setExportInterval(Duration.create(60, 0))
.build());
}
// Register Prometheus exporters and export metrics to a Prometheus HTTPServer.
PrometheusStatsCollector.createAndRegister();
HelloWorldClient client = new HelloWorldClient(host, serverPort);
try {
client.greet(user);
} finally {
client.shutdown();
}
logger.info("Client sleeping, ^C to exit. Meanwhile you can view stats and spans on zpages.");
while (true) {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
logger.info("Exiting HelloWorldClient...");
}
}
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"throws",
"IOException",
",",
"InterruptedException",
"{",
"// Add final keyword to pass checkStyle.",
"final",
"String",
"user",
"=",
"getStringOrDefaultFromArgs",
"(",
"args",
",",
"0",
",",
"\"world\"",
")",
";",
"final",
"String",
"host",
"=",
"getStringOrDefaultFromArgs",
"(",
"args",
",",
"1",
",",
"\"localhost\"",
")",
";",
"final",
"int",
"serverPort",
"=",
"getPortOrDefaultFromArgs",
"(",
"args",
",",
"2",
",",
"50051",
")",
";",
"final",
"String",
"cloudProjectId",
"=",
"getStringOrDefaultFromArgs",
"(",
"args",
",",
"3",
",",
"null",
")",
";",
"final",
"int",
"zPagePort",
"=",
"getPortOrDefaultFromArgs",
"(",
"args",
",",
"4",
",",
"3001",
")",
";",
"// Registers all RPC views. For demonstration all views are registered. You may want to",
"// start with registering basic views and register other views as needed for your application.",
"RpcViews",
".",
"registerAllViews",
"(",
")",
";",
"// Starts a HTTP server and registers all Zpages to it.",
"ZPageHandlers",
".",
"startHttpServerAndRegisterAll",
"(",
"zPagePort",
")",
";",
"logger",
".",
"info",
"(",
"\"ZPages server starts at localhost:\"",
"+",
"zPagePort",
")",
";",
"// Registers logging trace exporter.",
"LoggingTraceExporter",
".",
"register",
"(",
")",
";",
"// Registers Stackdriver exporters.",
"if",
"(",
"cloudProjectId",
"!=",
"null",
")",
"{",
"StackdriverTraceExporter",
".",
"createAndRegister",
"(",
"StackdriverTraceConfiguration",
".",
"builder",
"(",
")",
".",
"setProjectId",
"(",
"cloudProjectId",
")",
".",
"build",
"(",
")",
")",
";",
"StackdriverStatsExporter",
".",
"createAndRegister",
"(",
"StackdriverStatsConfiguration",
".",
"builder",
"(",
")",
".",
"setProjectId",
"(",
"cloudProjectId",
")",
".",
"setExportInterval",
"(",
"Duration",
".",
"create",
"(",
"60",
",",
"0",
")",
")",
".",
"build",
"(",
")",
")",
";",
"}",
"// Register Prometheus exporters and export metrics to a Prometheus HTTPServer.",
"PrometheusStatsCollector",
".",
"createAndRegister",
"(",
")",
";",
"HelloWorldClient",
"client",
"=",
"new",
"HelloWorldClient",
"(",
"host",
",",
"serverPort",
")",
";",
"try",
"{",
"client",
".",
"greet",
"(",
"user",
")",
";",
"}",
"finally",
"{",
"client",
".",
"shutdown",
"(",
")",
";",
"}",
"logger",
".",
"info",
"(",
"\"Client sleeping, ^C to exit. Meanwhile you can view stats and spans on zpages.\"",
")",
";",
"while",
"(",
"true",
")",
"{",
"try",
"{",
"Thread",
".",
"sleep",
"(",
"10000",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"logger",
".",
"info",
"(",
"\"Exiting HelloWorldClient...\"",
")",
";",
"}",
"}",
"}"
] | Greet server. If provided, the first element of {@code args} is the name to use in the
greeting. | [
"Greet",
"server",
".",
"If",
"provided",
"the",
"first",
"element",
"of",
"{"
] | train | https://github.com/census-instrumentation/opencensus-java/blob/deefac9bed77e40a2297bff1ca5ec5aa48a5f755/examples/src/main/java/io/opencensus/examples/grpc/helloworld/HelloWorldClient.java#L103-L151 |
QSFT/Doradus | doradus-server/src/examples/java/com/dell/doradus/service/olap/mono/OLAPMonoService.java | OLAPMonoService.addBatch | public BatchResult addBatch(ApplicationDefinition appDef, OlapBatch batch) {
"""
Add the given batch of object updates for the given application. The updates may
be new, updated, or deleted objects. The updates are applied to the application's
mono shard.
@param appDef Application to which update batch is applied.
@param batch {@link OlapBatch} of object adds, updates, and/or deletes.
@return {@link BatchResult} reflecting status of update.
"""
return OLAPService.instance().addBatch(appDef, MONO_SHARD_NAME, batch);
} | java | public BatchResult addBatch(ApplicationDefinition appDef, OlapBatch batch) {
return OLAPService.instance().addBatch(appDef, MONO_SHARD_NAME, batch);
} | [
"public",
"BatchResult",
"addBatch",
"(",
"ApplicationDefinition",
"appDef",
",",
"OlapBatch",
"batch",
")",
"{",
"return",
"OLAPService",
".",
"instance",
"(",
")",
".",
"addBatch",
"(",
"appDef",
",",
"MONO_SHARD_NAME",
",",
"batch",
")",
";",
"}"
] | Add the given batch of object updates for the given application. The updates may
be new, updated, or deleted objects. The updates are applied to the application's
mono shard.
@param appDef Application to which update batch is applied.
@param batch {@link OlapBatch} of object adds, updates, and/or deletes.
@return {@link BatchResult} reflecting status of update. | [
"Add",
"the",
"given",
"batch",
"of",
"object",
"updates",
"for",
"the",
"given",
"application",
".",
"The",
"updates",
"may",
"be",
"new",
"updated",
"or",
"deleted",
"objects",
".",
"The",
"updates",
"are",
"applied",
"to",
"the",
"application",
"s",
"mono",
"shard",
"."
] | train | https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/examples/java/com/dell/doradus/service/olap/mono/OLAPMonoService.java#L161-L163 |
GerdHolz/TOVAL | src/de/invation/code/toval/properties/AbstractTypedProperties.java | AbstractTypedProperties.getProperty | public Object getProperty(P property) throws PropertyException {
"""
Extracts the value of the given property.<br>
@param property The property whose value is requested.
@return The property value or <code>null</code> in case there is no entry for the property.
@note Note, that for mandatory properties an exception will be thrown in case no corresponding entry can be found.
@throws PropertyException in case no entry for a mandatory property can be found.
@see #getPropertyValueFromString(Enum, String)
"""
// System.out.println("Getting property value " + property.getPropertyCharacteristics().getName());
String propertyValueAsString = props.getProperty(property.getPropertyCharacteristics().getName());
// System.out.println("Property value as string:" + propertyValueAsString);
if(propertyValueAsString == null){
if(property.getPropertyCharacteristics().isMandatory())
throw new PropertyException(property, propertyValueAsString, "No entry for mandatory property");
return null;
}
return getPropertyValueFromString(property, propertyValueAsString);
} | java | public Object getProperty(P property) throws PropertyException{
// System.out.println("Getting property value " + property.getPropertyCharacteristics().getName());
String propertyValueAsString = props.getProperty(property.getPropertyCharacteristics().getName());
// System.out.println("Property value as string:" + propertyValueAsString);
if(propertyValueAsString == null){
if(property.getPropertyCharacteristics().isMandatory())
throw new PropertyException(property, propertyValueAsString, "No entry for mandatory property");
return null;
}
return getPropertyValueFromString(property, propertyValueAsString);
} | [
"public",
"Object",
"getProperty",
"(",
"P",
"property",
")",
"throws",
"PropertyException",
"{",
"//\t\tSystem.out.println(\"Getting property value \" + property.getPropertyCharacteristics().getName());\r",
"String",
"propertyValueAsString",
"=",
"props",
".",
"getProperty",
"(",
"property",
".",
"getPropertyCharacteristics",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"//\t\tSystem.out.println(\"Property value as string:\" + propertyValueAsString);\r",
"if",
"(",
"propertyValueAsString",
"==",
"null",
")",
"{",
"if",
"(",
"property",
".",
"getPropertyCharacteristics",
"(",
")",
".",
"isMandatory",
"(",
")",
")",
"throw",
"new",
"PropertyException",
"(",
"property",
",",
"propertyValueAsString",
",",
"\"No entry for mandatory property\"",
")",
";",
"return",
"null",
";",
"}",
"return",
"getPropertyValueFromString",
"(",
"property",
",",
"propertyValueAsString",
")",
";",
"}"
] | Extracts the value of the given property.<br>
@param property The property whose value is requested.
@return The property value or <code>null</code> in case there is no entry for the property.
@note Note, that for mandatory properties an exception will be thrown in case no corresponding entry can be found.
@throws PropertyException in case no entry for a mandatory property can be found.
@see #getPropertyValueFromString(Enum, String) | [
"Extracts",
"the",
"value",
"of",
"the",
"given",
"property",
".",
"<br",
">"
] | train | https://github.com/GerdHolz/TOVAL/blob/036922cdfd710fa53b18e5dbe1e07f226f731fde/src/de/invation/code/toval/properties/AbstractTypedProperties.java#L124-L134 |
Azure/azure-sdk-for-java | batch/data-plane/src/main/java/com/microsoft/azure/batch/protocol/implementation/ComputeNodesImpl.java | ComputeNodesImpl.getRemoteLoginSettingsAsync | public Observable<ComputeNodeGetRemoteLoginSettingsResult> getRemoteLoginSettingsAsync(String poolId, String nodeId) {
"""
Gets the settings required for remote login to a compute node.
Before you can remotely login to a node using the remote login settings, you must create a user account on the node. This API can be invoked only on pools created with the virtual machine configuration property. For pools created with a cloud service configuration, see the GetRemoteDesktop API.
@param poolId The ID of the pool that contains the compute node.
@param nodeId The ID of the compute node for which to obtain the remote login settings.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ComputeNodeGetRemoteLoginSettingsResult object
"""
return getRemoteLoginSettingsWithServiceResponseAsync(poolId, nodeId).map(new Func1<ServiceResponseWithHeaders<ComputeNodeGetRemoteLoginSettingsResult, ComputeNodeGetRemoteLoginSettingsHeaders>, ComputeNodeGetRemoteLoginSettingsResult>() {
@Override
public ComputeNodeGetRemoteLoginSettingsResult call(ServiceResponseWithHeaders<ComputeNodeGetRemoteLoginSettingsResult, ComputeNodeGetRemoteLoginSettingsHeaders> response) {
return response.body();
}
});
} | java | public Observable<ComputeNodeGetRemoteLoginSettingsResult> getRemoteLoginSettingsAsync(String poolId, String nodeId) {
return getRemoteLoginSettingsWithServiceResponseAsync(poolId, nodeId).map(new Func1<ServiceResponseWithHeaders<ComputeNodeGetRemoteLoginSettingsResult, ComputeNodeGetRemoteLoginSettingsHeaders>, ComputeNodeGetRemoteLoginSettingsResult>() {
@Override
public ComputeNodeGetRemoteLoginSettingsResult call(ServiceResponseWithHeaders<ComputeNodeGetRemoteLoginSettingsResult, ComputeNodeGetRemoteLoginSettingsHeaders> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ComputeNodeGetRemoteLoginSettingsResult",
">",
"getRemoteLoginSettingsAsync",
"(",
"String",
"poolId",
",",
"String",
"nodeId",
")",
"{",
"return",
"getRemoteLoginSettingsWithServiceResponseAsync",
"(",
"poolId",
",",
"nodeId",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponseWithHeaders",
"<",
"ComputeNodeGetRemoteLoginSettingsResult",
",",
"ComputeNodeGetRemoteLoginSettingsHeaders",
">",
",",
"ComputeNodeGetRemoteLoginSettingsResult",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"ComputeNodeGetRemoteLoginSettingsResult",
"call",
"(",
"ServiceResponseWithHeaders",
"<",
"ComputeNodeGetRemoteLoginSettingsResult",
",",
"ComputeNodeGetRemoteLoginSettingsHeaders",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Gets the settings required for remote login to a compute node.
Before you can remotely login to a node using the remote login settings, you must create a user account on the node. This API can be invoked only on pools created with the virtual machine configuration property. For pools created with a cloud service configuration, see the GetRemoteDesktop API.
@param poolId The ID of the pool that contains the compute node.
@param nodeId The ID of the compute node for which to obtain the remote login settings.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ComputeNodeGetRemoteLoginSettingsResult object | [
"Gets",
"the",
"settings",
"required",
"for",
"remote",
"login",
"to",
"a",
"compute",
"node",
".",
"Before",
"you",
"can",
"remotely",
"login",
"to",
"a",
"node",
"using",
"the",
"remote",
"login",
"settings",
"you",
"must",
"create",
"a",
"user",
"account",
"on",
"the",
"node",
".",
"This",
"API",
"can",
"be",
"invoked",
"only",
"on",
"pools",
"created",
"with",
"the",
"virtual",
"machine",
"configuration",
"property",
".",
"For",
"pools",
"created",
"with",
"a",
"cloud",
"service",
"configuration",
"see",
"the",
"GetRemoteDesktop",
"API",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batch/data-plane/src/main/java/com/microsoft/azure/batch/protocol/implementation/ComputeNodesImpl.java#L1956-L1963 |
lessthanoptimal/BoofCV | main/boofcv-io/src/main/java/boofcv/io/image/ConvertBufferedImage.java | ConvertBufferedImage.convertFrom | public static <T extends ImageBase<T>> void convertFrom(BufferedImage src, T dst , boolean orderRgb) {
"""
Converts a buffered image into an image of the specified type.
@param src Input BufferedImage which is to be converted
@param dst The image which it is being converted into
@param orderRgb If applicable, should it adjust the ordering of each color band to maintain color consistency
"""
if( dst instanceof ImageGray) {
ImageGray sb = (ImageGray)dst;
convertFromSingle(src, sb, (Class<ImageGray>) sb.getClass());
} else if( dst instanceof Planar) {
Planar ms = (Planar)dst;
convertFromPlanar(src,ms,orderRgb,ms.getBandType());
} else if( dst instanceof ImageInterleaved ) {
convertFromInterleaved(src, (ImageInterleaved) dst, orderRgb);
} else {
throw new IllegalArgumentException("Unknown type " + dst.getClass().getSimpleName());
}
} | java | public static <T extends ImageBase<T>> void convertFrom(BufferedImage src, T dst , boolean orderRgb) {
if( dst instanceof ImageGray) {
ImageGray sb = (ImageGray)dst;
convertFromSingle(src, sb, (Class<ImageGray>) sb.getClass());
} else if( dst instanceof Planar) {
Planar ms = (Planar)dst;
convertFromPlanar(src,ms,orderRgb,ms.getBandType());
} else if( dst instanceof ImageInterleaved ) {
convertFromInterleaved(src, (ImageInterleaved) dst, orderRgb);
} else {
throw new IllegalArgumentException("Unknown type " + dst.getClass().getSimpleName());
}
} | [
"public",
"static",
"<",
"T",
"extends",
"ImageBase",
"<",
"T",
">",
">",
"void",
"convertFrom",
"(",
"BufferedImage",
"src",
",",
"T",
"dst",
",",
"boolean",
"orderRgb",
")",
"{",
"if",
"(",
"dst",
"instanceof",
"ImageGray",
")",
"{",
"ImageGray",
"sb",
"=",
"(",
"ImageGray",
")",
"dst",
";",
"convertFromSingle",
"(",
"src",
",",
"sb",
",",
"(",
"Class",
"<",
"ImageGray",
">",
")",
"sb",
".",
"getClass",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"dst",
"instanceof",
"Planar",
")",
"{",
"Planar",
"ms",
"=",
"(",
"Planar",
")",
"dst",
";",
"convertFromPlanar",
"(",
"src",
",",
"ms",
",",
"orderRgb",
",",
"ms",
".",
"getBandType",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"dst",
"instanceof",
"ImageInterleaved",
")",
"{",
"convertFromInterleaved",
"(",
"src",
",",
"(",
"ImageInterleaved",
")",
"dst",
",",
"orderRgb",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unknown type \"",
"+",
"dst",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
")",
";",
"}",
"}"
] | Converts a buffered image into an image of the specified type.
@param src Input BufferedImage which is to be converted
@param dst The image which it is being converted into
@param orderRgb If applicable, should it adjust the ordering of each color band to maintain color consistency | [
"Converts",
"a",
"buffered",
"image",
"into",
"an",
"image",
"of",
"the",
"specified",
"type",
"."
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-io/src/main/java/boofcv/io/image/ConvertBufferedImage.java#L269-L281 |
venmo/cursor-utils | cursor-utils/src/main/java/com/venmo/cursor/IterableCursorWrapper.java | IterableCursorWrapper.getLong | public long getLong(String columnName, long defaultValue) {
"""
Convenience alias to {@code getLong\(getColumnIndex(columnName))}. If the column does not
exist for the cursor, return {@code defaultValue}.
"""
int index = getColumnIndex(columnName);
if (isValidIndex(index)) {
return getLong(index);
} else {
return defaultValue;
}
} | java | public long getLong(String columnName, long defaultValue) {
int index = getColumnIndex(columnName);
if (isValidIndex(index)) {
return getLong(index);
} else {
return defaultValue;
}
} | [
"public",
"long",
"getLong",
"(",
"String",
"columnName",
",",
"long",
"defaultValue",
")",
"{",
"int",
"index",
"=",
"getColumnIndex",
"(",
"columnName",
")",
";",
"if",
"(",
"isValidIndex",
"(",
"index",
")",
")",
"{",
"return",
"getLong",
"(",
"index",
")",
";",
"}",
"else",
"{",
"return",
"defaultValue",
";",
"}",
"}"
] | Convenience alias to {@code getLong\(getColumnIndex(columnName))}. If the column does not
exist for the cursor, return {@code defaultValue}. | [
"Convenience",
"alias",
"to",
"{"
] | train | https://github.com/venmo/cursor-utils/blob/52cf91c4253346632fe70b8d7b7eab8bbcc9b248/cursor-utils/src/main/java/com/venmo/cursor/IterableCursorWrapper.java#L90-L97 |
netscaler/nitro | src/main/java/com/citrix/netscaler/nitro/resource/stat/basic/service_stats.java | service_stats.get | public static service_stats get(nitro_service service, String name) throws Exception {
"""
Use this API to fetch statistics of service_stats resource of given name .
"""
service_stats obj = new service_stats();
obj.set_name(name);
service_stats response = (service_stats) obj.stat_resource(service);
return response;
} | java | public static service_stats get(nitro_service service, String name) throws Exception{
service_stats obj = new service_stats();
obj.set_name(name);
service_stats response = (service_stats) obj.stat_resource(service);
return response;
} | [
"public",
"static",
"service_stats",
"get",
"(",
"nitro_service",
"service",
",",
"String",
"name",
")",
"throws",
"Exception",
"{",
"service_stats",
"obj",
"=",
"new",
"service_stats",
"(",
")",
";",
"obj",
".",
"set_name",
"(",
"name",
")",
";",
"service_stats",
"response",
"=",
"(",
"service_stats",
")",
"obj",
".",
"stat_resource",
"(",
"service",
")",
";",
"return",
"response",
";",
"}"
] | Use this API to fetch statistics of service_stats resource of given name . | [
"Use",
"this",
"API",
"to",
"fetch",
"statistics",
"of",
"service_stats",
"resource",
"of",
"given",
"name",
"."
] | train | https://github.com/netscaler/nitro/blob/2a98692dcf4e4ec430c7d7baab8382e4ba5a35e4/src/main/java/com/citrix/netscaler/nitro/resource/stat/basic/service_stats.java#L390-L395 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/network/v2018_04_01/implementation/RouteFiltersInner.java | RouteFiltersInner.beginDelete | public void beginDelete(String resourceGroupName, String routeFilterName) {
"""
Deletes the specified route filter.
@param resourceGroupName The name of the resource group.
@param routeFilterName The name of the route filter.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
"""
beginDeleteWithServiceResponseAsync(resourceGroupName, routeFilterName).toBlocking().single().body();
} | java | public void beginDelete(String resourceGroupName, String routeFilterName) {
beginDeleteWithServiceResponseAsync(resourceGroupName, routeFilterName).toBlocking().single().body();
} | [
"public",
"void",
"beginDelete",
"(",
"String",
"resourceGroupName",
",",
"String",
"routeFilterName",
")",
"{",
"beginDeleteWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"routeFilterName",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Deletes the specified route filter.
@param resourceGroupName The name of the resource group.
@param routeFilterName The name of the route filter.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent | [
"Deletes",
"the",
"specified",
"route",
"filter",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/network/v2018_04_01/implementation/RouteFiltersInner.java#L190-L192 |
Azure/azure-sdk-for-java | sql/resource-manager/v2015_05_01_preview/src/main/java/com/microsoft/azure/management/sql/v2015_05_01_preview/implementation/ManagedInstancesInner.java | ManagedInstancesInner.beginCreateOrUpdateAsync | public Observable<ManagedInstanceInner> beginCreateOrUpdateAsync(String resourceGroupName, String managedInstanceName, ManagedInstanceInner parameters) {
"""
Creates or updates a managed instance.
@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 managedInstanceName The name of the managed instance.
@param parameters The requested managed instance resource state.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ManagedInstanceInner object
"""
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, managedInstanceName, parameters).map(new Func1<ServiceResponse<ManagedInstanceInner>, ManagedInstanceInner>() {
@Override
public ManagedInstanceInner call(ServiceResponse<ManagedInstanceInner> response) {
return response.body();
}
});
} | java | public Observable<ManagedInstanceInner> beginCreateOrUpdateAsync(String resourceGroupName, String managedInstanceName, ManagedInstanceInner parameters) {
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, managedInstanceName, parameters).map(new Func1<ServiceResponse<ManagedInstanceInner>, ManagedInstanceInner>() {
@Override
public ManagedInstanceInner call(ServiceResponse<ManagedInstanceInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ManagedInstanceInner",
">",
"beginCreateOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"managedInstanceName",
",",
"ManagedInstanceInner",
"parameters",
")",
"{",
"return",
"beginCreateOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"managedInstanceName",
",",
"parameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"ManagedInstanceInner",
">",
",",
"ManagedInstanceInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"ManagedInstanceInner",
"call",
"(",
"ServiceResponse",
"<",
"ManagedInstanceInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Creates or updates a managed instance.
@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 managedInstanceName The name of the managed instance.
@param parameters The requested managed instance resource state.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ManagedInstanceInner object | [
"Creates",
"or",
"updates",
"a",
"managed",
"instance",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2015_05_01_preview/src/main/java/com/microsoft/azure/management/sql/v2015_05_01_preview/implementation/ManagedInstancesInner.java#L538-L545 |
taimos/dvalin | interconnect/model/src/main/java/de/taimos/dvalin/interconnect/model/service/DaemonScanner.java | DaemonScanner.isAnnotationPresent | public static boolean isAnnotationPresent(final Class<? extends Annotation> annotation, final Method method) {
"""
Checks also the inheritance hierarchy.
@param annotation Annotation
@param method Method
@return Is present?
"""
final Annotation e = DaemonScanner.getAnnotation(annotation, method);
return e != null;
} | java | public static boolean isAnnotationPresent(final Class<? extends Annotation> annotation, final Method method) {
final Annotation e = DaemonScanner.getAnnotation(annotation, method);
return e != null;
} | [
"public",
"static",
"boolean",
"isAnnotationPresent",
"(",
"final",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"annotation",
",",
"final",
"Method",
"method",
")",
"{",
"final",
"Annotation",
"e",
"=",
"DaemonScanner",
".",
"getAnnotation",
"(",
"annotation",
",",
"method",
")",
";",
"return",
"e",
"!=",
"null",
";",
"}"
] | Checks also the inheritance hierarchy.
@param annotation Annotation
@param method Method
@return Is present? | [
"Checks",
"also",
"the",
"inheritance",
"hierarchy",
"."
] | train | https://github.com/taimos/dvalin/blob/ff8f1bf594e43d7e8ca8de0b4da9f923b66a1a47/interconnect/model/src/main/java/de/taimos/dvalin/interconnect/model/service/DaemonScanner.java#L134-L137 |
square/okhttp | okhttp/src/main/java/okhttp3/internal/Util.java | Util.skipAll | public static boolean skipAll(Source source, int duration, TimeUnit timeUnit) throws IOException {
"""
Reads until {@code in} is exhausted or the deadline has been reached. This is careful to not
extend the deadline if one exists already.
"""
long now = System.nanoTime();
long originalDuration = source.timeout().hasDeadline()
? source.timeout().deadlineNanoTime() - now
: Long.MAX_VALUE;
source.timeout().deadlineNanoTime(now + Math.min(originalDuration, timeUnit.toNanos(duration)));
try {
Buffer skipBuffer = new Buffer();
while (source.read(skipBuffer, 8192) != -1) {
skipBuffer.clear();
}
return true; // Success! The source has been exhausted.
} catch (InterruptedIOException e) {
return false; // We ran out of time before exhausting the source.
} finally {
if (originalDuration == Long.MAX_VALUE) {
source.timeout().clearDeadline();
} else {
source.timeout().deadlineNanoTime(now + originalDuration);
}
}
} | java | public static boolean skipAll(Source source, int duration, TimeUnit timeUnit) throws IOException {
long now = System.nanoTime();
long originalDuration = source.timeout().hasDeadline()
? source.timeout().deadlineNanoTime() - now
: Long.MAX_VALUE;
source.timeout().deadlineNanoTime(now + Math.min(originalDuration, timeUnit.toNanos(duration)));
try {
Buffer skipBuffer = new Buffer();
while (source.read(skipBuffer, 8192) != -1) {
skipBuffer.clear();
}
return true; // Success! The source has been exhausted.
} catch (InterruptedIOException e) {
return false; // We ran out of time before exhausting the source.
} finally {
if (originalDuration == Long.MAX_VALUE) {
source.timeout().clearDeadline();
} else {
source.timeout().deadlineNanoTime(now + originalDuration);
}
}
} | [
"public",
"static",
"boolean",
"skipAll",
"(",
"Source",
"source",
",",
"int",
"duration",
",",
"TimeUnit",
"timeUnit",
")",
"throws",
"IOException",
"{",
"long",
"now",
"=",
"System",
".",
"nanoTime",
"(",
")",
";",
"long",
"originalDuration",
"=",
"source",
".",
"timeout",
"(",
")",
".",
"hasDeadline",
"(",
")",
"?",
"source",
".",
"timeout",
"(",
")",
".",
"deadlineNanoTime",
"(",
")",
"-",
"now",
":",
"Long",
".",
"MAX_VALUE",
";",
"source",
".",
"timeout",
"(",
")",
".",
"deadlineNanoTime",
"(",
"now",
"+",
"Math",
".",
"min",
"(",
"originalDuration",
",",
"timeUnit",
".",
"toNanos",
"(",
"duration",
")",
")",
")",
";",
"try",
"{",
"Buffer",
"skipBuffer",
"=",
"new",
"Buffer",
"(",
")",
";",
"while",
"(",
"source",
".",
"read",
"(",
"skipBuffer",
",",
"8192",
")",
"!=",
"-",
"1",
")",
"{",
"skipBuffer",
".",
"clear",
"(",
")",
";",
"}",
"return",
"true",
";",
"// Success! The source has been exhausted.",
"}",
"catch",
"(",
"InterruptedIOException",
"e",
")",
"{",
"return",
"false",
";",
"// We ran out of time before exhausting the source.",
"}",
"finally",
"{",
"if",
"(",
"originalDuration",
"==",
"Long",
".",
"MAX_VALUE",
")",
"{",
"source",
".",
"timeout",
"(",
")",
".",
"clearDeadline",
"(",
")",
";",
"}",
"else",
"{",
"source",
".",
"timeout",
"(",
")",
".",
"deadlineNanoTime",
"(",
"now",
"+",
"originalDuration",
")",
";",
"}",
"}",
"}"
] | Reads until {@code in} is exhausted or the deadline has been reached. This is careful to not
extend the deadline if one exists already. | [
"Reads",
"until",
"{"
] | train | https://github.com/square/okhttp/blob/a8c65a822dd6cadd2de7d115bf94adf312e67868/okhttp/src/main/java/okhttp3/internal/Util.java#L173-L194 |
palaima/DebugDrawer | debugdrawer/src/main/java/io/palaima/debugdrawer/util/UIUtils.java | UIUtils.getCompatDrawable | public static Drawable getCompatDrawable(Context c, int drawableRes) {
"""
helper method to get the drawable by its resource. specific to the correct android version
@param c
@param drawableRes
@return
"""
Drawable d = null;
try {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
d = c.getResources().getDrawable(drawableRes);
} else {
d = c.getResources().getDrawable(drawableRes, c.getTheme());
}
} catch (Exception ex) {
}
return d;
} | java | public static Drawable getCompatDrawable(Context c, int drawableRes) {
Drawable d = null;
try {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
d = c.getResources().getDrawable(drawableRes);
} else {
d = c.getResources().getDrawable(drawableRes, c.getTheme());
}
} catch (Exception ex) {
}
return d;
} | [
"public",
"static",
"Drawable",
"getCompatDrawable",
"(",
"Context",
"c",
",",
"int",
"drawableRes",
")",
"{",
"Drawable",
"d",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"Build",
".",
"VERSION",
".",
"SDK_INT",
"<",
"Build",
".",
"VERSION_CODES",
".",
"LOLLIPOP",
")",
"{",
"d",
"=",
"c",
".",
"getResources",
"(",
")",
".",
"getDrawable",
"(",
"drawableRes",
")",
";",
"}",
"else",
"{",
"d",
"=",
"c",
".",
"getResources",
"(",
")",
".",
"getDrawable",
"(",
"drawableRes",
",",
"c",
".",
"getTheme",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"}",
"return",
"d",
";",
"}"
] | helper method to get the drawable by its resource. specific to the correct android version
@param c
@param drawableRes
@return | [
"helper",
"method",
"to",
"get",
"the",
"drawable",
"by",
"its",
"resource",
".",
"specific",
"to",
"the",
"correct",
"android",
"version"
] | train | https://github.com/palaima/DebugDrawer/blob/49b5992a1148757bd740c4a0b7df10ef70ade6d8/debugdrawer/src/main/java/io/palaima/debugdrawer/util/UIUtils.java#L64-L75 |
voldemort/voldemort | src/java/voldemort/rest/coordinator/config/ClientConfigUtil.java | ClientConfigUtil.compareSingleClientConfigAvro | public static Boolean compareSingleClientConfigAvro(String configAvro1, String configAvro2) {
"""
Compares two avro strings which contains single store configs
@param configAvro1
@param configAvro2
@return true if two config avro strings have same content
"""
Properties props1 = readSingleClientConfigAvro(configAvro1);
Properties props2 = readSingleClientConfigAvro(configAvro2);
if(props1.equals(props2)) {
return true;
} else {
return false;
}
} | java | public static Boolean compareSingleClientConfigAvro(String configAvro1, String configAvro2) {
Properties props1 = readSingleClientConfigAvro(configAvro1);
Properties props2 = readSingleClientConfigAvro(configAvro2);
if(props1.equals(props2)) {
return true;
} else {
return false;
}
} | [
"public",
"static",
"Boolean",
"compareSingleClientConfigAvro",
"(",
"String",
"configAvro1",
",",
"String",
"configAvro2",
")",
"{",
"Properties",
"props1",
"=",
"readSingleClientConfigAvro",
"(",
"configAvro1",
")",
";",
"Properties",
"props2",
"=",
"readSingleClientConfigAvro",
"(",
"configAvro2",
")",
";",
"if",
"(",
"props1",
".",
"equals",
"(",
"props2",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | Compares two avro strings which contains single store configs
@param configAvro1
@param configAvro2
@return true if two config avro strings have same content | [
"Compares",
"two",
"avro",
"strings",
"which",
"contains",
"single",
"store",
"configs"
] | train | https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/rest/coordinator/config/ClientConfigUtil.java#L145-L153 |
xwiki/xwiki-rendering | xwiki-rendering-syntaxes/xwiki-rendering-syntax-xhtml/src/main/java/org/xwiki/rendering/internal/renderer/xhtml/link/AbstractXHTMLLinkTypeRenderer.java | AbstractXHTMLLinkTypeRenderer.addAttributeValue | private String addAttributeValue(String currentValue, String valueToAdd) {
"""
Add an attribute value to an existing attribute. This is useful for example for adding a value to an HTML CLASS
attribute.
@param currentValue the current value of the attribute (can be null)
@param valueToAdd the value to add
@return the current value augmented by the value to add
"""
String newValue;
if (currentValue == null || currentValue.length() == 0) {
newValue = "";
} else {
newValue = currentValue + " ";
}
return newValue + valueToAdd;
} | java | private String addAttributeValue(String currentValue, String valueToAdd)
{
String newValue;
if (currentValue == null || currentValue.length() == 0) {
newValue = "";
} else {
newValue = currentValue + " ";
}
return newValue + valueToAdd;
} | [
"private",
"String",
"addAttributeValue",
"(",
"String",
"currentValue",
",",
"String",
"valueToAdd",
")",
"{",
"String",
"newValue",
";",
"if",
"(",
"currentValue",
"==",
"null",
"||",
"currentValue",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"newValue",
"=",
"\"\"",
";",
"}",
"else",
"{",
"newValue",
"=",
"currentValue",
"+",
"\" \"",
";",
"}",
"return",
"newValue",
"+",
"valueToAdd",
";",
"}"
] | Add an attribute value to an existing attribute. This is useful for example for adding a value to an HTML CLASS
attribute.
@param currentValue the current value of the attribute (can be null)
@param valueToAdd the value to add
@return the current value augmented by the value to add | [
"Add",
"an",
"attribute",
"value",
"to",
"an",
"existing",
"attribute",
".",
"This",
"is",
"useful",
"for",
"example",
"for",
"adding",
"a",
"value",
"to",
"an",
"HTML",
"CLASS",
"attribute",
"."
] | train | https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-syntaxes/xwiki-rendering-syntax-xhtml/src/main/java/org/xwiki/rendering/internal/renderer/xhtml/link/AbstractXHTMLLinkTypeRenderer.java#L241-L250 |
adobe/htl-tck | src/main/java/io/sightly/tck/html/HTMLExtractor.java | HTMLExtractor.hasAttribute | public static boolean hasAttribute(String url, String markup, String selector, String attributeName) {
"""
Checks if any of the elements matched by the {@code selector} contain the attribute {@code attributeName}. The {@code url} is used
only for caching purposes, to avoid parsing multiple times the markup returned for the same resource.
@param url the url that identifies the markup
@param markup the markup
@param selector the selector used for retrieval
@param attributeName the attribute's name
@return {@code true} if the attribute was found, {@code false} otherwise
"""
ensureMarkup(url, markup);
Document document = documents.get(url);
Elements elements = document.select(selector);
return !elements.isEmpty() && elements.hasAttr(attributeName);
} | java | public static boolean hasAttribute(String url, String markup, String selector, String attributeName) {
ensureMarkup(url, markup);
Document document = documents.get(url);
Elements elements = document.select(selector);
return !elements.isEmpty() && elements.hasAttr(attributeName);
} | [
"public",
"static",
"boolean",
"hasAttribute",
"(",
"String",
"url",
",",
"String",
"markup",
",",
"String",
"selector",
",",
"String",
"attributeName",
")",
"{",
"ensureMarkup",
"(",
"url",
",",
"markup",
")",
";",
"Document",
"document",
"=",
"documents",
".",
"get",
"(",
"url",
")",
";",
"Elements",
"elements",
"=",
"document",
".",
"select",
"(",
"selector",
")",
";",
"return",
"!",
"elements",
".",
"isEmpty",
"(",
")",
"&&",
"elements",
".",
"hasAttr",
"(",
"attributeName",
")",
";",
"}"
] | Checks if any of the elements matched by the {@code selector} contain the attribute {@code attributeName}. The {@code url} is used
only for caching purposes, to avoid parsing multiple times the markup returned for the same resource.
@param url the url that identifies the markup
@param markup the markup
@param selector the selector used for retrieval
@param attributeName the attribute's name
@return {@code true} if the attribute was found, {@code false} otherwise | [
"Checks",
"if",
"any",
"of",
"the",
"elements",
"matched",
"by",
"the",
"{",
"@code",
"selector",
"}",
"contain",
"the",
"attribute",
"{",
"@code",
"attributeName",
"}",
".",
"The",
"{",
"@code",
"url",
"}",
"is",
"used",
"only",
"for",
"caching",
"purposes",
"to",
"avoid",
"parsing",
"multiple",
"times",
"the",
"markup",
"returned",
"for",
"the",
"same",
"resource",
"."
] | train | https://github.com/adobe/htl-tck/blob/2043a9616083c06cefbd685798c9a2b2ac2ea98e/src/main/java/io/sightly/tck/html/HTMLExtractor.java#L90-L95 |
facebookarchive/hadoop-20 | src/contrib/corona/src/java/org/apache/hadoop/corona/ClusterManagerMetrics.java | ClusterManagerMetrics.createTypeToCountMap | private Map<ResourceType, MetricsIntValue> createTypeToCountMap(
Collection<ResourceType> resourceTypes, String actionType) {
"""
Create a map of resource type -> current count.
@param resourceTypes The resource types.
@param actionType A string indicating pending, running etc.
@return The map.
"""
Map<ResourceType, MetricsIntValue> m =
new HashMap<ResourceType, MetricsIntValue>();
for (ResourceType t : resourceTypes) {
String name = (actionType + "_" + t).toLowerCase();
MetricsIntValue value = new MetricsIntValue(name, registry);
m.put(t, value);
}
return m;
} | java | private Map<ResourceType, MetricsIntValue> createTypeToCountMap(
Collection<ResourceType> resourceTypes, String actionType) {
Map<ResourceType, MetricsIntValue> m =
new HashMap<ResourceType, MetricsIntValue>();
for (ResourceType t : resourceTypes) {
String name = (actionType + "_" + t).toLowerCase();
MetricsIntValue value = new MetricsIntValue(name, registry);
m.put(t, value);
}
return m;
} | [
"private",
"Map",
"<",
"ResourceType",
",",
"MetricsIntValue",
">",
"createTypeToCountMap",
"(",
"Collection",
"<",
"ResourceType",
">",
"resourceTypes",
",",
"String",
"actionType",
")",
"{",
"Map",
"<",
"ResourceType",
",",
"MetricsIntValue",
">",
"m",
"=",
"new",
"HashMap",
"<",
"ResourceType",
",",
"MetricsIntValue",
">",
"(",
")",
";",
"for",
"(",
"ResourceType",
"t",
":",
"resourceTypes",
")",
"{",
"String",
"name",
"=",
"(",
"actionType",
"+",
"\"_\"",
"+",
"t",
")",
".",
"toLowerCase",
"(",
")",
";",
"MetricsIntValue",
"value",
"=",
"new",
"MetricsIntValue",
"(",
"name",
",",
"registry",
")",
";",
"m",
".",
"put",
"(",
"t",
",",
"value",
")",
";",
"}",
"return",
"m",
";",
"}"
] | Create a map of resource type -> current count.
@param resourceTypes The resource types.
@param actionType A string indicating pending, running etc.
@return The map. | [
"Create",
"a",
"map",
"of",
"resource",
"type",
"-",
">",
"current",
"count",
"."
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/contrib/corona/src/java/org/apache/hadoop/corona/ClusterManagerMetrics.java#L345-L355 |
livetribe/livetribe-slp | core/src/main/java/org/livetribe/slp/spi/ServiceInfoCache.java | ServiceInfoCache.addAttributes | public Result<T> addAttributes(ServiceInfo.Key key, Attributes attributes) {
"""
Updates an existing ServiceInfo identified by the given Key, adding the given attributes.
@param key the service's key
@param attributes the attributes to add
@return a result whose previous is the service prior the update and where current is the current service
"""
T previous = null;
T current = null;
lock();
try
{
previous = get(key);
// Updating a service that does not exist must fail (RFC 2608, 9.3)
if (previous == null)
throw new ServiceLocationException("Could not find service to update " + key, SLPError.INVALID_UPDATE);
current = (T)previous.addAttributes(attributes);
keysToServiceInfos.put(current.getKey(), current);
current.setRegistered(true);
previous.setRegistered(false);
}
finally
{
unlock();
}
notifyServiceUpdated(previous, current);
return new Result<T>(previous, current);
} | java | public Result<T> addAttributes(ServiceInfo.Key key, Attributes attributes)
{
T previous = null;
T current = null;
lock();
try
{
previous = get(key);
// Updating a service that does not exist must fail (RFC 2608, 9.3)
if (previous == null)
throw new ServiceLocationException("Could not find service to update " + key, SLPError.INVALID_UPDATE);
current = (T)previous.addAttributes(attributes);
keysToServiceInfos.put(current.getKey(), current);
current.setRegistered(true);
previous.setRegistered(false);
}
finally
{
unlock();
}
notifyServiceUpdated(previous, current);
return new Result<T>(previous, current);
} | [
"public",
"Result",
"<",
"T",
">",
"addAttributes",
"(",
"ServiceInfo",
".",
"Key",
"key",
",",
"Attributes",
"attributes",
")",
"{",
"T",
"previous",
"=",
"null",
";",
"T",
"current",
"=",
"null",
";",
"lock",
"(",
")",
";",
"try",
"{",
"previous",
"=",
"get",
"(",
"key",
")",
";",
"// Updating a service that does not exist must fail (RFC 2608, 9.3)",
"if",
"(",
"previous",
"==",
"null",
")",
"throw",
"new",
"ServiceLocationException",
"(",
"\"Could not find service to update \"",
"+",
"key",
",",
"SLPError",
".",
"INVALID_UPDATE",
")",
";",
"current",
"=",
"(",
"T",
")",
"previous",
".",
"addAttributes",
"(",
"attributes",
")",
";",
"keysToServiceInfos",
".",
"put",
"(",
"current",
".",
"getKey",
"(",
")",
",",
"current",
")",
";",
"current",
".",
"setRegistered",
"(",
"true",
")",
";",
"previous",
".",
"setRegistered",
"(",
"false",
")",
";",
"}",
"finally",
"{",
"unlock",
"(",
")",
";",
"}",
"notifyServiceUpdated",
"(",
"previous",
",",
"current",
")",
";",
"return",
"new",
"Result",
"<",
"T",
">",
"(",
"previous",
",",
"current",
")",
";",
"}"
] | Updates an existing ServiceInfo identified by the given Key, adding the given attributes.
@param key the service's key
@param attributes the attributes to add
@return a result whose previous is the service prior the update and where current is the current service | [
"Updates",
"an",
"existing",
"ServiceInfo",
"identified",
"by",
"the",
"given",
"Key",
"adding",
"the",
"given",
"attributes",
"."
] | train | https://github.com/livetribe/livetribe-slp/blob/6cc13dbe81feab133fe3dd291ca081cbc6e1f591/core/src/main/java/org/livetribe/slp/spi/ServiceInfoCache.java#L185-L210 |
hawkular/hawkular-commons | hawkular-command-gateway/hawkular-command-gateway-war/src/main/java/org/hawkular/cmdgw/command/ws/server/WebSocketHelper.java | WebSocketHelper.sendBinaryAsync | public void sendBinaryAsync(Session session, InputStream inputStream, ExecutorService threadPool) {
"""
Sends binary data to a client asynchronously.
@param session the client session where the message will be sent
@param inputStream the binary data to send
@param threadPool where the job will be submitted so it can execute asynchronously
"""
if (session == null) {
return;
}
if (inputStream == null) {
throw new IllegalArgumentException("inputStream must not be null");
}
log.debugf("Attempting to send async binary data to client [%s]", session.getId());
if (session.isOpen()) {
if (this.asyncTimeout != null) {
// TODO: what to do with timeout?
}
CopyStreamRunnable runnable = new CopyStreamRunnable(session, inputStream);
threadPool.execute(runnable);
}
return;
} | java | public void sendBinaryAsync(Session session, InputStream inputStream, ExecutorService threadPool) {
if (session == null) {
return;
}
if (inputStream == null) {
throw new IllegalArgumentException("inputStream must not be null");
}
log.debugf("Attempting to send async binary data to client [%s]", session.getId());
if (session.isOpen()) {
if (this.asyncTimeout != null) {
// TODO: what to do with timeout?
}
CopyStreamRunnable runnable = new CopyStreamRunnable(session, inputStream);
threadPool.execute(runnable);
}
return;
} | [
"public",
"void",
"sendBinaryAsync",
"(",
"Session",
"session",
",",
"InputStream",
"inputStream",
",",
"ExecutorService",
"threadPool",
")",
"{",
"if",
"(",
"session",
"==",
"null",
")",
"{",
"return",
";",
"}",
"if",
"(",
"inputStream",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"inputStream must not be null\"",
")",
";",
"}",
"log",
".",
"debugf",
"(",
"\"Attempting to send async binary data to client [%s]\"",
",",
"session",
".",
"getId",
"(",
")",
")",
";",
"if",
"(",
"session",
".",
"isOpen",
"(",
")",
")",
"{",
"if",
"(",
"this",
".",
"asyncTimeout",
"!=",
"null",
")",
"{",
"// TODO: what to do with timeout?",
"}",
"CopyStreamRunnable",
"runnable",
"=",
"new",
"CopyStreamRunnable",
"(",
"session",
",",
"inputStream",
")",
";",
"threadPool",
".",
"execute",
"(",
"runnable",
")",
";",
"}",
"return",
";",
"}"
] | Sends binary data to a client asynchronously.
@param session the client session where the message will be sent
@param inputStream the binary data to send
@param threadPool where the job will be submitted so it can execute asynchronously | [
"Sends",
"binary",
"data",
"to",
"a",
"client",
"asynchronously",
"."
] | train | https://github.com/hawkular/hawkular-commons/blob/e4a832862b3446d7f4d629bb05790f2df578e035/hawkular-command-gateway/hawkular-command-gateway-war/src/main/java/org/hawkular/cmdgw/command/ws/server/WebSocketHelper.java#L113-L134 |
maxirosson/jdroid-android | jdroid-android-core/src/main/java/com/jdroid/android/domain/GeoLocation.java | GeoLocation.calculateDistance | public double calculateDistance(double srcLat, double srcLong, double destLat, double destLong) {
"""
/*
@return: Distance in kilometers between this src location and the specified destination
"""
float[] results = new float[1];
Location.distanceBetween(srcLat, srcLong, destLat, destLong, results);
return results[0] / 1000;
} | java | public double calculateDistance(double srcLat, double srcLong, double destLat, double destLong) {
float[] results = new float[1];
Location.distanceBetween(srcLat, srcLong, destLat, destLong, results);
return results[0] / 1000;
} | [
"public",
"double",
"calculateDistance",
"(",
"double",
"srcLat",
",",
"double",
"srcLong",
",",
"double",
"destLat",
",",
"double",
"destLong",
")",
"{",
"float",
"[",
"]",
"results",
"=",
"new",
"float",
"[",
"1",
"]",
";",
"Location",
".",
"distanceBetween",
"(",
"srcLat",
",",
"srcLong",
",",
"destLat",
",",
"destLong",
",",
"results",
")",
";",
"return",
"results",
"[",
"0",
"]",
"/",
"1000",
";",
"}"
] | /*
@return: Distance in kilometers between this src location and the specified destination | [
"/",
"*"
] | train | https://github.com/maxirosson/jdroid-android/blob/1ba9cae56a16fa36bdb2c9c04379853f0300707f/jdroid-android-core/src/main/java/com/jdroid/android/domain/GeoLocation.java#L64-L68 |
Azure/azure-sdk-for-java | batch/data-plane/src/main/java/com/microsoft/azure/batch/FileOperations.java | FileOperations.listFilesFromTask | public PagedList<NodeFile> listFilesFromTask(String jobId, String taskId) throws BatchErrorException, IOException {
"""
Lists the files in the specified task's directory on its compute node.
@param jobId The ID of the job.
@param taskId The ID of the task.
@return A list of {@link NodeFile} objects.
@throws BatchErrorException Exception thrown when an error response is received from the Batch service.
@throws IOException Exception thrown when there is an error in serialization/deserialization of data sent to/received from the Batch service.
"""
return listFilesFromTask(jobId, taskId, null, null, null);
} | java | public PagedList<NodeFile> listFilesFromTask(String jobId, String taskId) throws BatchErrorException, IOException {
return listFilesFromTask(jobId, taskId, null, null, null);
} | [
"public",
"PagedList",
"<",
"NodeFile",
">",
"listFilesFromTask",
"(",
"String",
"jobId",
",",
"String",
"taskId",
")",
"throws",
"BatchErrorException",
",",
"IOException",
"{",
"return",
"listFilesFromTask",
"(",
"jobId",
",",
"taskId",
",",
"null",
",",
"null",
",",
"null",
")",
";",
"}"
] | Lists the files in the specified task's directory on its compute node.
@param jobId The ID of the job.
@param taskId The ID of the task.
@return A list of {@link NodeFile} objects.
@throws BatchErrorException Exception thrown when an error response is received from the Batch service.
@throws IOException Exception thrown when there is an error in serialization/deserialization of data sent to/received from the Batch service. | [
"Lists",
"the",
"files",
"in",
"the",
"specified",
"task",
"s",
"directory",
"on",
"its",
"compute",
"node",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batch/data-plane/src/main/java/com/microsoft/azure/batch/FileOperations.java#L73-L75 |
Azure/azure-sdk-for-java | containerregistry/resource-manager/v2018_02_01_preview/src/main/java/com/microsoft/azure/management/containerregistry/v2018_02_01_preview/implementation/BuildTasksInner.java | BuildTasksInner.beginCreateAsync | public Observable<BuildTaskInner> beginCreateAsync(String resourceGroupName, String registryName, String buildTaskName, BuildTaskInner buildTaskCreateParameters) {
"""
Creates a build task for a container registry with the specified parameters.
@param resourceGroupName The name of the resource group to which the container registry belongs.
@param registryName The name of the container registry.
@param buildTaskName The name of the container registry build task.
@param buildTaskCreateParameters The parameters for creating a build task.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the BuildTaskInner object
"""
return beginCreateWithServiceResponseAsync(resourceGroupName, registryName, buildTaskName, buildTaskCreateParameters).map(new Func1<ServiceResponse<BuildTaskInner>, BuildTaskInner>() {
@Override
public BuildTaskInner call(ServiceResponse<BuildTaskInner> response) {
return response.body();
}
});
} | java | public Observable<BuildTaskInner> beginCreateAsync(String resourceGroupName, String registryName, String buildTaskName, BuildTaskInner buildTaskCreateParameters) {
return beginCreateWithServiceResponseAsync(resourceGroupName, registryName, buildTaskName, buildTaskCreateParameters).map(new Func1<ServiceResponse<BuildTaskInner>, BuildTaskInner>() {
@Override
public BuildTaskInner call(ServiceResponse<BuildTaskInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"BuildTaskInner",
">",
"beginCreateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"registryName",
",",
"String",
"buildTaskName",
",",
"BuildTaskInner",
"buildTaskCreateParameters",
")",
"{",
"return",
"beginCreateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"registryName",
",",
"buildTaskName",
",",
"buildTaskCreateParameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"BuildTaskInner",
">",
",",
"BuildTaskInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"BuildTaskInner",
"call",
"(",
"ServiceResponse",
"<",
"BuildTaskInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Creates a build task for a container registry with the specified parameters.
@param resourceGroupName The name of the resource group to which the container registry belongs.
@param registryName The name of the container registry.
@param buildTaskName The name of the container registry build task.
@param buildTaskCreateParameters The parameters for creating a build task.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the BuildTaskInner object | [
"Creates",
"a",
"build",
"task",
"for",
"a",
"container",
"registry",
"with",
"the",
"specified",
"parameters",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/containerregistry/resource-manager/v2018_02_01_preview/src/main/java/com/microsoft/azure/management/containerregistry/v2018_02_01_preview/implementation/BuildTasksInner.java#L570-L577 |
apache/incubator-zipkin | zipkin/src/main/java/zipkin2/internal/Trace.java | Trace.compareEndpoint | static int compareEndpoint(Endpoint left, Endpoint right) {
"""
Put spans with null endpoints first, so that their data can be attached to the first span with
the same ID and endpoint. It is possible that a server can get the same request on a different
port. Not addressing this.
"""
if (left == null) { // nulls first
return (right == null) ? 0 : -1;
} else if (right == null) {
return 1;
}
int byService = nullSafeCompareTo(left.serviceName(), right.serviceName(), false);
if (byService != 0) return byService;
int byIpV4 = nullSafeCompareTo(left.ipv4(), right.ipv4(), false);
if (byIpV4 != 0) return byIpV4;
return nullSafeCompareTo(left.ipv6(), right.ipv6(), false);
} | java | static int compareEndpoint(Endpoint left, Endpoint right) {
if (left == null) { // nulls first
return (right == null) ? 0 : -1;
} else if (right == null) {
return 1;
}
int byService = nullSafeCompareTo(left.serviceName(), right.serviceName(), false);
if (byService != 0) return byService;
int byIpV4 = nullSafeCompareTo(left.ipv4(), right.ipv4(), false);
if (byIpV4 != 0) return byIpV4;
return nullSafeCompareTo(left.ipv6(), right.ipv6(), false);
} | [
"static",
"int",
"compareEndpoint",
"(",
"Endpoint",
"left",
",",
"Endpoint",
"right",
")",
"{",
"if",
"(",
"left",
"==",
"null",
")",
"{",
"// nulls first",
"return",
"(",
"right",
"==",
"null",
")",
"?",
"0",
":",
"-",
"1",
";",
"}",
"else",
"if",
"(",
"right",
"==",
"null",
")",
"{",
"return",
"1",
";",
"}",
"int",
"byService",
"=",
"nullSafeCompareTo",
"(",
"left",
".",
"serviceName",
"(",
")",
",",
"right",
".",
"serviceName",
"(",
")",
",",
"false",
")",
";",
"if",
"(",
"byService",
"!=",
"0",
")",
"return",
"byService",
";",
"int",
"byIpV4",
"=",
"nullSafeCompareTo",
"(",
"left",
".",
"ipv4",
"(",
")",
",",
"right",
".",
"ipv4",
"(",
")",
",",
"false",
")",
";",
"if",
"(",
"byIpV4",
"!=",
"0",
")",
"return",
"byIpV4",
";",
"return",
"nullSafeCompareTo",
"(",
"left",
".",
"ipv6",
"(",
")",
",",
"right",
".",
"ipv6",
"(",
")",
",",
"false",
")",
";",
"}"
] | Put spans with null endpoints first, so that their data can be attached to the first span with
the same ID and endpoint. It is possible that a server can get the same request on a different
port. Not addressing this. | [
"Put",
"spans",
"with",
"null",
"endpoints",
"first",
"so",
"that",
"their",
"data",
"can",
"be",
"attached",
"to",
"the",
"first",
"span",
"with",
"the",
"same",
"ID",
"and",
"endpoint",
".",
"It",
"is",
"possible",
"that",
"a",
"server",
"can",
"get",
"the",
"same",
"request",
"on",
"a",
"different",
"port",
".",
"Not",
"addressing",
"this",
"."
] | train | https://github.com/apache/incubator-zipkin/blob/89b2fab983fc626b3be32ce9d7cf64b3f01f1a87/zipkin/src/main/java/zipkin2/internal/Trace.java#L144-L155 |
sarl/sarl | main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/natures/RemoveSarlNatureHandler.java | RemoveSarlNatureHandler.doConvert | protected void doConvert(IProject project, IProgressMonitor monitor) throws ExecutionException {
"""
Convert the given project.
@param project the project to convert..
@param monitor the progress monitor.
@throws ExecutionException if something going wrong.
"""
monitor.setTaskName(MessageFormat.format(Messages.RemoveSarlNatureHandler_2, project.getName()));
final SubMonitor mon = SubMonitor.convert(monitor, 2);
if (this.configurator.canUnconfigure(project, mon.newChild(1))) {
try {
this.configurator.unconfigure(project, mon.newChild(1));
} catch (CoreException exception) {
throw new ExecutionException(exception.getLocalizedMessage(), exception);
}
}
monitor.done();
} | java | protected void doConvert(IProject project, IProgressMonitor monitor) throws ExecutionException {
monitor.setTaskName(MessageFormat.format(Messages.RemoveSarlNatureHandler_2, project.getName()));
final SubMonitor mon = SubMonitor.convert(monitor, 2);
if (this.configurator.canUnconfigure(project, mon.newChild(1))) {
try {
this.configurator.unconfigure(project, mon.newChild(1));
} catch (CoreException exception) {
throw new ExecutionException(exception.getLocalizedMessage(), exception);
}
}
monitor.done();
} | [
"protected",
"void",
"doConvert",
"(",
"IProject",
"project",
",",
"IProgressMonitor",
"monitor",
")",
"throws",
"ExecutionException",
"{",
"monitor",
".",
"setTaskName",
"(",
"MessageFormat",
".",
"format",
"(",
"Messages",
".",
"RemoveSarlNatureHandler_2",
",",
"project",
".",
"getName",
"(",
")",
")",
")",
";",
"final",
"SubMonitor",
"mon",
"=",
"SubMonitor",
".",
"convert",
"(",
"monitor",
",",
"2",
")",
";",
"if",
"(",
"this",
".",
"configurator",
".",
"canUnconfigure",
"(",
"project",
",",
"mon",
".",
"newChild",
"(",
"1",
")",
")",
")",
"{",
"try",
"{",
"this",
".",
"configurator",
".",
"unconfigure",
"(",
"project",
",",
"mon",
".",
"newChild",
"(",
"1",
")",
")",
";",
"}",
"catch",
"(",
"CoreException",
"exception",
")",
"{",
"throw",
"new",
"ExecutionException",
"(",
"exception",
".",
"getLocalizedMessage",
"(",
")",
",",
"exception",
")",
";",
"}",
"}",
"monitor",
".",
"done",
"(",
")",
";",
"}"
] | Convert the given project.
@param project the project to convert..
@param monitor the progress monitor.
@throws ExecutionException if something going wrong. | [
"Convert",
"the",
"given",
"project",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.eclipse/src/io/sarl/eclipse/natures/RemoveSarlNatureHandler.java#L116-L127 |
wildfly/wildfly-core | jmx/src/main/java/org/jboss/as/jmx/model/ObjectNameAddressUtil.java | ObjectNameAddressUtil.createObjectName | static ObjectName createObjectName(final String domain, final PathAddress pathAddress, ObjectNameCreationContext context) {
"""
Creates an ObjectName representation of a {@link PathAddress}.
@param domain the JMX domain to use for the ObjectName. Cannot be {@code null}
@param pathAddress the address. Cannot be {@code null}
@param context contextual objection that allows this method to cache state across invocations. May be {@code null}
@return the ObjectName. Will not return {@code null}
"""
if (pathAddress.size() == 0) {
return ModelControllerMBeanHelper.createRootObjectName(domain);
}
final StringBuilder sb = new StringBuilder(domain);
sb.append(":");
boolean first = true;
for (PathElement element : pathAddress) {
if (first) {
first = false;
} else {
sb.append(",");
}
escapeKey(ESCAPED_KEY_CHARACTERS, sb, element.getKey(), context);
sb.append("=");
escapeValue(sb, element.getValue(), context);
}
try {
return ObjectName.getInstance(sb.toString());
} catch (MalformedObjectNameException e) {
throw JmxLogger.ROOT_LOGGER.cannotCreateObjectName(e, pathAddress, sb.toString());
}
} | java | static ObjectName createObjectName(final String domain, final PathAddress pathAddress, ObjectNameCreationContext context) {
if (pathAddress.size() == 0) {
return ModelControllerMBeanHelper.createRootObjectName(domain);
}
final StringBuilder sb = new StringBuilder(domain);
sb.append(":");
boolean first = true;
for (PathElement element : pathAddress) {
if (first) {
first = false;
} else {
sb.append(",");
}
escapeKey(ESCAPED_KEY_CHARACTERS, sb, element.getKey(), context);
sb.append("=");
escapeValue(sb, element.getValue(), context);
}
try {
return ObjectName.getInstance(sb.toString());
} catch (MalformedObjectNameException e) {
throw JmxLogger.ROOT_LOGGER.cannotCreateObjectName(e, pathAddress, sb.toString());
}
} | [
"static",
"ObjectName",
"createObjectName",
"(",
"final",
"String",
"domain",
",",
"final",
"PathAddress",
"pathAddress",
",",
"ObjectNameCreationContext",
"context",
")",
"{",
"if",
"(",
"pathAddress",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"return",
"ModelControllerMBeanHelper",
".",
"createRootObjectName",
"(",
"domain",
")",
";",
"}",
"final",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"domain",
")",
";",
"sb",
".",
"append",
"(",
"\":\"",
")",
";",
"boolean",
"first",
"=",
"true",
";",
"for",
"(",
"PathElement",
"element",
":",
"pathAddress",
")",
"{",
"if",
"(",
"first",
")",
"{",
"first",
"=",
"false",
";",
"}",
"else",
"{",
"sb",
".",
"append",
"(",
"\",\"",
")",
";",
"}",
"escapeKey",
"(",
"ESCAPED_KEY_CHARACTERS",
",",
"sb",
",",
"element",
".",
"getKey",
"(",
")",
",",
"context",
")",
";",
"sb",
".",
"append",
"(",
"\"=\"",
")",
";",
"escapeValue",
"(",
"sb",
",",
"element",
".",
"getValue",
"(",
")",
",",
"context",
")",
";",
"}",
"try",
"{",
"return",
"ObjectName",
".",
"getInstance",
"(",
"sb",
".",
"toString",
"(",
")",
")",
";",
"}",
"catch",
"(",
"MalformedObjectNameException",
"e",
")",
"{",
"throw",
"JmxLogger",
".",
"ROOT_LOGGER",
".",
"cannotCreateObjectName",
"(",
"e",
",",
"pathAddress",
",",
"sb",
".",
"toString",
"(",
")",
")",
";",
"}",
"}"
] | Creates an ObjectName representation of a {@link PathAddress}.
@param domain the JMX domain to use for the ObjectName. Cannot be {@code null}
@param pathAddress the address. Cannot be {@code null}
@param context contextual objection that allows this method to cache state across invocations. May be {@code null}
@return the ObjectName. Will not return {@code null} | [
"Creates",
"an",
"ObjectName",
"representation",
"of",
"a",
"{"
] | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/jmx/src/main/java/org/jboss/as/jmx/model/ObjectNameAddressUtil.java#L146-L169 |
groovy/groovy-core | src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java | StringGroovyMethods.getAt | public static String getAt(String text, Range range) {
"""
Support the range subscript operator for String
@param text a String
@param range a Range
@return a substring corresponding to the Range
@since 1.0
"""
RangeInfo info = subListBorders(text.length(), range);
String answer = text.substring(info.from, info.to);
if (info.reverse) {
answer = reverse(answer);
}
return answer;
} | java | public static String getAt(String text, Range range) {
RangeInfo info = subListBorders(text.length(), range);
String answer = text.substring(info.from, info.to);
if (info.reverse) {
answer = reverse(answer);
}
return answer;
} | [
"public",
"static",
"String",
"getAt",
"(",
"String",
"text",
",",
"Range",
"range",
")",
"{",
"RangeInfo",
"info",
"=",
"subListBorders",
"(",
"text",
".",
"length",
"(",
")",
",",
"range",
")",
";",
"String",
"answer",
"=",
"text",
".",
"substring",
"(",
"info",
".",
"from",
",",
"info",
".",
"to",
")",
";",
"if",
"(",
"info",
".",
"reverse",
")",
"{",
"answer",
"=",
"reverse",
"(",
"answer",
")",
";",
"}",
"return",
"answer",
";",
"}"
] | Support the range subscript operator for String
@param text a String
@param range a Range
@return a substring corresponding to the Range
@since 1.0 | [
"Support",
"the",
"range",
"subscript",
"operator",
"for",
"String"
] | train | https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L1474-L1481 |
cerner/beadledom | pagination/src/main/java/com/cerner/beadledom/pagination/OffsetPaginationLinks.java | OffsetPaginationLinks.prevLink | String prevLink() {
"""
Returns the next prev link; null if no prev page link is available.
"""
if (currentOffset == 0 || currentLimit == 0) {
return null;
}
return urlWithUpdatedPagination(Math.max(0, currentOffset - currentLimit), currentLimit);
} | java | String prevLink() {
if (currentOffset == 0 || currentLimit == 0) {
return null;
}
return urlWithUpdatedPagination(Math.max(0, currentOffset - currentLimit), currentLimit);
} | [
"String",
"prevLink",
"(",
")",
"{",
"if",
"(",
"currentOffset",
"==",
"0",
"||",
"currentLimit",
"==",
"0",
")",
"{",
"return",
"null",
";",
"}",
"return",
"urlWithUpdatedPagination",
"(",
"Math",
".",
"max",
"(",
"0",
",",
"currentOffset",
"-",
"currentLimit",
")",
",",
"currentLimit",
")",
";",
"}"
] | Returns the next prev link; null if no prev page link is available. | [
"Returns",
"the",
"next",
"prev",
"link",
";",
"null",
"if",
"no",
"prev",
"page",
"link",
"is",
"available",
"."
] | train | https://github.com/cerner/beadledom/blob/75435bced5187d5455b46518fadf85c93cf32014/pagination/src/main/java/com/cerner/beadledom/pagination/OffsetPaginationLinks.java#L110-L116 |
lshift/jamume | src/main/java/net/lshift/java/dispatch/JavaC3.java | JavaC3.isCandidate | private static <X> Predicate<X> isCandidate(final Iterable<List<X>> remainingInputs) {
"""
To be a candidate for the next place in the linearization, you must
be the head of at least one list, and in the tail of none of the lists.
@param remainingInputs the lists we are looking for position in.
@return true if the class is a candidate for next.
"""
return new Predicate<X>() {
Predicate<List<X>> headIs(final X c) {
return new Predicate<List<X>>() {
public boolean apply(List<X> input) {
return !input.isEmpty() && c.equals(input.get(0));
}
};
}
Predicate<List<X>> tailContains(final X c) {
return new Predicate<List<X>>() {
public boolean apply(List<X> input) {
return input.indexOf(c) > 0;
}
};
}
public boolean apply(final X c) {
return any(remainingInputs, headIs(c)) &&
all(remainingInputs, not(tailContains(c)));
}
};
} | java | private static <X> Predicate<X> isCandidate(final Iterable<List<X>> remainingInputs) {
return new Predicate<X>() {
Predicate<List<X>> headIs(final X c) {
return new Predicate<List<X>>() {
public boolean apply(List<X> input) {
return !input.isEmpty() && c.equals(input.get(0));
}
};
}
Predicate<List<X>> tailContains(final X c) {
return new Predicate<List<X>>() {
public boolean apply(List<X> input) {
return input.indexOf(c) > 0;
}
};
}
public boolean apply(final X c) {
return any(remainingInputs, headIs(c)) &&
all(remainingInputs, not(tailContains(c)));
}
};
} | [
"private",
"static",
"<",
"X",
">",
"Predicate",
"<",
"X",
">",
"isCandidate",
"(",
"final",
"Iterable",
"<",
"List",
"<",
"X",
">",
">",
"remainingInputs",
")",
"{",
"return",
"new",
"Predicate",
"<",
"X",
">",
"(",
")",
"{",
"Predicate",
"<",
"List",
"<",
"X",
">",
">",
"headIs",
"(",
"final",
"X",
"c",
")",
"{",
"return",
"new",
"Predicate",
"<",
"List",
"<",
"X",
">",
">",
"(",
")",
"{",
"public",
"boolean",
"apply",
"(",
"List",
"<",
"X",
">",
"input",
")",
"{",
"return",
"!",
"input",
".",
"isEmpty",
"(",
")",
"&&",
"c",
".",
"equals",
"(",
"input",
".",
"get",
"(",
"0",
")",
")",
";",
"}",
"}",
";",
"}",
"Predicate",
"<",
"List",
"<",
"X",
">",
">",
"tailContains",
"(",
"final",
"X",
"c",
")",
"{",
"return",
"new",
"Predicate",
"<",
"List",
"<",
"X",
">",
">",
"(",
")",
"{",
"public",
"boolean",
"apply",
"(",
"List",
"<",
"X",
">",
"input",
")",
"{",
"return",
"input",
".",
"indexOf",
"(",
"c",
")",
">",
"0",
";",
"}",
"}",
";",
"}",
"public",
"boolean",
"apply",
"(",
"final",
"X",
"c",
")",
"{",
"return",
"any",
"(",
"remainingInputs",
",",
"headIs",
"(",
"c",
")",
")",
"&&",
"all",
"(",
"remainingInputs",
",",
"not",
"(",
"tailContains",
"(",
"c",
")",
")",
")",
";",
"}",
"}",
";",
"}"
] | To be a candidate for the next place in the linearization, you must
be the head of at least one list, and in the tail of none of the lists.
@param remainingInputs the lists we are looking for position in.
@return true if the class is a candidate for next. | [
"To",
"be",
"a",
"candidate",
"for",
"the",
"next",
"place",
"in",
"the",
"linearization",
"you",
"must",
"be",
"the",
"head",
"of",
"at",
"least",
"one",
"list",
"and",
"in",
"the",
"tail",
"of",
"none",
"of",
"the",
"lists",
"."
] | train | https://github.com/lshift/jamume/blob/754d9ab29311601328a2f39928775e4e010305b7/src/main/java/net/lshift/java/dispatch/JavaC3.java#L186-L210 |
graphql-java/java-dataloader | src/main/java/org/dataloader/DataLoader.java | DataLoader.newMappedDataLoaderWithTry | public static <K, V> DataLoader<K, V> newMappedDataLoaderWithTry(MappedBatchLoader<K, Try<V>> batchLoadFunction) {
"""
Creates new DataLoader with the specified batch loader function and default options
(batching, caching and unlimited batch size) where the batch loader function returns a list of
{@link org.dataloader.Try} objects.
<p>
If its important you to know the exact status of each item in a batch call and whether it threw exceptions then
you can use this form to create the data loader.
Using Try objects allows you to capture a value returned or an exception that might
have occurred trying to get a value. .
<p>
@param batchLoadFunction the batch load function to use that uses {@link org.dataloader.Try} objects
@param <K> the key type
@param <V> the value type
@return a new DataLoader
"""
return newMappedDataLoaderWithTry(batchLoadFunction, null);
} | java | public static <K, V> DataLoader<K, V> newMappedDataLoaderWithTry(MappedBatchLoader<K, Try<V>> batchLoadFunction) {
return newMappedDataLoaderWithTry(batchLoadFunction, null);
} | [
"public",
"static",
"<",
"K",
",",
"V",
">",
"DataLoader",
"<",
"K",
",",
"V",
">",
"newMappedDataLoaderWithTry",
"(",
"MappedBatchLoader",
"<",
"K",
",",
"Try",
"<",
"V",
">",
">",
"batchLoadFunction",
")",
"{",
"return",
"newMappedDataLoaderWithTry",
"(",
"batchLoadFunction",
",",
"null",
")",
";",
"}"
] | Creates new DataLoader with the specified batch loader function and default options
(batching, caching and unlimited batch size) where the batch loader function returns a list of
{@link org.dataloader.Try} objects.
<p>
If its important you to know the exact status of each item in a batch call and whether it threw exceptions then
you can use this form to create the data loader.
Using Try objects allows you to capture a value returned or an exception that might
have occurred trying to get a value. .
<p>
@param batchLoadFunction the batch load function to use that uses {@link org.dataloader.Try} objects
@param <K> the key type
@param <V> the value type
@return a new DataLoader | [
"Creates",
"new",
"DataLoader",
"with",
"the",
"specified",
"batch",
"loader",
"function",
"and",
"default",
"options",
"(",
"batching",
"caching",
"and",
"unlimited",
"batch",
"size",
")",
"where",
"the",
"batch",
"loader",
"function",
"returns",
"a",
"list",
"of",
"{",
"@link",
"org",
".",
"dataloader",
".",
"Try",
"}",
"objects",
".",
"<p",
">",
"If",
"its",
"important",
"you",
"to",
"know",
"the",
"exact",
"status",
"of",
"each",
"item",
"in",
"a",
"batch",
"call",
"and",
"whether",
"it",
"threw",
"exceptions",
"then",
"you",
"can",
"use",
"this",
"form",
"to",
"create",
"the",
"data",
"loader",
"."
] | train | https://github.com/graphql-java/java-dataloader/blob/dfdc8133ead10aa723f896b4a1fa4a1cec9a6fbc/src/main/java/org/dataloader/DataLoader.java#L245-L247 |
beihaifeiwu/dolphin | dolphin-common/src/main/java/com/freetmp/common/util/BridgeMethodResolver.java | BridgeMethodResolver.isVisibilityBridgeMethodPair | public static boolean isVisibilityBridgeMethodPair(Method bridgeMethod, Method bridgedMethod) {
"""
Compare the signatures of the bridge method and the method which it bridges. If
the parameter and return types are the same, it is a 'visibility' bridge method
introduced in Java 6 to fix http://bugs.sun.com/view_bug.do?bug_id=6342411.
See also http://stas-blogspot.blogspot.com/2010/03/java-bridge-methods-explained.html
@return whether signatures match as described
"""
if (bridgeMethod == bridgedMethod) {
return true;
}
return (Arrays.equals(bridgeMethod.getParameterTypes(), bridgedMethod.getParameterTypes()) &&
bridgeMethod.getReturnType().equals(bridgedMethod.getReturnType()));
} | java | public static boolean isVisibilityBridgeMethodPair(Method bridgeMethod, Method bridgedMethod) {
if (bridgeMethod == bridgedMethod) {
return true;
}
return (Arrays.equals(bridgeMethod.getParameterTypes(), bridgedMethod.getParameterTypes()) &&
bridgeMethod.getReturnType().equals(bridgedMethod.getReturnType()));
} | [
"public",
"static",
"boolean",
"isVisibilityBridgeMethodPair",
"(",
"Method",
"bridgeMethod",
",",
"Method",
"bridgedMethod",
")",
"{",
"if",
"(",
"bridgeMethod",
"==",
"bridgedMethod",
")",
"{",
"return",
"true",
";",
"}",
"return",
"(",
"Arrays",
".",
"equals",
"(",
"bridgeMethod",
".",
"getParameterTypes",
"(",
")",
",",
"bridgedMethod",
".",
"getParameterTypes",
"(",
")",
")",
"&&",
"bridgeMethod",
".",
"getReturnType",
"(",
")",
".",
"equals",
"(",
"bridgedMethod",
".",
"getReturnType",
"(",
")",
")",
")",
";",
"}"
] | Compare the signatures of the bridge method and the method which it bridges. If
the parameter and return types are the same, it is a 'visibility' bridge method
introduced in Java 6 to fix http://bugs.sun.com/view_bug.do?bug_id=6342411.
See also http://stas-blogspot.blogspot.com/2010/03/java-bridge-methods-explained.html
@return whether signatures match as described | [
"Compare",
"the",
"signatures",
"of",
"the",
"bridge",
"method",
"and",
"the",
"method",
"which",
"it",
"bridges",
".",
"If",
"the",
"parameter",
"and",
"return",
"types",
"are",
"the",
"same",
"it",
"is",
"a",
"visibility",
"bridge",
"method",
"introduced",
"in",
"Java",
"6",
"to",
"fix",
"http",
":",
"//",
"bugs",
".",
"sun",
".",
"com",
"/",
"view_bug",
".",
"do?bug_id",
"=",
"6342411",
".",
"See",
"also",
"http",
":",
"//",
"stas",
"-",
"blogspot",
".",
"blogspot",
".",
"com",
"/",
"2010",
"/",
"03",
"/",
"java",
"-",
"bridge",
"-",
"methods",
"-",
"explained",
".",
"html"
] | train | https://github.com/beihaifeiwu/dolphin/blob/b100579cc6986dce5eba5593ebb5fbae7bad9d1a/dolphin-common/src/main/java/com/freetmp/common/util/BridgeMethodResolver.java#L209-L215 |
TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/RegionMap.java | RegionMap.snapToNextHigherInRegionResolution | public Coordinate snapToNextHigherInRegionResolution( double x, double y ) {
"""
Snaps a geographic point to be on the region grid.
<p>
Moves the point given by X and Y to be on the grid of the supplied
region.
</p>
@param x the easting of the arbitrary point.
@param y the northing of the arbitrary point.
@return the snapped coordinate.
"""
double minx = getWest();
double ewres = getXres();
double xsnap = minx + (Math.ceil((x - minx) / ewres) * ewres);
double miny = getSouth();
double nsres = getYres();
double ysnap = miny + (Math.ceil((y - miny) / nsres) * nsres);
return new Coordinate(xsnap, ysnap);
} | java | public Coordinate snapToNextHigherInRegionResolution( double x, double y ) {
double minx = getWest();
double ewres = getXres();
double xsnap = minx + (Math.ceil((x - minx) / ewres) * ewres);
double miny = getSouth();
double nsres = getYres();
double ysnap = miny + (Math.ceil((y - miny) / nsres) * nsres);
return new Coordinate(xsnap, ysnap);
} | [
"public",
"Coordinate",
"snapToNextHigherInRegionResolution",
"(",
"double",
"x",
",",
"double",
"y",
")",
"{",
"double",
"minx",
"=",
"getWest",
"(",
")",
";",
"double",
"ewres",
"=",
"getXres",
"(",
")",
";",
"double",
"xsnap",
"=",
"minx",
"+",
"(",
"Math",
".",
"ceil",
"(",
"(",
"x",
"-",
"minx",
")",
"/",
"ewres",
")",
"*",
"ewres",
")",
";",
"double",
"miny",
"=",
"getSouth",
"(",
")",
";",
"double",
"nsres",
"=",
"getYres",
"(",
")",
";",
"double",
"ysnap",
"=",
"miny",
"+",
"(",
"Math",
".",
"ceil",
"(",
"(",
"y",
"-",
"miny",
")",
"/",
"nsres",
")",
"*",
"nsres",
")",
";",
"return",
"new",
"Coordinate",
"(",
"xsnap",
",",
"ysnap",
")",
";",
"}"
] | Snaps a geographic point to be on the region grid.
<p>
Moves the point given by X and Y to be on the grid of the supplied
region.
</p>
@param x the easting of the arbitrary point.
@param y the northing of the arbitrary point.
@return the snapped coordinate. | [
"Snaps",
"a",
"geographic",
"point",
"to",
"be",
"on",
"the",
"region",
"grid",
"."
] | train | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/RegionMap.java#L180-L191 |
nostra13/Android-Universal-Image-Loader | library/src/main/java/com/nostra13/universalimageloader/utils/DiskCacheUtils.java | DiskCacheUtils.findInCache | public static File findInCache(String imageUri, DiskCache diskCache) {
"""
Returns {@link File} of cached image or <b>null</b> if image was not cached in disk cache
"""
File image = diskCache.get(imageUri);
return image != null && image.exists() ? image : null;
} | java | public static File findInCache(String imageUri, DiskCache diskCache) {
File image = diskCache.get(imageUri);
return image != null && image.exists() ? image : null;
} | [
"public",
"static",
"File",
"findInCache",
"(",
"String",
"imageUri",
",",
"DiskCache",
"diskCache",
")",
"{",
"File",
"image",
"=",
"diskCache",
".",
"get",
"(",
"imageUri",
")",
";",
"return",
"image",
"!=",
"null",
"&&",
"image",
".",
"exists",
"(",
")",
"?",
"image",
":",
"null",
";",
"}"
] | Returns {@link File} of cached image or <b>null</b> if image was not cached in disk cache | [
"Returns",
"{"
] | train | https://github.com/nostra13/Android-Universal-Image-Loader/blob/fc3c5f6779bb4f702e233653b61bd9d559e345cc/library/src/main/java/com/nostra13/universalimageloader/utils/DiskCacheUtils.java#L35-L38 |
JodaOrg/joda-time | src/main/java/org/joda/time/format/PeriodFormatterBuilder.java | PeriodFormatterBuilder.appendSeparator | public PeriodFormatterBuilder appendSeparator(String text, String finalText,
String[] variants) {
"""
Append a separator, which is output if fields are printed both before
and after the separator.
<p>
This method changes the separator depending on whether it is the last separator
to be output.
<p>
For example, <code>builder.appendDays().appendSeparator(",", "&").appendHours().appendSeparator(",", "&").appendMinutes()</code>
will output '1,2&3' if all three fields are output, '1&2' if two fields are output
and '1' if just one field is output.
<p>
The text will be parsed case-insensitively.
<p>
Note: appending a separator discontinues any further work on the latest
appended field.
@param text the text to use as a separator
@param finalText the text used used if this is the final separator to be printed
@param variants set of text values which are also acceptable when parsed
@return this PeriodFormatterBuilder
@throws IllegalStateException if this separator follows a previous one
"""
return appendSeparator(text, finalText, variants, true, true);
} | java | public PeriodFormatterBuilder appendSeparator(String text, String finalText,
String[] variants) {
return appendSeparator(text, finalText, variants, true, true);
} | [
"public",
"PeriodFormatterBuilder",
"appendSeparator",
"(",
"String",
"text",
",",
"String",
"finalText",
",",
"String",
"[",
"]",
"variants",
")",
"{",
"return",
"appendSeparator",
"(",
"text",
",",
"finalText",
",",
"variants",
",",
"true",
",",
"true",
")",
";",
"}"
] | Append a separator, which is output if fields are printed both before
and after the separator.
<p>
This method changes the separator depending on whether it is the last separator
to be output.
<p>
For example, <code>builder.appendDays().appendSeparator(",", "&").appendHours().appendSeparator(",", "&").appendMinutes()</code>
will output '1,2&3' if all three fields are output, '1&2' if two fields are output
and '1' if just one field is output.
<p>
The text will be parsed case-insensitively.
<p>
Note: appending a separator discontinues any further work on the latest
appended field.
@param text the text to use as a separator
@param finalText the text used used if this is the final separator to be printed
@param variants set of text values which are also acceptable when parsed
@return this PeriodFormatterBuilder
@throws IllegalStateException if this separator follows a previous one | [
"Append",
"a",
"separator",
"which",
"is",
"output",
"if",
"fields",
"are",
"printed",
"both",
"before",
"and",
"after",
"the",
"separator",
".",
"<p",
">",
"This",
"method",
"changes",
"the",
"separator",
"depending",
"on",
"whether",
"it",
"is",
"the",
"last",
"separator",
"to",
"be",
"output",
".",
"<p",
">",
"For",
"example",
"<code",
">",
"builder",
".",
"appendDays",
"()",
".",
"appendSeparator",
"(",
"&",
")",
".",
"appendHours",
"()",
".",
"appendSeparator",
"(",
"&",
")",
".",
"appendMinutes",
"()",
"<",
"/",
"code",
">",
"will",
"output",
"1",
"2&3",
"if",
"all",
"three",
"fields",
"are",
"output",
"1&2",
"if",
"two",
"fields",
"are",
"output",
"and",
"1",
"if",
"just",
"one",
"field",
"is",
"output",
".",
"<p",
">",
"The",
"text",
"will",
"be",
"parsed",
"case",
"-",
"insensitively",
".",
"<p",
">",
"Note",
":",
"appending",
"a",
"separator",
"discontinues",
"any",
"further",
"work",
"on",
"the",
"latest",
"appended",
"field",
"."
] | train | https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/format/PeriodFormatterBuilder.java#L818-L821 |
ngageoint/geopackage-android-map | geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/overlay/FeatureOverlayQuery.java | FeatureOverlayQuery.buildMapClickTableData | private FeatureTableData buildMapClickTableData(LatLng latLng, double zoom, BoundingBox boundingBox, double tolerance, Projection projection) {
"""
Perform a query based upon the map click location and build feature table data
@param latLng location
@param zoom current zoom level
@param boundingBox click bounding box
@param tolerance distance tolerance
@param projection desired geometry projection
@return table data on what was clicked, or null
"""
FeatureTableData tableData = null;
// Verify the features are indexed and we are getting information
if (isIndexed() && (maxFeaturesInfo || featuresInfo)) {
if (isOnAtCurrentZoom(zoom, latLng)) {
// Get the number of features in the tile location
long tileFeatureCount = tileFeatureCount(latLng, zoom);
// If more than a configured max features to draw
if (isMoreThanMaxFeatures(tileFeatureCount)) {
// Build the max features message
if (maxFeaturesInfo) {
tableData = new FeatureTableData(featureTiles.getFeatureDao().getTableName(), tileFeatureCount);
}
}
// Else, query for the features near the click
else if (featuresInfo) {
// Query for results and build the message
FeatureIndexResults results = queryFeatures(boundingBox, projection);
tableData = featureInfoBuilder.buildTableDataAndClose(results, tolerance, latLng, projection);
}
}
}
return tableData;
} | java | private FeatureTableData buildMapClickTableData(LatLng latLng, double zoom, BoundingBox boundingBox, double tolerance, Projection projection) {
FeatureTableData tableData = null;
// Verify the features are indexed and we are getting information
if (isIndexed() && (maxFeaturesInfo || featuresInfo)) {
if (isOnAtCurrentZoom(zoom, latLng)) {
// Get the number of features in the tile location
long tileFeatureCount = tileFeatureCount(latLng, zoom);
// If more than a configured max features to draw
if (isMoreThanMaxFeatures(tileFeatureCount)) {
// Build the max features message
if (maxFeaturesInfo) {
tableData = new FeatureTableData(featureTiles.getFeatureDao().getTableName(), tileFeatureCount);
}
}
// Else, query for the features near the click
else if (featuresInfo) {
// Query for results and build the message
FeatureIndexResults results = queryFeatures(boundingBox, projection);
tableData = featureInfoBuilder.buildTableDataAndClose(results, tolerance, latLng, projection);
}
}
}
return tableData;
} | [
"private",
"FeatureTableData",
"buildMapClickTableData",
"(",
"LatLng",
"latLng",
",",
"double",
"zoom",
",",
"BoundingBox",
"boundingBox",
",",
"double",
"tolerance",
",",
"Projection",
"projection",
")",
"{",
"FeatureTableData",
"tableData",
"=",
"null",
";",
"// Verify the features are indexed and we are getting information",
"if",
"(",
"isIndexed",
"(",
")",
"&&",
"(",
"maxFeaturesInfo",
"||",
"featuresInfo",
")",
")",
"{",
"if",
"(",
"isOnAtCurrentZoom",
"(",
"zoom",
",",
"latLng",
")",
")",
"{",
"// Get the number of features in the tile location",
"long",
"tileFeatureCount",
"=",
"tileFeatureCount",
"(",
"latLng",
",",
"zoom",
")",
";",
"// If more than a configured max features to draw",
"if",
"(",
"isMoreThanMaxFeatures",
"(",
"tileFeatureCount",
")",
")",
"{",
"// Build the max features message",
"if",
"(",
"maxFeaturesInfo",
")",
"{",
"tableData",
"=",
"new",
"FeatureTableData",
"(",
"featureTiles",
".",
"getFeatureDao",
"(",
")",
".",
"getTableName",
"(",
")",
",",
"tileFeatureCount",
")",
";",
"}",
"}",
"// Else, query for the features near the click",
"else",
"if",
"(",
"featuresInfo",
")",
"{",
"// Query for results and build the message",
"FeatureIndexResults",
"results",
"=",
"queryFeatures",
"(",
"boundingBox",
",",
"projection",
")",
";",
"tableData",
"=",
"featureInfoBuilder",
".",
"buildTableDataAndClose",
"(",
"results",
",",
"tolerance",
",",
"latLng",
",",
"projection",
")",
";",
"}",
"}",
"}",
"return",
"tableData",
";",
"}"
] | Perform a query based upon the map click location and build feature table data
@param latLng location
@param zoom current zoom level
@param boundingBox click bounding box
@param tolerance distance tolerance
@param projection desired geometry projection
@return table data on what was clicked, or null | [
"Perform",
"a",
"query",
"based",
"upon",
"the",
"map",
"click",
"location",
"and",
"build",
"feature",
"table",
"data"
] | train | https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/overlay/FeatureOverlayQuery.java#L536-L568 |
CodeNarc/CodeNarc | src/main/java/org/codenarc/util/AstUtil.java | AstUtil.isConstructorCall | public static boolean isConstructorCall(Expression expression, List<String> classNames) {
"""
Return true if the expression is a constructor call on any of the named classes, with any number of parameters.
@param expression - the expression
@param classNames - the possible List of class names
@return as described
"""
return expression instanceof ConstructorCallExpression && classNames.contains(expression.getType().getName());
} | java | public static boolean isConstructorCall(Expression expression, List<String> classNames) {
return expression instanceof ConstructorCallExpression && classNames.contains(expression.getType().getName());
} | [
"public",
"static",
"boolean",
"isConstructorCall",
"(",
"Expression",
"expression",
",",
"List",
"<",
"String",
">",
"classNames",
")",
"{",
"return",
"expression",
"instanceof",
"ConstructorCallExpression",
"&&",
"classNames",
".",
"contains",
"(",
"expression",
".",
"getType",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}"
] | Return true if the expression is a constructor call on any of the named classes, with any number of parameters.
@param expression - the expression
@param classNames - the possible List of class names
@return as described | [
"Return",
"true",
"if",
"the",
"expression",
"is",
"a",
"constructor",
"call",
"on",
"any",
"of",
"the",
"named",
"classes",
"with",
"any",
"number",
"of",
"parameters",
"."
] | train | https://github.com/CodeNarc/CodeNarc/blob/9a7cec02cb8cbaf845030f2434309e8968f5d7a7/src/main/java/org/codenarc/util/AstUtil.java#L452-L454 |
aws/aws-sdk-java | aws-java-sdk-dynamodb/src/main/java/com/amazonaws/services/dynamodbv2/model/ScanRequest.java | ScanRequest.withScanFilter | public ScanRequest withScanFilter(java.util.Map<String, Condition> scanFilter) {
"""
<p>
This is a legacy parameter. Use <code>FilterExpression</code> instead. For more information, see <a href=
"https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LegacyConditionalParameters.ScanFilter.html"
>ScanFilter</a> in the <i>Amazon DynamoDB Developer Guide</i>.
</p>
@param scanFilter
This is a legacy parameter. Use <code>FilterExpression</code> instead. For more information, see <a href=
"https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LegacyConditionalParameters.ScanFilter.html"
>ScanFilter</a> in the <i>Amazon DynamoDB Developer Guide</i>.
@return Returns a reference to this object so that method calls can be chained together.
"""
setScanFilter(scanFilter);
return this;
} | java | public ScanRequest withScanFilter(java.util.Map<String, Condition> scanFilter) {
setScanFilter(scanFilter);
return this;
} | [
"public",
"ScanRequest",
"withScanFilter",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"Condition",
">",
"scanFilter",
")",
"{",
"setScanFilter",
"(",
"scanFilter",
")",
";",
"return",
"this",
";",
"}"
] | <p>
This is a legacy parameter. Use <code>FilterExpression</code> instead. For more information, see <a href=
"https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LegacyConditionalParameters.ScanFilter.html"
>ScanFilter</a> in the <i>Amazon DynamoDB Developer Guide</i>.
</p>
@param scanFilter
This is a legacy parameter. Use <code>FilterExpression</code> instead. For more information, see <a href=
"https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LegacyConditionalParameters.ScanFilter.html"
>ScanFilter</a> in the <i>Amazon DynamoDB Developer Guide</i>.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"This",
"is",
"a",
"legacy",
"parameter",
".",
"Use",
"<code",
">",
"FilterExpression<",
"/",
"code",
">",
"instead",
".",
"For",
"more",
"information",
"see",
"<a",
"href",
"=",
"https",
":",
"//",
"docs",
".",
"aws",
".",
"amazon",
".",
"com",
"/",
"amazondynamodb",
"/",
"latest",
"/",
"developerguide",
"/",
"LegacyConditionalParameters",
".",
"ScanFilter",
".",
"html",
">",
"ScanFilter<",
"/",
"a",
">",
"in",
"the",
"<i",
">",
"Amazon",
"DynamoDB",
"Developer",
"Guide<",
"/",
"i",
">",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-dynamodb/src/main/java/com/amazonaws/services/dynamodbv2/model/ScanRequest.java#L1301-L1304 |
GCRC/nunaliit | nunaliit2-dbSec/src/main/java/ca/carleton/gcrc/dbSec/FieldSelectorCentroid.java | FieldSelectorCentroid.getQueryString | public String getQueryString(TableSchema tableSchema, Phase phase) throws Exception {
"""
/*
ST_X(ST_Centroid(coalesce(ST_GeometryN(the_geom,1),the_geom)))
ST_Y(ST_Centroid(coalesce(ST_GeometryN(the_geom,1),the_geom)))
ST_GeometryN - Return the 1-based Nth geometry if the geometry is a
GEOMETRYCOLLECTION, MULTIPOINT, MULTILINESTRING, MULTICURVE or
MULTIPOLYGON. Otherwise, return NULL.
ST_Centroid - Returns the geometric center of a geometry
coalesce - The COALESCE function returns the first of its arguments that
is not null. Null is returned only if all arguments are null.
ST_X(
ST_Centroid(
coalesce(
ST_GeometryN(
the_geom
,1
)
,the_geom
)
)
)
"""
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
if( Type.X == type ) {
pw.print("ST_X");
} else if( Type.Y == type ) {
pw.print("ST_Y");
} else {
throw new Exception("Can not handle type: "+type);
}
pw.print("(ST_Centroid(coalesce(ST_GeometryN(");
pw.print(fieldName);
pw.print(",1),");
pw.print(fieldName);
pw.print(")))");
if( Phase.SELECT == phase ) {
if( Type.X == type ) {
pw.print(" AS x");
} else if( Type.Y == type ) {
pw.print(" AS y");
} else {
throw new Exception("Can not handle type: "+type);
}
}
pw.flush();
return sw.toString();
} | java | public String getQueryString(TableSchema tableSchema, Phase phase) throws Exception {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
if( Type.X == type ) {
pw.print("ST_X");
} else if( Type.Y == type ) {
pw.print("ST_Y");
} else {
throw new Exception("Can not handle type: "+type);
}
pw.print("(ST_Centroid(coalesce(ST_GeometryN(");
pw.print(fieldName);
pw.print(",1),");
pw.print(fieldName);
pw.print(")))");
if( Phase.SELECT == phase ) {
if( Type.X == type ) {
pw.print(" AS x");
} else if( Type.Y == type ) {
pw.print(" AS y");
} else {
throw new Exception("Can not handle type: "+type);
}
}
pw.flush();
return sw.toString();
} | [
"public",
"String",
"getQueryString",
"(",
"TableSchema",
"tableSchema",
",",
"Phase",
"phase",
")",
"throws",
"Exception",
"{",
"StringWriter",
"sw",
"=",
"new",
"StringWriter",
"(",
")",
";",
"PrintWriter",
"pw",
"=",
"new",
"PrintWriter",
"(",
"sw",
")",
";",
"if",
"(",
"Type",
".",
"X",
"==",
"type",
")",
"{",
"pw",
".",
"print",
"(",
"\"ST_X\"",
")",
";",
"}",
"else",
"if",
"(",
"Type",
".",
"Y",
"==",
"type",
")",
"{",
"pw",
".",
"print",
"(",
"\"ST_Y\"",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"\"Can not handle type: \"",
"+",
"type",
")",
";",
"}",
"pw",
".",
"print",
"(",
"\"(ST_Centroid(coalesce(ST_GeometryN(\"",
")",
";",
"pw",
".",
"print",
"(",
"fieldName",
")",
";",
"pw",
".",
"print",
"(",
"\",1),\"",
")",
";",
"pw",
".",
"print",
"(",
"fieldName",
")",
";",
"pw",
".",
"print",
"(",
"\")))\"",
")",
";",
"if",
"(",
"Phase",
".",
"SELECT",
"==",
"phase",
")",
"{",
"if",
"(",
"Type",
".",
"X",
"==",
"type",
")",
"{",
"pw",
".",
"print",
"(",
"\" AS x\"",
")",
";",
"}",
"else",
"if",
"(",
"Type",
".",
"Y",
"==",
"type",
")",
"{",
"pw",
".",
"print",
"(",
"\" AS y\"",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"\"Can not handle type: \"",
"+",
"type",
")",
";",
"}",
"}",
"pw",
".",
"flush",
"(",
")",
";",
"return",
"sw",
".",
"toString",
"(",
")",
";",
"}"
] | /*
ST_X(ST_Centroid(coalesce(ST_GeometryN(the_geom,1),the_geom)))
ST_Y(ST_Centroid(coalesce(ST_GeometryN(the_geom,1),the_geom)))
ST_GeometryN - Return the 1-based Nth geometry if the geometry is a
GEOMETRYCOLLECTION, MULTIPOINT, MULTILINESTRING, MULTICURVE or
MULTIPOLYGON. Otherwise, return NULL.
ST_Centroid - Returns the geometric center of a geometry
coalesce - The COALESCE function returns the first of its arguments that
is not null. Null is returned only if all arguments are null.
ST_X(
ST_Centroid(
coalesce(
ST_GeometryN(
the_geom
,1
)
,the_geom
)
)
) | [
"/",
"*",
"ST_X",
"(",
"ST_Centroid",
"(",
"coalesce",
"(",
"ST_GeometryN",
"(",
"the_geom",
"1",
")",
"the_geom",
")))",
"ST_Y",
"(",
"ST_Centroid",
"(",
"coalesce",
"(",
"ST_GeometryN",
"(",
"the_geom",
"1",
")",
"the_geom",
")))"
] | train | https://github.com/GCRC/nunaliit/blob/0b4abfc64eef2eb8b94f852ce697de2e851d8e67/nunaliit2-dbSec/src/main/java/ca/carleton/gcrc/dbSec/FieldSelectorCentroid.java#L99-L129 |
aws/aws-sdk-java | aws-java-sdk-batch/src/main/java/com/amazonaws/services/batch/model/JobDetail.java | JobDetail.withParameters | public JobDetail withParameters(java.util.Map<String, String> parameters) {
"""
<p>
Additional parameters passed to the job that replace parameter substitution placeholders or override any
corresponding parameter defaults from the job definition.
</p>
@param parameters
Additional parameters passed to the job that replace parameter substitution placeholders or override any
corresponding parameter defaults from the job definition.
@return Returns a reference to this object so that method calls can be chained together.
"""
setParameters(parameters);
return this;
} | java | public JobDetail withParameters(java.util.Map<String, String> parameters) {
setParameters(parameters);
return this;
} | [
"public",
"JobDetail",
"withParameters",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"parameters",
")",
"{",
"setParameters",
"(",
"parameters",
")",
";",
"return",
"this",
";",
"}"
] | <p>
Additional parameters passed to the job that replace parameter substitution placeholders or override any
corresponding parameter defaults from the job definition.
</p>
@param parameters
Additional parameters passed to the job that replace parameter substitution placeholders or override any
corresponding parameter defaults from the job definition.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"Additional",
"parameters",
"passed",
"to",
"the",
"job",
"that",
"replace",
"parameter",
"substitution",
"placeholders",
"or",
"override",
"any",
"corresponding",
"parameter",
"defaults",
"from",
"the",
"job",
"definition",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-batch/src/main/java/com/amazonaws/services/batch/model/JobDetail.java#L865-L868 |
google/error-prone | core/src/main/java/com/google/errorprone/bugpatterns/AbstractToString.java | AbstractToString.isToString | ToStringKind isToString(Tree parent, ExpressionTree tree, VisitorState state) {
"""
Classifies expressions that are converted to strings by their enclosing expression.
"""
// is the enclosing expression string concat?
if (isStringConcat(parent, state)) {
return ToStringKind.IMPLICIT;
}
if (parent instanceof ExpressionTree) {
ExpressionTree parentExpression = (ExpressionTree) parent;
// the enclosing method is print() or println()
if (PRINT_STRING.matches(parentExpression, state)) {
return ToStringKind.IMPLICIT;
}
// the enclosing method is String.valueOf()
if (VALUE_OF.matches(parentExpression, state)) {
return ToStringKind.EXPLICIT;
}
}
return ToStringKind.NONE;
} | java | ToStringKind isToString(Tree parent, ExpressionTree tree, VisitorState state) {
// is the enclosing expression string concat?
if (isStringConcat(parent, state)) {
return ToStringKind.IMPLICIT;
}
if (parent instanceof ExpressionTree) {
ExpressionTree parentExpression = (ExpressionTree) parent;
// the enclosing method is print() or println()
if (PRINT_STRING.matches(parentExpression, state)) {
return ToStringKind.IMPLICIT;
}
// the enclosing method is String.valueOf()
if (VALUE_OF.matches(parentExpression, state)) {
return ToStringKind.EXPLICIT;
}
}
return ToStringKind.NONE;
} | [
"ToStringKind",
"isToString",
"(",
"Tree",
"parent",
",",
"ExpressionTree",
"tree",
",",
"VisitorState",
"state",
")",
"{",
"// is the enclosing expression string concat?",
"if",
"(",
"isStringConcat",
"(",
"parent",
",",
"state",
")",
")",
"{",
"return",
"ToStringKind",
".",
"IMPLICIT",
";",
"}",
"if",
"(",
"parent",
"instanceof",
"ExpressionTree",
")",
"{",
"ExpressionTree",
"parentExpression",
"=",
"(",
"ExpressionTree",
")",
"parent",
";",
"// the enclosing method is print() or println()",
"if",
"(",
"PRINT_STRING",
".",
"matches",
"(",
"parentExpression",
",",
"state",
")",
")",
"{",
"return",
"ToStringKind",
".",
"IMPLICIT",
";",
"}",
"// the enclosing method is String.valueOf()",
"if",
"(",
"VALUE_OF",
".",
"matches",
"(",
"parentExpression",
",",
"state",
")",
")",
"{",
"return",
"ToStringKind",
".",
"EXPLICIT",
";",
"}",
"}",
"return",
"ToStringKind",
".",
"NONE",
";",
"}"
] | Classifies expressions that are converted to strings by their enclosing expression. | [
"Classifies",
"expressions",
"that",
"are",
"converted",
"to",
"strings",
"by",
"their",
"enclosing",
"expression",
"."
] | train | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/AbstractToString.java#L162-L179 |
banq/jdonframework | JdonAccessory/jdon-remote/src/main/java/com/jdon/bussinessproxy/remote/hessian/HessianToJdonRequestProcessor.java | HessianToJdonRequestProcessor.writeException | protected void writeException(final AbstractHessianOutput out, Exception ex)
throws IOException {
"""
Writes Exception information to Hessian Output.
@param out
Hessian Output
@param ex
Exception
@throws java.io.IOException
If i/o error occur
"""
OutputStream os = new ByteArrayOutputStream();
ex.printStackTrace(new PrintStream(os));
out.writeFault(ex.getClass().toString(), os.toString(), null);
} | java | protected void writeException(final AbstractHessianOutput out, Exception ex)
throws IOException {
OutputStream os = new ByteArrayOutputStream();
ex.printStackTrace(new PrintStream(os));
out.writeFault(ex.getClass().toString(), os.toString(), null);
} | [
"protected",
"void",
"writeException",
"(",
"final",
"AbstractHessianOutput",
"out",
",",
"Exception",
"ex",
")",
"throws",
"IOException",
"{",
"OutputStream",
"os",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"ex",
".",
"printStackTrace",
"(",
"new",
"PrintStream",
"(",
"os",
")",
")",
";",
"out",
".",
"writeFault",
"(",
"ex",
".",
"getClass",
"(",
")",
".",
"toString",
"(",
")",
",",
"os",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"}"
] | Writes Exception information to Hessian Output.
@param out
Hessian Output
@param ex
Exception
@throws java.io.IOException
If i/o error occur | [
"Writes",
"Exception",
"information",
"to",
"Hessian",
"Output",
"."
] | train | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/JdonAccessory/jdon-remote/src/main/java/com/jdon/bussinessproxy/remote/hessian/HessianToJdonRequestProcessor.java#L205-L210 |
ist-dresden/composum | sling/core/commons/src/main/java/com/composum/sling/cpnl/CpnlElFunctions.java | CpnlElFunctions.mappedExternalUrl | public static String mappedExternalUrl(SlingHttpServletRequest request, String path) {
"""
Builds an external (full qualified) URL for a repository path using the LinkUtil.getMappedURL() method.
@param request the current request (domain host hint)
@param path the repository path
@return the URL built in the context of the requested domain host
"""
return LinkUtil.getAbsoluteUrl(request, LinkUtil.getMappedUrl(request, path));
} | java | public static String mappedExternalUrl(SlingHttpServletRequest request, String path) {
return LinkUtil.getAbsoluteUrl(request, LinkUtil.getMappedUrl(request, path));
} | [
"public",
"static",
"String",
"mappedExternalUrl",
"(",
"SlingHttpServletRequest",
"request",
",",
"String",
"path",
")",
"{",
"return",
"LinkUtil",
".",
"getAbsoluteUrl",
"(",
"request",
",",
"LinkUtil",
".",
"getMappedUrl",
"(",
"request",
",",
"path",
")",
")",
";",
"}"
] | Builds an external (full qualified) URL for a repository path using the LinkUtil.getMappedURL() method.
@param request the current request (domain host hint)
@param path the repository path
@return the URL built in the context of the requested domain host | [
"Builds",
"an",
"external",
"(",
"full",
"qualified",
")",
"URL",
"for",
"a",
"repository",
"path",
"using",
"the",
"LinkUtil",
".",
"getMappedURL",
"()",
"method",
"."
] | train | https://github.com/ist-dresden/composum/blob/ebc79f559f6022c935240c19102539bdfb1bd1e2/sling/core/commons/src/main/java/com/composum/sling/cpnl/CpnlElFunctions.java#L220-L222 |
VerbalExpressions/JavaVerbalExpressions | src/main/java/ru/lanwen/verbalregex/VerbalExpression.java | VerbalExpression.getText | public String getText(final String toTest, final int group) {
"""
Extract exact group from string
@param toTest - string to extract from
@param group - group to extract
@return extracted group
@since 1.1
"""
Matcher m = pattern.matcher(toTest);
StringBuilder result = new StringBuilder();
while (m.find()) {
result.append(m.group(group));
}
return result.toString();
} | java | public String getText(final String toTest, final int group) {
Matcher m = pattern.matcher(toTest);
StringBuilder result = new StringBuilder();
while (m.find()) {
result.append(m.group(group));
}
return result.toString();
} | [
"public",
"String",
"getText",
"(",
"final",
"String",
"toTest",
",",
"final",
"int",
"group",
")",
"{",
"Matcher",
"m",
"=",
"pattern",
".",
"matcher",
"(",
"toTest",
")",
";",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"while",
"(",
"m",
".",
"find",
"(",
")",
")",
"{",
"result",
".",
"append",
"(",
"m",
".",
"group",
"(",
"group",
")",
")",
";",
"}",
"return",
"result",
".",
"toString",
"(",
")",
";",
"}"
] | Extract exact group from string
@param toTest - string to extract from
@param group - group to extract
@return extracted group
@since 1.1 | [
"Extract",
"exact",
"group",
"from",
"string"
] | train | https://github.com/VerbalExpressions/JavaVerbalExpressions/blob/4ee34e6c96ea2cf8335e3b425afa44c535229347/src/main/java/ru/lanwen/verbalregex/VerbalExpression.java#L742-L749 |
b3dgs/lionengine | lionengine-core/src/main/java/com/b3dgs/lionengine/UtilReflection.java | UtilReflection.getMethod | public static <T> T getMethod(Object object, String name, Object... params) {
"""
Get method and call its return value with parameters.
@param <T> The object type.
@param object The object caller (must not be <code>null</code>).
@param name The method name (must not be <code>null</code>).
@param params The method parameters (must not be <code>null</code>).
@return The value returned.
@throws LionEngineException If invalid parameters.
"""
Check.notNull(object);
Check.notNull(name);
Check.notNull(params);
try
{
final Class<?> clazz = getClass(object);
final Method method = clazz.getDeclaredMethod(name, getParamTypes(params));
setAccessible(method, true);
@SuppressWarnings("unchecked")
final T value = (T) method.invoke(object, params);
return value;
}
catch (final NoSuchMethodException | InvocationTargetException | IllegalAccessException exception)
{
if (exception.getCause() instanceof LionEngineException)
{
throw (LionEngineException) exception.getCause();
}
throw new LionEngineException(exception, ERROR_METHOD + name);
}
} | java | public static <T> T getMethod(Object object, String name, Object... params)
{
Check.notNull(object);
Check.notNull(name);
Check.notNull(params);
try
{
final Class<?> clazz = getClass(object);
final Method method = clazz.getDeclaredMethod(name, getParamTypes(params));
setAccessible(method, true);
@SuppressWarnings("unchecked")
final T value = (T) method.invoke(object, params);
return value;
}
catch (final NoSuchMethodException | InvocationTargetException | IllegalAccessException exception)
{
if (exception.getCause() instanceof LionEngineException)
{
throw (LionEngineException) exception.getCause();
}
throw new LionEngineException(exception, ERROR_METHOD + name);
}
} | [
"public",
"static",
"<",
"T",
">",
"T",
"getMethod",
"(",
"Object",
"object",
",",
"String",
"name",
",",
"Object",
"...",
"params",
")",
"{",
"Check",
".",
"notNull",
"(",
"object",
")",
";",
"Check",
".",
"notNull",
"(",
"name",
")",
";",
"Check",
".",
"notNull",
"(",
"params",
")",
";",
"try",
"{",
"final",
"Class",
"<",
"?",
">",
"clazz",
"=",
"getClass",
"(",
"object",
")",
";",
"final",
"Method",
"method",
"=",
"clazz",
".",
"getDeclaredMethod",
"(",
"name",
",",
"getParamTypes",
"(",
"params",
")",
")",
";",
"setAccessible",
"(",
"method",
",",
"true",
")",
";",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"final",
"T",
"value",
"=",
"(",
"T",
")",
"method",
".",
"invoke",
"(",
"object",
",",
"params",
")",
";",
"return",
"value",
";",
"}",
"catch",
"(",
"final",
"NoSuchMethodException",
"|",
"InvocationTargetException",
"|",
"IllegalAccessException",
"exception",
")",
"{",
"if",
"(",
"exception",
".",
"getCause",
"(",
")",
"instanceof",
"LionEngineException",
")",
"{",
"throw",
"(",
"LionEngineException",
")",
"exception",
".",
"getCause",
"(",
")",
";",
"}",
"throw",
"new",
"LionEngineException",
"(",
"exception",
",",
"ERROR_METHOD",
"+",
"name",
")",
";",
"}",
"}"
] | Get method and call its return value with parameters.
@param <T> The object type.
@param object The object caller (must not be <code>null</code>).
@param name The method name (must not be <code>null</code>).
@param params The method parameters (must not be <code>null</code>).
@return The value returned.
@throws LionEngineException If invalid parameters. | [
"Get",
"method",
"and",
"call",
"its",
"return",
"value",
"with",
"parameters",
"."
] | train | https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-core/src/main/java/com/b3dgs/lionengine/UtilReflection.java#L220-L243 |
anotheria/moskito | moskito-extensions/moskito-notification-providers/src/main/java/net/anotheria/moskito/extensions/notificationtemplate/MailTemplateProcessor.java | MailTemplateProcessor.processingAllowed | private boolean processingAllowed(final String prefix, final String variable, final TemplateReplacementContext context) {
"""
Checks whether processing is allowed.
@param prefix variable prefix
@param context {@link TemplateReplacementContext}
@return {@code boolean} flag
"""
return (PREFIX.equals(prefix) && !StringUtils.isEmpty(variable) && context instanceof MailTemplateReplacementContext);
} | java | private boolean processingAllowed(final String prefix, final String variable, final TemplateReplacementContext context) {
return (PREFIX.equals(prefix) && !StringUtils.isEmpty(variable) && context instanceof MailTemplateReplacementContext);
} | [
"private",
"boolean",
"processingAllowed",
"(",
"final",
"String",
"prefix",
",",
"final",
"String",
"variable",
",",
"final",
"TemplateReplacementContext",
"context",
")",
"{",
"return",
"(",
"PREFIX",
".",
"equals",
"(",
"prefix",
")",
"&&",
"!",
"StringUtils",
".",
"isEmpty",
"(",
"variable",
")",
"&&",
"context",
"instanceof",
"MailTemplateReplacementContext",
")",
";",
"}"
] | Checks whether processing is allowed.
@param prefix variable prefix
@param context {@link TemplateReplacementContext}
@return {@code boolean} flag | [
"Checks",
"whether",
"processing",
"is",
"allowed",
"."
] | train | https://github.com/anotheria/moskito/blob/0fdb79053b98a6ece610fa159f59bc3331e4cf05/moskito-extensions/moskito-notification-providers/src/main/java/net/anotheria/moskito/extensions/notificationtemplate/MailTemplateProcessor.java#L44-L46 |
OpenLiberty/open-liberty | dev/com.ibm.ws.logging.core/src/com/ibm/ws/logging/internal/TraceNLSResolver.java | TraceNLSResolver.getResourceBundle | public ResourceBundle getResourceBundle(Class<?> aClass, String bundleName, Locale locale) {
"""
Like {@link #getResourceBundle(Class, String, List)}, but takes a single
Locale.
@see #getResourceBundle(Class, String, List)
"""
return getResourceBundle(aClass, bundleName, (locale == null) ? null : Collections.singletonList(locale));
} | java | public ResourceBundle getResourceBundle(Class<?> aClass, String bundleName, Locale locale) {
return getResourceBundle(aClass, bundleName, (locale == null) ? null : Collections.singletonList(locale));
} | [
"public",
"ResourceBundle",
"getResourceBundle",
"(",
"Class",
"<",
"?",
">",
"aClass",
",",
"String",
"bundleName",
",",
"Locale",
"locale",
")",
"{",
"return",
"getResourceBundle",
"(",
"aClass",
",",
"bundleName",
",",
"(",
"locale",
"==",
"null",
")",
"?",
"null",
":",
"Collections",
".",
"singletonList",
"(",
"locale",
")",
")",
";",
"}"
] | Like {@link #getResourceBundle(Class, String, List)}, but takes a single
Locale.
@see #getResourceBundle(Class, String, List) | [
"Like",
"{",
"@link",
"#getResourceBundle",
"(",
"Class",
"String",
"List",
")",
"}",
"but",
"takes",
"a",
"single",
"Locale",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.logging.core/src/com/ibm/ws/logging/internal/TraceNLSResolver.java#L303-L305 |
Azure/azure-sdk-for-java | compute/resource-manager/v2017_12_01/src/main/java/com/microsoft/azure/management/compute/v2017_12_01/implementation/VirtualMachineExtensionsInner.java | VirtualMachineExtensionsInner.createOrUpdate | public VirtualMachineExtensionInner createOrUpdate(String resourceGroupName, String vmName, String vmExtensionName, VirtualMachineExtensionInner extensionParameters) {
"""
The operation to create or update the extension.
@param resourceGroupName The name of the resource group.
@param vmName The name of the virtual machine where the extension should be created or updated.
@param vmExtensionName The name of the virtual machine extension.
@param extensionParameters Parameters supplied to the Create Virtual Machine Extension operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the VirtualMachineExtensionInner object if successful.
"""
return createOrUpdateWithServiceResponseAsync(resourceGroupName, vmName, vmExtensionName, extensionParameters).toBlocking().last().body();
} | java | public VirtualMachineExtensionInner createOrUpdate(String resourceGroupName, String vmName, String vmExtensionName, VirtualMachineExtensionInner extensionParameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, vmName, vmExtensionName, extensionParameters).toBlocking().last().body();
} | [
"public",
"VirtualMachineExtensionInner",
"createOrUpdate",
"(",
"String",
"resourceGroupName",
",",
"String",
"vmName",
",",
"String",
"vmExtensionName",
",",
"VirtualMachineExtensionInner",
"extensionParameters",
")",
"{",
"return",
"createOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"vmName",
",",
"vmExtensionName",
",",
"extensionParameters",
")",
".",
"toBlocking",
"(",
")",
".",
"last",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | The operation to create or update the extension.
@param resourceGroupName The name of the resource group.
@param vmName The name of the virtual machine where the extension should be created or updated.
@param vmExtensionName The name of the virtual machine extension.
@param extensionParameters Parameters supplied to the Create Virtual Machine Extension operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the VirtualMachineExtensionInner object if successful. | [
"The",
"operation",
"to",
"create",
"or",
"update",
"the",
"extension",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/compute/resource-manager/v2017_12_01/src/main/java/com/microsoft/azure/management/compute/v2017_12_01/implementation/VirtualMachineExtensionsInner.java#L102-L104 |
inkstand-io/scribble | scribble-jcr/src/main/java/io/inkstand/scribble/jcr/JCRAssert.java | JCRAssert.assertPrimaryNodeType | public static void assertPrimaryNodeType(final Node node, final String nodeType) throws RepositoryException {
"""
Asserts the primary node type of the node
@param node
the node whose primary node type should be checked
@param nodeType
the nodetype that is asserted to be the node type of the node
@throws RepositoryException
"""
final NodeType primaryNodeType = node.getPrimaryNodeType();
assertEquals(nodeType, primaryNodeType.getName());
} | java | public static void assertPrimaryNodeType(final Node node, final String nodeType) throws RepositoryException {
final NodeType primaryNodeType = node.getPrimaryNodeType();
assertEquals(nodeType, primaryNodeType.getName());
} | [
"public",
"static",
"void",
"assertPrimaryNodeType",
"(",
"final",
"Node",
"node",
",",
"final",
"String",
"nodeType",
")",
"throws",
"RepositoryException",
"{",
"final",
"NodeType",
"primaryNodeType",
"=",
"node",
".",
"getPrimaryNodeType",
"(",
")",
";",
"assertEquals",
"(",
"nodeType",
",",
"primaryNodeType",
".",
"getName",
"(",
")",
")",
";",
"}"
] | Asserts the primary node type of the node
@param node
the node whose primary node type should be checked
@param nodeType
the nodetype that is asserted to be the node type of the node
@throws RepositoryException | [
"Asserts",
"the",
"primary",
"node",
"type",
"of",
"the",
"node"
] | train | https://github.com/inkstand-io/scribble/blob/66e67553bad4b1ff817e1715fd1d3dd833406744/scribble-jcr/src/main/java/io/inkstand/scribble/jcr/JCRAssert.java#L173-L176 |
orbisgis/h2gis | h2gis-functions/src/main/java/org/h2gis/functions/factory/H2GISDBFactory.java | H2GISDBFactory.createDataSource | public static DataSource createDataSource(String dbName ,boolean initSpatial) throws SQLException {
"""
Create a database and return a DataSource
@param dbName DataBase name, or path URI
@param initSpatial True to enable basic spatial capabilities
@return DataSource
@throws SQLException
"""
return createDataSource(dbName, initSpatial, H2_PARAMETERS);
} | java | public static DataSource createDataSource(String dbName ,boolean initSpatial) throws SQLException {
return createDataSource(dbName, initSpatial, H2_PARAMETERS);
} | [
"public",
"static",
"DataSource",
"createDataSource",
"(",
"String",
"dbName",
",",
"boolean",
"initSpatial",
")",
"throws",
"SQLException",
"{",
"return",
"createDataSource",
"(",
"dbName",
",",
"initSpatial",
",",
"H2_PARAMETERS",
")",
";",
"}"
] | Create a database and return a DataSource
@param dbName DataBase name, or path URI
@param initSpatial True to enable basic spatial capabilities
@return DataSource
@throws SQLException | [
"Create",
"a",
"database",
"and",
"return",
"a",
"DataSource"
] | train | https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/factory/H2GISDBFactory.java#L93-L95 |
dnsjava/dnsjava | org/xbill/DNS/DNSInput.java | DNSInput.readByteArray | public void
readByteArray(byte [] b, int off, int len) throws WireParseException {
"""
Reads a byte array of a specified length from the stream into an existing
array.
@param b The array to read into.
@param off The offset of the array to start copying data into.
@param len The number of bytes to copy.
@throws WireParseException The end of the stream was reached.
"""
require(len);
byteBuffer.get(b, off, len);
} | java | public void
readByteArray(byte [] b, int off, int len) throws WireParseException {
require(len);
byteBuffer.get(b, off, len);
} | [
"public",
"void",
"readByteArray",
"(",
"byte",
"[",
"]",
"b",
",",
"int",
"off",
",",
"int",
"len",
")",
"throws",
"WireParseException",
"{",
"require",
"(",
"len",
")",
";",
"byteBuffer",
".",
"get",
"(",
"b",
",",
"off",
",",
"len",
")",
";",
"}"
] | Reads a byte array of a specified length from the stream into an existing
array.
@param b The array to read into.
@param off The offset of the array to start copying data into.
@param len The number of bytes to copy.
@throws WireParseException The end of the stream was reached. | [
"Reads",
"a",
"byte",
"array",
"of",
"a",
"specified",
"length",
"from",
"the",
"stream",
"into",
"an",
"existing",
"array",
"."
] | train | https://github.com/dnsjava/dnsjava/blob/d97b6a0685d59143372bb392ab591dd8dd840b61/org/xbill/DNS/DNSInput.java#L194-L198 |
census-instrumentation/opencensus-java | api/src/main/java/io/opencensus/trace/BigendianEncoding.java | BigendianEncoding.longToByteArray | static void longToByteArray(long value, byte[] dest, int destOffset) {
"""
Stores the big-endian representation of {@code value} in the {@code dest} starting from the
{@code destOffset}.
@param value the value to be converted.
@param dest the destination byte array.
@param destOffset the starting offset in the destination byte array.
"""
Utils.checkArgument(dest.length >= destOffset + LONG_BYTES, "array too small");
dest[destOffset + 7] = (byte) (value & 0xFFL);
dest[destOffset + 6] = (byte) (value >> 8 & 0xFFL);
dest[destOffset + 5] = (byte) (value >> 16 & 0xFFL);
dest[destOffset + 4] = (byte) (value >> 24 & 0xFFL);
dest[destOffset + 3] = (byte) (value >> 32 & 0xFFL);
dest[destOffset + 2] = (byte) (value >> 40 & 0xFFL);
dest[destOffset + 1] = (byte) (value >> 48 & 0xFFL);
dest[destOffset] = (byte) (value >> 56 & 0xFFL);
} | java | static void longToByteArray(long value, byte[] dest, int destOffset) {
Utils.checkArgument(dest.length >= destOffset + LONG_BYTES, "array too small");
dest[destOffset + 7] = (byte) (value & 0xFFL);
dest[destOffset + 6] = (byte) (value >> 8 & 0xFFL);
dest[destOffset + 5] = (byte) (value >> 16 & 0xFFL);
dest[destOffset + 4] = (byte) (value >> 24 & 0xFFL);
dest[destOffset + 3] = (byte) (value >> 32 & 0xFFL);
dest[destOffset + 2] = (byte) (value >> 40 & 0xFFL);
dest[destOffset + 1] = (byte) (value >> 48 & 0xFFL);
dest[destOffset] = (byte) (value >> 56 & 0xFFL);
} | [
"static",
"void",
"longToByteArray",
"(",
"long",
"value",
",",
"byte",
"[",
"]",
"dest",
",",
"int",
"destOffset",
")",
"{",
"Utils",
".",
"checkArgument",
"(",
"dest",
".",
"length",
">=",
"destOffset",
"+",
"LONG_BYTES",
",",
"\"array too small\"",
")",
";",
"dest",
"[",
"destOffset",
"+",
"7",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
"&",
"0xFF",
"L",
")",
";",
"dest",
"[",
"destOffset",
"+",
"6",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
">>",
"8",
"&",
"0xFF",
"L",
")",
";",
"dest",
"[",
"destOffset",
"+",
"5",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
">>",
"16",
"&",
"0xFF",
"L",
")",
";",
"dest",
"[",
"destOffset",
"+",
"4",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
">>",
"24",
"&",
"0xFF",
"L",
")",
";",
"dest",
"[",
"destOffset",
"+",
"3",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
">>",
"32",
"&",
"0xFF",
"L",
")",
";",
"dest",
"[",
"destOffset",
"+",
"2",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
">>",
"40",
"&",
"0xFF",
"L",
")",
";",
"dest",
"[",
"destOffset",
"+",
"1",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
">>",
"48",
"&",
"0xFF",
"L",
")",
";",
"dest",
"[",
"destOffset",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
">>",
"56",
"&",
"0xFF",
"L",
")",
";",
"}"
] | Stores the big-endian representation of {@code value} in the {@code dest} starting from the
{@code destOffset}.
@param value the value to be converted.
@param dest the destination byte array.
@param destOffset the starting offset in the destination byte array. | [
"Stores",
"the",
"big",
"-",
"endian",
"representation",
"of",
"{",
"@code",
"value",
"}",
"in",
"the",
"{",
"@code",
"dest",
"}",
"starting",
"from",
"the",
"{",
"@code",
"destOffset",
"}",
"."
] | train | https://github.com/census-instrumentation/opencensus-java/blob/deefac9bed77e40a2297bff1ca5ec5aa48a5f755/api/src/main/java/io/opencensus/trace/BigendianEncoding.java#L79-L89 |
dkpro/dkpro-jwpl | de.tudarmstadt.ukp.wikipedia.api/src/main/java/de/tudarmstadt/ukp/wikipedia/api/WikipediaInfo.java | WikipediaInfo.getNumberOfCategorizedArticles | public int getNumberOfCategorizedArticles(Wikipedia pWiki, CategoryGraph catGraph) throws WikiApiException {
"""
If the return value has been already computed, it is returned, else it is computed at retrieval time.
@param pWiki The wikipedia object.
@param catGraph The category graph.
@return The number of categorized articles, i.e. articles that have at least one category.
"""
if (categorizedArticleSet == null) { // has not been initialized yet
iterateCategoriesGetArticles(pWiki, catGraph);
}
return categorizedArticleSet.size();
} | java | public int getNumberOfCategorizedArticles(Wikipedia pWiki, CategoryGraph catGraph) throws WikiApiException{
if (categorizedArticleSet == null) { // has not been initialized yet
iterateCategoriesGetArticles(pWiki, catGraph);
}
return categorizedArticleSet.size();
} | [
"public",
"int",
"getNumberOfCategorizedArticles",
"(",
"Wikipedia",
"pWiki",
",",
"CategoryGraph",
"catGraph",
")",
"throws",
"WikiApiException",
"{",
"if",
"(",
"categorizedArticleSet",
"==",
"null",
")",
"{",
"// has not been initialized yet",
"iterateCategoriesGetArticles",
"(",
"pWiki",
",",
"catGraph",
")",
";",
"}",
"return",
"categorizedArticleSet",
".",
"size",
"(",
")",
";",
"}"
] | If the return value has been already computed, it is returned, else it is computed at retrieval time.
@param pWiki The wikipedia object.
@param catGraph The category graph.
@return The number of categorized articles, i.e. articles that have at least one category. | [
"If",
"the",
"return",
"value",
"has",
"been",
"already",
"computed",
"it",
"is",
"returned",
"else",
"it",
"is",
"computed",
"at",
"retrieval",
"time",
"."
] | train | https://github.com/dkpro/dkpro-jwpl/blob/0a0304b6a0aa13acc18838957994e06dd4613a58/de.tudarmstadt.ukp.wikipedia.api/src/main/java/de/tudarmstadt/ukp/wikipedia/api/WikipediaInfo.java#L287-L292 |
joniles/mpxj | src/main/java/net/sf/mpxj/primavera/PrimaveraReader.java | PrimaveraReader.applyAliases | private void applyAliases(Map<FieldType, String> aliases) {
"""
Apply aliases to task and resource fields.
@param aliases map of aliases
"""
CustomFieldContainer fields = m_project.getCustomFields();
for (Map.Entry<FieldType, String> entry : aliases.entrySet())
{
fields.getCustomField(entry.getKey()).setAlias(entry.getValue());
}
} | java | private void applyAliases(Map<FieldType, String> aliases)
{
CustomFieldContainer fields = m_project.getCustomFields();
for (Map.Entry<FieldType, String> entry : aliases.entrySet())
{
fields.getCustomField(entry.getKey()).setAlias(entry.getValue());
}
} | [
"private",
"void",
"applyAliases",
"(",
"Map",
"<",
"FieldType",
",",
"String",
">",
"aliases",
")",
"{",
"CustomFieldContainer",
"fields",
"=",
"m_project",
".",
"getCustomFields",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"FieldType",
",",
"String",
">",
"entry",
":",
"aliases",
".",
"entrySet",
"(",
")",
")",
"{",
"fields",
".",
"getCustomField",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
".",
"setAlias",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}"
] | Apply aliases to task and resource fields.
@param aliases map of aliases | [
"Apply",
"aliases",
"to",
"task",
"and",
"resource",
"fields",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/primavera/PrimaveraReader.java#L1481-L1488 |
vlingo/vlingo-actors | src/main/java/io/vlingo/actors/Stage.java | Stage.actorFor | public <T> T actorFor(final Class<T> protocol, final Definition definition, final Logger logger) {
"""
Answers the {@code T} protocol of the newly created {@code Actor} that implements the {@code protocol} and
that will be assigned the specific {@code logger}.
@param <T> the protocol type
@param protocol the {@code Class<T>} protocol
@param definition the {@code Definition} used to initialize the newly created {@code Actor}
@param logger the {@code Logger} to assign to the newly created {@code Actor}
@return T
"""
return actorFor(
protocol,
definition,
definition.parentOr(world.defaultParent()),
definition.supervisor(),
logger);
} | java | public <T> T actorFor(final Class<T> protocol, final Definition definition, final Logger logger) {
return actorFor(
protocol,
definition,
definition.parentOr(world.defaultParent()),
definition.supervisor(),
logger);
} | [
"public",
"<",
"T",
">",
"T",
"actorFor",
"(",
"final",
"Class",
"<",
"T",
">",
"protocol",
",",
"final",
"Definition",
"definition",
",",
"final",
"Logger",
"logger",
")",
"{",
"return",
"actorFor",
"(",
"protocol",
",",
"definition",
",",
"definition",
".",
"parentOr",
"(",
"world",
".",
"defaultParent",
"(",
")",
")",
",",
"definition",
".",
"supervisor",
"(",
")",
",",
"logger",
")",
";",
"}"
] | Answers the {@code T} protocol of the newly created {@code Actor} that implements the {@code protocol} and
that will be assigned the specific {@code logger}.
@param <T> the protocol type
@param protocol the {@code Class<T>} protocol
@param definition the {@code Definition} used to initialize the newly created {@code Actor}
@param logger the {@code Logger} to assign to the newly created {@code Actor}
@return T | [
"Answers",
"the",
"{"
] | train | https://github.com/vlingo/vlingo-actors/blob/c7d046fd139c0490cf0fd2588d7dc2f792f13493/src/main/java/io/vlingo/actors/Stage.java#L103-L110 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/PatternsImpl.java | PatternsImpl.updatePatterns | public List<PatternRuleInfo> updatePatterns(UUID appId, String versionId, List<PatternRuleUpdateObject> patterns) {
"""
Updates patterns.
@param appId The application ID.
@param versionId The version ID.
@param patterns An array represents the patterns.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the List<PatternRuleInfo> object if successful.
"""
return updatePatternsWithServiceResponseAsync(appId, versionId, patterns).toBlocking().single().body();
} | java | public List<PatternRuleInfo> updatePatterns(UUID appId, String versionId, List<PatternRuleUpdateObject> patterns) {
return updatePatternsWithServiceResponseAsync(appId, versionId, patterns).toBlocking().single().body();
} | [
"public",
"List",
"<",
"PatternRuleInfo",
">",
"updatePatterns",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"List",
"<",
"PatternRuleUpdateObject",
">",
"patterns",
")",
"{",
"return",
"updatePatternsWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
"patterns",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Updates patterns.
@param appId The application ID.
@param versionId The version ID.
@param patterns An array represents the patterns.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the List<PatternRuleInfo> object if successful. | [
"Updates",
"patterns",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/PatternsImpl.java#L384-L386 |
payneteasy/superfly | superfly-web/src/main/java/com/payneteasy/superfly/web/wicket/component/label/DateLabels.java | DateLabels.forDateTime | public static DateLabel forDateTime(String id, Date date) {
"""
Creates a label which displays date and time.
@param id component id
@param date date to display
@return date label
"""
return DateLabel.forDatePattern(id, new Model<Date>(date),
DATE_TIME_PATTERN);
} | java | public static DateLabel forDateTime(String id, Date date) {
return DateLabel.forDatePattern(id, new Model<Date>(date),
DATE_TIME_PATTERN);
} | [
"public",
"static",
"DateLabel",
"forDateTime",
"(",
"String",
"id",
",",
"Date",
"date",
")",
"{",
"return",
"DateLabel",
".",
"forDatePattern",
"(",
"id",
",",
"new",
"Model",
"<",
"Date",
">",
"(",
"date",
")",
",",
"DATE_TIME_PATTERN",
")",
";",
"}"
] | Creates a label which displays date and time.
@param id component id
@param date date to display
@return date label | [
"Creates",
"a",
"label",
"which",
"displays",
"date",
"and",
"time",
"."
] | train | https://github.com/payneteasy/superfly/blob/4cad6d0f8e951a61f3c302c49b13a51d179076f8/superfly-web/src/main/java/com/payneteasy/superfly/web/wicket/component/label/DateLabels.java#L48-L51 |
Azure/azure-sdk-for-java | hdinsight/resource-manager/v2018_06_01_preview/src/main/java/com/microsoft/azure/management/hdinsight/v2018_06_01_preview/implementation/ExtensionsInner.java | ExtensionsInner.beginCreate | public void beginCreate(String resourceGroupName, String clusterName, String extensionName, ExtensionInner parameters) {
"""
Creates an HDInsight cluster extension.
@param resourceGroupName The name of the resource group.
@param clusterName The name of the cluster.
@param extensionName The name of the cluster extension.
@param parameters The cluster extensions create request.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
"""
beginCreateWithServiceResponseAsync(resourceGroupName, clusterName, extensionName, parameters).toBlocking().single().body();
} | java | public void beginCreate(String resourceGroupName, String clusterName, String extensionName, ExtensionInner parameters) {
beginCreateWithServiceResponseAsync(resourceGroupName, clusterName, extensionName, parameters).toBlocking().single().body();
} | [
"public",
"void",
"beginCreate",
"(",
"String",
"resourceGroupName",
",",
"String",
"clusterName",
",",
"String",
"extensionName",
",",
"ExtensionInner",
"parameters",
")",
"{",
"beginCreateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"clusterName",
",",
"extensionName",
",",
"parameters",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Creates an HDInsight cluster extension.
@param resourceGroupName The name of the resource group.
@param clusterName The name of the cluster.
@param extensionName The name of the cluster extension.
@param parameters The cluster extensions create request.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent | [
"Creates",
"an",
"HDInsight",
"cluster",
"extension",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/hdinsight/resource-manager/v2018_06_01_preview/src/main/java/com/microsoft/azure/management/hdinsight/v2018_06_01_preview/implementation/ExtensionsInner.java#L605-L607 |
looly/hutool | hutool-crypto/src/main/java/cn/hutool/crypto/asymmetric/Sign.java | Sign.init | @Override
public Sign init(String algorithm, PrivateKey privateKey, PublicKey publicKey) {
"""
初始化
@param algorithm 算法
@param privateKey 私钥
@param publicKey 公钥
@return this
"""
try {
signature = Signature.getInstance(algorithm);
} catch (NoSuchAlgorithmException e) {
throw new CryptoException(e);
}
super.init(algorithm, privateKey, publicKey);
return this;
} | java | @Override
public Sign init(String algorithm, PrivateKey privateKey, PublicKey publicKey) {
try {
signature = Signature.getInstance(algorithm);
} catch (NoSuchAlgorithmException e) {
throw new CryptoException(e);
}
super.init(algorithm, privateKey, publicKey);
return this;
} | [
"@",
"Override",
"public",
"Sign",
"init",
"(",
"String",
"algorithm",
",",
"PrivateKey",
"privateKey",
",",
"PublicKey",
"publicKey",
")",
"{",
"try",
"{",
"signature",
"=",
"Signature",
".",
"getInstance",
"(",
"algorithm",
")",
";",
"}",
"catch",
"(",
"NoSuchAlgorithmException",
"e",
")",
"{",
"throw",
"new",
"CryptoException",
"(",
"e",
")",
";",
"}",
"super",
".",
"init",
"(",
"algorithm",
",",
"privateKey",
",",
"publicKey",
")",
";",
"return",
"this",
";",
"}"
] | 初始化
@param algorithm 算法
@param privateKey 私钥
@param publicKey 公钥
@return this | [
"初始化"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-crypto/src/main/java/cn/hutool/crypto/asymmetric/Sign.java#L157-L166 |
groovy/groovy-core | subprojects/groovy-json/src/main/java/groovy/json/StreamingJsonBuilder.java | StreamingJsonBuilder.call | public Object call(Collection coll, Closure c) throws IOException {
"""
A collection and closure passed to a JSON builder will create a root JSON array applying
the closure to each object in the collection
<p>
Example:
<pre class="groovyTestCase">
class Author {
String name
}
def authors = [new Author (name: "Guillaume"), new Author (name: "Jochen"), new Author (name: "Paul")]
new StringWriter().with { w ->
def json = new groovy.json.StreamingJsonBuilder(w)
json authors, { Author author ->
name author.name
}
assert w.toString() == '[{"name":"Guillaume"},{"name":"Jochen"},{"name":"Paul"}]'
}
</pre>
@param coll a collection
@param c a closure used to convert the objects of coll
"""
StreamingJsonDelegate.writeCollectionWithClosure(writer, coll, c);
return null;
} | java | public Object call(Collection coll, Closure c) throws IOException {
StreamingJsonDelegate.writeCollectionWithClosure(writer, coll, c);
return null;
} | [
"public",
"Object",
"call",
"(",
"Collection",
"coll",
",",
"Closure",
"c",
")",
"throws",
"IOException",
"{",
"StreamingJsonDelegate",
".",
"writeCollectionWithClosure",
"(",
"writer",
",",
"coll",
",",
"c",
")",
";",
"return",
"null",
";",
"}"
] | A collection and closure passed to a JSON builder will create a root JSON array applying
the closure to each object in the collection
<p>
Example:
<pre class="groovyTestCase">
class Author {
String name
}
def authors = [new Author (name: "Guillaume"), new Author (name: "Jochen"), new Author (name: "Paul")]
new StringWriter().with { w ->
def json = new groovy.json.StreamingJsonBuilder(w)
json authors, { Author author ->
name author.name
}
assert w.toString() == '[{"name":"Guillaume"},{"name":"Jochen"},{"name":"Paul"}]'
}
</pre>
@param coll a collection
@param c a closure used to convert the objects of coll | [
"A",
"collection",
"and",
"closure",
"passed",
"to",
"a",
"JSON",
"builder",
"will",
"create",
"a",
"root",
"JSON",
"array",
"applying",
"the",
"closure",
"to",
"each",
"object",
"in",
"the",
"collection",
"<p",
">",
"Example",
":",
"<pre",
"class",
"=",
"groovyTestCase",
">",
"class",
"Author",
"{",
"String",
"name",
"}",
"def",
"authors",
"=",
"[",
"new",
"Author",
"(",
"name",
":",
"Guillaume",
")",
"new",
"Author",
"(",
"name",
":",
"Jochen",
")",
"new",
"Author",
"(",
"name",
":",
"Paul",
")",
"]"
] | train | https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/subprojects/groovy-json/src/main/java/groovy/json/StreamingJsonBuilder.java#L184-L188 |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/row/CommonOps_DDRM.java | CommonOps_DDRM.multTransB | public static void multTransB(DMatrix1Row a , DMatrix1Row b , DMatrix1Row c ) {
"""
<p>
Performs the following operation:<br>
<br>
c = a * b<sup>T</sup> <br>
c<sub>ij</sub> = ∑<sub>k=1:n</sub> { a<sub>ik</sub> * b<sub>jk</sub>}
</p>
@param a The left matrix in the multiplication operation. Not modified.
@param b The right matrix in the multiplication operation. Not modified.
@param c Where the results of the operation are stored. Modified.
"""
if( b.numRows == 1 ) {
MatrixVectorMult_DDRM.mult(a, b, c);
} else {
MatrixMatrixMult_DDRM.multTransB(a, b, c);
}
} | java | public static void multTransB(DMatrix1Row a , DMatrix1Row b , DMatrix1Row c )
{
if( b.numRows == 1 ) {
MatrixVectorMult_DDRM.mult(a, b, c);
} else {
MatrixMatrixMult_DDRM.multTransB(a, b, c);
}
} | [
"public",
"static",
"void",
"multTransB",
"(",
"DMatrix1Row",
"a",
",",
"DMatrix1Row",
"b",
",",
"DMatrix1Row",
"c",
")",
"{",
"if",
"(",
"b",
".",
"numRows",
"==",
"1",
")",
"{",
"MatrixVectorMult_DDRM",
".",
"mult",
"(",
"a",
",",
"b",
",",
"c",
")",
";",
"}",
"else",
"{",
"MatrixMatrixMult_DDRM",
".",
"multTransB",
"(",
"a",
",",
"b",
",",
"c",
")",
";",
"}",
"}"
] | <p>
Performs the following operation:<br>
<br>
c = a * b<sup>T</sup> <br>
c<sub>ij</sub> = ∑<sub>k=1:n</sub> { a<sub>ik</sub> * b<sub>jk</sub>}
</p>
@param a The left matrix in the multiplication operation. Not modified.
@param b The right matrix in the multiplication operation. Not modified.
@param c Where the results of the operation are stored. Modified. | [
"<p",
">",
"Performs",
"the",
"following",
"operation",
":",
"<br",
">",
"<br",
">",
"c",
"=",
"a",
"*",
"b<sup",
">",
"T<",
"/",
"sup",
">",
"<br",
">",
"c<sub",
">",
"ij<",
"/",
"sub",
">",
"=",
"&sum",
";",
"<sub",
">",
"k",
"=",
"1",
":",
"n<",
"/",
"sub",
">",
"{",
"a<sub",
">",
"ik<",
"/",
"sub",
">",
"*",
"b<sub",
">",
"jk<",
"/",
"sub",
">",
"}",
"<",
"/",
"p",
">"
] | train | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/row/CommonOps_DDRM.java#L175-L182 |
ManfredTremmel/gwt-commons-lang3 | src/main/java/org/apache/commons/lang3/StringUtils.java | StringUtils.indexOfDifference | public static int indexOfDifference(final CharSequence cs1, final CharSequence cs2) {
"""
<p>Compares two CharSequences, and returns the index at which the
CharSequences begin to differ.</p>
<p>For example,
{@code indexOfDifference("i am a machine", "i am a robot") -> 7}</p>
<pre>
StringUtils.indexOfDifference(null, null) = -1
StringUtils.indexOfDifference("", "") = -1
StringUtils.indexOfDifference("", "abc") = 0
StringUtils.indexOfDifference("abc", "") = 0
StringUtils.indexOfDifference("abc", "abc") = -1
StringUtils.indexOfDifference("ab", "abxyz") = 2
StringUtils.indexOfDifference("abcde", "abxyz") = 2
StringUtils.indexOfDifference("abcde", "xyz") = 0
</pre>
@param cs1 the first CharSequence, may be null
@param cs2 the second CharSequence, may be null
@return the index where cs1 and cs2 begin to differ; -1 if they are equal
@since 2.0
@since 3.0 Changed signature from indexOfDifference(String, String) to
indexOfDifference(CharSequence, CharSequence)
"""
if (cs1 == cs2) {
return INDEX_NOT_FOUND;
}
if (cs1 == null || cs2 == null) {
return 0;
}
int i;
for (i = 0; i < cs1.length() && i < cs2.length(); ++i) {
if (cs1.charAt(i) != cs2.charAt(i)) {
break;
}
}
if (i < cs2.length() || i < cs1.length()) {
return i;
}
return INDEX_NOT_FOUND;
} | java | public static int indexOfDifference(final CharSequence cs1, final CharSequence cs2) {
if (cs1 == cs2) {
return INDEX_NOT_FOUND;
}
if (cs1 == null || cs2 == null) {
return 0;
}
int i;
for (i = 0; i < cs1.length() && i < cs2.length(); ++i) {
if (cs1.charAt(i) != cs2.charAt(i)) {
break;
}
}
if (i < cs2.length() || i < cs1.length()) {
return i;
}
return INDEX_NOT_FOUND;
} | [
"public",
"static",
"int",
"indexOfDifference",
"(",
"final",
"CharSequence",
"cs1",
",",
"final",
"CharSequence",
"cs2",
")",
"{",
"if",
"(",
"cs1",
"==",
"cs2",
")",
"{",
"return",
"INDEX_NOT_FOUND",
";",
"}",
"if",
"(",
"cs1",
"==",
"null",
"||",
"cs2",
"==",
"null",
")",
"{",
"return",
"0",
";",
"}",
"int",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"cs1",
".",
"length",
"(",
")",
"&&",
"i",
"<",
"cs2",
".",
"length",
"(",
")",
";",
"++",
"i",
")",
"{",
"if",
"(",
"cs1",
".",
"charAt",
"(",
"i",
")",
"!=",
"cs2",
".",
"charAt",
"(",
"i",
")",
")",
"{",
"break",
";",
"}",
"}",
"if",
"(",
"i",
"<",
"cs2",
".",
"length",
"(",
")",
"||",
"i",
"<",
"cs1",
".",
"length",
"(",
")",
")",
"{",
"return",
"i",
";",
"}",
"return",
"INDEX_NOT_FOUND",
";",
"}"
] | <p>Compares two CharSequences, and returns the index at which the
CharSequences begin to differ.</p>
<p>For example,
{@code indexOfDifference("i am a machine", "i am a robot") -> 7}</p>
<pre>
StringUtils.indexOfDifference(null, null) = -1
StringUtils.indexOfDifference("", "") = -1
StringUtils.indexOfDifference("", "abc") = 0
StringUtils.indexOfDifference("abc", "") = 0
StringUtils.indexOfDifference("abc", "abc") = -1
StringUtils.indexOfDifference("ab", "abxyz") = 2
StringUtils.indexOfDifference("abcde", "abxyz") = 2
StringUtils.indexOfDifference("abcde", "xyz") = 0
</pre>
@param cs1 the first CharSequence, may be null
@param cs2 the second CharSequence, may be null
@return the index where cs1 and cs2 begin to differ; -1 if they are equal
@since 2.0
@since 3.0 Changed signature from indexOfDifference(String, String) to
indexOfDifference(CharSequence, CharSequence) | [
"<p",
">",
"Compares",
"two",
"CharSequences",
"and",
"returns",
"the",
"index",
"at",
"which",
"the",
"CharSequences",
"begin",
"to",
"differ",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/StringUtils.java#L7846-L7863 |
OpenLiberty/open-liberty | dev/com.ibm.ws.security.common/src/com/ibm/ws/security/common/web/JavaScriptUtils.java | JavaScriptUtils.getJavaScriptHtmlCookieString | public String getJavaScriptHtmlCookieString(String name, String value) {
"""
Creates and returns a JavaScript line that sets a cookie with the specified name and value. For example, a cookie name
of "test" and value of "123" would return {@code document.cookie="test=123;";}. Note: The name and value will be
HTML-encoded.
"""
return getJavaScriptHtmlCookieString(name, value, null);
} | java | public String getJavaScriptHtmlCookieString(String name, String value) {
return getJavaScriptHtmlCookieString(name, value, null);
} | [
"public",
"String",
"getJavaScriptHtmlCookieString",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"return",
"getJavaScriptHtmlCookieString",
"(",
"name",
",",
"value",
",",
"null",
")",
";",
"}"
] | Creates and returns a JavaScript line that sets a cookie with the specified name and value. For example, a cookie name
of "test" and value of "123" would return {@code document.cookie="test=123;";}. Note: The name and value will be
HTML-encoded. | [
"Creates",
"and",
"returns",
"a",
"JavaScript",
"line",
"that",
"sets",
"a",
"cookie",
"with",
"the",
"specified",
"name",
"and",
"value",
".",
"For",
"example",
"a",
"cookie",
"name",
"of",
"test",
"and",
"value",
"of",
"123",
"would",
"return",
"{"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.common/src/com/ibm/ws/security/common/web/JavaScriptUtils.java#L39-L41 |
OpenLiberty/open-liberty | dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/internal/HttpChannelConfig.java | HttpChannelConfig.parseAllowRetries | private void parseAllowRetries(Map<Object, Object> props) {
"""
Parse the input configuration for the flag on whether to allow retries
or not.
@param props
"""
Object value = props.get(HttpConfigConstants.PROPNAME_ALLOW_RETRIES);
if (null != value) {
this.bAllowRetries = convertBoolean(value);
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Config: allow retries is " + allowsRetries());
}
}
} | java | private void parseAllowRetries(Map<Object, Object> props) {
Object value = props.get(HttpConfigConstants.PROPNAME_ALLOW_RETRIES);
if (null != value) {
this.bAllowRetries = convertBoolean(value);
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Config: allow retries is " + allowsRetries());
}
}
} | [
"private",
"void",
"parseAllowRetries",
"(",
"Map",
"<",
"Object",
",",
"Object",
">",
"props",
")",
"{",
"Object",
"value",
"=",
"props",
".",
"get",
"(",
"HttpConfigConstants",
".",
"PROPNAME_ALLOW_RETRIES",
")",
";",
"if",
"(",
"null",
"!=",
"value",
")",
"{",
"this",
".",
"bAllowRetries",
"=",
"convertBoolean",
"(",
"value",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEventEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"event",
"(",
"tc",
",",
"\"Config: allow retries is \"",
"+",
"allowsRetries",
"(",
")",
")",
";",
"}",
"}",
"}"
] | Parse the input configuration for the flag on whether to allow retries
or not.
@param props | [
"Parse",
"the",
"input",
"configuration",
"for",
"the",
"flag",
"on",
"whether",
"to",
"allow",
"retries",
"or",
"not",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/internal/HttpChannelConfig.java#L998-L1006 |
auth0/java-jwt | lib/src/main/java/com/auth0/jwt/algorithms/CryptoHelper.java | CryptoHelper.verifySignatureFor | boolean verifySignatureFor(String algorithm, byte[] secretBytes, byte[] headerBytes, byte[] payloadBytes, byte[] signatureBytes) throws NoSuchAlgorithmException, InvalidKeyException {
"""
Verify signature for JWT header and payload.
@param algorithm algorithm name.
@param secretBytes algorithm secret.
@param headerBytes JWT header.
@param payloadBytes JWT payload.
@param signatureBytes JWT signature.
@return true if signature is valid.
@throws NoSuchAlgorithmException if the algorithm is not supported.
@throws InvalidKeyException if the given key is inappropriate for initializing the specified algorithm.
"""
return MessageDigest.isEqual(createSignatureFor(algorithm, secretBytes, headerBytes, payloadBytes), signatureBytes);
} | java | boolean verifySignatureFor(String algorithm, byte[] secretBytes, byte[] headerBytes, byte[] payloadBytes, byte[] signatureBytes) throws NoSuchAlgorithmException, InvalidKeyException {
return MessageDigest.isEqual(createSignatureFor(algorithm, secretBytes, headerBytes, payloadBytes), signatureBytes);
} | [
"boolean",
"verifySignatureFor",
"(",
"String",
"algorithm",
",",
"byte",
"[",
"]",
"secretBytes",
",",
"byte",
"[",
"]",
"headerBytes",
",",
"byte",
"[",
"]",
"payloadBytes",
",",
"byte",
"[",
"]",
"signatureBytes",
")",
"throws",
"NoSuchAlgorithmException",
",",
"InvalidKeyException",
"{",
"return",
"MessageDigest",
".",
"isEqual",
"(",
"createSignatureFor",
"(",
"algorithm",
",",
"secretBytes",
",",
"headerBytes",
",",
"payloadBytes",
")",
",",
"signatureBytes",
")",
";",
"}"
] | Verify signature for JWT header and payload.
@param algorithm algorithm name.
@param secretBytes algorithm secret.
@param headerBytes JWT header.
@param payloadBytes JWT payload.
@param signatureBytes JWT signature.
@return true if signature is valid.
@throws NoSuchAlgorithmException if the algorithm is not supported.
@throws InvalidKeyException if the given key is inappropriate for initializing the specified algorithm. | [
"Verify",
"signature",
"for",
"JWT",
"header",
"and",
"payload",
"."
] | train | https://github.com/auth0/java-jwt/blob/890538970a9699b7251a4bfe4f26e8d7605ad530/lib/src/main/java/com/auth0/jwt/algorithms/CryptoHelper.java#L43-L45 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/time/LocalTime.java | LocalTime.plusSeconds | public LocalTime plusSeconds(long secondstoAdd) {
"""
Returns a copy of this {@code LocalTime} with the specified number of seconds added.
<p>
This adds the specified number of seconds to this time, returning a new time.
The calculation wraps around midnight.
<p>
This instance is immutable and unaffected by this method call.
@param secondstoAdd the seconds to add, may be negative
@return a {@code LocalTime} based on this time with the seconds added, not null
"""
if (secondstoAdd == 0) {
return this;
}
int sofd = hour * SECONDS_PER_HOUR +
minute * SECONDS_PER_MINUTE + second;
int newSofd = ((int) (secondstoAdd % SECONDS_PER_DAY) + sofd + SECONDS_PER_DAY) % SECONDS_PER_DAY;
if (sofd == newSofd) {
return this;
}
int newHour = newSofd / SECONDS_PER_HOUR;
int newMinute = (newSofd / SECONDS_PER_MINUTE) % MINUTES_PER_HOUR;
int newSecond = newSofd % SECONDS_PER_MINUTE;
return create(newHour, newMinute, newSecond, nano);
} | java | public LocalTime plusSeconds(long secondstoAdd) {
if (secondstoAdd == 0) {
return this;
}
int sofd = hour * SECONDS_PER_HOUR +
minute * SECONDS_PER_MINUTE + second;
int newSofd = ((int) (secondstoAdd % SECONDS_PER_DAY) + sofd + SECONDS_PER_DAY) % SECONDS_PER_DAY;
if (sofd == newSofd) {
return this;
}
int newHour = newSofd / SECONDS_PER_HOUR;
int newMinute = (newSofd / SECONDS_PER_MINUTE) % MINUTES_PER_HOUR;
int newSecond = newSofd % SECONDS_PER_MINUTE;
return create(newHour, newMinute, newSecond, nano);
} | [
"public",
"LocalTime",
"plusSeconds",
"(",
"long",
"secondstoAdd",
")",
"{",
"if",
"(",
"secondstoAdd",
"==",
"0",
")",
"{",
"return",
"this",
";",
"}",
"int",
"sofd",
"=",
"hour",
"*",
"SECONDS_PER_HOUR",
"+",
"minute",
"*",
"SECONDS_PER_MINUTE",
"+",
"second",
";",
"int",
"newSofd",
"=",
"(",
"(",
"int",
")",
"(",
"secondstoAdd",
"%",
"SECONDS_PER_DAY",
")",
"+",
"sofd",
"+",
"SECONDS_PER_DAY",
")",
"%",
"SECONDS_PER_DAY",
";",
"if",
"(",
"sofd",
"==",
"newSofd",
")",
"{",
"return",
"this",
";",
"}",
"int",
"newHour",
"=",
"newSofd",
"/",
"SECONDS_PER_HOUR",
";",
"int",
"newMinute",
"=",
"(",
"newSofd",
"/",
"SECONDS_PER_MINUTE",
")",
"%",
"MINUTES_PER_HOUR",
";",
"int",
"newSecond",
"=",
"newSofd",
"%",
"SECONDS_PER_MINUTE",
";",
"return",
"create",
"(",
"newHour",
",",
"newMinute",
",",
"newSecond",
",",
"nano",
")",
";",
"}"
] | Returns a copy of this {@code LocalTime} with the specified number of seconds added.
<p>
This adds the specified number of seconds to this time, returning a new time.
The calculation wraps around midnight.
<p>
This instance is immutable and unaffected by this method call.
@param secondstoAdd the seconds to add, may be negative
@return a {@code LocalTime} based on this time with the seconds added, not null | [
"Returns",
"a",
"copy",
"of",
"this",
"{",
"@code",
"LocalTime",
"}",
"with",
"the",
"specified",
"number",
"of",
"seconds",
"added",
".",
"<p",
">",
"This",
"adds",
"the",
"specified",
"number",
"of",
"seconds",
"to",
"this",
"time",
"returning",
"a",
"new",
"time",
".",
"The",
"calculation",
"wraps",
"around",
"midnight",
".",
"<p",
">",
"This",
"instance",
"is",
"immutable",
"and",
"unaffected",
"by",
"this",
"method",
"call",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/time/LocalTime.java#L1110-L1124 |
meltmedia/jgroups-aws | src/main/java/com/meltmedia/jgroups/aws/InstanceIdentity.java | InstanceIdentity.getIdentityDocument | private static String getIdentityDocument(final HttpClient client) throws IOException {
"""
Gets the body of the content returned from a GET request to uri.
@param client
@return the body of the message returned from the GET request.
@throws IOException if there is an error encountered while getting the content.
"""
try {
final HttpGet getInstance = new HttpGet();
getInstance.setURI(INSTANCE_IDENTITY_URI);
final HttpResponse response = client.execute(getInstance);
if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
throw new IOException("failed to get instance identity, tried: " + INSTANCE_IDENTITY_URL + ", response: " + response.getStatusLine().getReasonPhrase());
}
return EntityUtils.toString(response.getEntity());
} catch (Exception e) {
throw new IOException("failed to get instance identity", e);
}
} | java | private static String getIdentityDocument(final HttpClient client) throws IOException {
try {
final HttpGet getInstance = new HttpGet();
getInstance.setURI(INSTANCE_IDENTITY_URI);
final HttpResponse response = client.execute(getInstance);
if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
throw new IOException("failed to get instance identity, tried: " + INSTANCE_IDENTITY_URL + ", response: " + response.getStatusLine().getReasonPhrase());
}
return EntityUtils.toString(response.getEntity());
} catch (Exception e) {
throw new IOException("failed to get instance identity", e);
}
} | [
"private",
"static",
"String",
"getIdentityDocument",
"(",
"final",
"HttpClient",
"client",
")",
"throws",
"IOException",
"{",
"try",
"{",
"final",
"HttpGet",
"getInstance",
"=",
"new",
"HttpGet",
"(",
")",
";",
"getInstance",
".",
"setURI",
"(",
"INSTANCE_IDENTITY_URI",
")",
";",
"final",
"HttpResponse",
"response",
"=",
"client",
".",
"execute",
"(",
"getInstance",
")",
";",
"if",
"(",
"response",
".",
"getStatusLine",
"(",
")",
".",
"getStatusCode",
"(",
")",
"!=",
"HttpStatus",
".",
"SC_OK",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"failed to get instance identity, tried: \"",
"+",
"INSTANCE_IDENTITY_URL",
"+",
"\", response: \"",
"+",
"response",
".",
"getStatusLine",
"(",
")",
".",
"getReasonPhrase",
"(",
")",
")",
";",
"}",
"return",
"EntityUtils",
".",
"toString",
"(",
"response",
".",
"getEntity",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"failed to get instance identity\"",
",",
"e",
")",
";",
"}",
"}"
] | Gets the body of the content returned from a GET request to uri.
@param client
@return the body of the message returned from the GET request.
@throws IOException if there is an error encountered while getting the content. | [
"Gets",
"the",
"body",
"of",
"the",
"content",
"returned",
"from",
"a",
"GET",
"request",
"to",
"uri",
"."
] | train | https://github.com/meltmedia/jgroups-aws/blob/b5e861a6809677e317dc624f981c983ed109fed6/src/main/java/com/meltmedia/jgroups/aws/InstanceIdentity.java#L67-L79 |
arnaudroger/SimpleFlatMapper | sfm-jdbc/src/main/java/org/simpleflatmapper/jdbc/ConnectedCrud.java | ConnectedCrud.read | public <RH extends CheckedConsumer<? super T>> RH read(final Collection<K> keys, final RH consumer) throws SQLException {
"""
retrieve the objects with the specified keys and pass them to the consumer.
@param keys the keys
@param consumer the handler that is callback for each row
@throws SQLException if an error occurs
"""
transactionTemplate
.doInTransaction(new SQLFunction<Connection, Object>() {
@Override
public Object apply(Connection connection) throws SQLException {
delegate.read(connection, keys, consumer);
return null;
}
});
return consumer;
} | java | public <RH extends CheckedConsumer<? super T>> RH read(final Collection<K> keys, final RH consumer) throws SQLException {
transactionTemplate
.doInTransaction(new SQLFunction<Connection, Object>() {
@Override
public Object apply(Connection connection) throws SQLException {
delegate.read(connection, keys, consumer);
return null;
}
});
return consumer;
} | [
"public",
"<",
"RH",
"extends",
"CheckedConsumer",
"<",
"?",
"super",
"T",
">",
">",
"RH",
"read",
"(",
"final",
"Collection",
"<",
"K",
">",
"keys",
",",
"final",
"RH",
"consumer",
")",
"throws",
"SQLException",
"{",
"transactionTemplate",
".",
"doInTransaction",
"(",
"new",
"SQLFunction",
"<",
"Connection",
",",
"Object",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Object",
"apply",
"(",
"Connection",
"connection",
")",
"throws",
"SQLException",
"{",
"delegate",
".",
"read",
"(",
"connection",
",",
"keys",
",",
"consumer",
")",
";",
"return",
"null",
";",
"}",
"}",
")",
";",
"return",
"consumer",
";",
"}"
] | retrieve the objects with the specified keys and pass them to the consumer.
@param keys the keys
@param consumer the handler that is callback for each row
@throws SQLException if an error occurs | [
"retrieve",
"the",
"objects",
"with",
"the",
"specified",
"keys",
"and",
"pass",
"them",
"to",
"the",
"consumer",
"."
] | train | https://github.com/arnaudroger/SimpleFlatMapper/blob/93435438c18f26c87963d5e0f3ebf0f264dcd8c2/sfm-jdbc/src/main/java/org/simpleflatmapper/jdbc/ConnectedCrud.java#L129-L139 |
hellosign/hellosign-java-sdk | src/main/java/com/hellosign/sdk/HelloSignClient.java | HelloSignClient.getEmbeddedTemplateEditUrl | public EmbeddedResponse getEmbeddedTemplateEditUrl(String templateId, boolean skipSignerRoles,
boolean skipSubjectMessage) throws HelloSignException {
"""
Retrieves the necessary information to edit an embedded template.
@param templateId String ID of the signature request to embed
@param skipSignerRoles true if the edited template should not allow the
user to modify the template's signer roles. Defaults to false.
@param skipSubjectMessage true if the edited template should not allow
the user to modify the template's subject and message. Defaults to
false.
@return EmbeddedResponse
@throws HelloSignException thrown if there's a problem processing the
HTTP request or the JSON response.
"""
return getEmbeddedTemplateEditUrl(templateId, skipSignerRoles, skipSubjectMessage, false);
} | java | public EmbeddedResponse getEmbeddedTemplateEditUrl(String templateId, boolean skipSignerRoles,
boolean skipSubjectMessage) throws HelloSignException {
return getEmbeddedTemplateEditUrl(templateId, skipSignerRoles, skipSubjectMessage, false);
} | [
"public",
"EmbeddedResponse",
"getEmbeddedTemplateEditUrl",
"(",
"String",
"templateId",
",",
"boolean",
"skipSignerRoles",
",",
"boolean",
"skipSubjectMessage",
")",
"throws",
"HelloSignException",
"{",
"return",
"getEmbeddedTemplateEditUrl",
"(",
"templateId",
",",
"skipSignerRoles",
",",
"skipSubjectMessage",
",",
"false",
")",
";",
"}"
] | Retrieves the necessary information to edit an embedded template.
@param templateId String ID of the signature request to embed
@param skipSignerRoles true if the edited template should not allow the
user to modify the template's signer roles. Defaults to false.
@param skipSubjectMessage true if the edited template should not allow
the user to modify the template's subject and message. Defaults to
false.
@return EmbeddedResponse
@throws HelloSignException thrown if there's a problem processing the
HTTP request or the JSON response. | [
"Retrieves",
"the",
"necessary",
"information",
"to",
"edit",
"an",
"embedded",
"template",
"."
] | train | https://github.com/hellosign/hellosign-java-sdk/blob/08fa7aeb3b0c68ddb6c7ea797d114d55d36d36b1/src/main/java/com/hellosign/sdk/HelloSignClient.java#L873-L876 |
impossibl/stencil | engine/src/main/java/com/impossibl/stencil/engine/internal/StencilOperands.java | StencilOperands.toCollection | public Collection<?> toCollection(Object val) {
"""
Coerce to a collection
@param val
Object to be coerced.
@return The Collection coerced value.
"""
if (val == null) {
return Collections.emptyList();
}
else if (val instanceof Collection<?>) {
return (Collection<?>) val;
}
else if (val.getClass().isArray()) {
return newArrayList((Object[]) val);
}
else if (val instanceof Map<?,?>) {
return ((Map<?,?>)val).entrySet();
}
else {
return newArrayList(val);
}
} | java | public Collection<?> toCollection(Object val) {
if (val == null) {
return Collections.emptyList();
}
else if (val instanceof Collection<?>) {
return (Collection<?>) val;
}
else if (val.getClass().isArray()) {
return newArrayList((Object[]) val);
}
else if (val instanceof Map<?,?>) {
return ((Map<?,?>)val).entrySet();
}
else {
return newArrayList(val);
}
} | [
"public",
"Collection",
"<",
"?",
">",
"toCollection",
"(",
"Object",
"val",
")",
"{",
"if",
"(",
"val",
"==",
"null",
")",
"{",
"return",
"Collections",
".",
"emptyList",
"(",
")",
";",
"}",
"else",
"if",
"(",
"val",
"instanceof",
"Collection",
"<",
"?",
">",
")",
"{",
"return",
"(",
"Collection",
"<",
"?",
">",
")",
"val",
";",
"}",
"else",
"if",
"(",
"val",
".",
"getClass",
"(",
")",
".",
"isArray",
"(",
")",
")",
"{",
"return",
"newArrayList",
"(",
"(",
"Object",
"[",
"]",
")",
"val",
")",
";",
"}",
"else",
"if",
"(",
"val",
"instanceof",
"Map",
"<",
"?",
",",
"?",
">",
")",
"{",
"return",
"(",
"(",
"Map",
"<",
"?",
",",
"?",
">",
")",
"val",
")",
".",
"entrySet",
"(",
")",
";",
"}",
"else",
"{",
"return",
"newArrayList",
"(",
"val",
")",
";",
"}",
"}"
] | Coerce to a collection
@param val
Object to be coerced.
@return The Collection coerced value. | [
"Coerce",
"to",
"a",
"collection"
] | train | https://github.com/impossibl/stencil/blob/4aac1be605542b4248be95bf8916be4e2f755d1c/engine/src/main/java/com/impossibl/stencil/engine/internal/StencilOperands.java#L1153-L1170 |
lemire/JavaFastPFOR | src/main/java/me/lemire/integercompression/synth/UniformDataGenerator.java | UniformDataGenerator.generateUniform | public int[] generateUniform(int N, int Max) {
"""
generates randomly N distinct integers from 0 to Max.
@param N
number of integers to generate
@param Max
bound on the value of integers
@return an array containing randomly selected integers
"""
if (N * 2 > Max) {
return negate(generateUniform(Max - N, Max), Max);
}
if (2048 * N > Max)
return generateUniformBitmap(N, Max);
return generateUniformHash(N, Max);
} | java | public int[] generateUniform(int N, int Max) {
if (N * 2 > Max) {
return negate(generateUniform(Max - N, Max), Max);
}
if (2048 * N > Max)
return generateUniformBitmap(N, Max);
return generateUniformHash(N, Max);
} | [
"public",
"int",
"[",
"]",
"generateUniform",
"(",
"int",
"N",
",",
"int",
"Max",
")",
"{",
"if",
"(",
"N",
"*",
"2",
">",
"Max",
")",
"{",
"return",
"negate",
"(",
"generateUniform",
"(",
"Max",
"-",
"N",
",",
"Max",
")",
",",
"Max",
")",
";",
"}",
"if",
"(",
"2048",
"*",
"N",
">",
"Max",
")",
"return",
"generateUniformBitmap",
"(",
"N",
",",
"Max",
")",
";",
"return",
"generateUniformHash",
"(",
"N",
",",
"Max",
")",
";",
"}"
] | generates randomly N distinct integers from 0 to Max.
@param N
number of integers to generate
@param Max
bound on the value of integers
@return an array containing randomly selected integers | [
"generates",
"randomly",
"N",
"distinct",
"integers",
"from",
"0",
"to",
"Max",
"."
] | train | https://github.com/lemire/JavaFastPFOR/blob/ffeea61ab2fdb3854da7b0a557f8d22d674477f4/src/main/java/me/lemire/integercompression/synth/UniformDataGenerator.java#L80-L87 |
lievendoclo/Valkyrie-RCP | valkyrie-rcp-core/src/main/java/org/valkyriercp/form/binding/swing/SwingBindingFactory.java | SwingBindingFactory.createBoundShuttleList | public Binding createBoundShuttleList( String selectionFormProperty, Object selectableItems, String renderedProperty ) {
"""
Binds the values specified in the collection contained within
<code>selectableItems</code> (which will be wrapped in a
{@link ValueHolder} to a {@link ShuttleList}, with any user selection
being placed in the form property referred to by
<code>selectionFormProperty</code>. Each item in the list will be
rendered by looking up a property on the item by the name contained in
<code>renderedProperty</code>, retrieving the value of the property,
and rendering that value in the UI.
<p>
Note that the selection in the bound list will track any changes to the
<code>selectionFormProperty</code>. This is especially useful to
preselect items in the list - if <code>selectionFormProperty</code> is
not empty when the list is bound, then its content will be used for the
initial selection.
@param selectionFormProperty form property to hold user's selection. This
property must be a <code>Collection</code> or array type.
@param selectableItems Collection or array containing the items with
which to populate the selectable list (this object will be wrapped
in a ValueHolder).
@param renderedProperty the property to be queried for each item in the
list, the result of which will be used to render that item in the
UI. May be null, in which case the selectable items will be
rendered as strings.
@return constructed {@link Binding}. Note that the bound control is of
type {@link ShuttleList}. Access this component to set specific
display properties.
"""
return createBoundShuttleList(selectionFormProperty, new ValueHolder(selectableItems), renderedProperty);
} | java | public Binding createBoundShuttleList( String selectionFormProperty, Object selectableItems, String renderedProperty ) {
return createBoundShuttleList(selectionFormProperty, new ValueHolder(selectableItems), renderedProperty);
} | [
"public",
"Binding",
"createBoundShuttleList",
"(",
"String",
"selectionFormProperty",
",",
"Object",
"selectableItems",
",",
"String",
"renderedProperty",
")",
"{",
"return",
"createBoundShuttleList",
"(",
"selectionFormProperty",
",",
"new",
"ValueHolder",
"(",
"selectableItems",
")",
",",
"renderedProperty",
")",
";",
"}"
] | Binds the values specified in the collection contained within
<code>selectableItems</code> (which will be wrapped in a
{@link ValueHolder} to a {@link ShuttleList}, with any user selection
being placed in the form property referred to by
<code>selectionFormProperty</code>. Each item in the list will be
rendered by looking up a property on the item by the name contained in
<code>renderedProperty</code>, retrieving the value of the property,
and rendering that value in the UI.
<p>
Note that the selection in the bound list will track any changes to the
<code>selectionFormProperty</code>. This is especially useful to
preselect items in the list - if <code>selectionFormProperty</code> is
not empty when the list is bound, then its content will be used for the
initial selection.
@param selectionFormProperty form property to hold user's selection. This
property must be a <code>Collection</code> or array type.
@param selectableItems Collection or array containing the items with
which to populate the selectable list (this object will be wrapped
in a ValueHolder).
@param renderedProperty the property to be queried for each item in the
list, the result of which will be used to render that item in the
UI. May be null, in which case the selectable items will be
rendered as strings.
@return constructed {@link Binding}. Note that the bound control is of
type {@link ShuttleList}. Access this component to set specific
display properties. | [
"Binds",
"the",
"values",
"specified",
"in",
"the",
"collection",
"contained",
"within",
"<code",
">",
"selectableItems<",
"/",
"code",
">",
"(",
"which",
"will",
"be",
"wrapped",
"in",
"a",
"{",
"@link",
"ValueHolder",
"}",
"to",
"a",
"{",
"@link",
"ShuttleList",
"}",
"with",
"any",
"user",
"selection",
"being",
"placed",
"in",
"the",
"form",
"property",
"referred",
"to",
"by",
"<code",
">",
"selectionFormProperty<",
"/",
"code",
">",
".",
"Each",
"item",
"in",
"the",
"list",
"will",
"be",
"rendered",
"by",
"looking",
"up",
"a",
"property",
"on",
"the",
"item",
"by",
"the",
"name",
"contained",
"in",
"<code",
">",
"renderedProperty<",
"/",
"code",
">",
"retrieving",
"the",
"value",
"of",
"the",
"property",
"and",
"rendering",
"that",
"value",
"in",
"the",
"UI",
".",
"<p",
">",
"Note",
"that",
"the",
"selection",
"in",
"the",
"bound",
"list",
"will",
"track",
"any",
"changes",
"to",
"the",
"<code",
">",
"selectionFormProperty<",
"/",
"code",
">",
".",
"This",
"is",
"especially",
"useful",
"to",
"preselect",
"items",
"in",
"the",
"list",
"-",
"if",
"<code",
">",
"selectionFormProperty<",
"/",
"code",
">",
"is",
"not",
"empty",
"when",
"the",
"list",
"is",
"bound",
"then",
"its",
"content",
"will",
"be",
"used",
"for",
"the",
"initial",
"selection",
"."
] | train | https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/form/binding/swing/SwingBindingFactory.java#L387-L389 |
sdl/odata | odata_api/src/main/java/com/sdl/odata/util/edm/EntityDataModelUtil.java | EntityDataModelUtil.isCollection | public static boolean isCollection(EntityDataModel entityDataModel, String typeName) {
"""
Checks if the specified typeName is a collection.
@param entityDataModel The entity data model.
@param typeName The type name to check.
@return True if the type is a collection, False if not
"""
EntitySet entitySet = entityDataModel.getEntityContainer().getEntitySet(typeName);
if (entitySet != null) {
return true;
}
try {
if (Collection.class.isAssignableFrom(Class.forName(typeName))
|| COLLECTION_PATTERN.matcher(typeName).matches()) {
return true;
}
} catch (ClassNotFoundException e) {
LOG.debug("Not possible to find class for type name: {}", typeName);
}
return false;
} | java | public static boolean isCollection(EntityDataModel entityDataModel, String typeName) {
EntitySet entitySet = entityDataModel.getEntityContainer().getEntitySet(typeName);
if (entitySet != null) {
return true;
}
try {
if (Collection.class.isAssignableFrom(Class.forName(typeName))
|| COLLECTION_PATTERN.matcher(typeName).matches()) {
return true;
}
} catch (ClassNotFoundException e) {
LOG.debug("Not possible to find class for type name: {}", typeName);
}
return false;
} | [
"public",
"static",
"boolean",
"isCollection",
"(",
"EntityDataModel",
"entityDataModel",
",",
"String",
"typeName",
")",
"{",
"EntitySet",
"entitySet",
"=",
"entityDataModel",
".",
"getEntityContainer",
"(",
")",
".",
"getEntitySet",
"(",
"typeName",
")",
";",
"if",
"(",
"entitySet",
"!=",
"null",
")",
"{",
"return",
"true",
";",
"}",
"try",
"{",
"if",
"(",
"Collection",
".",
"class",
".",
"isAssignableFrom",
"(",
"Class",
".",
"forName",
"(",
"typeName",
")",
")",
"||",
"COLLECTION_PATTERN",
".",
"matcher",
"(",
"typeName",
")",
".",
"matches",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"catch",
"(",
"ClassNotFoundException",
"e",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Not possible to find class for type name: {}\"",
",",
"typeName",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Checks if the specified typeName is a collection.
@param entityDataModel The entity data model.
@param typeName The type name to check.
@return True if the type is a collection, False if not | [
"Checks",
"if",
"the",
"specified",
"typeName",
"is",
"a",
"collection",
"."
] | train | https://github.com/sdl/odata/blob/eb747d73e9af0f4e59a25b82ed656e526a7e2189/odata_api/src/main/java/com/sdl/odata/util/edm/EntityDataModelUtil.java#L671-L686 |
orbisgis/h2gis | h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/ST_AsGeoJSON.java | ST_AsGeoJSON.toGeojsonPoint | public static void toGeojsonPoint(Point point, StringBuilder sb) {
"""
For type "Point", the "coordinates" member must be a single position.
A position is the fundamental geometry construct. The "coordinates"
member of a geometry object is composed of one position (in the case of a
Point geometry), an array of positions (LineString or MultiPoint
geometries), an array of arrays of positions (Polygons,
MultiLineStrings), or a multidimensional array of positions
(MultiPolygon).
A position is represented by an array of numbers. There must be at least
two elements, and may be more. The order of elements must follow x, y, z
order (easting, northing, altitude for coordinates in a projected
coordinate reference system, or longitude, latitude, altitude for
coordinates in a geographic coordinate reference system). Any number of
additional elements are allowed -- interpretation and meaning of
additional elements is beyond the scope of this specification.
Syntax:
{ "type": "Point", "coordinates": [100.0, 0.0] }
@param point
@param sb
"""
Coordinate coord = point.getCoordinate();
sb.append("{\"type\":\"Point\",\"coordinates\":[");
sb.append(coord.x).append(",").append(coord.y);
if (!Double.isNaN(coord.z)) {
sb.append(",").append(coord.z);
}
sb.append("]}");
} | java | public static void toGeojsonPoint(Point point, StringBuilder sb) {
Coordinate coord = point.getCoordinate();
sb.append("{\"type\":\"Point\",\"coordinates\":[");
sb.append(coord.x).append(",").append(coord.y);
if (!Double.isNaN(coord.z)) {
sb.append(",").append(coord.z);
}
sb.append("]}");
} | [
"public",
"static",
"void",
"toGeojsonPoint",
"(",
"Point",
"point",
",",
"StringBuilder",
"sb",
")",
"{",
"Coordinate",
"coord",
"=",
"point",
".",
"getCoordinate",
"(",
")",
";",
"sb",
".",
"append",
"(",
"\"{\\\"type\\\":\\\"Point\\\",\\\"coordinates\\\":[\"",
")",
";",
"sb",
".",
"append",
"(",
"coord",
".",
"x",
")",
".",
"append",
"(",
"\",\"",
")",
".",
"append",
"(",
"coord",
".",
"y",
")",
";",
"if",
"(",
"!",
"Double",
".",
"isNaN",
"(",
"coord",
".",
"z",
")",
")",
"{",
"sb",
".",
"append",
"(",
"\",\"",
")",
".",
"append",
"(",
"coord",
".",
"z",
")",
";",
"}",
"sb",
".",
"append",
"(",
"\"]}\"",
")",
";",
"}"
] | For type "Point", the "coordinates" member must be a single position.
A position is the fundamental geometry construct. The "coordinates"
member of a geometry object is composed of one position (in the case of a
Point geometry), an array of positions (LineString or MultiPoint
geometries), an array of arrays of positions (Polygons,
MultiLineStrings), or a multidimensional array of positions
(MultiPolygon).
A position is represented by an array of numbers. There must be at least
two elements, and may be more. The order of elements must follow x, y, z
order (easting, northing, altitude for coordinates in a projected
coordinate reference system, or longitude, latitude, altitude for
coordinates in a geographic coordinate reference system). Any number of
additional elements are allowed -- interpretation and meaning of
additional elements is beyond the scope of this specification.
Syntax:
{ "type": "Point", "coordinates": [100.0, 0.0] }
@param point
@param sb | [
"For",
"type",
"Point",
"the",
"coordinates",
"member",
"must",
"be",
"a",
"single",
"position",
"."
] | train | https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/ST_AsGeoJSON.java#L106-L114 |
JOML-CI/JOML | src/org/joml/Matrix4x3f.java | Matrix4x3f.rotateAround | public Matrix4x3f rotateAround(Quaternionfc quat, float ox, float oy, float oz) {
"""
Apply the rotation transformation of the given {@link Quaternionfc} to this matrix while using <code>(ox, oy, oz)</code> as the rotation origin.
<p>
When used with a right-handed coordinate system, the produced rotation will rotate a vector
counter-clockwise around the rotation axis, when viewing along the negative axis direction towards the origin.
When used with a left-handed coordinate system, the rotation is clockwise.
<p>
If <code>M</code> is <code>this</code> matrix and <code>Q</code> the rotation matrix obtained from the given quaternion,
then the new matrix will be <code>M * Q</code>. So when transforming a
vector <code>v</code> with the new matrix by using <code>M * Q * v</code>,
the quaternion rotation will be applied first!
<p>
This method is equivalent to calling: <code>translate(ox, oy, oz).rotate(quat).translate(-ox, -oy, -oz)</code>
<p>
Reference: <a href="http://en.wikipedia.org/wiki/Rotation_matrix#Quaternion">http://en.wikipedia.org</a>
@param quat
the {@link Quaternionfc}
@param ox
the x coordinate of the rotation origin
@param oy
the y coordinate of the rotation origin
@param oz
the z coordinate of the rotation origin
@return a matrix holding the result
"""
return rotateAround(quat, ox, oy, oz, this);
} | java | public Matrix4x3f rotateAround(Quaternionfc quat, float ox, float oy, float oz) {
return rotateAround(quat, ox, oy, oz, this);
} | [
"public",
"Matrix4x3f",
"rotateAround",
"(",
"Quaternionfc",
"quat",
",",
"float",
"ox",
",",
"float",
"oy",
",",
"float",
"oz",
")",
"{",
"return",
"rotateAround",
"(",
"quat",
",",
"ox",
",",
"oy",
",",
"oz",
",",
"this",
")",
";",
"}"
] | Apply the rotation transformation of the given {@link Quaternionfc} to this matrix while using <code>(ox, oy, oz)</code> as the rotation origin.
<p>
When used with a right-handed coordinate system, the produced rotation will rotate a vector
counter-clockwise around the rotation axis, when viewing along the negative axis direction towards the origin.
When used with a left-handed coordinate system, the rotation is clockwise.
<p>
If <code>M</code> is <code>this</code> matrix and <code>Q</code> the rotation matrix obtained from the given quaternion,
then the new matrix will be <code>M * Q</code>. So when transforming a
vector <code>v</code> with the new matrix by using <code>M * Q * v</code>,
the quaternion rotation will be applied first!
<p>
This method is equivalent to calling: <code>translate(ox, oy, oz).rotate(quat).translate(-ox, -oy, -oz)</code>
<p>
Reference: <a href="http://en.wikipedia.org/wiki/Rotation_matrix#Quaternion">http://en.wikipedia.org</a>
@param quat
the {@link Quaternionfc}
@param ox
the x coordinate of the rotation origin
@param oy
the y coordinate of the rotation origin
@param oz
the z coordinate of the rotation origin
@return a matrix holding the result | [
"Apply",
"the",
"rotation",
"transformation",
"of",
"the",
"given",
"{",
"@link",
"Quaternionfc",
"}",
"to",
"this",
"matrix",
"while",
"using",
"<code",
">",
"(",
"ox",
"oy",
"oz",
")",
"<",
"/",
"code",
">",
"as",
"the",
"rotation",
"origin",
".",
"<p",
">",
"When",
"used",
"with",
"a",
"right",
"-",
"handed",
"coordinate",
"system",
"the",
"produced",
"rotation",
"will",
"rotate",
"a",
"vector",
"counter",
"-",
"clockwise",
"around",
"the",
"rotation",
"axis",
"when",
"viewing",
"along",
"the",
"negative",
"axis",
"direction",
"towards",
"the",
"origin",
".",
"When",
"used",
"with",
"a",
"left",
"-",
"handed",
"coordinate",
"system",
"the",
"rotation",
"is",
"clockwise",
".",
"<p",
">",
"If",
"<code",
">",
"M<",
"/",
"code",
">",
"is",
"<code",
">",
"this<",
"/",
"code",
">",
"matrix",
"and",
"<code",
">",
"Q<",
"/",
"code",
">",
"the",
"rotation",
"matrix",
"obtained",
"from",
"the",
"given",
"quaternion",
"then",
"the",
"new",
"matrix",
"will",
"be",
"<code",
">",
"M",
"*",
"Q<",
"/",
"code",
">",
".",
"So",
"when",
"transforming",
"a",
"vector",
"<code",
">",
"v<",
"/",
"code",
">",
"with",
"the",
"new",
"matrix",
"by",
"using",
"<code",
">",
"M",
"*",
"Q",
"*",
"v<",
"/",
"code",
">",
"the",
"quaternion",
"rotation",
"will",
"be",
"applied",
"first!",
"<p",
">",
"This",
"method",
"is",
"equivalent",
"to",
"calling",
":",
"<code",
">",
"translate",
"(",
"ox",
"oy",
"oz",
")",
".",
"rotate",
"(",
"quat",
")",
".",
"translate",
"(",
"-",
"ox",
"-",
"oy",
"-",
"oz",
")",
"<",
"/",
"code",
">",
"<p",
">",
"Reference",
":",
"<a",
"href",
"=",
"http",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"Rotation_matrix#Quaternion",
">",
"http",
":",
"//",
"en",
".",
"wikipedia",
".",
"org<",
"/",
"a",
">"
] | train | https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Matrix4x3f.java#L4008-L4010 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/AlphabeticIndex.java | AlphabeticIndex.isOneLabelBetterThanOther | private static boolean isOneLabelBetterThanOther(Normalizer2 nfkdNormalizer, String one, String other) {
"""
Returns true if one index character string is "better" than the other.
Shorter NFKD is better, and otherwise NFKD-binary-less-than is
better, and otherwise binary-less-than is better.
"""
// This is called with primary-equal strings, but never with one.equals(other).
String n1 = nfkdNormalizer.normalize(one);
String n2 = nfkdNormalizer.normalize(other);
int result = n1.codePointCount(0, n1.length()) - n2.codePointCount(0, n2.length());
if (result != 0) {
return result < 0;
}
result = binaryCmp.compare(n1, n2);
if (result != 0) {
return result < 0;
}
return binaryCmp.compare(one, other) < 0;
} | java | private static boolean isOneLabelBetterThanOther(Normalizer2 nfkdNormalizer, String one, String other) {
// This is called with primary-equal strings, but never with one.equals(other).
String n1 = nfkdNormalizer.normalize(one);
String n2 = nfkdNormalizer.normalize(other);
int result = n1.codePointCount(0, n1.length()) - n2.codePointCount(0, n2.length());
if (result != 0) {
return result < 0;
}
result = binaryCmp.compare(n1, n2);
if (result != 0) {
return result < 0;
}
return binaryCmp.compare(one, other) < 0;
} | [
"private",
"static",
"boolean",
"isOneLabelBetterThanOther",
"(",
"Normalizer2",
"nfkdNormalizer",
",",
"String",
"one",
",",
"String",
"other",
")",
"{",
"// This is called with primary-equal strings, but never with one.equals(other).",
"String",
"n1",
"=",
"nfkdNormalizer",
".",
"normalize",
"(",
"one",
")",
";",
"String",
"n2",
"=",
"nfkdNormalizer",
".",
"normalize",
"(",
"other",
")",
";",
"int",
"result",
"=",
"n1",
".",
"codePointCount",
"(",
"0",
",",
"n1",
".",
"length",
"(",
")",
")",
"-",
"n2",
".",
"codePointCount",
"(",
"0",
",",
"n2",
".",
"length",
"(",
")",
")",
";",
"if",
"(",
"result",
"!=",
"0",
")",
"{",
"return",
"result",
"<",
"0",
";",
"}",
"result",
"=",
"binaryCmp",
".",
"compare",
"(",
"n1",
",",
"n2",
")",
";",
"if",
"(",
"result",
"!=",
"0",
")",
"{",
"return",
"result",
"<",
"0",
";",
"}",
"return",
"binaryCmp",
".",
"compare",
"(",
"one",
",",
"other",
")",
"<",
"0",
";",
"}"
] | Returns true if one index character string is "better" than the other.
Shorter NFKD is better, and otherwise NFKD-binary-less-than is
better, and otherwise binary-less-than is better. | [
"Returns",
"true",
"if",
"one",
"index",
"character",
"string",
"is",
"better",
"than",
"the",
"other",
".",
"Shorter",
"NFKD",
"is",
"better",
"and",
"otherwise",
"NFKD",
"-",
"binary",
"-",
"less",
"-",
"than",
"is",
"better",
"and",
"otherwise",
"binary",
"-",
"less",
"-",
"than",
"is",
"better",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/AlphabeticIndex.java#L799-L812 |
pmayweg/sonar-groovy | sonar-groovy-plugin/src/main/java/org/sonar/plugins/groovy/jacoco/JaCoCoReportReader.java | JaCoCoReportReader.analyzeClassFile | private static void analyzeClassFile(org.jacoco.previous.core.analysis.Analyzer analyzer, File classFile) {
"""
Caller must guarantee that {@code classFile} is actually class file.
"""
try (InputStream inputStream = new FileInputStream(classFile)) {
analyzer.analyzeClass(inputStream, classFile.getPath());
} catch (IOException e) {
// (Godin): in fact JaCoCo includes name into exception
JaCoCoExtensions.logger().warn("Exception during analysis of file " + classFile.getAbsolutePath(), e);
}
} | java | private static void analyzeClassFile(org.jacoco.previous.core.analysis.Analyzer analyzer, File classFile) {
try (InputStream inputStream = new FileInputStream(classFile)) {
analyzer.analyzeClass(inputStream, classFile.getPath());
} catch (IOException e) {
// (Godin): in fact JaCoCo includes name into exception
JaCoCoExtensions.logger().warn("Exception during analysis of file " + classFile.getAbsolutePath(), e);
}
} | [
"private",
"static",
"void",
"analyzeClassFile",
"(",
"org",
".",
"jacoco",
".",
"previous",
".",
"core",
".",
"analysis",
".",
"Analyzer",
"analyzer",
",",
"File",
"classFile",
")",
"{",
"try",
"(",
"InputStream",
"inputStream",
"=",
"new",
"FileInputStream",
"(",
"classFile",
")",
")",
"{",
"analyzer",
".",
"analyzeClass",
"(",
"inputStream",
",",
"classFile",
".",
"getPath",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"// (Godin): in fact JaCoCo includes name into exception",
"JaCoCoExtensions",
".",
"logger",
"(",
")",
".",
"warn",
"(",
"\"Exception during analysis of file \"",
"+",
"classFile",
".",
"getAbsolutePath",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] | Caller must guarantee that {@code classFile} is actually class file. | [
"Caller",
"must",
"guarantee",
"that",
"{"
] | train | https://github.com/pmayweg/sonar-groovy/blob/2d78d6578304601613db928795d81de340e6fa34/sonar-groovy-plugin/src/main/java/org/sonar/plugins/groovy/jacoco/JaCoCoReportReader.java#L126-L133 |
j256/ormlite-core | src/main/java/com/j256/ormlite/table/DatabaseTableConfigLoader.java | DatabaseTableConfigLoader.readFields | private static <T> void readFields(BufferedReader reader, DatabaseTableConfig<T> config) throws SQLException {
"""
Read all of the fields information from the configuration file.
"""
List<DatabaseFieldConfig> fields = new ArrayList<DatabaseFieldConfig>();
while (true) {
String line;
try {
line = reader.readLine();
} catch (IOException e) {
throw SqlExceptionUtil.create("Could not read next field from config file", e);
}
if (line == null || line.equals(CONFIG_FILE_FIELDS_END)) {
break;
}
DatabaseFieldConfig fieldConfig = DatabaseFieldConfigLoader.fromReader(reader);
if (fieldConfig == null) {
break;
}
fields.add(fieldConfig);
}
config.setFieldConfigs(fields);
} | java | private static <T> void readFields(BufferedReader reader, DatabaseTableConfig<T> config) throws SQLException {
List<DatabaseFieldConfig> fields = new ArrayList<DatabaseFieldConfig>();
while (true) {
String line;
try {
line = reader.readLine();
} catch (IOException e) {
throw SqlExceptionUtil.create("Could not read next field from config file", e);
}
if (line == null || line.equals(CONFIG_FILE_FIELDS_END)) {
break;
}
DatabaseFieldConfig fieldConfig = DatabaseFieldConfigLoader.fromReader(reader);
if (fieldConfig == null) {
break;
}
fields.add(fieldConfig);
}
config.setFieldConfigs(fields);
} | [
"private",
"static",
"<",
"T",
">",
"void",
"readFields",
"(",
"BufferedReader",
"reader",
",",
"DatabaseTableConfig",
"<",
"T",
">",
"config",
")",
"throws",
"SQLException",
"{",
"List",
"<",
"DatabaseFieldConfig",
">",
"fields",
"=",
"new",
"ArrayList",
"<",
"DatabaseFieldConfig",
">",
"(",
")",
";",
"while",
"(",
"true",
")",
"{",
"String",
"line",
";",
"try",
"{",
"line",
"=",
"reader",
".",
"readLine",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"SqlExceptionUtil",
".",
"create",
"(",
"\"Could not read next field from config file\"",
",",
"e",
")",
";",
"}",
"if",
"(",
"line",
"==",
"null",
"||",
"line",
".",
"equals",
"(",
"CONFIG_FILE_FIELDS_END",
")",
")",
"{",
"break",
";",
"}",
"DatabaseFieldConfig",
"fieldConfig",
"=",
"DatabaseFieldConfigLoader",
".",
"fromReader",
"(",
"reader",
")",
";",
"if",
"(",
"fieldConfig",
"==",
"null",
")",
"{",
"break",
";",
"}",
"fields",
".",
"add",
"(",
"fieldConfig",
")",
";",
"}",
"config",
".",
"setFieldConfigs",
"(",
"fields",
")",
";",
"}"
] | Read all of the fields information from the configuration file. | [
"Read",
"all",
"of",
"the",
"fields",
"information",
"from",
"the",
"configuration",
"file",
"."
] | train | https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/table/DatabaseTableConfigLoader.java#L151-L170 |
google/flogger | google/src/main/java/com/google/common/flogger/GoogleLogger.java | GoogleLogger.forInjectedClassName | @Deprecated
public static GoogleLogger forInjectedClassName(String className) {
"""
Returns a new Google specific logger instance for the given class, using printf
style message formatting.
@deprecated prefer forEnclosingClass(); this method exists only to support
compile-time log site injection.
"""
checkArgument(!className.isEmpty(), "injected class name is empty");
// The injected class name is in binary form (e.g. java/util/Map$Entry) to re-use
// constant pool entries.
return new GoogleLogger(Platform.getBackend(className.replace('/', '.')));
} | java | @Deprecated
public static GoogleLogger forInjectedClassName(String className) {
checkArgument(!className.isEmpty(), "injected class name is empty");
// The injected class name is in binary form (e.g. java/util/Map$Entry) to re-use
// constant pool entries.
return new GoogleLogger(Platform.getBackend(className.replace('/', '.')));
} | [
"@",
"Deprecated",
"public",
"static",
"GoogleLogger",
"forInjectedClassName",
"(",
"String",
"className",
")",
"{",
"checkArgument",
"(",
"!",
"className",
".",
"isEmpty",
"(",
")",
",",
"\"injected class name is empty\"",
")",
";",
"// The injected class name is in binary form (e.g. java/util/Map$Entry) to re-use",
"// constant pool entries.",
"return",
"new",
"GoogleLogger",
"(",
"Platform",
".",
"getBackend",
"(",
"className",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
")",
")",
";",
"}"
] | Returns a new Google specific logger instance for the given class, using printf
style message formatting.
@deprecated prefer forEnclosingClass(); this method exists only to support
compile-time log site injection. | [
"Returns",
"a",
"new",
"Google",
"specific",
"logger",
"instance",
"for",
"the",
"given",
"class",
"using",
"printf",
"style",
"message",
"formatting",
"."
] | train | https://github.com/google/flogger/blob/a164967a93a9f4ce92f34319fc0cc7c91a57321c/google/src/main/java/com/google/common/flogger/GoogleLogger.java#L59-L65 |
Subsets and Splits