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
|
---|---|---|---|---|---|---|---|---|---|---|
looly/hutool | hutool-extra/src/main/java/cn/hutool/extra/qrcode/QrCodeUtil.java | QrCodeUtil.encode | public static BitMatrix encode(String content, BarcodeFormat format, int width, int height) {
"""
将文本内容编码为条形码或二维码
@param content 文本内容
@param format 格式枚举
@param width 宽度
@param height 高度
@return {@link BitMatrix}
"""
return encode(content, format, new QrConfig(width, height));
} | java | public static BitMatrix encode(String content, BarcodeFormat format, int width, int height) {
return encode(content, format, new QrConfig(width, height));
} | [
"public",
"static",
"BitMatrix",
"encode",
"(",
"String",
"content",
",",
"BarcodeFormat",
"format",
",",
"int",
"width",
",",
"int",
"height",
")",
"{",
"return",
"encode",
"(",
"content",
",",
"format",
",",
"new",
"QrConfig",
"(",
"width",
",",
"height",
")",
")",
";",
"}"
] | 将文本内容编码为条形码或二维码
@param content 文本内容
@param format 格式枚举
@param width 宽度
@param height 高度
@return {@link BitMatrix} | [
"将文本内容编码为条形码或二维码"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-extra/src/main/java/cn/hutool/extra/qrcode/QrCodeUtil.java#L234-L236 |
gallandarakhneorg/afc | advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapPolyline.java | MapPolyline.toPath2D | @SuppressWarnings( {
"""
Replies the Path2D that corresponds to this polyline.
If <var>startPosition</var> is greater to zero,
the replied path will be clipped to ignore the part of
the polyline before the given value.
If <var>endPosition</var> is lower to the length of the polyline,
the replied path will be clipped to ignore the part of
the polyline after the given value.
@param startPosition is the curviline position from which the polyline is drawn.
@param endPosition is the curviline position to which the polyline is drawn.
@return the clipped 2D path.
@since 4.0
""""checkstyle:cyclomaticcomplexity", "checkstyle:npathcomplexity"})
@Pure
public final Path2d toPath2D(double startPosition, double endPosition) {
final Path2d path = new Path2d();
toPath2D(path, startPosition, endPosition);
return path;
} | java | @SuppressWarnings({"checkstyle:cyclomaticcomplexity", "checkstyle:npathcomplexity"})
@Pure
public final Path2d toPath2D(double startPosition, double endPosition) {
final Path2d path = new Path2d();
toPath2D(path, startPosition, endPosition);
return path;
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"checkstyle:cyclomaticcomplexity\"",
",",
"\"checkstyle:npathcomplexity\"",
"}",
")",
"@",
"Pure",
"public",
"final",
"Path2d",
"toPath2D",
"(",
"double",
"startPosition",
",",
"double",
"endPosition",
")",
"{",
"final",
"Path2d",
"path",
"=",
"new",
"Path2d",
"(",
")",
";",
"toPath2D",
"(",
"path",
",",
"startPosition",
",",
"endPosition",
")",
";",
"return",
"path",
";",
"}"
] | Replies the Path2D that corresponds to this polyline.
If <var>startPosition</var> is greater to zero,
the replied path will be clipped to ignore the part of
the polyline before the given value.
If <var>endPosition</var> is lower to the length of the polyline,
the replied path will be clipped to ignore the part of
the polyline after the given value.
@param startPosition is the curviline position from which the polyline is drawn.
@param endPosition is the curviline position to which the polyline is drawn.
@return the clipped 2D path.
@since 4.0 | [
"Replies",
"the",
"Path2D",
"that",
"corresponds",
"to",
"this",
"polyline",
".",
"If",
"<var",
">",
"startPosition<",
"/",
"var",
">",
"is",
"greater",
"to",
"zero",
"the",
"replied",
"path",
"will",
"be",
"clipped",
"to",
"ignore",
"the",
"part",
"of",
"the",
"polyline",
"before",
"the",
"given",
"value",
".",
"If",
"<var",
">",
"endPosition<",
"/",
"var",
">",
"is",
"lower",
"to",
"the",
"length",
"of",
"the",
"polyline",
"the",
"replied",
"path",
"will",
"be",
"clipped",
"to",
"ignore",
"the",
"part",
"of",
"the",
"polyline",
"after",
"the",
"given",
"value",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/mapelement/MapPolyline.java#L518-L524 |
Whiley/WhileyCompiler | src/main/java/wyil/type/util/ConcreteTypeExtractor.java | ConcreteTypeExtractor.apply | @Override
public Type apply(SemanticType type, LifetimeRelation lifetimes) {
"""
Extract an instance of <code>Type</code> from <code>SemanticType</code> which
is the best possible approximation.
@param type
The semantic type being converted into a concrete type.
@return
"""
switch (type.getOpcode()) {
case SEMTYPE_array:
return apply((SemanticType.Array) type, lifetimes);
case SEMTYPE_reference:
case SEMTYPE_staticreference:
return apply((SemanticType.Reference) type, lifetimes);
case SEMTYPE_record:
return apply((SemanticType.Record) type, lifetimes);
case SEMTYPE_union:
return apply((SemanticType.Union) type, lifetimes);
case SEMTYPE_intersection:
return apply((SemanticType.Intersection) type, lifetimes);
case SEMTYPE_difference:
return apply((SemanticType.Difference) type, lifetimes);
default:
// NOTE: all other cases are already instances of Type
return (Type) type;
}
} | java | @Override
public Type apply(SemanticType type, LifetimeRelation lifetimes) {
switch (type.getOpcode()) {
case SEMTYPE_array:
return apply((SemanticType.Array) type, lifetimes);
case SEMTYPE_reference:
case SEMTYPE_staticreference:
return apply((SemanticType.Reference) type, lifetimes);
case SEMTYPE_record:
return apply((SemanticType.Record) type, lifetimes);
case SEMTYPE_union:
return apply((SemanticType.Union) type, lifetimes);
case SEMTYPE_intersection:
return apply((SemanticType.Intersection) type, lifetimes);
case SEMTYPE_difference:
return apply((SemanticType.Difference) type, lifetimes);
default:
// NOTE: all other cases are already instances of Type
return (Type) type;
}
} | [
"@",
"Override",
"public",
"Type",
"apply",
"(",
"SemanticType",
"type",
",",
"LifetimeRelation",
"lifetimes",
")",
"{",
"switch",
"(",
"type",
".",
"getOpcode",
"(",
")",
")",
"{",
"case",
"SEMTYPE_array",
":",
"return",
"apply",
"(",
"(",
"SemanticType",
".",
"Array",
")",
"type",
",",
"lifetimes",
")",
";",
"case",
"SEMTYPE_reference",
":",
"case",
"SEMTYPE_staticreference",
":",
"return",
"apply",
"(",
"(",
"SemanticType",
".",
"Reference",
")",
"type",
",",
"lifetimes",
")",
";",
"case",
"SEMTYPE_record",
":",
"return",
"apply",
"(",
"(",
"SemanticType",
".",
"Record",
")",
"type",
",",
"lifetimes",
")",
";",
"case",
"SEMTYPE_union",
":",
"return",
"apply",
"(",
"(",
"SemanticType",
".",
"Union",
")",
"type",
",",
"lifetimes",
")",
";",
"case",
"SEMTYPE_intersection",
":",
"return",
"apply",
"(",
"(",
"SemanticType",
".",
"Intersection",
")",
"type",
",",
"lifetimes",
")",
";",
"case",
"SEMTYPE_difference",
":",
"return",
"apply",
"(",
"(",
"SemanticType",
".",
"Difference",
")",
"type",
",",
"lifetimes",
")",
";",
"default",
":",
"// NOTE: all other cases are already instances of Type",
"return",
"(",
"Type",
")",
"type",
";",
"}",
"}"
] | Extract an instance of <code>Type</code> from <code>SemanticType</code> which
is the best possible approximation.
@param type
The semantic type being converted into a concrete type.
@return | [
"Extract",
"an",
"instance",
"of",
"<code",
">",
"Type<",
"/",
"code",
">",
"from",
"<code",
">",
"SemanticType<",
"/",
"code",
">",
"which",
"is",
"the",
"best",
"possible",
"approximation",
"."
] | train | https://github.com/Whiley/WhileyCompiler/blob/680f8a657d3fc286f8cc422755988b6d74ab3f4c/src/main/java/wyil/type/util/ConcreteTypeExtractor.java#L83-L103 |
Azure/azure-sdk-for-java | sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/ReplicationLinksInner.java | ReplicationLinksInner.beginFailoverAllowDataLoss | public void beginFailoverAllowDataLoss(String resourceGroupName, String serverName, String databaseName, String linkId) {
"""
Sets which replica database is primary by failing over from the current primary replica database. This operation might result in data loss.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param databaseName The name of the database that has the replication link to be failed over.
@param linkId The ID of the replication link to be failed over.
@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
"""
beginFailoverAllowDataLossWithServiceResponseAsync(resourceGroupName, serverName, databaseName, linkId).toBlocking().single().body();
} | java | public void beginFailoverAllowDataLoss(String resourceGroupName, String serverName, String databaseName, String linkId) {
beginFailoverAllowDataLossWithServiceResponseAsync(resourceGroupName, serverName, databaseName, linkId).toBlocking().single().body();
} | [
"public",
"void",
"beginFailoverAllowDataLoss",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"String",
"databaseName",
",",
"String",
"linkId",
")",
"{",
"beginFailoverAllowDataLossWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
",",
"databaseName",
",",
"linkId",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Sets which replica database is primary by failing over from the current primary replica database. This operation might result in data loss.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param databaseName The name of the database that has the replication link to be failed over.
@param linkId The ID of the replication link to be failed over.
@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 | [
"Sets",
"which",
"replica",
"database",
"is",
"primary",
"by",
"failing",
"over",
"from",
"the",
"current",
"primary",
"replica",
"database",
".",
"This",
"operation",
"might",
"result",
"in",
"data",
"loss",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/ReplicationLinksInner.java#L562-L564 |
matthewhorridge/owlapi-gwt | owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLIrreflexiveObjectPropertyAxiomImpl_CustomFieldSerializer.java | OWLIrreflexiveObjectPropertyAxiomImpl_CustomFieldSerializer.deserializeInstance | @Override
public void deserializeInstance(SerializationStreamReader streamReader, OWLIrreflexiveObjectPropertyAxiomImpl instance) throws SerializationException {
"""
Deserializes the content of the object from the
{@link com.google.gwt.user.client.rpc.SerializationStreamReader}.
@param streamReader the {@link com.google.gwt.user.client.rpc.SerializationStreamReader} to read the
object's content from
@param instance the object instance to deserialize
@throws com.google.gwt.user.client.rpc.SerializationException
if the deserialization operation is not
successful
"""
deserialize(streamReader, instance);
} | java | @Override
public void deserializeInstance(SerializationStreamReader streamReader, OWLIrreflexiveObjectPropertyAxiomImpl instance) throws SerializationException {
deserialize(streamReader, instance);
} | [
"@",
"Override",
"public",
"void",
"deserializeInstance",
"(",
"SerializationStreamReader",
"streamReader",
",",
"OWLIrreflexiveObjectPropertyAxiomImpl",
"instance",
")",
"throws",
"SerializationException",
"{",
"deserialize",
"(",
"streamReader",
",",
"instance",
")",
";",
"}"
] | Deserializes the content of the object from the
{@link com.google.gwt.user.client.rpc.SerializationStreamReader}.
@param streamReader the {@link com.google.gwt.user.client.rpc.SerializationStreamReader} to read the
object's content from
@param instance the object instance to deserialize
@throws com.google.gwt.user.client.rpc.SerializationException
if the deserialization operation is not
successful | [
"Deserializes",
"the",
"content",
"of",
"the",
"object",
"from",
"the",
"{",
"@link",
"com",
".",
"google",
".",
"gwt",
".",
"user",
".",
"client",
".",
"rpc",
".",
"SerializationStreamReader",
"}",
"."
] | train | https://github.com/matthewhorridge/owlapi-gwt/blob/7ab975fb6cef3c8947099983551672a3b5d4e2fd/owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLIrreflexiveObjectPropertyAxiomImpl_CustomFieldSerializer.java#L95-L98 |
netscaler/nitro | src/main/java/com/citrix/netscaler/nitro/resource/config/transform/transformprofile_binding.java | transformprofile_binding.get | public static transformprofile_binding get(nitro_service service, String name) throws Exception {
"""
Use this API to fetch transformprofile_binding resource of given name .
"""
transformprofile_binding obj = new transformprofile_binding();
obj.set_name(name);
transformprofile_binding response = (transformprofile_binding) obj.get_resource(service);
return response;
} | java | public static transformprofile_binding get(nitro_service service, String name) throws Exception{
transformprofile_binding obj = new transformprofile_binding();
obj.set_name(name);
transformprofile_binding response = (transformprofile_binding) obj.get_resource(service);
return response;
} | [
"public",
"static",
"transformprofile_binding",
"get",
"(",
"nitro_service",
"service",
",",
"String",
"name",
")",
"throws",
"Exception",
"{",
"transformprofile_binding",
"obj",
"=",
"new",
"transformprofile_binding",
"(",
")",
";",
"obj",
".",
"set_name",
"(",
"name",
")",
";",
"transformprofile_binding",
"response",
"=",
"(",
"transformprofile_binding",
")",
"obj",
".",
"get_resource",
"(",
"service",
")",
";",
"return",
"response",
";",
"}"
] | Use this API to fetch transformprofile_binding resource of given name . | [
"Use",
"this",
"API",
"to",
"fetch",
"transformprofile_binding",
"resource",
"of",
"given",
"name",
"."
] | train | https://github.com/netscaler/nitro/blob/2a98692dcf4e4ec430c7d7baab8382e4ba5a35e4/src/main/java/com/citrix/netscaler/nitro/resource/config/transform/transformprofile_binding.java#L103-L108 |
alkacon/opencms-core | src-modules/org/opencms/workplace/search/CmsSearchResourcesCollector.java | CmsSearchResourcesCollector.getSearchBean | private CmsSearch getSearchBean(Map<String, String> params) {
"""
Returns the search bean object.<p>
@param params the parameter map
@return the used search bean
"""
if (m_searchBean == null) {
m_searchBean = new CmsSearch();
m_searchBean.init(getWp().getCms());
m_searchBean.setParameters(getSearchParameters(params));
if (CmsStringUtil.isEmptyOrWhitespaceOnly(m_searchBean.getIndex())) {
m_searchBean.setIndex(getWp().getSettings().getUserSettings().getWorkplaceSearchIndexName());
}
m_searchBean.setMatchesPerPage(getWp().getSettings().getUserSettings().getExplorerFileEntries());
m_searchBean.setSearchPage(Integer.parseInt(params.get(I_CmsListResourceCollector.PARAM_PAGE)));
// set search roots
List<String> resources = getResourceNamesFromParam(params);
String[] searchRoots = new String[resources.size()];
resources.toArray(searchRoots);
for (int i = 0; i < searchRoots.length; i++) {
searchRoots[i] = getWp().getCms().addSiteRoot(searchRoots[i]);
}
m_searchBean.setSearchRoots(searchRoots);
} else {
int page = Integer.parseInt(params.get(I_CmsListResourceCollector.PARAM_PAGE));
if (m_searchBean.getSearchPage() != page) {
m_searchBean.setSearchPage(page);
m_searchResults = null;
}
}
return m_searchBean;
} | java | private CmsSearch getSearchBean(Map<String, String> params) {
if (m_searchBean == null) {
m_searchBean = new CmsSearch();
m_searchBean.init(getWp().getCms());
m_searchBean.setParameters(getSearchParameters(params));
if (CmsStringUtil.isEmptyOrWhitespaceOnly(m_searchBean.getIndex())) {
m_searchBean.setIndex(getWp().getSettings().getUserSettings().getWorkplaceSearchIndexName());
}
m_searchBean.setMatchesPerPage(getWp().getSettings().getUserSettings().getExplorerFileEntries());
m_searchBean.setSearchPage(Integer.parseInt(params.get(I_CmsListResourceCollector.PARAM_PAGE)));
// set search roots
List<String> resources = getResourceNamesFromParam(params);
String[] searchRoots = new String[resources.size()];
resources.toArray(searchRoots);
for (int i = 0; i < searchRoots.length; i++) {
searchRoots[i] = getWp().getCms().addSiteRoot(searchRoots[i]);
}
m_searchBean.setSearchRoots(searchRoots);
} else {
int page = Integer.parseInt(params.get(I_CmsListResourceCollector.PARAM_PAGE));
if (m_searchBean.getSearchPage() != page) {
m_searchBean.setSearchPage(page);
m_searchResults = null;
}
}
return m_searchBean;
} | [
"private",
"CmsSearch",
"getSearchBean",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"params",
")",
"{",
"if",
"(",
"m_searchBean",
"==",
"null",
")",
"{",
"m_searchBean",
"=",
"new",
"CmsSearch",
"(",
")",
";",
"m_searchBean",
".",
"init",
"(",
"getWp",
"(",
")",
".",
"getCms",
"(",
")",
")",
";",
"m_searchBean",
".",
"setParameters",
"(",
"getSearchParameters",
"(",
"params",
")",
")",
";",
"if",
"(",
"CmsStringUtil",
".",
"isEmptyOrWhitespaceOnly",
"(",
"m_searchBean",
".",
"getIndex",
"(",
")",
")",
")",
"{",
"m_searchBean",
".",
"setIndex",
"(",
"getWp",
"(",
")",
".",
"getSettings",
"(",
")",
".",
"getUserSettings",
"(",
")",
".",
"getWorkplaceSearchIndexName",
"(",
")",
")",
";",
"}",
"m_searchBean",
".",
"setMatchesPerPage",
"(",
"getWp",
"(",
")",
".",
"getSettings",
"(",
")",
".",
"getUserSettings",
"(",
")",
".",
"getExplorerFileEntries",
"(",
")",
")",
";",
"m_searchBean",
".",
"setSearchPage",
"(",
"Integer",
".",
"parseInt",
"(",
"params",
".",
"get",
"(",
"I_CmsListResourceCollector",
".",
"PARAM_PAGE",
")",
")",
")",
";",
"// set search roots",
"List",
"<",
"String",
">",
"resources",
"=",
"getResourceNamesFromParam",
"(",
"params",
")",
";",
"String",
"[",
"]",
"searchRoots",
"=",
"new",
"String",
"[",
"resources",
".",
"size",
"(",
")",
"]",
";",
"resources",
".",
"toArray",
"(",
"searchRoots",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"searchRoots",
".",
"length",
";",
"i",
"++",
")",
"{",
"searchRoots",
"[",
"i",
"]",
"=",
"getWp",
"(",
")",
".",
"getCms",
"(",
")",
".",
"addSiteRoot",
"(",
"searchRoots",
"[",
"i",
"]",
")",
";",
"}",
"m_searchBean",
".",
"setSearchRoots",
"(",
"searchRoots",
")",
";",
"}",
"else",
"{",
"int",
"page",
"=",
"Integer",
".",
"parseInt",
"(",
"params",
".",
"get",
"(",
"I_CmsListResourceCollector",
".",
"PARAM_PAGE",
")",
")",
";",
"if",
"(",
"m_searchBean",
".",
"getSearchPage",
"(",
")",
"!=",
"page",
")",
"{",
"m_searchBean",
".",
"setSearchPage",
"(",
"page",
")",
";",
"m_searchResults",
"=",
"null",
";",
"}",
"}",
"return",
"m_searchBean",
";",
"}"
] | Returns the search bean object.<p>
@param params the parameter map
@return the used search bean | [
"Returns",
"the",
"search",
"bean",
"object",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-modules/org/opencms/workplace/search/CmsSearchResourcesCollector.java#L264-L291 |
Erudika/para | para-server/src/main/java/com/erudika/para/security/filters/PasswordAuthFilter.java | PasswordAuthFilter.getOrCreateUser | public UserAuthentication getOrCreateUser(App app, String accessToken) {
"""
Authenticates or creates a {@link User} using an email and password.
Access token must be in the format: "email:full_name:password" or "email::password_hash"
@param app the app where the user will be created, use null for root app
@param accessToken token in the format "email:full_name:password" or "email::password_hash"
@return {@link UserAuthentication} object or null if something went wrong
"""
UserAuthentication userAuth = null;
User user = new User();
if (accessToken != null && accessToken.contains(Config.SEPARATOR)) {
String[] parts = accessToken.split(Config.SEPARATOR, 3);
String email = parts[0];
String name = parts[1];
String pass = (parts.length > 2) ? parts[2] : "";
String appid = (app == null) ? null : app.getAppIdentifier();
User u = new User();
u.setAppid(appid);
u.setIdentifier(email);
u.setPassword(pass);
u.setEmail(email);
// NOTE TO SELF:
// do not overwrite 'u' here - overwrites the password hash!
user = User.readUserForIdentifier(u);
if (user == null) {
user = new User();
user.setActive(Config.getConfigBoolean("security.allow_unverified_emails", false));
user.setAppid(appid);
user.setName(name);
user.setIdentifier(email);
user.setEmail(email);
user.setPassword(pass);
if (user.create() != null) {
// allow temporary first-time login without verifying email address
userAuth = new UserAuthentication(new AuthenticatedUserDetails(user));
}
} else if (User.passwordMatches(u)) {
userAuth = new UserAuthentication(new AuthenticatedUserDetails(user));
}
}
return SecurityUtils.checkIfActive(userAuth, user, false);
} | java | public UserAuthentication getOrCreateUser(App app, String accessToken) {
UserAuthentication userAuth = null;
User user = new User();
if (accessToken != null && accessToken.contains(Config.SEPARATOR)) {
String[] parts = accessToken.split(Config.SEPARATOR, 3);
String email = parts[0];
String name = parts[1];
String pass = (parts.length > 2) ? parts[2] : "";
String appid = (app == null) ? null : app.getAppIdentifier();
User u = new User();
u.setAppid(appid);
u.setIdentifier(email);
u.setPassword(pass);
u.setEmail(email);
// NOTE TO SELF:
// do not overwrite 'u' here - overwrites the password hash!
user = User.readUserForIdentifier(u);
if (user == null) {
user = new User();
user.setActive(Config.getConfigBoolean("security.allow_unverified_emails", false));
user.setAppid(appid);
user.setName(name);
user.setIdentifier(email);
user.setEmail(email);
user.setPassword(pass);
if (user.create() != null) {
// allow temporary first-time login without verifying email address
userAuth = new UserAuthentication(new AuthenticatedUserDetails(user));
}
} else if (User.passwordMatches(u)) {
userAuth = new UserAuthentication(new AuthenticatedUserDetails(user));
}
}
return SecurityUtils.checkIfActive(userAuth, user, false);
} | [
"public",
"UserAuthentication",
"getOrCreateUser",
"(",
"App",
"app",
",",
"String",
"accessToken",
")",
"{",
"UserAuthentication",
"userAuth",
"=",
"null",
";",
"User",
"user",
"=",
"new",
"User",
"(",
")",
";",
"if",
"(",
"accessToken",
"!=",
"null",
"&&",
"accessToken",
".",
"contains",
"(",
"Config",
".",
"SEPARATOR",
")",
")",
"{",
"String",
"[",
"]",
"parts",
"=",
"accessToken",
".",
"split",
"(",
"Config",
".",
"SEPARATOR",
",",
"3",
")",
";",
"String",
"email",
"=",
"parts",
"[",
"0",
"]",
";",
"String",
"name",
"=",
"parts",
"[",
"1",
"]",
";",
"String",
"pass",
"=",
"(",
"parts",
".",
"length",
">",
"2",
")",
"?",
"parts",
"[",
"2",
"]",
":",
"\"\"",
";",
"String",
"appid",
"=",
"(",
"app",
"==",
"null",
")",
"?",
"null",
":",
"app",
".",
"getAppIdentifier",
"(",
")",
";",
"User",
"u",
"=",
"new",
"User",
"(",
")",
";",
"u",
".",
"setAppid",
"(",
"appid",
")",
";",
"u",
".",
"setIdentifier",
"(",
"email",
")",
";",
"u",
".",
"setPassword",
"(",
"pass",
")",
";",
"u",
".",
"setEmail",
"(",
"email",
")",
";",
"// NOTE TO SELF:",
"// do not overwrite 'u' here - overwrites the password hash!",
"user",
"=",
"User",
".",
"readUserForIdentifier",
"(",
"u",
")",
";",
"if",
"(",
"user",
"==",
"null",
")",
"{",
"user",
"=",
"new",
"User",
"(",
")",
";",
"user",
".",
"setActive",
"(",
"Config",
".",
"getConfigBoolean",
"(",
"\"security.allow_unverified_emails\"",
",",
"false",
")",
")",
";",
"user",
".",
"setAppid",
"(",
"appid",
")",
";",
"user",
".",
"setName",
"(",
"name",
")",
";",
"user",
".",
"setIdentifier",
"(",
"email",
")",
";",
"user",
".",
"setEmail",
"(",
"email",
")",
";",
"user",
".",
"setPassword",
"(",
"pass",
")",
";",
"if",
"(",
"user",
".",
"create",
"(",
")",
"!=",
"null",
")",
"{",
"// allow temporary first-time login without verifying email address",
"userAuth",
"=",
"new",
"UserAuthentication",
"(",
"new",
"AuthenticatedUserDetails",
"(",
"user",
")",
")",
";",
"}",
"}",
"else",
"if",
"(",
"User",
".",
"passwordMatches",
"(",
"u",
")",
")",
"{",
"userAuth",
"=",
"new",
"UserAuthentication",
"(",
"new",
"AuthenticatedUserDetails",
"(",
"user",
")",
")",
";",
"}",
"}",
"return",
"SecurityUtils",
".",
"checkIfActive",
"(",
"userAuth",
",",
"user",
",",
"false",
")",
";",
"}"
] | Authenticates or creates a {@link User} using an email and password.
Access token must be in the format: "email:full_name:password" or "email::password_hash"
@param app the app where the user will be created, use null for root app
@param accessToken token in the format "email:full_name:password" or "email::password_hash"
@return {@link UserAuthentication} object or null if something went wrong | [
"Authenticates",
"or",
"creates",
"a",
"{"
] | train | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-server/src/main/java/com/erudika/para/security/filters/PasswordAuthFilter.java#L100-L135 |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/admin/internal/JsMainImpl.java | JsMainImpl.stopMessagingEngine | private void stopMessagingEngine(String busName, String name, int mode)
throws Exception {
"""
Stop a messaging engine
@param busName
@param name
@param mode
"""
String thisMethodName = CLASS_NAME
+ ".stopMessagingEngine(String, String, int)";
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
SibTr.entry(tc, thisMethodName, new Object[] { busName, name,
Integer.toString(mode) });
}
BaseMessagingEngineImpl me = (BaseMessagingEngineImpl) getMessagingEngine(
busName, name);
if (me != null) {
me.stopConditional(mode);
} else {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
SibTr.debug(tc, "Unable to locate engine <bus=" + busName
+ " name=" + name + ">");
throw new Exception("The messaging engine <bus=" + busName
+ " name=" + name + "> does not exist");
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
SibTr.exit(tc, thisMethodName);
}
} | java | private void stopMessagingEngine(String busName, String name, int mode)
throws Exception {
String thisMethodName = CLASS_NAME
+ ".stopMessagingEngine(String, String, int)";
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
SibTr.entry(tc, thisMethodName, new Object[] { busName, name,
Integer.toString(mode) });
}
BaseMessagingEngineImpl me = (BaseMessagingEngineImpl) getMessagingEngine(
busName, name);
if (me != null) {
me.stopConditional(mode);
} else {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
SibTr.debug(tc, "Unable to locate engine <bus=" + busName
+ " name=" + name + ">");
throw new Exception("The messaging engine <bus=" + busName
+ " name=" + name + "> does not exist");
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
SibTr.exit(tc, thisMethodName);
}
} | [
"private",
"void",
"stopMessagingEngine",
"(",
"String",
"busName",
",",
"String",
"name",
",",
"int",
"mode",
")",
"throws",
"Exception",
"{",
"String",
"thisMethodName",
"=",
"CLASS_NAME",
"+",
"\".stopMessagingEngine(String, String, int)\"",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"{",
"SibTr",
".",
"entry",
"(",
"tc",
",",
"thisMethodName",
",",
"new",
"Object",
"[",
"]",
"{",
"busName",
",",
"name",
",",
"Integer",
".",
"toString",
"(",
"mode",
")",
"}",
")",
";",
"}",
"BaseMessagingEngineImpl",
"me",
"=",
"(",
"BaseMessagingEngineImpl",
")",
"getMessagingEngine",
"(",
"busName",
",",
"name",
")",
";",
"if",
"(",
"me",
"!=",
"null",
")",
"{",
"me",
".",
"stopConditional",
"(",
"mode",
")",
";",
"}",
"else",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"SibTr",
".",
"debug",
"(",
"tc",
",",
"\"Unable to locate engine <bus=\"",
"+",
"busName",
"+",
"\" name=\"",
"+",
"name",
"+",
"\">\"",
")",
";",
"throw",
"new",
"Exception",
"(",
"\"The messaging engine <bus=\"",
"+",
"busName",
"+",
"\" name=\"",
"+",
"name",
"+",
"\"> does not exist\"",
")",
";",
"}",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"{",
"SibTr",
".",
"exit",
"(",
"tc",
",",
"thisMethodName",
")",
";",
"}",
"}"
] | Stop a messaging engine
@param busName
@param name
@param mode | [
"Stop",
"a",
"messaging",
"engine"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/admin/internal/JsMainImpl.java#L909-L935 |
ops4j/org.ops4j.pax.logging | pax-logging-service/src/main/java/org/apache/log4j/Category.java | Category.forcedLog | protected void forcedLog(String fqcn, Priority level, Object message, Throwable t) {
"""
This method creates a new logging event and logs the event without further checks.
"""
callAppenders(new LoggingEvent(fqcn, this, level, message, t));
} | java | protected void forcedLog(String fqcn, Priority level, Object message, Throwable t) {
callAppenders(new LoggingEvent(fqcn, this, level, message, t));
} | [
"protected",
"void",
"forcedLog",
"(",
"String",
"fqcn",
",",
"Priority",
"level",
",",
"Object",
"message",
",",
"Throwable",
"t",
")",
"{",
"callAppenders",
"(",
"new",
"LoggingEvent",
"(",
"fqcn",
",",
"this",
",",
"level",
",",
"message",
",",
"t",
")",
")",
";",
"}"
] | This method creates a new logging event and logs the event without further checks. | [
"This",
"method",
"creates",
"a",
"new",
"logging",
"event",
"and",
"logs",
"the",
"event",
"without",
"further",
"checks",
"."
] | train | https://github.com/ops4j/org.ops4j.pax.logging/blob/493de4e1db4fe9f981f3dd78b8e40e5bf2b2e59d/pax-logging-service/src/main/java/org/apache/log4j/Category.java#L332-L334 |
kuali/ojb-1.0.4 | src/xdoclet/java/src/xdoclet/modules/ojb/model/PropertyHelper.java | PropertyHelper.toBoolean | public static boolean toBoolean(String value, boolean defaultValue) {
"""
Determines whether the boolean value of the given string value.
@param value The value
@param defaultValue The boolean value to use if the string value is neither 'true' nor 'false'
@return The boolean value of the string
"""
return "true".equals(value) ? true : ("false".equals(value) ? false : defaultValue);
} | java | public static boolean toBoolean(String value, boolean defaultValue)
{
return "true".equals(value) ? true : ("false".equals(value) ? false : defaultValue);
} | [
"public",
"static",
"boolean",
"toBoolean",
"(",
"String",
"value",
",",
"boolean",
"defaultValue",
")",
"{",
"return",
"\"true\"",
".",
"equals",
"(",
"value",
")",
"?",
"true",
":",
"(",
"\"false\"",
".",
"equals",
"(",
"value",
")",
"?",
"false",
":",
"defaultValue",
")",
";",
"}"
] | Determines whether the boolean value of the given string value.
@param value The value
@param defaultValue The boolean value to use if the string value is neither 'true' nor 'false'
@return The boolean value of the string | [
"Determines",
"whether",
"the",
"boolean",
"value",
"of",
"the",
"given",
"string",
"value",
"."
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/xdoclet/java/src/xdoclet/modules/ojb/model/PropertyHelper.java#L256-L259 |
Azure/azure-sdk-for-java | batch/data-plane/src/main/java/com/microsoft/azure/batch/protocol/implementation/PoolsImpl.java | PoolsImpl.evaluateAutoScale | public AutoScaleRun evaluateAutoScale(String poolId, String autoScaleFormula, PoolEvaluateAutoScaleOptions poolEvaluateAutoScaleOptions) {
"""
Gets the result of evaluating an automatic scaling formula on the pool.
This API is primarily for validating an autoscale formula, as it simply returns the result without applying the formula to the pool. The pool must have auto scaling enabled in order to evaluate a formula.
@param poolId The ID of the pool on which to evaluate the automatic scaling formula.
@param autoScaleFormula The formula for the desired number of compute nodes in the pool. The formula is validated and its results calculated, but it is not applied to the pool. To apply the formula to the pool, 'Enable automatic scaling on a pool'. For more information about specifying this formula, see Automatically scale compute nodes in an Azure Batch pool (https://azure.microsoft.com/en-us/documentation/articles/batch-automatic-scaling).
@param poolEvaluateAutoScaleOptions Additional parameters for the operation
@throws IllegalArgumentException thrown if parameters fail the validation
@throws BatchErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the AutoScaleRun object if successful.
"""
return evaluateAutoScaleWithServiceResponseAsync(poolId, autoScaleFormula, poolEvaluateAutoScaleOptions).toBlocking().single().body();
} | java | public AutoScaleRun evaluateAutoScale(String poolId, String autoScaleFormula, PoolEvaluateAutoScaleOptions poolEvaluateAutoScaleOptions) {
return evaluateAutoScaleWithServiceResponseAsync(poolId, autoScaleFormula, poolEvaluateAutoScaleOptions).toBlocking().single().body();
} | [
"public",
"AutoScaleRun",
"evaluateAutoScale",
"(",
"String",
"poolId",
",",
"String",
"autoScaleFormula",
",",
"PoolEvaluateAutoScaleOptions",
"poolEvaluateAutoScaleOptions",
")",
"{",
"return",
"evaluateAutoScaleWithServiceResponseAsync",
"(",
"poolId",
",",
"autoScaleFormula",
",",
"poolEvaluateAutoScaleOptions",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Gets the result of evaluating an automatic scaling formula on the pool.
This API is primarily for validating an autoscale formula, as it simply returns the result without applying the formula to the pool. The pool must have auto scaling enabled in order to evaluate a formula.
@param poolId The ID of the pool on which to evaluate the automatic scaling formula.
@param autoScaleFormula The formula for the desired number of compute nodes in the pool. The formula is validated and its results calculated, but it is not applied to the pool. To apply the formula to the pool, 'Enable automatic scaling on a pool'. For more information about specifying this formula, see Automatically scale compute nodes in an Azure Batch pool (https://azure.microsoft.com/en-us/documentation/articles/batch-automatic-scaling).
@param poolEvaluateAutoScaleOptions Additional parameters for the operation
@throws IllegalArgumentException thrown if parameters fail the validation
@throws BatchErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the AutoScaleRun object if successful. | [
"Gets",
"the",
"result",
"of",
"evaluating",
"an",
"automatic",
"scaling",
"formula",
"on",
"the",
"pool",
".",
"This",
"API",
"is",
"primarily",
"for",
"validating",
"an",
"autoscale",
"formula",
"as",
"it",
"simply",
"returns",
"the",
"result",
"without",
"applying",
"the",
"formula",
"to",
"the",
"pool",
".",
"The",
"pool",
"must",
"have",
"auto",
"scaling",
"enabled",
"in",
"order",
"to",
"evaluate",
"a",
"formula",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batch/data-plane/src/main/java/com/microsoft/azure/batch/protocol/implementation/PoolsImpl.java#L2605-L2607 |
Impetus/Kundera | src/kundera-kudu/src/main/java/com/impetus/client/kudu/KuduDBDataHandler.java | KuduDBDataHandler.getEqualComparisonPredicate | public static KuduPredicate getEqualComparisonPredicate(ColumnSchema column, Type type, Object key) {
"""
Gets the equal comparison predicate.
@param column
the column
@param type
the type
@param key
the key
@return the equal comparison predicate
"""
return getPredicate(column, KuduPredicate.ComparisonOp.EQUAL, type, key);
} | java | public static KuduPredicate getEqualComparisonPredicate(ColumnSchema column, Type type, Object key)
{
return getPredicate(column, KuduPredicate.ComparisonOp.EQUAL, type, key);
} | [
"public",
"static",
"KuduPredicate",
"getEqualComparisonPredicate",
"(",
"ColumnSchema",
"column",
",",
"Type",
"type",
",",
"Object",
"key",
")",
"{",
"return",
"getPredicate",
"(",
"column",
",",
"KuduPredicate",
".",
"ComparisonOp",
".",
"EQUAL",
",",
"type",
",",
"key",
")",
";",
"}"
] | Gets the equal comparison predicate.
@param column
the column
@param type
the type
@param key
the key
@return the equal comparison predicate | [
"Gets",
"the",
"equal",
"comparison",
"predicate",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-kudu/src/main/java/com/impetus/client/kudu/KuduDBDataHandler.java#L168-L172 |
landawn/AbacusUtil | src/com/landawn/abacus/util/Primitives.java | Primitives.unbox | public static short[] unbox(final Short[] a, final short valueForNull) {
"""
<p>
Converts an array of object Short to primitives handling {@code null}.
</p>
<p>
This method returns {@code null} for a {@code null} input array.
</p>
@param a
a {@code Short} array, may be {@code null}
@param valueForNull
the value to insert if {@code null} found
@return a {@code byte} array, {@code null} if null array input
"""
if (a == null) {
return null;
}
return unbox(a, 0, a.length, valueForNull);
} | java | public static short[] unbox(final Short[] a, final short valueForNull) {
if (a == null) {
return null;
}
return unbox(a, 0, a.length, valueForNull);
} | [
"public",
"static",
"short",
"[",
"]",
"unbox",
"(",
"final",
"Short",
"[",
"]",
"a",
",",
"final",
"short",
"valueForNull",
")",
"{",
"if",
"(",
"a",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"unbox",
"(",
"a",
",",
"0",
",",
"a",
".",
"length",
",",
"valueForNull",
")",
";",
"}"
] | <p>
Converts an array of object Short to primitives handling {@code null}.
</p>
<p>
This method returns {@code null} for a {@code null} input array.
</p>
@param a
a {@code Short} array, may be {@code null}
@param valueForNull
the value to insert if {@code null} found
@return a {@code byte} array, {@code null} if null array input | [
"<p",
">",
"Converts",
"an",
"array",
"of",
"object",
"Short",
"to",
"primitives",
"handling",
"{",
"@code",
"null",
"}",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/util/Primitives.java#L960-L966 |
larsga/Duke | duke-core/src/main/java/no/priv/garshol/duke/utils/StringUtils.java | StringUtils.normalizeWS | public static String normalizeWS(String value) {
"""
Removes trailing and leading whitespace, and also reduces each
sequence of internal whitespace to a single space.
"""
char[] tmp = new char[value.length()];
int pos = 0;
boolean prevws = false;
for (int ix = 0; ix < tmp.length; ix++) {
char ch = value.charAt(ix);
if (ch != ' ' && ch != '\t' && ch != '\n' && ch != '\r') {
if (prevws && pos != 0)
tmp[pos++] = ' ';
tmp[pos++] = ch;
prevws = false;
} else
prevws = true;
}
return new String(tmp, 0, pos);
} | java | public static String normalizeWS(String value) {
char[] tmp = new char[value.length()];
int pos = 0;
boolean prevws = false;
for (int ix = 0; ix < tmp.length; ix++) {
char ch = value.charAt(ix);
if (ch != ' ' && ch != '\t' && ch != '\n' && ch != '\r') {
if (prevws && pos != 0)
tmp[pos++] = ' ';
tmp[pos++] = ch;
prevws = false;
} else
prevws = true;
}
return new String(tmp, 0, pos);
} | [
"public",
"static",
"String",
"normalizeWS",
"(",
"String",
"value",
")",
"{",
"char",
"[",
"]",
"tmp",
"=",
"new",
"char",
"[",
"value",
".",
"length",
"(",
")",
"]",
";",
"int",
"pos",
"=",
"0",
";",
"boolean",
"prevws",
"=",
"false",
";",
"for",
"(",
"int",
"ix",
"=",
"0",
";",
"ix",
"<",
"tmp",
".",
"length",
";",
"ix",
"++",
")",
"{",
"char",
"ch",
"=",
"value",
".",
"charAt",
"(",
"ix",
")",
";",
"if",
"(",
"ch",
"!=",
"'",
"'",
"&&",
"ch",
"!=",
"'",
"'",
"&&",
"ch",
"!=",
"'",
"'",
"&&",
"ch",
"!=",
"'",
"'",
")",
"{",
"if",
"(",
"prevws",
"&&",
"pos",
"!=",
"0",
")",
"tmp",
"[",
"pos",
"++",
"]",
"=",
"'",
"'",
";",
"tmp",
"[",
"pos",
"++",
"]",
"=",
"ch",
";",
"prevws",
"=",
"false",
";",
"}",
"else",
"prevws",
"=",
"true",
";",
"}",
"return",
"new",
"String",
"(",
"tmp",
",",
"0",
",",
"pos",
")",
";",
"}"
] | Removes trailing and leading whitespace, and also reduces each
sequence of internal whitespace to a single space. | [
"Removes",
"trailing",
"and",
"leading",
"whitespace",
"and",
"also",
"reduces",
"each",
"sequence",
"of",
"internal",
"whitespace",
"to",
"a",
"single",
"space",
"."
] | train | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-core/src/main/java/no/priv/garshol/duke/utils/StringUtils.java#L31-L47 |
ManfredTremmel/gwt-bean-validators | mt-bean-validators/src/main/java/de/knightsoftnet/validators/shared/util/BeanPropertyReaderUtil.java | BeanPropertyReaderUtil.getNullSaveStringProperty | public static String getNullSaveStringProperty(final Object pbean, final String pname)
throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
"""
<p>
Return the value of the specified property of the specified bean, no matter which property
reference format is used, as a String.
</p>
<p>
If there is a null value in path hierarchy, exception is cached and null returned.
</p>
@param pbean Bean whose property is to be extracted
@param pname Possibly indexed and/or nested name of the property to be extracted
@return The property's value, converted to a String
@exception IllegalAccessException if the caller does not have access to the property accessor
method
@exception InvocationTargetException if the property accessor method throws an exception
@exception NoSuchMethodException if an accessor method for this property cannot be found
@see BeanUtilsBean#getProperty
"""
String property;
try {
property = BeanUtils.getProperty(pbean, pname);
} catch (final NestedNullException pexception) {
property = null;
}
return property;
} | java | public static String getNullSaveStringProperty(final Object pbean, final String pname)
throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
String property;
try {
property = BeanUtils.getProperty(pbean, pname);
} catch (final NestedNullException pexception) {
property = null;
}
return property;
} | [
"public",
"static",
"String",
"getNullSaveStringProperty",
"(",
"final",
"Object",
"pbean",
",",
"final",
"String",
"pname",
")",
"throws",
"IllegalAccessException",
",",
"InvocationTargetException",
",",
"NoSuchMethodException",
"{",
"String",
"property",
";",
"try",
"{",
"property",
"=",
"BeanUtils",
".",
"getProperty",
"(",
"pbean",
",",
"pname",
")",
";",
"}",
"catch",
"(",
"final",
"NestedNullException",
"pexception",
")",
"{",
"property",
"=",
"null",
";",
"}",
"return",
"property",
";",
"}"
] | <p>
Return the value of the specified property of the specified bean, no matter which property
reference format is used, as a String.
</p>
<p>
If there is a null value in path hierarchy, exception is cached and null returned.
</p>
@param pbean Bean whose property is to be extracted
@param pname Possibly indexed and/or nested name of the property to be extracted
@return The property's value, converted to a String
@exception IllegalAccessException if the caller does not have access to the property accessor
method
@exception InvocationTargetException if the property accessor method throws an exception
@exception NoSuchMethodException if an accessor method for this property cannot be found
@see BeanUtilsBean#getProperty | [
"<p",
">",
"Return",
"the",
"value",
"of",
"the",
"specified",
"property",
"of",
"the",
"specified",
"bean",
"no",
"matter",
"which",
"property",
"reference",
"format",
"is",
"used",
"as",
"a",
"String",
".",
"<",
"/",
"p",
">",
"<p",
">",
"If",
"there",
"is",
"a",
"null",
"value",
"in",
"path",
"hierarchy",
"exception",
"is",
"cached",
"and",
"null",
"returned",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/ManfredTremmel/gwt-bean-validators/blob/cff7a2c3d68c2d17bf9d3cc57c79cc16fa8b4d5c/mt-bean-validators/src/main/java/de/knightsoftnet/validators/shared/util/BeanPropertyReaderUtil.java#L59-L68 |
MTDdk/jawn | jawn-core/src/main/java/net/javapla/jawn/core/images/ImageHandlerBuilder.java | ImageHandlerBuilder.uniqueImagename | String uniqueImagename(String folder, String filename) {
"""
Calculates a unique filename located in the image upload folder.
WARNING: not threadsafe! Another file with the calculated name might very well get written onto disk first after this name is found
@param filename
@return Outputs the relative path of the calculated filename.
"""
String buildFileName = filename;//.replace(' ', '_');
while ( (new File(folder , buildFileName)).exists())
buildFileName = fn.increment();
return buildFileName;//output.getPath();
} | java | String uniqueImagename(String folder, String filename) {
String buildFileName = filename;//.replace(' ', '_');
while ( (new File(folder , buildFileName)).exists())
buildFileName = fn.increment();
return buildFileName;//output.getPath();
} | [
"String",
"uniqueImagename",
"(",
"String",
"folder",
",",
"String",
"filename",
")",
"{",
"String",
"buildFileName",
"=",
"filename",
";",
"//.replace(' ', '_');",
"while",
"(",
"(",
"new",
"File",
"(",
"folder",
",",
"buildFileName",
")",
")",
".",
"exists",
"(",
")",
")",
"buildFileName",
"=",
"fn",
".",
"increment",
"(",
")",
";",
"return",
"buildFileName",
";",
"//output.getPath();",
"}"
] | Calculates a unique filename located in the image upload folder.
WARNING: not threadsafe! Another file with the calculated name might very well get written onto disk first after this name is found
@param filename
@return Outputs the relative path of the calculated filename. | [
"Calculates",
"a",
"unique",
"filename",
"located",
"in",
"the",
"image",
"upload",
"folder",
"."
] | train | https://github.com/MTDdk/jawn/blob/4ec2d09b97d413efdead7487e6075e5bfd13b925/jawn-core/src/main/java/net/javapla/jawn/core/images/ImageHandlerBuilder.java#L327-L334 |
jmeetsma/Iglu-Http | src/main/java/org/ijsberg/iglu/server/http/filter/WebAppEntryPoint.java | WebAppEntryPoint.onSessionUpdate | public void onSessionUpdate(Request currentRequest, Session session) {
"""
Notification of a session registration event.
@param session
"""
HttpServletResponse response = (HttpServletResponse)httpResponse.get();
storeSessionDataInCookie(SESSION_TOKEN_KEY, session.getToken(), response);
if(session.getUser(/*realm.getId()*/) != null)
{
storeSessionDataInCookie(USER_ID_KEY, session.getUser(/*realm.getId()*/).getId(), response);
}
else
{
storeSessionDataInCookie(USER_ID_KEY, null, response);
}
} | java | public void onSessionUpdate(Request currentRequest, Session session)
{
HttpServletResponse response = (HttpServletResponse)httpResponse.get();
storeSessionDataInCookie(SESSION_TOKEN_KEY, session.getToken(), response);
if(session.getUser(/*realm.getId()*/) != null)
{
storeSessionDataInCookie(USER_ID_KEY, session.getUser(/*realm.getId()*/).getId(), response);
}
else
{
storeSessionDataInCookie(USER_ID_KEY, null, response);
}
} | [
"public",
"void",
"onSessionUpdate",
"(",
"Request",
"currentRequest",
",",
"Session",
"session",
")",
"{",
"HttpServletResponse",
"response",
"=",
"(",
"HttpServletResponse",
")",
"httpResponse",
".",
"get",
"(",
")",
";",
"storeSessionDataInCookie",
"(",
"SESSION_TOKEN_KEY",
",",
"session",
".",
"getToken",
"(",
")",
",",
"response",
")",
";",
"if",
"(",
"session",
".",
"getUser",
"(",
"/*realm.getId()*/",
")",
"!=",
"null",
")",
"{",
"storeSessionDataInCookie",
"(",
"USER_ID_KEY",
",",
"session",
".",
"getUser",
"(",
"/*realm.getId()*/",
")",
".",
"getId",
"(",
")",
",",
"response",
")",
";",
"}",
"else",
"{",
"storeSessionDataInCookie",
"(",
"USER_ID_KEY",
",",
"null",
",",
"response",
")",
";",
"}",
"}"
] | Notification of a session registration event.
@param session | [
"Notification",
"of",
"a",
"session",
"registration",
"event",
"."
] | train | https://github.com/jmeetsma/Iglu-Http/blob/5b5ed3b417285dc79b7aa013bf2340bb5ba1ffbe/src/main/java/org/ijsberg/iglu/server/http/filter/WebAppEntryPoint.java#L116-L128 |
alkacon/opencms-core | src/org/opencms/search/solr/spellchecking/CmsSolrSpellchecker.java | CmsSolrSpellchecker.getInstance | public static CmsSolrSpellchecker getInstance(CoreContainer container) {
"""
Return an instance of this class.
@param container Solr CoreContainer container object in order to create a server object.
@return instance of CmsSolrSpellchecker
"""
if (null == instance) {
synchronized (CmsSolrSpellchecker.class) {
if (null == instance) {
@SuppressWarnings("resource")
SolrCore spellcheckCore = container.getCore(CmsSolrSpellchecker.SPELLCHECKER_INDEX_CORE);
if (spellcheckCore == null) {
LOG.error(
Messages.get().getBundle().key(
Messages.ERR_SPELLCHECK_CORE_NOT_AVAILABLE_1,
CmsSolrSpellchecker.SPELLCHECKER_INDEX_CORE));
return null;
}
instance = new CmsSolrSpellchecker(container, spellcheckCore);
}
}
}
return instance;
} | java | public static CmsSolrSpellchecker getInstance(CoreContainer container) {
if (null == instance) {
synchronized (CmsSolrSpellchecker.class) {
if (null == instance) {
@SuppressWarnings("resource")
SolrCore spellcheckCore = container.getCore(CmsSolrSpellchecker.SPELLCHECKER_INDEX_CORE);
if (spellcheckCore == null) {
LOG.error(
Messages.get().getBundle().key(
Messages.ERR_SPELLCHECK_CORE_NOT_AVAILABLE_1,
CmsSolrSpellchecker.SPELLCHECKER_INDEX_CORE));
return null;
}
instance = new CmsSolrSpellchecker(container, spellcheckCore);
}
}
}
return instance;
} | [
"public",
"static",
"CmsSolrSpellchecker",
"getInstance",
"(",
"CoreContainer",
"container",
")",
"{",
"if",
"(",
"null",
"==",
"instance",
")",
"{",
"synchronized",
"(",
"CmsSolrSpellchecker",
".",
"class",
")",
"{",
"if",
"(",
"null",
"==",
"instance",
")",
"{",
"@",
"SuppressWarnings",
"(",
"\"resource\"",
")",
"SolrCore",
"spellcheckCore",
"=",
"container",
".",
"getCore",
"(",
"CmsSolrSpellchecker",
".",
"SPELLCHECKER_INDEX_CORE",
")",
";",
"if",
"(",
"spellcheckCore",
"==",
"null",
")",
"{",
"LOG",
".",
"error",
"(",
"Messages",
".",
"get",
"(",
")",
".",
"getBundle",
"(",
")",
".",
"key",
"(",
"Messages",
".",
"ERR_SPELLCHECK_CORE_NOT_AVAILABLE_1",
",",
"CmsSolrSpellchecker",
".",
"SPELLCHECKER_INDEX_CORE",
")",
")",
";",
"return",
"null",
";",
"}",
"instance",
"=",
"new",
"CmsSolrSpellchecker",
"(",
"container",
",",
"spellcheckCore",
")",
";",
"}",
"}",
"}",
"return",
"instance",
";",
"}"
] | Return an instance of this class.
@param container Solr CoreContainer container object in order to create a server object.
@return instance of CmsSolrSpellchecker | [
"Return",
"an",
"instance",
"of",
"this",
"class",
"."
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/search/solr/spellchecking/CmsSolrSpellchecker.java#L155-L175 |
infinispan/infinispan | lucene/lucene-directory/src/main/java/org/infinispan/lucene/directory/DirectoryBuilder.java | DirectoryBuilder.newDirectoryInstance | public static BuildContext newDirectoryInstance(Cache<?, ?> metadataCache, Cache<?, ?> chunksCache, Cache<?, ?> distLocksCache, String indexName) {
"""
Starting point to create a Directory instance.
@param metadataCache contains the metadata of stored elements
@param chunksCache cache containing the bulk of the index; this is the larger part of data
@param distLocksCache cache to store locks; should be replicated and not using a persistent CacheStore
@param indexName identifies the index; you can store different indexes in the same set of caches using
different identifiers
"""
validateIndexCaches(indexName, metadataCache, chunksCache, distLocksCache);
return new DirectoryBuilderImpl(metadataCache, chunksCache, distLocksCache, indexName);
} | java | public static BuildContext newDirectoryInstance(Cache<?, ?> metadataCache, Cache<?, ?> chunksCache, Cache<?, ?> distLocksCache, String indexName) {
validateIndexCaches(indexName, metadataCache, chunksCache, distLocksCache);
return new DirectoryBuilderImpl(metadataCache, chunksCache, distLocksCache, indexName);
} | [
"public",
"static",
"BuildContext",
"newDirectoryInstance",
"(",
"Cache",
"<",
"?",
",",
"?",
">",
"metadataCache",
",",
"Cache",
"<",
"?",
",",
"?",
">",
"chunksCache",
",",
"Cache",
"<",
"?",
",",
"?",
">",
"distLocksCache",
",",
"String",
"indexName",
")",
"{",
"validateIndexCaches",
"(",
"indexName",
",",
"metadataCache",
",",
"chunksCache",
",",
"distLocksCache",
")",
";",
"return",
"new",
"DirectoryBuilderImpl",
"(",
"metadataCache",
",",
"chunksCache",
",",
"distLocksCache",
",",
"indexName",
")",
";",
"}"
] | Starting point to create a Directory instance.
@param metadataCache contains the metadata of stored elements
@param chunksCache cache containing the bulk of the index; this is the larger part of data
@param distLocksCache cache to store locks; should be replicated and not using a persistent CacheStore
@param indexName identifies the index; you can store different indexes in the same set of caches using
different identifiers | [
"Starting",
"point",
"to",
"create",
"a",
"Directory",
"instance",
"."
] | train | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/lucene/lucene-directory/src/main/java/org/infinispan/lucene/directory/DirectoryBuilder.java#L35-L38 |
pravega/pravega | segmentstore/server/src/main/java/io/pravega/segmentstore/server/writer/SegmentAggregator.java | SegmentAggregator.aggregateAppendOperation | private void aggregateAppendOperation(CachedStreamSegmentAppendOperation operation, AggregatedAppendOperation aggregatedAppend) {
"""
Aggregates the given operation by recording the fact that it exists in the current Aggregated Append.
An Aggregated Append cannot exceed a certain size, so if the given operation doesn't fit, it will need to
span multiple AggregatedAppends.
When aggregating, the SequenceNumber of the AggregatedAppend is the sequence number of the operation
that occupies its first byte. As such, getLowestUncommittedSequenceNumber() will always return the SeqNo
of that first operation that hasn't yet been fully flushed.
@param operation The operation to aggregate.
@param aggregatedAppend The AggregatedAppend to add to.
"""
long remainingLength = operation.getLength();
if (operation.getStreamSegmentOffset() < aggregatedAppend.getLastStreamSegmentOffset()) {
// The given operation begins before the AggregatedAppendOperation. This is likely due to it having been
// partially written to Storage prior to some recovery event. We must make sure we only include the part that
// has not yet been written.
long delta = aggregatedAppend.getLastStreamSegmentOffset() - operation.getStreamSegmentOffset();
remainingLength -= delta;
log.debug("{}: Skipping {} bytes from the beginning of '{}' since it has already been partially written to Storage.", this.traceObjectId, delta, operation);
}
// We only include the attributes in the first AggregatedAppend of an Append (it makes no difference if we had
// chosen to do so in the last one, as long as we are consistent).
aggregatedAppend.includeAttributes(getExtendedAttributes(operation));
while (remainingLength > 0) {
// All append lengths are integers, so it's safe to cast here.
int lengthToAdd = (int) Math.min(this.config.getMaxFlushSizeBytes() - aggregatedAppend.getLength(), remainingLength);
aggregatedAppend.increaseLength(lengthToAdd);
remainingLength -= lengthToAdd;
if (remainingLength > 0) {
// We still have data to add, which means we filled up the current AggregatedAppend; make a new one.
aggregatedAppend = new AggregatedAppendOperation(this.metadata.getId(), aggregatedAppend.getLastStreamSegmentOffset(), operation.getSequenceNumber());
this.operations.add(aggregatedAppend);
}
}
} | java | private void aggregateAppendOperation(CachedStreamSegmentAppendOperation operation, AggregatedAppendOperation aggregatedAppend) {
long remainingLength = operation.getLength();
if (operation.getStreamSegmentOffset() < aggregatedAppend.getLastStreamSegmentOffset()) {
// The given operation begins before the AggregatedAppendOperation. This is likely due to it having been
// partially written to Storage prior to some recovery event. We must make sure we only include the part that
// has not yet been written.
long delta = aggregatedAppend.getLastStreamSegmentOffset() - operation.getStreamSegmentOffset();
remainingLength -= delta;
log.debug("{}: Skipping {} bytes from the beginning of '{}' since it has already been partially written to Storage.", this.traceObjectId, delta, operation);
}
// We only include the attributes in the first AggregatedAppend of an Append (it makes no difference if we had
// chosen to do so in the last one, as long as we are consistent).
aggregatedAppend.includeAttributes(getExtendedAttributes(operation));
while (remainingLength > 0) {
// All append lengths are integers, so it's safe to cast here.
int lengthToAdd = (int) Math.min(this.config.getMaxFlushSizeBytes() - aggregatedAppend.getLength(), remainingLength);
aggregatedAppend.increaseLength(lengthToAdd);
remainingLength -= lengthToAdd;
if (remainingLength > 0) {
// We still have data to add, which means we filled up the current AggregatedAppend; make a new one.
aggregatedAppend = new AggregatedAppendOperation(this.metadata.getId(), aggregatedAppend.getLastStreamSegmentOffset(), operation.getSequenceNumber());
this.operations.add(aggregatedAppend);
}
}
} | [
"private",
"void",
"aggregateAppendOperation",
"(",
"CachedStreamSegmentAppendOperation",
"operation",
",",
"AggregatedAppendOperation",
"aggregatedAppend",
")",
"{",
"long",
"remainingLength",
"=",
"operation",
".",
"getLength",
"(",
")",
";",
"if",
"(",
"operation",
".",
"getStreamSegmentOffset",
"(",
")",
"<",
"aggregatedAppend",
".",
"getLastStreamSegmentOffset",
"(",
")",
")",
"{",
"// The given operation begins before the AggregatedAppendOperation. This is likely due to it having been",
"// partially written to Storage prior to some recovery event. We must make sure we only include the part that",
"// has not yet been written.",
"long",
"delta",
"=",
"aggregatedAppend",
".",
"getLastStreamSegmentOffset",
"(",
")",
"-",
"operation",
".",
"getStreamSegmentOffset",
"(",
")",
";",
"remainingLength",
"-=",
"delta",
";",
"log",
".",
"debug",
"(",
"\"{}: Skipping {} bytes from the beginning of '{}' since it has already been partially written to Storage.\"",
",",
"this",
".",
"traceObjectId",
",",
"delta",
",",
"operation",
")",
";",
"}",
"// We only include the attributes in the first AggregatedAppend of an Append (it makes no difference if we had",
"// chosen to do so in the last one, as long as we are consistent).",
"aggregatedAppend",
".",
"includeAttributes",
"(",
"getExtendedAttributes",
"(",
"operation",
")",
")",
";",
"while",
"(",
"remainingLength",
">",
"0",
")",
"{",
"// All append lengths are integers, so it's safe to cast here.",
"int",
"lengthToAdd",
"=",
"(",
"int",
")",
"Math",
".",
"min",
"(",
"this",
".",
"config",
".",
"getMaxFlushSizeBytes",
"(",
")",
"-",
"aggregatedAppend",
".",
"getLength",
"(",
")",
",",
"remainingLength",
")",
";",
"aggregatedAppend",
".",
"increaseLength",
"(",
"lengthToAdd",
")",
";",
"remainingLength",
"-=",
"lengthToAdd",
";",
"if",
"(",
"remainingLength",
">",
"0",
")",
"{",
"// We still have data to add, which means we filled up the current AggregatedAppend; make a new one.",
"aggregatedAppend",
"=",
"new",
"AggregatedAppendOperation",
"(",
"this",
".",
"metadata",
".",
"getId",
"(",
")",
",",
"aggregatedAppend",
".",
"getLastStreamSegmentOffset",
"(",
")",
",",
"operation",
".",
"getSequenceNumber",
"(",
")",
")",
";",
"this",
".",
"operations",
".",
"add",
"(",
"aggregatedAppend",
")",
";",
"}",
"}",
"}"
] | Aggregates the given operation by recording the fact that it exists in the current Aggregated Append.
An Aggregated Append cannot exceed a certain size, so if the given operation doesn't fit, it will need to
span multiple AggregatedAppends.
When aggregating, the SequenceNumber of the AggregatedAppend is the sequence number of the operation
that occupies its first byte. As such, getLowestUncommittedSequenceNumber() will always return the SeqNo
of that first operation that hasn't yet been fully flushed.
@param operation The operation to aggregate.
@param aggregatedAppend The AggregatedAppend to add to. | [
"Aggregates",
"the",
"given",
"operation",
"by",
"recording",
"the",
"fact",
"that",
"it",
"exists",
"in",
"the",
"current",
"Aggregated",
"Append",
".",
"An",
"Aggregated",
"Append",
"cannot",
"exceed",
"a",
"certain",
"size",
"so",
"if",
"the",
"given",
"operation",
"doesn",
"t",
"fit",
"it",
"will",
"need",
"to",
"span",
"multiple",
"AggregatedAppends",
".",
"When",
"aggregating",
"the",
"SequenceNumber",
"of",
"the",
"AggregatedAppend",
"is",
"the",
"sequence",
"number",
"of",
"the",
"operation",
"that",
"occupies",
"its",
"first",
"byte",
".",
"As",
"such",
"getLowestUncommittedSequenceNumber",
"()",
"will",
"always",
"return",
"the",
"SeqNo",
"of",
"that",
"first",
"operation",
"that",
"hasn",
"t",
"yet",
"been",
"fully",
"flushed",
"."
] | train | https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/segmentstore/server/src/main/java/io/pravega/segmentstore/server/writer/SegmentAggregator.java#L463-L488 |
Coveros/selenified | src/main/java/com/coveros/selenified/utilities/Reporter.java | Reporter.recordStep | private void recordStep(String action, String expectedResult, String actualResult, Boolean screenshot, Success success) {
"""
Records the performed step to the output file. This includes the action taken if any, the
expected result, and the actual result. If a screenshot is desired, indicate as such. If
a 'real' browser is not being used (not NONE or HTMLUNIT), then no screenshot will be taken
@param action - the step that was performed
@param expectedResult - the result that was expected to occur
@param actualResult - the result that actually occurred
@param screenshot - should a screenshot be taken
@param success - the result of the action
"""
stepNum++;
String imageLink = "";
if (screenshot && isRealBrowser()) {
// get a screen shot of the action
imageLink = captureEntirePageScreenshot();
}
// determine time differences
Date currentTime = new Date();
long dTime = currentTime.getTime() - lastTime;
long tTime = currentTime.getTime() - startTime;
lastTime = currentTime.getTime();
try (
// Reopen file
FileWriter fw = new FileWriter(file, true); BufferedWriter out = new BufferedWriter(fw)) {
// record the action
out.write(START_ROW);
out.write(" <td align='center'>" + stepNum + ".</td>\n");
out.write(START_CELL + action + END_CELL);
out.write(START_CELL + expectedResult + END_CELL);
out.write(START_CELL + actualResult + imageLink + END_CELL);
out.write(START_CELL + dTime + "ms / " + tTime + "ms</td>\n");
out.write(" <td class='" + success.toString().toLowerCase() + "'>" + success + END_CELL);
out.write(END_ROW);
} catch (IOException e) {
log.error(e);
}
} | java | private void recordStep(String action, String expectedResult, String actualResult, Boolean screenshot, Success success) {
stepNum++;
String imageLink = "";
if (screenshot && isRealBrowser()) {
// get a screen shot of the action
imageLink = captureEntirePageScreenshot();
}
// determine time differences
Date currentTime = new Date();
long dTime = currentTime.getTime() - lastTime;
long tTime = currentTime.getTime() - startTime;
lastTime = currentTime.getTime();
try (
// Reopen file
FileWriter fw = new FileWriter(file, true); BufferedWriter out = new BufferedWriter(fw)) {
// record the action
out.write(START_ROW);
out.write(" <td align='center'>" + stepNum + ".</td>\n");
out.write(START_CELL + action + END_CELL);
out.write(START_CELL + expectedResult + END_CELL);
out.write(START_CELL + actualResult + imageLink + END_CELL);
out.write(START_CELL + dTime + "ms / " + tTime + "ms</td>\n");
out.write(" <td class='" + success.toString().toLowerCase() + "'>" + success + END_CELL);
out.write(END_ROW);
} catch (IOException e) {
log.error(e);
}
} | [
"private",
"void",
"recordStep",
"(",
"String",
"action",
",",
"String",
"expectedResult",
",",
"String",
"actualResult",
",",
"Boolean",
"screenshot",
",",
"Success",
"success",
")",
"{",
"stepNum",
"++",
";",
"String",
"imageLink",
"=",
"\"\"",
";",
"if",
"(",
"screenshot",
"&&",
"isRealBrowser",
"(",
")",
")",
"{",
"// get a screen shot of the action",
"imageLink",
"=",
"captureEntirePageScreenshot",
"(",
")",
";",
"}",
"// determine time differences",
"Date",
"currentTime",
"=",
"new",
"Date",
"(",
")",
";",
"long",
"dTime",
"=",
"currentTime",
".",
"getTime",
"(",
")",
"-",
"lastTime",
";",
"long",
"tTime",
"=",
"currentTime",
".",
"getTime",
"(",
")",
"-",
"startTime",
";",
"lastTime",
"=",
"currentTime",
".",
"getTime",
"(",
")",
";",
"try",
"(",
"// Reopen file",
"FileWriter",
"fw",
"=",
"new",
"FileWriter",
"(",
"file",
",",
"true",
")",
";",
"BufferedWriter",
"out",
"=",
"new",
"BufferedWriter",
"(",
"fw",
")",
")",
"{",
"// record the action",
"out",
".",
"write",
"(",
"START_ROW",
")",
";",
"out",
".",
"write",
"(",
"\" <td align='center'>\"",
"+",
"stepNum",
"+",
"\".</td>\\n\"",
")",
";",
"out",
".",
"write",
"(",
"START_CELL",
"+",
"action",
"+",
"END_CELL",
")",
";",
"out",
".",
"write",
"(",
"START_CELL",
"+",
"expectedResult",
"+",
"END_CELL",
")",
";",
"out",
".",
"write",
"(",
"START_CELL",
"+",
"actualResult",
"+",
"imageLink",
"+",
"END_CELL",
")",
";",
"out",
".",
"write",
"(",
"START_CELL",
"+",
"dTime",
"+",
"\"ms / \"",
"+",
"tTime",
"+",
"\"ms</td>\\n\"",
")",
";",
"out",
".",
"write",
"(",
"\" <td class='\"",
"+",
"success",
".",
"toString",
"(",
")",
".",
"toLowerCase",
"(",
")",
"+",
"\"'>\"",
"+",
"success",
"+",
"END_CELL",
")",
";",
"out",
".",
"write",
"(",
"END_ROW",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"log",
".",
"error",
"(",
"e",
")",
";",
"}",
"}"
] | Records the performed step to the output file. This includes the action taken if any, the
expected result, and the actual result. If a screenshot is desired, indicate as such. If
a 'real' browser is not being used (not NONE or HTMLUNIT), then no screenshot will be taken
@param action - the step that was performed
@param expectedResult - the result that was expected to occur
@param actualResult - the result that actually occurred
@param screenshot - should a screenshot be taken
@param success - the result of the action | [
"Records",
"the",
"performed",
"step",
"to",
"the",
"output",
"file",
".",
"This",
"includes",
"the",
"action",
"taken",
"if",
"any",
"the",
"expected",
"result",
"and",
"the",
"actual",
"result",
".",
"If",
"a",
"screenshot",
"is",
"desired",
"indicate",
"as",
"such",
".",
"If",
"a",
"real",
"browser",
"is",
"not",
"being",
"used",
"(",
"not",
"NONE",
"or",
"HTMLUNIT",
")",
"then",
"no",
"screenshot",
"will",
"be",
"taken"
] | train | https://github.com/Coveros/selenified/blob/396cc1f010dd69eed33cc5061c41253de246a4cd/src/main/java/com/coveros/selenified/utilities/Reporter.java#L462-L489 |
noties/Handle | handle-library/src/main/java/ru/noties/handle/Handle.java | Handle.postAtTime | public static void postAtTime(Object what, long uptimeMillis) {
"""
The same as {@link #post(Object)} but with a time when this event should be delivered
@see SystemClock#elapsedRealtime()
@see #post(Object)
@param what an Object to be queued
@param uptimeMillis the time when this event should be delivered
"""
Handle.getInstance().mHandler.postAtTime(what, uptimeMillis);
} | java | public static void postAtTime(Object what, long uptimeMillis) {
Handle.getInstance().mHandler.postAtTime(what, uptimeMillis);
} | [
"public",
"static",
"void",
"postAtTime",
"(",
"Object",
"what",
",",
"long",
"uptimeMillis",
")",
"{",
"Handle",
".",
"getInstance",
"(",
")",
".",
"mHandler",
".",
"postAtTime",
"(",
"what",
",",
"uptimeMillis",
")",
";",
"}"
] | The same as {@link #post(Object)} but with a time when this event should be delivered
@see SystemClock#elapsedRealtime()
@see #post(Object)
@param what an Object to be queued
@param uptimeMillis the time when this event should be delivered | [
"The",
"same",
"as",
"{"
] | train | https://github.com/noties/Handle/blob/257c5e71334ce442b5c55b50bae6d5ae3a667ab9/handle-library/src/main/java/ru/noties/handle/Handle.java#L135-L137 |
milaboratory/milib | src/main/java/com/milaboratory/core/alignment/Alignment.java | Alignment.convertToSeq1Range | public Range convertToSeq1Range(Range rangeInSeq2) {
"""
Converts range in sequence2 to range in sequence1, or returns null if input range is not fully covered by
alignment
@param rangeInSeq2 range in sequence 2
@return range in sequence1 or null if rangeInSeq2 is not fully covered by alignment
"""
int from = aabs(convertToSeq1Position(rangeInSeq2.getFrom()));
int to = aabs(convertToSeq1Position(rangeInSeq2.getTo()));
if (from == -1 || to == -1)
return null;
return new Range(from, to);
} | java | public Range convertToSeq1Range(Range rangeInSeq2) {
int from = aabs(convertToSeq1Position(rangeInSeq2.getFrom()));
int to = aabs(convertToSeq1Position(rangeInSeq2.getTo()));
if (from == -1 || to == -1)
return null;
return new Range(from, to);
} | [
"public",
"Range",
"convertToSeq1Range",
"(",
"Range",
"rangeInSeq2",
")",
"{",
"int",
"from",
"=",
"aabs",
"(",
"convertToSeq1Position",
"(",
"rangeInSeq2",
".",
"getFrom",
"(",
")",
")",
")",
";",
"int",
"to",
"=",
"aabs",
"(",
"convertToSeq1Position",
"(",
"rangeInSeq2",
".",
"getTo",
"(",
")",
")",
")",
";",
"if",
"(",
"from",
"==",
"-",
"1",
"||",
"to",
"==",
"-",
"1",
")",
"return",
"null",
";",
"return",
"new",
"Range",
"(",
"from",
",",
"to",
")",
";",
"}"
] | Converts range in sequence2 to range in sequence1, or returns null if input range is not fully covered by
alignment
@param rangeInSeq2 range in sequence 2
@return range in sequence1 or null if rangeInSeq2 is not fully covered by alignment | [
"Converts",
"range",
"in",
"sequence2",
"to",
"range",
"in",
"sequence1",
"or",
"returns",
"null",
"if",
"input",
"range",
"is",
"not",
"fully",
"covered",
"by",
"alignment"
] | train | https://github.com/milaboratory/milib/blob/2349b3dccdd3c7948643760e570238d6e30d5a34/src/main/java/com/milaboratory/core/alignment/Alignment.java#L231-L239 |
OpenLiberty/open-liberty | dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/util/cache/BucketImpl.java | BucketImpl.removeByKey | public Element removeByKey(Object key, boolean dropRef) {
"""
Remove the object associated with the specified key from the bucket.
Returns the Element holding the removed object. Optionally drops
a reference on the object before removing it
@param key key of the object element to be removed.
@param dropRef true indicates a reference should be dropped
@return the Element holding the removed object.
"""
int i = findIndexByKey(key);
Element element = null;
// Check if the object is in the cache
if (i != -1)
{
element = (Element) get(i);
// Objects must either be unpinned, or pinned only once
// (presumably by the caller)
if ((!dropRef && element.pinned > 0) ||
(dropRef && element.pinned > 1)) {
throw new IllegalOperationException(key, element.pinned);
}
remove(i);
}
return element;
} | java | public Element removeByKey(Object key, boolean dropRef)
{
int i = findIndexByKey(key);
Element element = null;
// Check if the object is in the cache
if (i != -1)
{
element = (Element) get(i);
// Objects must either be unpinned, or pinned only once
// (presumably by the caller)
if ((!dropRef && element.pinned > 0) ||
(dropRef && element.pinned > 1)) {
throw new IllegalOperationException(key, element.pinned);
}
remove(i);
}
return element;
} | [
"public",
"Element",
"removeByKey",
"(",
"Object",
"key",
",",
"boolean",
"dropRef",
")",
"{",
"int",
"i",
"=",
"findIndexByKey",
"(",
"key",
")",
";",
"Element",
"element",
"=",
"null",
";",
"// Check if the object is in the cache",
"if",
"(",
"i",
"!=",
"-",
"1",
")",
"{",
"element",
"=",
"(",
"Element",
")",
"get",
"(",
"i",
")",
";",
"// Objects must either be unpinned, or pinned only once",
"// (presumably by the caller)",
"if",
"(",
"(",
"!",
"dropRef",
"&&",
"element",
".",
"pinned",
">",
"0",
")",
"||",
"(",
"dropRef",
"&&",
"element",
".",
"pinned",
">",
"1",
")",
")",
"{",
"throw",
"new",
"IllegalOperationException",
"(",
"key",
",",
"element",
".",
"pinned",
")",
";",
"}",
"remove",
"(",
"i",
")",
";",
"}",
"return",
"element",
";",
"}"
] | Remove the object associated with the specified key from the bucket.
Returns the Element holding the removed object. Optionally drops
a reference on the object before removing it
@param key key of the object element to be removed.
@param dropRef true indicates a reference should be dropped
@return the Element holding the removed object. | [
"Remove",
"the",
"object",
"associated",
"with",
"the",
"specified",
"key",
"from",
"the",
"bucket",
".",
"Returns",
"the",
"Element",
"holding",
"the",
"removed",
"object",
".",
"Optionally",
"drops",
"a",
"reference",
"on",
"the",
"object",
"before",
"removing",
"it"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/util/cache/BucketImpl.java#L157-L178 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/network/v2018_04_01/implementation/ApplicationGatewaysInner.java | ApplicationGatewaysInner.beginStart | public void beginStart(String resourceGroupName, String applicationGatewayName) {
"""
Starts the specified application gateway.
@param resourceGroupName The name of the resource group.
@param applicationGatewayName The name of the application gateway.
@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
"""
beginStartWithServiceResponseAsync(resourceGroupName, applicationGatewayName).toBlocking().single().body();
} | java | public void beginStart(String resourceGroupName, String applicationGatewayName) {
beginStartWithServiceResponseAsync(resourceGroupName, applicationGatewayName).toBlocking().single().body();
} | [
"public",
"void",
"beginStart",
"(",
"String",
"resourceGroupName",
",",
"String",
"applicationGatewayName",
")",
"{",
"beginStartWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"applicationGatewayName",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Starts the specified application gateway.
@param resourceGroupName The name of the resource group.
@param applicationGatewayName The name of the application gateway.
@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 | [
"Starts",
"the",
"specified",
"application",
"gateway",
"."
] | 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/ApplicationGatewaysInner.java#L1170-L1172 |
xcesco/kripton | kripton-orm/src/main/java/com/abubusoft/kripton/android/sqlite/SQLiteEvent.java | SQLiteEvent.createInsertWithUid | public static SQLiteEvent createInsertWithUid(String result) {
"""
Creates the insert.
@param result
the result
@return the SQ lite event
"""
return new SQLiteEvent(SqlModificationType.INSERT, null, null, result);
} | java | public static SQLiteEvent createInsertWithUid(String result) {
return new SQLiteEvent(SqlModificationType.INSERT, null, null, result);
} | [
"public",
"static",
"SQLiteEvent",
"createInsertWithUid",
"(",
"String",
"result",
")",
"{",
"return",
"new",
"SQLiteEvent",
"(",
"SqlModificationType",
".",
"INSERT",
",",
"null",
",",
"null",
",",
"result",
")",
";",
"}"
] | Creates the insert.
@param result
the result
@return the SQ lite event | [
"Creates",
"the",
"insert",
"."
] | train | https://github.com/xcesco/kripton/blob/90de2c0523d39b99e81b8d38aa996898762f594a/kripton-orm/src/main/java/com/abubusoft/kripton/android/sqlite/SQLiteEvent.java#L68-L70 |
actframework/actframework | src/main/java/act/data/ApacheMultipartParser.java | ApacheMultipartParser.getHeader | private final String getHeader(Map /* String, String */ headers, String name) {
"""
Returns the header with the specified name from the supplied map. The
header lookup is case-insensitive.
@param headers A <code>Map</code> containing the HTTP request headers.
@param name The name of the header to return.
@return The value of specified header, or a comma-separated list if there
were multiple headers of that name.
"""
return (String) headers.get(name.toLowerCase());
} | java | private final String getHeader(Map /* String, String */ headers, String name) {
return (String) headers.get(name.toLowerCase());
} | [
"private",
"final",
"String",
"getHeader",
"(",
"Map",
"/* String, String */",
"headers",
",",
"String",
"name",
")",
"{",
"return",
"(",
"String",
")",
"headers",
".",
"get",
"(",
"name",
".",
"toLowerCase",
"(",
")",
")",
";",
"}"
] | Returns the header with the specified name from the supplied map. The
header lookup is case-insensitive.
@param headers A <code>Map</code> containing the HTTP request headers.
@param name The name of the header to return.
@return The value of specified header, or a comma-separated list if there
were multiple headers of that name. | [
"Returns",
"the",
"header",
"with",
"the",
"specified",
"name",
"from",
"the",
"supplied",
"map",
".",
"The",
"header",
"lookup",
"is",
"case",
"-",
"insensitive",
"."
] | train | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/data/ApacheMultipartParser.java#L322-L324 |
calrissian/mango | mango-core/src/main/java/org/calrissian/mango/batch/BatcherBuilder.java | BatcherBuilder.timeBound | public BatcherBuilder timeBound(long time, TimeUnit timeUnit) {
"""
Add a max time component for a batcher. If specified a batcher will call the {@link BatchListener}
as soon as the time bound has been exceeded.
NOTE: This interval is the time since successfully sending the last batch to the batchlistener. This means
that if a blocking {@link BatcherBuilder#listenerService(ExecutorService)} is used then the time interval will not
restart until it has been successfully handed off to the {@link BatcherBuilder#listenerService(ExecutorService)}.
"""
checkState(this.interval == UNSET_INT, "Max time already set");
checkArgument(time > 0, "Required to have a time interval greater than 0");
requireNonNull(timeUnit);
this.interval = timeUnit.toNanos(time);
return this;
} | java | public BatcherBuilder timeBound(long time, TimeUnit timeUnit) {
checkState(this.interval == UNSET_INT, "Max time already set");
checkArgument(time > 0, "Required to have a time interval greater than 0");
requireNonNull(timeUnit);
this.interval = timeUnit.toNanos(time);
return this;
} | [
"public",
"BatcherBuilder",
"timeBound",
"(",
"long",
"time",
",",
"TimeUnit",
"timeUnit",
")",
"{",
"checkState",
"(",
"this",
".",
"interval",
"==",
"UNSET_INT",
",",
"\"Max time already set\"",
")",
";",
"checkArgument",
"(",
"time",
">",
"0",
",",
"\"Required to have a time interval greater than 0\"",
")",
";",
"requireNonNull",
"(",
"timeUnit",
")",
";",
"this",
".",
"interval",
"=",
"timeUnit",
".",
"toNanos",
"(",
"time",
")",
";",
"return",
"this",
";",
"}"
] | Add a max time component for a batcher. If specified a batcher will call the {@link BatchListener}
as soon as the time bound has been exceeded.
NOTE: This interval is the time since successfully sending the last batch to the batchlistener. This means
that if a blocking {@link BatcherBuilder#listenerService(ExecutorService)} is used then the time interval will not
restart until it has been successfully handed off to the {@link BatcherBuilder#listenerService(ExecutorService)}. | [
"Add",
"a",
"max",
"time",
"component",
"for",
"a",
"batcher",
".",
"If",
"specified",
"a",
"batcher",
"will",
"call",
"the",
"{",
"@link",
"BatchListener",
"}",
"as",
"soon",
"as",
"the",
"time",
"bound",
"has",
"been",
"exceeded",
"."
] | train | https://github.com/calrissian/mango/blob/a95aa5e77af9aa0e629787228d80806560023452/mango-core/src/main/java/org/calrissian/mango/batch/BatcherBuilder.java#L72-L78 |
cloudfoundry/uaa | server/src/main/java/org/cloudfoundry/identity/uaa/authentication/BackwardsCompatibleTokenEndpointAuthenticationFilter.java | BackwardsCompatibleTokenEndpointAuthenticationFilter.extractCredentials | protected Authentication extractCredentials(HttpServletRequest request) {
"""
If the incoming request contains user credentials in headers or parameters then extract them here into an
Authentication token that can be validated later. This implementation only recognises password grant requests and
extracts the username and password.
@param request the incoming request, possibly with user credentials
@return an authentication for validation (or null if there is no further authentication)
"""
String username = request.getParameter("username");
String password = request.getParameter("password");
UsernamePasswordAuthenticationToken credentials = new UsernamePasswordAuthenticationToken(username, password);
credentials.setDetails(authenticationDetailsSource.buildDetails(request));
return credentials;
} | java | protected Authentication extractCredentials(HttpServletRequest request) {
String username = request.getParameter("username");
String password = request.getParameter("password");
UsernamePasswordAuthenticationToken credentials = new UsernamePasswordAuthenticationToken(username, password);
credentials.setDetails(authenticationDetailsSource.buildDetails(request));
return credentials;
} | [
"protected",
"Authentication",
"extractCredentials",
"(",
"HttpServletRequest",
"request",
")",
"{",
"String",
"username",
"=",
"request",
".",
"getParameter",
"(",
"\"username\"",
")",
";",
"String",
"password",
"=",
"request",
".",
"getParameter",
"(",
"\"password\"",
")",
";",
"UsernamePasswordAuthenticationToken",
"credentials",
"=",
"new",
"UsernamePasswordAuthenticationToken",
"(",
"username",
",",
"password",
")",
";",
"credentials",
".",
"setDetails",
"(",
"authenticationDetailsSource",
".",
"buildDetails",
"(",
"request",
")",
")",
";",
"return",
"credentials",
";",
"}"
] | If the incoming request contains user credentials in headers or parameters then extract them here into an
Authentication token that can be validated later. This implementation only recognises password grant requests and
extracts the username and password.
@param request the incoming request, possibly with user credentials
@return an authentication for validation (or null if there is no further authentication) | [
"If",
"the",
"incoming",
"request",
"contains",
"user",
"credentials",
"in",
"headers",
"or",
"parameters",
"then",
"extract",
"them",
"here",
"into",
"an",
"Authentication",
"token",
"that",
"can",
"be",
"validated",
"later",
".",
"This",
"implementation",
"only",
"recognises",
"password",
"grant",
"requests",
"and",
"extracts",
"the",
"username",
"and",
"password",
"."
] | train | https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/authentication/BackwardsCompatibleTokenEndpointAuthenticationFilter.java#L187-L193 |
Erudika/para | para-client/src/main/java/com/erudika/para/client/ParaClient.java | ParaClient.getCount | public Long getCount(String type, Map<String, ?> terms) {
"""
Counts indexed objects matching a set of terms/values.
@param type the type of object to search for. See {@link com.erudika.para.core.ParaObject#getType()}
@param terms a list of terms (property values)
@return the number of results found
"""
if (terms == null) {
return 0L;
}
MultivaluedMap<String, String> params = new MultivaluedHashMap<>();
LinkedList<String> list = new LinkedList<>();
for (Map.Entry<String, ? extends Object> term : terms.entrySet()) {
String key = term.getKey();
Object value = term.getValue();
if (value != null) {
list.add(key.concat(Config.SEPARATOR).concat(value.toString()));
}
}
if (!terms.isEmpty()) {
params.put("terms", list);
}
params.putSingle(Config._TYPE, type);
params.putSingle("count", "true");
Pager pager = new Pager();
getItems(find("terms", params), pager);
return pager.getCount();
} | java | public Long getCount(String type, Map<String, ?> terms) {
if (terms == null) {
return 0L;
}
MultivaluedMap<String, String> params = new MultivaluedHashMap<>();
LinkedList<String> list = new LinkedList<>();
for (Map.Entry<String, ? extends Object> term : terms.entrySet()) {
String key = term.getKey();
Object value = term.getValue();
if (value != null) {
list.add(key.concat(Config.SEPARATOR).concat(value.toString()));
}
}
if (!terms.isEmpty()) {
params.put("terms", list);
}
params.putSingle(Config._TYPE, type);
params.putSingle("count", "true");
Pager pager = new Pager();
getItems(find("terms", params), pager);
return pager.getCount();
} | [
"public",
"Long",
"getCount",
"(",
"String",
"type",
",",
"Map",
"<",
"String",
",",
"?",
">",
"terms",
")",
"{",
"if",
"(",
"terms",
"==",
"null",
")",
"{",
"return",
"0L",
";",
"}",
"MultivaluedMap",
"<",
"String",
",",
"String",
">",
"params",
"=",
"new",
"MultivaluedHashMap",
"<>",
"(",
")",
";",
"LinkedList",
"<",
"String",
">",
"list",
"=",
"new",
"LinkedList",
"<>",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"?",
"extends",
"Object",
">",
"term",
":",
"terms",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"key",
"=",
"term",
".",
"getKey",
"(",
")",
";",
"Object",
"value",
"=",
"term",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"list",
".",
"add",
"(",
"key",
".",
"concat",
"(",
"Config",
".",
"SEPARATOR",
")",
".",
"concat",
"(",
"value",
".",
"toString",
"(",
")",
")",
")",
";",
"}",
"}",
"if",
"(",
"!",
"terms",
".",
"isEmpty",
"(",
")",
")",
"{",
"params",
".",
"put",
"(",
"\"terms\"",
",",
"list",
")",
";",
"}",
"params",
".",
"putSingle",
"(",
"Config",
".",
"_TYPE",
",",
"type",
")",
";",
"params",
".",
"putSingle",
"(",
"\"count\"",
",",
"\"true\"",
")",
";",
"Pager",
"pager",
"=",
"new",
"Pager",
"(",
")",
";",
"getItems",
"(",
"find",
"(",
"\"terms\"",
",",
"params",
")",
",",
"pager",
")",
";",
"return",
"pager",
".",
"getCount",
"(",
")",
";",
"}"
] | Counts indexed objects matching a set of terms/values.
@param type the type of object to search for. See {@link com.erudika.para.core.ParaObject#getType()}
@param terms a list of terms (property values)
@return the number of results found | [
"Counts",
"indexed",
"objects",
"matching",
"a",
"set",
"of",
"terms",
"/",
"values",
"."
] | train | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-client/src/main/java/com/erudika/para/client/ParaClient.java#L888-L909 |
WiQuery/wiquery | wiquery-jquery-ui/src/main/java/org/odlabs/wiquery/ui/dialog/util/DialogUtilsBehavior.java | DialogUtilsBehavior.simpleDialog | public JsStatement simpleDialog(String title, String message) {
"""
Method creating a simple dialog
@param title
Title
@param message
Message
@return the required {@link JsStatement}
"""
JsStatement statement = new JsStatement();
statement.append("$.ui.dialog.wiquery.simpleDialog(");
statement.append("" + Session.get().nextSequenceValue() + ", ");
statement.append(DialogUtilsLanguages.getDialogUtilsLiteral(DialogUtilsLanguages
.getDialogUtilsLanguages(getLocale())) + ", ");
statement.append(JsUtils.quotes(title, true) + ", ");
statement.append(JsUtils.doubleQuotes(message, true) + ")");
return statement;
} | java | public JsStatement simpleDialog(String title, String message)
{
JsStatement statement = new JsStatement();
statement.append("$.ui.dialog.wiquery.simpleDialog(");
statement.append("" + Session.get().nextSequenceValue() + ", ");
statement.append(DialogUtilsLanguages.getDialogUtilsLiteral(DialogUtilsLanguages
.getDialogUtilsLanguages(getLocale())) + ", ");
statement.append(JsUtils.quotes(title, true) + ", ");
statement.append(JsUtils.doubleQuotes(message, true) + ")");
return statement;
} | [
"public",
"JsStatement",
"simpleDialog",
"(",
"String",
"title",
",",
"String",
"message",
")",
"{",
"JsStatement",
"statement",
"=",
"new",
"JsStatement",
"(",
")",
";",
"statement",
".",
"append",
"(",
"\"$.ui.dialog.wiquery.simpleDialog(\"",
")",
";",
"statement",
".",
"append",
"(",
"\"\"",
"+",
"Session",
".",
"get",
"(",
")",
".",
"nextSequenceValue",
"(",
")",
"+",
"\", \"",
")",
";",
"statement",
".",
"append",
"(",
"DialogUtilsLanguages",
".",
"getDialogUtilsLiteral",
"(",
"DialogUtilsLanguages",
".",
"getDialogUtilsLanguages",
"(",
"getLocale",
"(",
")",
")",
")",
"+",
"\", \"",
")",
";",
"statement",
".",
"append",
"(",
"JsUtils",
".",
"quotes",
"(",
"title",
",",
"true",
")",
"+",
"\", \"",
")",
";",
"statement",
".",
"append",
"(",
"JsUtils",
".",
"doubleQuotes",
"(",
"message",
",",
"true",
")",
"+",
"\")\"",
")",
";",
"return",
"statement",
";",
"}"
] | Method creating a simple dialog
@param title
Title
@param message
Message
@return the required {@link JsStatement} | [
"Method",
"creating",
"a",
"simple",
"dialog"
] | train | https://github.com/WiQuery/wiquery/blob/1b8d60c7a3c37b90fd68c9cd0ff97178fcbcbb08/wiquery-jquery-ui/src/main/java/org/odlabs/wiquery/ui/dialog/util/DialogUtilsBehavior.java#L372-L383 |
MorphiaOrg/morphia | morphia/src/main/java/dev/morphia/mapping/MappedField.java | MappedField.setFieldValue | public void setFieldValue(final Object instance, final Object value) {
"""
Sets the value for the java field
@param instance the instance to update
@param value the value to set
"""
try {
field.set(instance, value);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
} | java | public void setFieldValue(final Object instance, final Object value) {
try {
field.set(instance, value);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
} | [
"public",
"void",
"setFieldValue",
"(",
"final",
"Object",
"instance",
",",
"final",
"Object",
"value",
")",
"{",
"try",
"{",
"field",
".",
"set",
"(",
"instance",
",",
"value",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] | Sets the value for the java field
@param instance the instance to update
@param value the value to set | [
"Sets",
"the",
"value",
"for",
"the",
"java",
"field"
] | train | https://github.com/MorphiaOrg/morphia/blob/667c30bdc7c6f1d9f2e2eb8774835d6137b52d12/morphia/src/main/java/dev/morphia/mapping/MappedField.java#L450-L456 |
Stratio/bdt | src/main/java/com/stratio/qa/specs/SeleniumSpec.java | SeleniumSpec.seleniumIdFrame | @Given("^I switch to iframe with '([^:]*?):(.+?)'$")
public void seleniumIdFrame(String method, String idframe) throws IllegalAccessException, NoSuchFieldException, ClassNotFoundException {
"""
Swith to the iFrame where id matches idframe
@param idframe iframe to swith to
@throws IllegalAccessException exception
@throws NoSuchFieldException exception
@throws ClassNotFoundException exception
"""
assertThat(commonspec.locateElement(method, idframe, 1));
if (method.equals("id") || method.equals("name")) {
commonspec.getDriver().switchTo().frame(idframe);
} else {
throw new ClassNotFoundException("Can not use this method to switch iframe");
}
} | java | @Given("^I switch to iframe with '([^:]*?):(.+?)'$")
public void seleniumIdFrame(String method, String idframe) throws IllegalAccessException, NoSuchFieldException, ClassNotFoundException {
assertThat(commonspec.locateElement(method, idframe, 1));
if (method.equals("id") || method.equals("name")) {
commonspec.getDriver().switchTo().frame(idframe);
} else {
throw new ClassNotFoundException("Can not use this method to switch iframe");
}
} | [
"@",
"Given",
"(",
"\"^I switch to iframe with '([^:]*?):(.+?)'$\"",
")",
"public",
"void",
"seleniumIdFrame",
"(",
"String",
"method",
",",
"String",
"idframe",
")",
"throws",
"IllegalAccessException",
",",
"NoSuchFieldException",
",",
"ClassNotFoundException",
"{",
"assertThat",
"(",
"commonspec",
".",
"locateElement",
"(",
"method",
",",
"idframe",
",",
"1",
")",
")",
";",
"if",
"(",
"method",
".",
"equals",
"(",
"\"id\"",
")",
"||",
"method",
".",
"equals",
"(",
"\"name\"",
")",
")",
"{",
"commonspec",
".",
"getDriver",
"(",
")",
".",
"switchTo",
"(",
")",
".",
"frame",
"(",
"idframe",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"ClassNotFoundException",
"(",
"\"Can not use this method to switch iframe\"",
")",
";",
"}",
"}"
] | Swith to the iFrame where id matches idframe
@param idframe iframe to swith to
@throws IllegalAccessException exception
@throws NoSuchFieldException exception
@throws ClassNotFoundException exception | [
"Swith",
"to",
"the",
"iFrame",
"where",
"id",
"matches",
"idframe"
] | train | https://github.com/Stratio/bdt/blob/55324d19e7497764ad3dd7139923e13eb9841d75/src/main/java/com/stratio/qa/specs/SeleniumSpec.java#L132-L141 |
classgraph/classgraph | src/main/java/io/github/classgraph/ClasspathElement.java | ClasspathElement.maskClassfiles | void maskClassfiles(final int classpathIdx, final Set<String> classpathRelativePathsFound, final LogNode log) {
"""
Apply relative path masking within this classpath resource -- remove relative paths that were found in an
earlier classpath element.
@param classpathIdx
the classpath index
@param classpathRelativePathsFound
the classpath relative paths found
@param log
the log
"""
if (!scanSpec.performScan) {
// Should not happen
throw new IllegalArgumentException("performScan is false");
}
// Find relative paths that occur more than once in the classpath / module path.
// Usually duplicate relative paths occur only between classpath / module path elements, not within,
// but actually there is no restriction for paths within a zipfile to be unique, and in fact
// zipfiles in the wild do contain the same classfiles multiple times with the same exact path,
// e.g.: xmlbeans-2.6.0.jar!org/apache/xmlbeans/xml/stream/Location.class
final List<Resource> whitelistedClassfileResourcesFiltered = new ArrayList<>(
whitelistedClassfileResources.size());
boolean foundMasked = false;
for (final Resource res : whitelistedClassfileResources) {
final String pathRelativeToPackageRoot = res.getPath();
// Don't mask module-info.class or package-info.class, these are read for every module/package
if (!pathRelativeToPackageRoot.equals("module-info.class")
&& !pathRelativeToPackageRoot.endsWith("/module-info.class")
&& !pathRelativeToPackageRoot.equals("package-info.class")
&& !pathRelativeToPackageRoot.endsWith("/package-info.class")
// Check if pathRelativeToPackageRoot has been seen before
&& !classpathRelativePathsFound.add(pathRelativeToPackageRoot)) {
// This relative path has been encountered more than once;
// mask the second and subsequent occurrences of the path
foundMasked = true;
if (log != null) {
log.log(String.format("%06d-1", classpathIdx), "Ignoring duplicate (masked) class "
+ JarUtils.classfilePathToClassName(pathRelativeToPackageRoot) + " found at " + res);
}
} else {
whitelistedClassfileResourcesFiltered.add(res);
}
}
if (foundMasked) {
// Remove masked (duplicated) paths. N.B. this replaces the concurrent collection with a non-concurrent
// collection, but this is the last time the collection is changed during a scan, and this method is
// run from a single thread.
whitelistedClassfileResources = whitelistedClassfileResourcesFiltered;
}
} | java | void maskClassfiles(final int classpathIdx, final Set<String> classpathRelativePathsFound, final LogNode log) {
if (!scanSpec.performScan) {
// Should not happen
throw new IllegalArgumentException("performScan is false");
}
// Find relative paths that occur more than once in the classpath / module path.
// Usually duplicate relative paths occur only between classpath / module path elements, not within,
// but actually there is no restriction for paths within a zipfile to be unique, and in fact
// zipfiles in the wild do contain the same classfiles multiple times with the same exact path,
// e.g.: xmlbeans-2.6.0.jar!org/apache/xmlbeans/xml/stream/Location.class
final List<Resource> whitelistedClassfileResourcesFiltered = new ArrayList<>(
whitelistedClassfileResources.size());
boolean foundMasked = false;
for (final Resource res : whitelistedClassfileResources) {
final String pathRelativeToPackageRoot = res.getPath();
// Don't mask module-info.class or package-info.class, these are read for every module/package
if (!pathRelativeToPackageRoot.equals("module-info.class")
&& !pathRelativeToPackageRoot.endsWith("/module-info.class")
&& !pathRelativeToPackageRoot.equals("package-info.class")
&& !pathRelativeToPackageRoot.endsWith("/package-info.class")
// Check if pathRelativeToPackageRoot has been seen before
&& !classpathRelativePathsFound.add(pathRelativeToPackageRoot)) {
// This relative path has been encountered more than once;
// mask the second and subsequent occurrences of the path
foundMasked = true;
if (log != null) {
log.log(String.format("%06d-1", classpathIdx), "Ignoring duplicate (masked) class "
+ JarUtils.classfilePathToClassName(pathRelativeToPackageRoot) + " found at " + res);
}
} else {
whitelistedClassfileResourcesFiltered.add(res);
}
}
if (foundMasked) {
// Remove masked (duplicated) paths. N.B. this replaces the concurrent collection with a non-concurrent
// collection, but this is the last time the collection is changed during a scan, and this method is
// run from a single thread.
whitelistedClassfileResources = whitelistedClassfileResourcesFiltered;
}
} | [
"void",
"maskClassfiles",
"(",
"final",
"int",
"classpathIdx",
",",
"final",
"Set",
"<",
"String",
">",
"classpathRelativePathsFound",
",",
"final",
"LogNode",
"log",
")",
"{",
"if",
"(",
"!",
"scanSpec",
".",
"performScan",
")",
"{",
"// Should not happen",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"performScan is false\"",
")",
";",
"}",
"// Find relative paths that occur more than once in the classpath / module path.",
"// Usually duplicate relative paths occur only between classpath / module path elements, not within,",
"// but actually there is no restriction for paths within a zipfile to be unique, and in fact",
"// zipfiles in the wild do contain the same classfiles multiple times with the same exact path,",
"// e.g.: xmlbeans-2.6.0.jar!org/apache/xmlbeans/xml/stream/Location.class",
"final",
"List",
"<",
"Resource",
">",
"whitelistedClassfileResourcesFiltered",
"=",
"new",
"ArrayList",
"<>",
"(",
"whitelistedClassfileResources",
".",
"size",
"(",
")",
")",
";",
"boolean",
"foundMasked",
"=",
"false",
";",
"for",
"(",
"final",
"Resource",
"res",
":",
"whitelistedClassfileResources",
")",
"{",
"final",
"String",
"pathRelativeToPackageRoot",
"=",
"res",
".",
"getPath",
"(",
")",
";",
"// Don't mask module-info.class or package-info.class, these are read for every module/package",
"if",
"(",
"!",
"pathRelativeToPackageRoot",
".",
"equals",
"(",
"\"module-info.class\"",
")",
"&&",
"!",
"pathRelativeToPackageRoot",
".",
"endsWith",
"(",
"\"/module-info.class\"",
")",
"&&",
"!",
"pathRelativeToPackageRoot",
".",
"equals",
"(",
"\"package-info.class\"",
")",
"&&",
"!",
"pathRelativeToPackageRoot",
".",
"endsWith",
"(",
"\"/package-info.class\"",
")",
"// Check if pathRelativeToPackageRoot has been seen before",
"&&",
"!",
"classpathRelativePathsFound",
".",
"add",
"(",
"pathRelativeToPackageRoot",
")",
")",
"{",
"// This relative path has been encountered more than once;",
"// mask the second and subsequent occurrences of the path",
"foundMasked",
"=",
"true",
";",
"if",
"(",
"log",
"!=",
"null",
")",
"{",
"log",
".",
"log",
"(",
"String",
".",
"format",
"(",
"\"%06d-1\"",
",",
"classpathIdx",
")",
",",
"\"Ignoring duplicate (masked) class \"",
"+",
"JarUtils",
".",
"classfilePathToClassName",
"(",
"pathRelativeToPackageRoot",
")",
"+",
"\" found at \"",
"+",
"res",
")",
";",
"}",
"}",
"else",
"{",
"whitelistedClassfileResourcesFiltered",
".",
"add",
"(",
"res",
")",
";",
"}",
"}",
"if",
"(",
"foundMasked",
")",
"{",
"// Remove masked (duplicated) paths. N.B. this replaces the concurrent collection with a non-concurrent",
"// collection, but this is the last time the collection is changed during a scan, and this method is",
"// run from a single thread.",
"whitelistedClassfileResources",
"=",
"whitelistedClassfileResourcesFiltered",
";",
"}",
"}"
] | Apply relative path masking within this classpath resource -- remove relative paths that were found in an
earlier classpath element.
@param classpathIdx
the classpath index
@param classpathRelativePathsFound
the classpath relative paths found
@param log
the log | [
"Apply",
"relative",
"path",
"masking",
"within",
"this",
"classpath",
"resource",
"--",
"remove",
"relative",
"paths",
"that",
"were",
"found",
"in",
"an",
"earlier",
"classpath",
"element",
"."
] | train | https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClasspathElement.java#L186-L225 |
spotify/sparkey-java | src/main/java/com/spotify/sparkey/Sparkey.java | Sparkey.createNew | public static SparkeyWriter createNew(File file, CompressionType compressionType, int compressionBlockSize) throws IOException {
"""
Creates a new sparkey writer with the specified compression
This is not a thread-safe class, only use it from one thread.
@param file File base to use, the actual file endings will be set to .spi and .spl
@param compressionType
@param compressionBlockSize The maximum compression block size in bytes
@return a new writer,
"""
return SingleThreadedSparkeyWriter.createNew(file, compressionType, compressionBlockSize);
} | java | public static SparkeyWriter createNew(File file, CompressionType compressionType, int compressionBlockSize) throws IOException {
return SingleThreadedSparkeyWriter.createNew(file, compressionType, compressionBlockSize);
} | [
"public",
"static",
"SparkeyWriter",
"createNew",
"(",
"File",
"file",
",",
"CompressionType",
"compressionType",
",",
"int",
"compressionBlockSize",
")",
"throws",
"IOException",
"{",
"return",
"SingleThreadedSparkeyWriter",
".",
"createNew",
"(",
"file",
",",
"compressionType",
",",
"compressionBlockSize",
")",
";",
"}"
] | Creates a new sparkey writer with the specified compression
This is not a thread-safe class, only use it from one thread.
@param file File base to use, the actual file endings will be set to .spi and .spl
@param compressionType
@param compressionBlockSize The maximum compression block size in bytes
@return a new writer, | [
"Creates",
"a",
"new",
"sparkey",
"writer",
"with",
"the",
"specified",
"compression"
] | train | https://github.com/spotify/sparkey-java/blob/77ed13b17b4b28f38d6e335610269fb135c3a1be/src/main/java/com/spotify/sparkey/Sparkey.java#L55-L57 |
openbaton/openbaton-client | sdk/src/main/java/org/openbaton/sdk/api/rest/NetworkServiceRecordAgent.java | NetworkServiceRecordAgent.upgradeVnfr | @Help(help = "Upgrades a VNFR to a defined VNFD in a running NSR with specific id")
public void upgradeVnfr(final String idNsr, final String idVnfr, final String idVnfd)
throws SDKException {
"""
Upgrades a VNFR of a defined VNFD in a running NSR.
@param idNsr the ID of the NetworkServiceRecord
@param idVnfr the ID of the VNFR to be upgraded
@param idVnfd the VNFD ID to which the VNFR shall be upgraded
@throws SDKException if the request fails
"""
HashMap<String, Serializable> jsonBody = new HashMap<>();
jsonBody.put("vnfdId", idVnfd);
String url = idNsr + "/vnfrecords" + "/" + idVnfr + "/upgrade";
requestPost(url, jsonBody);
} | java | @Help(help = "Upgrades a VNFR to a defined VNFD in a running NSR with specific id")
public void upgradeVnfr(final String idNsr, final String idVnfr, final String idVnfd)
throws SDKException {
HashMap<String, Serializable> jsonBody = new HashMap<>();
jsonBody.put("vnfdId", idVnfd);
String url = idNsr + "/vnfrecords" + "/" + idVnfr + "/upgrade";
requestPost(url, jsonBody);
} | [
"@",
"Help",
"(",
"help",
"=",
"\"Upgrades a VNFR to a defined VNFD in a running NSR with specific id\"",
")",
"public",
"void",
"upgradeVnfr",
"(",
"final",
"String",
"idNsr",
",",
"final",
"String",
"idVnfr",
",",
"final",
"String",
"idVnfd",
")",
"throws",
"SDKException",
"{",
"HashMap",
"<",
"String",
",",
"Serializable",
">",
"jsonBody",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"jsonBody",
".",
"put",
"(",
"\"vnfdId\"",
",",
"idVnfd",
")",
";",
"String",
"url",
"=",
"idNsr",
"+",
"\"/vnfrecords\"",
"+",
"\"/\"",
"+",
"idVnfr",
"+",
"\"/upgrade\"",
";",
"requestPost",
"(",
"url",
",",
"jsonBody",
")",
";",
"}"
] | Upgrades a VNFR of a defined VNFD in a running NSR.
@param idNsr the ID of the NetworkServiceRecord
@param idVnfr the ID of the VNFR to be upgraded
@param idVnfd the VNFD ID to which the VNFR shall be upgraded
@throws SDKException if the request fails | [
"Upgrades",
"a",
"VNFR",
"of",
"a",
"defined",
"VNFD",
"in",
"a",
"running",
"NSR",
"."
] | train | https://github.com/openbaton/openbaton-client/blob/6ca6dd6b62a23940d312213d6fa489d5b636061a/sdk/src/main/java/org/openbaton/sdk/api/rest/NetworkServiceRecordAgent.java#L691-L698 |
Azure/azure-sdk-for-java | appservice/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/appservice/v2016_09_01/implementation/AppServiceEnvironmentsInner.java | AppServiceEnvironmentsInner.listAppServicePlansWithServiceResponseAsync | public Observable<ServiceResponse<Page<AppServicePlanInner>>> listAppServicePlansWithServiceResponseAsync(final String resourceGroupName, final String name) {
"""
Get all App Service plans in an App Service Environment.
Get all App Service plans in an App Service Environment.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param name Name of the App Service Environment.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<AppServicePlanInner> object
"""
return listAppServicePlansSinglePageAsync(resourceGroupName, name)
.concatMap(new Func1<ServiceResponse<Page<AppServicePlanInner>>, Observable<ServiceResponse<Page<AppServicePlanInner>>>>() {
@Override
public Observable<ServiceResponse<Page<AppServicePlanInner>>> call(ServiceResponse<Page<AppServicePlanInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(listAppServicePlansNextWithServiceResponseAsync(nextPageLink));
}
});
} | java | public Observable<ServiceResponse<Page<AppServicePlanInner>>> listAppServicePlansWithServiceResponseAsync(final String resourceGroupName, final String name) {
return listAppServicePlansSinglePageAsync(resourceGroupName, name)
.concatMap(new Func1<ServiceResponse<Page<AppServicePlanInner>>, Observable<ServiceResponse<Page<AppServicePlanInner>>>>() {
@Override
public Observable<ServiceResponse<Page<AppServicePlanInner>>> call(ServiceResponse<Page<AppServicePlanInner>> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(listAppServicePlansNextWithServiceResponseAsync(nextPageLink));
}
});
} | [
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"AppServicePlanInner",
">",
">",
">",
"listAppServicePlansWithServiceResponseAsync",
"(",
"final",
"String",
"resourceGroupName",
",",
"final",
"String",
"name",
")",
"{",
"return",
"listAppServicePlansSinglePageAsync",
"(",
"resourceGroupName",
",",
"name",
")",
".",
"concatMap",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"AppServicePlanInner",
">",
">",
",",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"AppServicePlanInner",
">",
">",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"AppServicePlanInner",
">",
">",
">",
"call",
"(",
"ServiceResponse",
"<",
"Page",
"<",
"AppServicePlanInner",
">",
">",
"page",
")",
"{",
"String",
"nextPageLink",
"=",
"page",
".",
"body",
"(",
")",
".",
"nextPageLink",
"(",
")",
";",
"if",
"(",
"nextPageLink",
"==",
"null",
")",
"{",
"return",
"Observable",
".",
"just",
"(",
"page",
")",
";",
"}",
"return",
"Observable",
".",
"just",
"(",
"page",
")",
".",
"concatWith",
"(",
"listAppServicePlansNextWithServiceResponseAsync",
"(",
"nextPageLink",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] | Get all App Service plans in an App Service Environment.
Get all App Service plans in an App Service Environment.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param name Name of the App Service Environment.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<AppServicePlanInner> object | [
"Get",
"all",
"App",
"Service",
"plans",
"in",
"an",
"App",
"Service",
"Environment",
".",
"Get",
"all",
"App",
"Service",
"plans",
"in",
"an",
"App",
"Service",
"Environment",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/appservice/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/appservice/v2016_09_01/implementation/AppServiceEnvironmentsInner.java#L4127-L4139 |
super-csv/super-csv | super-csv-joda/src/main/java/org/supercsv/cellprocessor/joda/FmtInterval.java | FmtInterval.execute | public Object execute(final Object value, final CsvContext context) {
"""
{@inheritDoc}
@throws SuperCsvCellProcessorException
if value is null or not a Interval
"""
validateInputNotNull(value, context);
if (!(value instanceof Interval)) {
throw new SuperCsvCellProcessorException(Interval.class, value,
context, this);
}
final Interval interval = (Interval) value;
final String result = interval.toString();
return next.execute(result, context);
} | java | public Object execute(final Object value, final CsvContext context) {
validateInputNotNull(value, context);
if (!(value instanceof Interval)) {
throw new SuperCsvCellProcessorException(Interval.class, value,
context, this);
}
final Interval interval = (Interval) value;
final String result = interval.toString();
return next.execute(result, context);
} | [
"public",
"Object",
"execute",
"(",
"final",
"Object",
"value",
",",
"final",
"CsvContext",
"context",
")",
"{",
"validateInputNotNull",
"(",
"value",
",",
"context",
")",
";",
"if",
"(",
"!",
"(",
"value",
"instanceof",
"Interval",
")",
")",
"{",
"throw",
"new",
"SuperCsvCellProcessorException",
"(",
"Interval",
".",
"class",
",",
"value",
",",
"context",
",",
"this",
")",
";",
"}",
"final",
"Interval",
"interval",
"=",
"(",
"Interval",
")",
"value",
";",
"final",
"String",
"result",
"=",
"interval",
".",
"toString",
"(",
")",
";",
"return",
"next",
".",
"execute",
"(",
"result",
",",
"context",
")",
";",
"}"
] | {@inheritDoc}
@throws SuperCsvCellProcessorException
if value is null or not a Interval | [
"{",
"@inheritDoc",
"}"
] | train | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv-joda/src/main/java/org/supercsv/cellprocessor/joda/FmtInterval.java#L58-L67 |
looly/hutool | hutool-extra/src/main/java/cn/hutool/extra/mail/MailUtil.java | MailUtil.sendText | public static void sendText(Collection<String> tos, String subject, String content, File... files) {
"""
使用配置文件中设置的账户发送文本邮件,发送给多人
@param tos 收件人列表
@param subject 标题
@param content 正文
@param files 附件列表
"""
send(tos, subject, content, false, files);
} | java | public static void sendText(Collection<String> tos, String subject, String content, File... files) {
send(tos, subject, content, false, files);
} | [
"public",
"static",
"void",
"sendText",
"(",
"Collection",
"<",
"String",
">",
"tos",
",",
"String",
"subject",
",",
"String",
"content",
",",
"File",
"...",
"files",
")",
"{",
"send",
"(",
"tos",
",",
"subject",
",",
"content",
",",
"false",
",",
"files",
")",
";",
"}"
] | 使用配置文件中设置的账户发送文本邮件,发送给多人
@param tos 收件人列表
@param subject 标题
@param content 正文
@param files 附件列表 | [
"使用配置文件中设置的账户发送文本邮件,发送给多人"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-extra/src/main/java/cn/hutool/extra/mail/MailUtil.java#L85-L87 |
geomajas/geomajas-project-client-gwt | plugin/widget-searchandfilter/searchandfilter-gwt/src/main/java/org/geomajas/widget/searchandfilter/client/widget/multifeaturelistgrid/MultiFeatureListGrid.java | MultiFeatureListGrid.addFeatures | public void addFeatures(Map<VectorLayer, List<Feature>> featureMap, Criterion criterion) {
"""
Add features in the widget for several layers.
@param featureMap map of features per layer
@param criterion the original request for this search
"""
if (showDetailsOnSingleResult && featureMap.size() == 1) {
// sorting is never needed if only 1 entry
List<Feature> features = featureMap.values().iterator().next();
if (features.size() == 1) {
showFeatureDetailWindow(map, features.get(0));
}
}
//Add feature tabs in map order
for (VectorLayer layer : map.getMapModel().getVectorLayers()) {
if (featureMap.containsKey(layer)) {
addFeatures(layer, featureMap.get(layer), criterion);
}
}
tabset.selectTab(0);
} | java | public void addFeatures(Map<VectorLayer, List<Feature>> featureMap, Criterion criterion) {
if (showDetailsOnSingleResult && featureMap.size() == 1) {
// sorting is never needed if only 1 entry
List<Feature> features = featureMap.values().iterator().next();
if (features.size() == 1) {
showFeatureDetailWindow(map, features.get(0));
}
}
//Add feature tabs in map order
for (VectorLayer layer : map.getMapModel().getVectorLayers()) {
if (featureMap.containsKey(layer)) {
addFeatures(layer, featureMap.get(layer), criterion);
}
}
tabset.selectTab(0);
} | [
"public",
"void",
"addFeatures",
"(",
"Map",
"<",
"VectorLayer",
",",
"List",
"<",
"Feature",
">",
">",
"featureMap",
",",
"Criterion",
"criterion",
")",
"{",
"if",
"(",
"showDetailsOnSingleResult",
"&&",
"featureMap",
".",
"size",
"(",
")",
"==",
"1",
")",
"{",
"// sorting is never needed if only 1 entry",
"List",
"<",
"Feature",
">",
"features",
"=",
"featureMap",
".",
"values",
"(",
")",
".",
"iterator",
"(",
")",
".",
"next",
"(",
")",
";",
"if",
"(",
"features",
".",
"size",
"(",
")",
"==",
"1",
")",
"{",
"showFeatureDetailWindow",
"(",
"map",
",",
"features",
".",
"get",
"(",
"0",
")",
")",
";",
"}",
"}",
"//Add feature tabs in map order",
"for",
"(",
"VectorLayer",
"layer",
":",
"map",
".",
"getMapModel",
"(",
")",
".",
"getVectorLayers",
"(",
")",
")",
"{",
"if",
"(",
"featureMap",
".",
"containsKey",
"(",
"layer",
")",
")",
"{",
"addFeatures",
"(",
"layer",
",",
"featureMap",
".",
"get",
"(",
"layer",
")",
",",
"criterion",
")",
";",
"}",
"}",
"tabset",
".",
"selectTab",
"(",
"0",
")",
";",
"}"
] | Add features in the widget for several layers.
@param featureMap map of features per layer
@param criterion the original request for this search | [
"Add",
"features",
"in",
"the",
"widget",
"for",
"several",
"layers",
"."
] | train | https://github.com/geomajas/geomajas-project-client-gwt/blob/1c1adc48deb192ed825265eebcc74d70bbf45670/plugin/widget-searchandfilter/searchandfilter-gwt/src/main/java/org/geomajas/widget/searchandfilter/client/widget/multifeaturelistgrid/MultiFeatureListGrid.java#L168-L184 |
Appendium/objectlabkit | fxcalc/src/main/java/net/objectlab/kit/fxcalc/MajorCurrencyRankingImpl.java | MajorCurrencyRankingImpl.isMarketConvention | @Override
public boolean isMarketConvention(final String ccy1, final String ccy2) {
"""
returns true if the ccy1 is the major one for the given currency pair.
"""
return selectMajorCurrency(ccy1, ccy2).equals(ccy1);
} | java | @Override
public boolean isMarketConvention(final String ccy1, final String ccy2) {
return selectMajorCurrency(ccy1, ccy2).equals(ccy1);
} | [
"@",
"Override",
"public",
"boolean",
"isMarketConvention",
"(",
"final",
"String",
"ccy1",
",",
"final",
"String",
"ccy2",
")",
"{",
"return",
"selectMajorCurrency",
"(",
"ccy1",
",",
"ccy2",
")",
".",
"equals",
"(",
"ccy1",
")",
";",
"}"
] | returns true if the ccy1 is the major one for the given currency pair. | [
"returns",
"true",
"if",
"the",
"ccy1",
"is",
"the",
"major",
"one",
"for",
"the",
"given",
"currency",
"pair",
"."
] | train | https://github.com/Appendium/objectlabkit/blob/cd649bce7a32e4e926520e62cb765f3b1d451594/fxcalc/src/main/java/net/objectlab/kit/fxcalc/MajorCurrencyRankingImpl.java#L55-L58 |
OpenLiberty/open-liberty | dev/com.ibm.ws.injection/src/com/ibm/ws/injectionengine/osgi/internal/IndirectJndiLookupObjectFactory.java | IndirectJndiLookupObjectFactory.getJNDIServiceObjectInstance | @FFDCIgnore(PrivilegedActionException.class)
private Object getJNDIServiceObjectInstance(final String className, final String bindingName, final Hashtable<?, ?> envmt) throws Exception {
"""
Try to get an object instance by looking in the OSGi service registry
similar to how /com.ibm.ws.jndi/ implements the default namespace.
@return the object instance, or null if an object could not be found
"""
try {
return AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
@Override
public Object run() throws Exception {
return getJNDIServiceObjectInstancePrivileged(className, bindingName, envmt);
}
});
} catch (PrivilegedActionException paex) {
Throwable cause = paex.getCause();
if (cause instanceof Exception) {
throw (Exception) cause;
}
throw new Error(cause);
}
} | java | @FFDCIgnore(PrivilegedActionException.class)
private Object getJNDIServiceObjectInstance(final String className, final String bindingName, final Hashtable<?, ?> envmt) throws Exception {
try {
return AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
@Override
public Object run() throws Exception {
return getJNDIServiceObjectInstancePrivileged(className, bindingName, envmt);
}
});
} catch (PrivilegedActionException paex) {
Throwable cause = paex.getCause();
if (cause instanceof Exception) {
throw (Exception) cause;
}
throw new Error(cause);
}
} | [
"@",
"FFDCIgnore",
"(",
"PrivilegedActionException",
".",
"class",
")",
"private",
"Object",
"getJNDIServiceObjectInstance",
"(",
"final",
"String",
"className",
",",
"final",
"String",
"bindingName",
",",
"final",
"Hashtable",
"<",
"?",
",",
"?",
">",
"envmt",
")",
"throws",
"Exception",
"{",
"try",
"{",
"return",
"AccessController",
".",
"doPrivileged",
"(",
"new",
"PrivilegedExceptionAction",
"<",
"Object",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Object",
"run",
"(",
")",
"throws",
"Exception",
"{",
"return",
"getJNDIServiceObjectInstancePrivileged",
"(",
"className",
",",
"bindingName",
",",
"envmt",
")",
";",
"}",
"}",
")",
";",
"}",
"catch",
"(",
"PrivilegedActionException",
"paex",
")",
"{",
"Throwable",
"cause",
"=",
"paex",
".",
"getCause",
"(",
")",
";",
"if",
"(",
"cause",
"instanceof",
"Exception",
")",
"{",
"throw",
"(",
"Exception",
")",
"cause",
";",
"}",
"throw",
"new",
"Error",
"(",
"cause",
")",
";",
"}",
"}"
] | Try to get an object instance by looking in the OSGi service registry
similar to how /com.ibm.ws.jndi/ implements the default namespace.
@return the object instance, or null if an object could not be found | [
"Try",
"to",
"get",
"an",
"object",
"instance",
"by",
"looking",
"in",
"the",
"OSGi",
"service",
"registry",
"similar",
"to",
"how",
"/",
"com",
".",
"ibm",
".",
"ws",
".",
"jndi",
"/",
"implements",
"the",
"default",
"namespace",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.injection/src/com/ibm/ws/injectionengine/osgi/internal/IndirectJndiLookupObjectFactory.java#L213-L229 |
zerodhatech/javakiteconnect | kiteconnect/src/com/zerodhatech/kiteconnect/KiteConnect.java | KiteConnect.convertPosition | public JSONObject convertPosition(String tradingSymbol, String exchange, String transactionType, String positionType, String oldProduct, String newProduct, int quantity) throws KiteException, JSONException, IOException {
"""
Modifies an open position's product type. Only an MIS, CNC, and NRML positions can be converted.
@param tradingSymbol Tradingsymbol of the instrument (ex. RELIANCE, INFY).
@param exchange Exchange in which instrument is listed (NSE, BSE, NFO, BFO, CDS, MCX).
@param transactionType Transaction type (BUY or SELL).
@param positionType day or overnight position
@param oldProduct Product code (NRML, MIS, CNC).
@param newProduct Product code (NRML, MIS, CNC).
@param quantity Order quantity
@return JSONObject which will have status.
@throws KiteException is thrown for all Kite trade related errors.
@throws JSONException is thrown when there is exception while parsing response.
@throws IOException is thrown when there is connection error.
"""
Map<String, Object> params = new HashMap<>();
params.put("tradingsymbol", tradingSymbol);
params.put("exchange", exchange);
params.put("transaction_type", transactionType);
params.put("position_type", positionType);
params.put("old_product", oldProduct);
params.put("new_product", newProduct);
params.put("quantity", quantity);
KiteRequestHandler kiteRequestHandler = new KiteRequestHandler(proxy);
return kiteRequestHandler.putRequest(routes.get("portfolio.positions.modify"), params, apiKey, accessToken);
} | java | public JSONObject convertPosition(String tradingSymbol, String exchange, String transactionType, String positionType, String oldProduct, String newProduct, int quantity) throws KiteException, JSONException, IOException {
Map<String, Object> params = new HashMap<>();
params.put("tradingsymbol", tradingSymbol);
params.put("exchange", exchange);
params.put("transaction_type", transactionType);
params.put("position_type", positionType);
params.put("old_product", oldProduct);
params.put("new_product", newProduct);
params.put("quantity", quantity);
KiteRequestHandler kiteRequestHandler = new KiteRequestHandler(proxy);
return kiteRequestHandler.putRequest(routes.get("portfolio.positions.modify"), params, apiKey, accessToken);
} | [
"public",
"JSONObject",
"convertPosition",
"(",
"String",
"tradingSymbol",
",",
"String",
"exchange",
",",
"String",
"transactionType",
",",
"String",
"positionType",
",",
"String",
"oldProduct",
",",
"String",
"newProduct",
",",
"int",
"quantity",
")",
"throws",
"KiteException",
",",
"JSONException",
",",
"IOException",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"params",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"params",
".",
"put",
"(",
"\"tradingsymbol\"",
",",
"tradingSymbol",
")",
";",
"params",
".",
"put",
"(",
"\"exchange\"",
",",
"exchange",
")",
";",
"params",
".",
"put",
"(",
"\"transaction_type\"",
",",
"transactionType",
")",
";",
"params",
".",
"put",
"(",
"\"position_type\"",
",",
"positionType",
")",
";",
"params",
".",
"put",
"(",
"\"old_product\"",
",",
"oldProduct",
")",
";",
"params",
".",
"put",
"(",
"\"new_product\"",
",",
"newProduct",
")",
";",
"params",
".",
"put",
"(",
"\"quantity\"",
",",
"quantity",
")",
";",
"KiteRequestHandler",
"kiteRequestHandler",
"=",
"new",
"KiteRequestHandler",
"(",
"proxy",
")",
";",
"return",
"kiteRequestHandler",
".",
"putRequest",
"(",
"routes",
".",
"get",
"(",
"\"portfolio.positions.modify\"",
")",
",",
"params",
",",
"apiKey",
",",
"accessToken",
")",
";",
"}"
] | Modifies an open position's product type. Only an MIS, CNC, and NRML positions can be converted.
@param tradingSymbol Tradingsymbol of the instrument (ex. RELIANCE, INFY).
@param exchange Exchange in which instrument is listed (NSE, BSE, NFO, BFO, CDS, MCX).
@param transactionType Transaction type (BUY or SELL).
@param positionType day or overnight position
@param oldProduct Product code (NRML, MIS, CNC).
@param newProduct Product code (NRML, MIS, CNC).
@param quantity Order quantity
@return JSONObject which will have status.
@throws KiteException is thrown for all Kite trade related errors.
@throws JSONException is thrown when there is exception while parsing response.
@throws IOException is thrown when there is connection error. | [
"Modifies",
"an",
"open",
"position",
"s",
"product",
"type",
".",
"Only",
"an",
"MIS",
"CNC",
"and",
"NRML",
"positions",
"can",
"be",
"converted",
"."
] | train | https://github.com/zerodhatech/javakiteconnect/blob/4a3f15ff2c8a1b3b6ec61799f8bb047e4dfeb92d/kiteconnect/src/com/zerodhatech/kiteconnect/KiteConnect.java#L458-L470 |
burberius/eve-esi | src/main/java/net/troja/eve/esi/api/CorporationApi.java | CorporationApi.getCorporationsCorporationIdStructuresWithHttpInfo | public ApiResponse<List<CorporationStructuresResponse>> getCorporationsCorporationIdStructuresWithHttpInfo(
Integer corporationId, String acceptLanguage, String datasource, String ifNoneMatch, String language,
Integer page, String token) throws ApiException {
"""
Get corporation structures Get a list of corporation structures. This
route's version includes the changes to structures detailed in this
blog:
https://www.eveonline.com/article/upwell-2.0-structures-changes-coming
-on-february-13th --- This route is cached for up to 3600 seconds ---
Requires one of the following EVE corporation role(s): Station_Manager
SSO Scope: esi-corporations.read_structures.v1
@param corporationId
An EVE corporation ID (required)
@param acceptLanguage
Language to use in the response (optional, default to en-us)
@param datasource
The server name you would like data from (optional, default to
tranquility)
@param ifNoneMatch
ETag from a previous request. A 304 will be returned if this
matches the current ETag (optional)
@param language
Language to use in the response, takes precedence over
Accept-Language (optional, default to en-us)
@param page
Which page of results to return (optional, default to 1)
@param token
Access token to use if unable to set a header (optional)
@return ApiResponse<List<CorporationStructuresResponse>>
@throws ApiException
If fail to call the API, e.g. server error or cannot
deserialize the response body
"""
com.squareup.okhttp.Call call = getCorporationsCorporationIdStructuresValidateBeforeCall(corporationId,
acceptLanguage, datasource, ifNoneMatch, language, page, token, null);
Type localVarReturnType = new TypeToken<List<CorporationStructuresResponse>>() {
}.getType();
return apiClient.execute(call, localVarReturnType);
} | java | public ApiResponse<List<CorporationStructuresResponse>> getCorporationsCorporationIdStructuresWithHttpInfo(
Integer corporationId, String acceptLanguage, String datasource, String ifNoneMatch, String language,
Integer page, String token) throws ApiException {
com.squareup.okhttp.Call call = getCorporationsCorporationIdStructuresValidateBeforeCall(corporationId,
acceptLanguage, datasource, ifNoneMatch, language, page, token, null);
Type localVarReturnType = new TypeToken<List<CorporationStructuresResponse>>() {
}.getType();
return apiClient.execute(call, localVarReturnType);
} | [
"public",
"ApiResponse",
"<",
"List",
"<",
"CorporationStructuresResponse",
">",
">",
"getCorporationsCorporationIdStructuresWithHttpInfo",
"(",
"Integer",
"corporationId",
",",
"String",
"acceptLanguage",
",",
"String",
"datasource",
",",
"String",
"ifNoneMatch",
",",
"String",
"language",
",",
"Integer",
"page",
",",
"String",
"token",
")",
"throws",
"ApiException",
"{",
"com",
".",
"squareup",
".",
"okhttp",
".",
"Call",
"call",
"=",
"getCorporationsCorporationIdStructuresValidateBeforeCall",
"(",
"corporationId",
",",
"acceptLanguage",
",",
"datasource",
",",
"ifNoneMatch",
",",
"language",
",",
"page",
",",
"token",
",",
"null",
")",
";",
"Type",
"localVarReturnType",
"=",
"new",
"TypeToken",
"<",
"List",
"<",
"CorporationStructuresResponse",
">",
">",
"(",
")",
"{",
"}",
".",
"getType",
"(",
")",
";",
"return",
"apiClient",
".",
"execute",
"(",
"call",
",",
"localVarReturnType",
")",
";",
"}"
] | Get corporation structures Get a list of corporation structures. This
route's version includes the changes to structures detailed in this
blog:
https://www.eveonline.com/article/upwell-2.0-structures-changes-coming
-on-february-13th --- This route is cached for up to 3600 seconds ---
Requires one of the following EVE corporation role(s): Station_Manager
SSO Scope: esi-corporations.read_structures.v1
@param corporationId
An EVE corporation ID (required)
@param acceptLanguage
Language to use in the response (optional, default to en-us)
@param datasource
The server name you would like data from (optional, default to
tranquility)
@param ifNoneMatch
ETag from a previous request. A 304 will be returned if this
matches the current ETag (optional)
@param language
Language to use in the response, takes precedence over
Accept-Language (optional, default to en-us)
@param page
Which page of results to return (optional, default to 1)
@param token
Access token to use if unable to set a header (optional)
@return ApiResponse<List<CorporationStructuresResponse>>
@throws ApiException
If fail to call the API, e.g. server error or cannot
deserialize the response body | [
"Get",
"corporation",
"structures",
"Get",
"a",
"list",
"of",
"corporation",
"structures",
".",
"This",
"route'",
";",
"s",
"version",
"includes",
"the",
"changes",
"to",
"structures",
"detailed",
"in",
"this",
"blog",
":",
"https",
":",
"//",
"www",
".",
"eveonline",
".",
"com",
"/",
"article",
"/",
"upwell",
"-",
"2",
".",
"0",
"-",
"structures",
"-",
"changes",
"-",
"coming",
"-",
"on",
"-",
"february",
"-",
"13th",
"---",
"This",
"route",
"is",
"cached",
"for",
"up",
"to",
"3600",
"seconds",
"---",
"Requires",
"one",
"of",
"the",
"following",
"EVE",
"corporation",
"role",
"(",
"s",
")",
":",
"Station_Manager",
"SSO",
"Scope",
":",
"esi",
"-",
"corporations",
".",
"read_structures",
".",
"v1"
] | train | https://github.com/burberius/eve-esi/blob/24a941c592cfc15f23471ef849b282fbc582ca13/src/main/java/net/troja/eve/esi/api/CorporationApi.java#L3556-L3564 |
haifengl/smile | core/src/main/java/smile/neighbor/MPLSH.java | MPLSH.learn | public void learn(RNNSearch<double[], double[]> range, double[][] samples, double radius, int Nz, double sigma) {
"""
Train the posteriori multiple probe algorithm.
@param range the neighborhood search data structure.
@param radius the radius for range search.
@param Nz the number of quantized values.
@param sigma the Parzen window width.
"""
TrainSample[] training = new TrainSample[samples.length];
for (int i = 0; i < samples.length; i++) {
training[i] = new TrainSample();
training[i].query = samples[i];
training[i].neighbors = new ArrayList<>();
ArrayList<Neighbor<double[], double[]>> neighbors = new ArrayList<>();
range.range(training[i].query, radius, neighbors);
for (Neighbor<double[], double[]> n : neighbors) {
training[i].neighbors.add(keys.get(n.index));
}
}
model = new ArrayList<>(hash.size());
for (int i = 0; i < hash.size(); i++) {
model.add(new PosterioriModel(hash.get(i), training, Nz, sigma));
}
} | java | public void learn(RNNSearch<double[], double[]> range, double[][] samples, double radius, int Nz, double sigma) {
TrainSample[] training = new TrainSample[samples.length];
for (int i = 0; i < samples.length; i++) {
training[i] = new TrainSample();
training[i].query = samples[i];
training[i].neighbors = new ArrayList<>();
ArrayList<Neighbor<double[], double[]>> neighbors = new ArrayList<>();
range.range(training[i].query, radius, neighbors);
for (Neighbor<double[], double[]> n : neighbors) {
training[i].neighbors.add(keys.get(n.index));
}
}
model = new ArrayList<>(hash.size());
for (int i = 0; i < hash.size(); i++) {
model.add(new PosterioriModel(hash.get(i), training, Nz, sigma));
}
} | [
"public",
"void",
"learn",
"(",
"RNNSearch",
"<",
"double",
"[",
"]",
",",
"double",
"[",
"]",
">",
"range",
",",
"double",
"[",
"]",
"[",
"]",
"samples",
",",
"double",
"radius",
",",
"int",
"Nz",
",",
"double",
"sigma",
")",
"{",
"TrainSample",
"[",
"]",
"training",
"=",
"new",
"TrainSample",
"[",
"samples",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"samples",
".",
"length",
";",
"i",
"++",
")",
"{",
"training",
"[",
"i",
"]",
"=",
"new",
"TrainSample",
"(",
")",
";",
"training",
"[",
"i",
"]",
".",
"query",
"=",
"samples",
"[",
"i",
"]",
";",
"training",
"[",
"i",
"]",
".",
"neighbors",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"ArrayList",
"<",
"Neighbor",
"<",
"double",
"[",
"]",
",",
"double",
"[",
"]",
">",
">",
"neighbors",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"range",
".",
"range",
"(",
"training",
"[",
"i",
"]",
".",
"query",
",",
"radius",
",",
"neighbors",
")",
";",
"for",
"(",
"Neighbor",
"<",
"double",
"[",
"]",
",",
"double",
"[",
"]",
">",
"n",
":",
"neighbors",
")",
"{",
"training",
"[",
"i",
"]",
".",
"neighbors",
".",
"add",
"(",
"keys",
".",
"get",
"(",
"n",
".",
"index",
")",
")",
";",
"}",
"}",
"model",
"=",
"new",
"ArrayList",
"<>",
"(",
"hash",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"hash",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"model",
".",
"add",
"(",
"new",
"PosterioriModel",
"(",
"hash",
".",
"get",
"(",
"i",
")",
",",
"training",
",",
"Nz",
",",
"sigma",
")",
")",
";",
"}",
"}"
] | Train the posteriori multiple probe algorithm.
@param range the neighborhood search data structure.
@param radius the radius for range search.
@param Nz the number of quantized values.
@param sigma the Parzen window width. | [
"Train",
"the",
"posteriori",
"multiple",
"probe",
"algorithm",
"."
] | train | https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/neighbor/MPLSH.java#L869-L886 |
Azure/azure-sdk-for-java | containerservice/resource-manager/v2019_02_01/src/main/java/com/microsoft/azure/management/containerservice/v2019_02_01/implementation/ManagedClustersInner.java | ManagedClustersInner.getAccessProfile | public ManagedClusterAccessProfileInner getAccessProfile(String resourceGroupName, String resourceName, String roleName) {
"""
Gets an access profile of a managed cluster.
Gets the accessProfile for the specified role name of the managed cluster with a specified resource group and name.
@param resourceGroupName The name of the resource group.
@param resourceName The name of the managed cluster resource.
@param roleName The name of the role for managed cluster accessProfile resource.
@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 ManagedClusterAccessProfileInner object if successful.
"""
return getAccessProfileWithServiceResponseAsync(resourceGroupName, resourceName, roleName).toBlocking().single().body();
} | java | public ManagedClusterAccessProfileInner getAccessProfile(String resourceGroupName, String resourceName, String roleName) {
return getAccessProfileWithServiceResponseAsync(resourceGroupName, resourceName, roleName).toBlocking().single().body();
} | [
"public",
"ManagedClusterAccessProfileInner",
"getAccessProfile",
"(",
"String",
"resourceGroupName",
",",
"String",
"resourceName",
",",
"String",
"roleName",
")",
"{",
"return",
"getAccessProfileWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"resourceName",
",",
"roleName",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Gets an access profile of a managed cluster.
Gets the accessProfile for the specified role name of the managed cluster with a specified resource group and name.
@param resourceGroupName The name of the resource group.
@param resourceName The name of the managed cluster resource.
@param roleName The name of the role for managed cluster accessProfile resource.
@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 ManagedClusterAccessProfileInner object if successful. | [
"Gets",
"an",
"access",
"profile",
"of",
"a",
"managed",
"cluster",
".",
"Gets",
"the",
"accessProfile",
"for",
"the",
"specified",
"role",
"name",
"of",
"the",
"managed",
"cluster",
"with",
"a",
"specified",
"resource",
"group",
"and",
"name",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/containerservice/resource-manager/v2019_02_01/src/main/java/com/microsoft/azure/management/containerservice/v2019_02_01/implementation/ManagedClustersInner.java#L479-L481 |
elki-project/elki | elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/KappaDistribution.java | KappaDistribution.logcdf | public static double logcdf(double val, double loc, double scale, double shape1, double shape2) {
"""
Cumulative density function.
@param val Value
@param loc Location
@param scale Scale
@param shape1 Shape parameter
@param shape2 Shape parameter
@return CDF
"""
return logcdf((val - loc) / scale, shape1, shape2);
} | java | public static double logcdf(double val, double loc, double scale, double shape1, double shape2) {
return logcdf((val - loc) / scale, shape1, shape2);
} | [
"public",
"static",
"double",
"logcdf",
"(",
"double",
"val",
",",
"double",
"loc",
",",
"double",
"scale",
",",
"double",
"shape1",
",",
"double",
"shape2",
")",
"{",
"return",
"logcdf",
"(",
"(",
"val",
"-",
"loc",
")",
"/",
"scale",
",",
"shape1",
",",
"shape2",
")",
";",
"}"
] | Cumulative density function.
@param val Value
@param loc Location
@param scale Scale
@param shape1 Shape parameter
@param shape2 Shape parameter
@return CDF | [
"Cumulative",
"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/KappaDistribution.java#L234-L236 |
hazelcast/hazelcast | hazelcast/src/main/java/com/hazelcast/cp/internal/raft/impl/RaftNodeImpl.java | RaftNodeImpl.registerFuture | public void registerFuture(long entryIndex, SimpleCompletableFuture future) {
"""
Registers the future for the appended entry with its {@code entryIndex}.
"""
SimpleCompletableFuture f = futures.put(entryIndex, future);
assert f == null : "Future object is already registered for entry index: " + entryIndex;
} | java | public void registerFuture(long entryIndex, SimpleCompletableFuture future) {
SimpleCompletableFuture f = futures.put(entryIndex, future);
assert f == null : "Future object is already registered for entry index: " + entryIndex;
} | [
"public",
"void",
"registerFuture",
"(",
"long",
"entryIndex",
",",
"SimpleCompletableFuture",
"future",
")",
"{",
"SimpleCompletableFuture",
"f",
"=",
"futures",
".",
"put",
"(",
"entryIndex",
",",
"future",
")",
";",
"assert",
"f",
"==",
"null",
":",
"\"Future object is already registered for entry index: \"",
"+",
"entryIndex",
";",
"}"
] | Registers the future for the appended entry with its {@code entryIndex}. | [
"Registers",
"the",
"future",
"for",
"the",
"appended",
"entry",
"with",
"its",
"{"
] | train | https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cp/internal/raft/impl/RaftNodeImpl.java#L666-L669 |
shamanland/xdroid | lib-core/src/main/java/xdroid/core/ThreadUtils.java | ThreadUtils.stopThread | public static void stopThread(Handler handler, boolean asap) {
"""
Post the {@link Runnable} instance with the following code to the {@link Handler} provided:
<pre>
public void run() {
Looper.myLooper().quit();
}
</pre>
@param handler target handler, can not be null
@param asap if true then method {@link Handler#postAtFrontOfQueue(Runnable)} will be used.
"""
Runnable stopper = sStopper;
if (stopper == null) {
stopper = new ThreadUtils();
sStopper = stopper;
}
if (asap) {
handler.postAtFrontOfQueue(stopper);
} else {
handler.post(stopper);
}
} | java | public static void stopThread(Handler handler, boolean asap) {
Runnable stopper = sStopper;
if (stopper == null) {
stopper = new ThreadUtils();
sStopper = stopper;
}
if (asap) {
handler.postAtFrontOfQueue(stopper);
} else {
handler.post(stopper);
}
} | [
"public",
"static",
"void",
"stopThread",
"(",
"Handler",
"handler",
",",
"boolean",
"asap",
")",
"{",
"Runnable",
"stopper",
"=",
"sStopper",
";",
"if",
"(",
"stopper",
"==",
"null",
")",
"{",
"stopper",
"=",
"new",
"ThreadUtils",
"(",
")",
";",
"sStopper",
"=",
"stopper",
";",
"}",
"if",
"(",
"asap",
")",
"{",
"handler",
".",
"postAtFrontOfQueue",
"(",
"stopper",
")",
";",
"}",
"else",
"{",
"handler",
".",
"post",
"(",
"stopper",
")",
";",
"}",
"}"
] | Post the {@link Runnable} instance with the following code to the {@link Handler} provided:
<pre>
public void run() {
Looper.myLooper().quit();
}
</pre>
@param handler target handler, can not be null
@param asap if true then method {@link Handler#postAtFrontOfQueue(Runnable)} will be used. | [
"Post",
"the",
"{",
"@link",
"Runnable",
"}",
"instance",
"with",
"the",
"following",
"code",
"to",
"the",
"{",
"@link",
"Handler",
"}",
"provided",
":",
"<pre",
">",
"public",
"void",
"run",
"()",
"{",
"Looper",
".",
"myLooper",
"()",
".",
"quit",
"()",
";",
"}",
"<",
"/",
"pre",
">"
] | train | https://github.com/shamanland/xdroid/blob/5330811114afaf6a7b8f9a10f3bbe19d37995d89/lib-core/src/main/java/xdroid/core/ThreadUtils.java#L89-L101 |
micronaut-projects/micronaut-core | core/src/main/java/io/micronaut/core/async/publisher/Publishers.java | Publishers.convertPublisher | public static <T> T convertPublisher(Object object, Class<T> publisherType) {
"""
Attempts to convert the publisher to the given type.
@param object The object to convert
@param publisherType The publisher type
@param <T> The generic type
@return The Resulting in publisher
"""
Objects.requireNonNull(object, "Invalid argument [object]: " + object);
Objects.requireNonNull(object, "Invalid argument [publisherType]: " + publisherType);
if (object instanceof CompletableFuture) {
@SuppressWarnings("unchecked") Publisher<T> futurePublisher = (Publisher<T>) Publishers.fromCompletableFuture(() -> ((CompletableFuture) object));
return ConversionService.SHARED.convert(futurePublisher, publisherType)
.orElseThrow(() -> new IllegalArgumentException("Unsupported Reactive type: " + object.getClass()));
} else {
return ConversionService.SHARED.convert(object, publisherType)
.orElseThrow(() -> new IllegalArgumentException("Unsupported Reactive type: " + object.getClass()));
}
} | java | public static <T> T convertPublisher(Object object, Class<T> publisherType) {
Objects.requireNonNull(object, "Invalid argument [object]: " + object);
Objects.requireNonNull(object, "Invalid argument [publisherType]: " + publisherType);
if (object instanceof CompletableFuture) {
@SuppressWarnings("unchecked") Publisher<T> futurePublisher = (Publisher<T>) Publishers.fromCompletableFuture(() -> ((CompletableFuture) object));
return ConversionService.SHARED.convert(futurePublisher, publisherType)
.orElseThrow(() -> new IllegalArgumentException("Unsupported Reactive type: " + object.getClass()));
} else {
return ConversionService.SHARED.convert(object, publisherType)
.orElseThrow(() -> new IllegalArgumentException("Unsupported Reactive type: " + object.getClass()));
}
} | [
"public",
"static",
"<",
"T",
">",
"T",
"convertPublisher",
"(",
"Object",
"object",
",",
"Class",
"<",
"T",
">",
"publisherType",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"object",
",",
"\"Invalid argument [object]: \"",
"+",
"object",
")",
";",
"Objects",
".",
"requireNonNull",
"(",
"object",
",",
"\"Invalid argument [publisherType]: \"",
"+",
"publisherType",
")",
";",
"if",
"(",
"object",
"instanceof",
"CompletableFuture",
")",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"Publisher",
"<",
"T",
">",
"futurePublisher",
"=",
"(",
"Publisher",
"<",
"T",
">",
")",
"Publishers",
".",
"fromCompletableFuture",
"(",
"(",
")",
"->",
"(",
"(",
"CompletableFuture",
")",
"object",
")",
")",
";",
"return",
"ConversionService",
".",
"SHARED",
".",
"convert",
"(",
"futurePublisher",
",",
"publisherType",
")",
".",
"orElseThrow",
"(",
"(",
")",
"->",
"new",
"IllegalArgumentException",
"(",
"\"Unsupported Reactive type: \"",
"+",
"object",
".",
"getClass",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"return",
"ConversionService",
".",
"SHARED",
".",
"convert",
"(",
"object",
",",
"publisherType",
")",
".",
"orElseThrow",
"(",
"(",
")",
"->",
"new",
"IllegalArgumentException",
"(",
"\"Unsupported Reactive type: \"",
"+",
"object",
".",
"getClass",
"(",
")",
")",
")",
";",
"}",
"}"
] | Attempts to convert the publisher to the given type.
@param object The object to convert
@param publisherType The publisher type
@param <T> The generic type
@return The Resulting in publisher | [
"Attempts",
"to",
"convert",
"the",
"publisher",
"to",
"the",
"given",
"type",
"."
] | train | https://github.com/micronaut-projects/micronaut-core/blob/c31f5b03ce0eb88c2f6470710987db03b8967d5c/core/src/main/java/io/micronaut/core/async/publisher/Publishers.java#L287-L298 |
Mozu/mozu-java | mozu-java-core/src/main/java/com/mozu/api/urls/commerce/checkouts/DestinationUrl.java | DestinationUrl.removeDestinationUrl | public static MozuUrl removeDestinationUrl(String checkoutId, String destinationId) {
"""
Get Resource Url for RemoveDestination
@param checkoutId The unique identifier of the checkout.
@param destinationId The unique identifier of the destination.
@return String Resource Url
"""
UrlFormatter formatter = new UrlFormatter("/api/commerce/checkouts/{checkoutId}/destinations/{destinationId}");
formatter.formatUrl("checkoutId", checkoutId);
formatter.formatUrl("destinationId", destinationId);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
} | java | public static MozuUrl removeDestinationUrl(String checkoutId, String destinationId)
{
UrlFormatter formatter = new UrlFormatter("/api/commerce/checkouts/{checkoutId}/destinations/{destinationId}");
formatter.formatUrl("checkoutId", checkoutId);
formatter.formatUrl("destinationId", destinationId);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
} | [
"public",
"static",
"MozuUrl",
"removeDestinationUrl",
"(",
"String",
"checkoutId",
",",
"String",
"destinationId",
")",
"{",
"UrlFormatter",
"formatter",
"=",
"new",
"UrlFormatter",
"(",
"\"/api/commerce/checkouts/{checkoutId}/destinations/{destinationId}\"",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"checkoutId\"",
",",
"checkoutId",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"destinationId\"",
",",
"destinationId",
")",
";",
"return",
"new",
"MozuUrl",
"(",
"formatter",
".",
"getResourceUrl",
"(",
")",
",",
"MozuUrl",
".",
"UrlLocation",
".",
"TENANT_POD",
")",
";",
"}"
] | Get Resource Url for RemoveDestination
@param checkoutId The unique identifier of the checkout.
@param destinationId The unique identifier of the destination.
@return String Resource Url | [
"Get",
"Resource",
"Url",
"for",
"RemoveDestination"
] | train | https://github.com/Mozu/mozu-java/blob/5beadde73601a859f845e3e2fc1077b39c8bea83/mozu-java-core/src/main/java/com/mozu/api/urls/commerce/checkouts/DestinationUrl.java#L80-L86 |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/util/ClassHelper.java | ClassHelper.newInstance | public static Object newInstance(Class target, Class[] types, Object[] args) throws InstantiationException,
IllegalAccessException,
IllegalArgumentException,
InvocationTargetException,
NoSuchMethodException,
SecurityException {
"""
Returns a new instance of the given class, using the constructor with the specified parameter types.
@param target The class to instantiate
@param types The parameter types
@param args The arguments
@return The instance
"""
return newInstance(target, types, args, false);
} | java | public static Object newInstance(Class target, Class[] types, Object[] args) throws InstantiationException,
IllegalAccessException,
IllegalArgumentException,
InvocationTargetException,
NoSuchMethodException,
SecurityException
{
return newInstance(target, types, args, false);
} | [
"public",
"static",
"Object",
"newInstance",
"(",
"Class",
"target",
",",
"Class",
"[",
"]",
"types",
",",
"Object",
"[",
"]",
"args",
")",
"throws",
"InstantiationException",
",",
"IllegalAccessException",
",",
"IllegalArgumentException",
",",
"InvocationTargetException",
",",
"NoSuchMethodException",
",",
"SecurityException",
"{",
"return",
"newInstance",
"(",
"target",
",",
"types",
",",
"args",
",",
"false",
")",
";",
"}"
] | Returns a new instance of the given class, using the constructor with the specified parameter types.
@param target The class to instantiate
@param types The parameter types
@param args The arguments
@return The instance | [
"Returns",
"a",
"new",
"instance",
"of",
"the",
"given",
"class",
"using",
"the",
"constructor",
"with",
"the",
"specified",
"parameter",
"types",
"."
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/util/ClassHelper.java#L180-L188 |
Azure/azure-sdk-for-java | sql/resource-manager/v2018_06_01_preview/src/main/java/com/microsoft/azure/management/sql/v2018_06_01_preview/implementation/ServerVulnerabilityAssessmentsInner.java | ServerVulnerabilityAssessmentsInner.getAsync | public Observable<ServerVulnerabilityAssessmentInner> getAsync(String resourceGroupName, String serverName) {
"""
Gets the server's vulnerability assessment.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server for which the vulnerability assessment is defined.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ServerVulnerabilityAssessmentInner object
"""
return getWithServiceResponseAsync(resourceGroupName, serverName).map(new Func1<ServiceResponse<ServerVulnerabilityAssessmentInner>, ServerVulnerabilityAssessmentInner>() {
@Override
public ServerVulnerabilityAssessmentInner call(ServiceResponse<ServerVulnerabilityAssessmentInner> response) {
return response.body();
}
});
} | java | public Observable<ServerVulnerabilityAssessmentInner> getAsync(String resourceGroupName, String serverName) {
return getWithServiceResponseAsync(resourceGroupName, serverName).map(new Func1<ServiceResponse<ServerVulnerabilityAssessmentInner>, ServerVulnerabilityAssessmentInner>() {
@Override
public ServerVulnerabilityAssessmentInner call(ServiceResponse<ServerVulnerabilityAssessmentInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ServerVulnerabilityAssessmentInner",
">",
"getAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"ServerVulnerabilityAssessmentInner",
">",
",",
"ServerVulnerabilityAssessmentInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"ServerVulnerabilityAssessmentInner",
"call",
"(",
"ServiceResponse",
"<",
"ServerVulnerabilityAssessmentInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Gets the server's vulnerability assessment.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server for which the vulnerability assessment is defined.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ServerVulnerabilityAssessmentInner object | [
"Gets",
"the",
"server",
"s",
"vulnerability",
"assessment",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2018_06_01_preview/src/main/java/com/microsoft/azure/management/sql/v2018_06_01_preview/implementation/ServerVulnerabilityAssessmentsInner.java#L122-L129 |
OpenLiberty/open-liberty | dev/com.ibm.ws.ssl/src/com/ibm/ws/ssl/config/SSLConfigManager.java | SSLConfigManager.checkURLHostNameVerificationProperty | public synchronized void checkURLHostNameVerificationProperty(boolean reinitialize) {
"""
*
This method installs a hostname verification checker that defaults to not
check the hostname. If it does not install this hostname verification
checker, then any URL connections must have a certificate that matches the
host that sent it.
@param reinitialize
*
"""
// enable/disable hostname verification
String urlHostNameVerification = getGlobalProperty(Constants.SSLPROP_URL_HOSTNAME_VERIFICATION);
if (urlHostNameVerification == null || urlHostNameVerification.equalsIgnoreCase("false") || urlHostNameVerification.equalsIgnoreCase("no")) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(tc, "com.ibm.ssl.performURLHostNameVerification disabled");
HostnameVerifier verifier = new HostnameVerifier() {
@Override
public boolean verify(String urlHostname, SSLSession session) {
return true;
}
};
HttpsURLConnection.setDefaultHostnameVerifier(verifier);
if (!reinitialize) {
Tr.info(tc, "ssl.disable.url.hostname.verification.CWPKI0027I");
}
} else {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(tc, "com.ibm.ssl.performURLHostNameVerification enabled");
}
} | java | public synchronized void checkURLHostNameVerificationProperty(boolean reinitialize) {
// enable/disable hostname verification
String urlHostNameVerification = getGlobalProperty(Constants.SSLPROP_URL_HOSTNAME_VERIFICATION);
if (urlHostNameVerification == null || urlHostNameVerification.equalsIgnoreCase("false") || urlHostNameVerification.equalsIgnoreCase("no")) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(tc, "com.ibm.ssl.performURLHostNameVerification disabled");
HostnameVerifier verifier = new HostnameVerifier() {
@Override
public boolean verify(String urlHostname, SSLSession session) {
return true;
}
};
HttpsURLConnection.setDefaultHostnameVerifier(verifier);
if (!reinitialize) {
Tr.info(tc, "ssl.disable.url.hostname.verification.CWPKI0027I");
}
} else {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(tc, "com.ibm.ssl.performURLHostNameVerification enabled");
}
} | [
"public",
"synchronized",
"void",
"checkURLHostNameVerificationProperty",
"(",
"boolean",
"reinitialize",
")",
"{",
"// enable/disable hostname verification",
"String",
"urlHostNameVerification",
"=",
"getGlobalProperty",
"(",
"Constants",
".",
"SSLPROP_URL_HOSTNAME_VERIFICATION",
")",
";",
"if",
"(",
"urlHostNameVerification",
"==",
"null",
"||",
"urlHostNameVerification",
".",
"equalsIgnoreCase",
"(",
"\"false\"",
")",
"||",
"urlHostNameVerification",
".",
"equalsIgnoreCase",
"(",
"\"no\"",
")",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"com.ibm.ssl.performURLHostNameVerification disabled\"",
")",
";",
"HostnameVerifier",
"verifier",
"=",
"new",
"HostnameVerifier",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"verify",
"(",
"String",
"urlHostname",
",",
"SSLSession",
"session",
")",
"{",
"return",
"true",
";",
"}",
"}",
";",
"HttpsURLConnection",
".",
"setDefaultHostnameVerifier",
"(",
"verifier",
")",
";",
"if",
"(",
"!",
"reinitialize",
")",
"{",
"Tr",
".",
"info",
"(",
"tc",
",",
"\"ssl.disable.url.hostname.verification.CWPKI0027I\"",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"com.ibm.ssl.performURLHostNameVerification enabled\"",
")",
";",
"}",
"}"
] | *
This method installs a hostname verification checker that defaults to not
check the hostname. If it does not install this hostname verification
checker, then any URL connections must have a certificate that matches the
host that sent it.
@param reinitialize
* | [
"*",
"This",
"method",
"installs",
"a",
"hostname",
"verification",
"checker",
"that",
"defaults",
"to",
"not",
"check",
"the",
"hostname",
".",
"If",
"it",
"does",
"not",
"install",
"this",
"hostname",
"verification",
"checker",
"then",
"any",
"URL",
"connections",
"must",
"have",
"a",
"certificate",
"that",
"matches",
"the",
"host",
"that",
"sent",
"it",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ssl/src/com/ibm/ws/ssl/config/SSLConfigManager.java#L1412-L1434 |
perwendel/spark | src/main/java/spark/Routable.java | Routable.afterAfter | public void afterAfter(String path, Filter filter) {
"""
Maps a filter to be executed after any matching routes even if the route throws any exception
@param filter The filter
"""
addFilter(HttpMethod.afterafter, FilterImpl.create(path, filter));
} | java | public void afterAfter(String path, Filter filter) {
addFilter(HttpMethod.afterafter, FilterImpl.create(path, filter));
} | [
"public",
"void",
"afterAfter",
"(",
"String",
"path",
",",
"Filter",
"filter",
")",
"{",
"addFilter",
"(",
"HttpMethod",
".",
"afterafter",
",",
"FilterImpl",
".",
"create",
"(",
"path",
",",
"filter",
")",
")",
";",
"}"
] | Maps a filter to be executed after any matching routes even if the route throws any exception
@param filter The filter | [
"Maps",
"a",
"filter",
"to",
"be",
"executed",
"after",
"any",
"matching",
"routes",
"even",
"if",
"the",
"route",
"throws",
"any",
"exception"
] | train | https://github.com/perwendel/spark/blob/080fb1f9d6e580f6742e9589044c7420d3157b8b/src/main/java/spark/Routable.java#L322-L324 |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/mfp/jmf/impl/MessageMap.java | MessageMap.setChoices | private void setChoices(BigInteger multiChoice, JSchema schema, JSVariant var) {
"""
Set the choices implied by the multiChoice code or contribution to a single JSVariant
"""
for (int i = 0; i < var.getCaseCount(); i++) {
BigInteger count = ((JSType)var.getCase(i)).getMultiChoiceCount();
if (multiChoice.compareTo(count) >= 0)
multiChoice = multiChoice.subtract(count);
else {
// We now have the case of our particular Variant in i. We set that in
// choiceCodes and then recursively visit the Variants dominated by ours.
choiceCodes[var.getIndex()] = i;
JSVariant[] subVars = var.getDominatedVariants(i);
setChoices(multiChoice, count, schema, subVars);
return;
}
}
// We should never get here
throw new RuntimeException("Bad multiChoice code");
} | java | private void setChoices(BigInteger multiChoice, JSchema schema, JSVariant var) {
for (int i = 0; i < var.getCaseCount(); i++) {
BigInteger count = ((JSType)var.getCase(i)).getMultiChoiceCount();
if (multiChoice.compareTo(count) >= 0)
multiChoice = multiChoice.subtract(count);
else {
// We now have the case of our particular Variant in i. We set that in
// choiceCodes and then recursively visit the Variants dominated by ours.
choiceCodes[var.getIndex()] = i;
JSVariant[] subVars = var.getDominatedVariants(i);
setChoices(multiChoice, count, schema, subVars);
return;
}
}
// We should never get here
throw new RuntimeException("Bad multiChoice code");
} | [
"private",
"void",
"setChoices",
"(",
"BigInteger",
"multiChoice",
",",
"JSchema",
"schema",
",",
"JSVariant",
"var",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"var",
".",
"getCaseCount",
"(",
")",
";",
"i",
"++",
")",
"{",
"BigInteger",
"count",
"=",
"(",
"(",
"JSType",
")",
"var",
".",
"getCase",
"(",
"i",
")",
")",
".",
"getMultiChoiceCount",
"(",
")",
";",
"if",
"(",
"multiChoice",
".",
"compareTo",
"(",
"count",
")",
">=",
"0",
")",
"multiChoice",
"=",
"multiChoice",
".",
"subtract",
"(",
"count",
")",
";",
"else",
"{",
"// We now have the case of our particular Variant in i. We set that in",
"// choiceCodes and then recursively visit the Variants dominated by ours.",
"choiceCodes",
"[",
"var",
".",
"getIndex",
"(",
")",
"]",
"=",
"i",
";",
"JSVariant",
"[",
"]",
"subVars",
"=",
"var",
".",
"getDominatedVariants",
"(",
"i",
")",
";",
"setChoices",
"(",
"multiChoice",
",",
"count",
",",
"schema",
",",
"subVars",
")",
";",
"return",
";",
"}",
"}",
"// We should never get here",
"throw",
"new",
"RuntimeException",
"(",
"\"Bad multiChoice code\"",
")",
";",
"}"
] | Set the choices implied by the multiChoice code or contribution to a single JSVariant | [
"Set",
"the",
"choices",
"implied",
"by",
"the",
"multiChoice",
"code",
"or",
"contribution",
"to",
"a",
"single",
"JSVariant"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/mfp/jmf/impl/MessageMap.java#L123-L139 |
infinispan/infinispan | core/src/main/java/org/infinispan/distribution/ch/impl/DefaultConsistentHash.java | DefaultConsistentHash.union | public DefaultConsistentHash union(DefaultConsistentHash dch2) {
"""
Merges two consistent hash objects that have the same number of segments, numOwners and hash function.
For each segment, the primary owner of the first CH has priority, the other primary owners become backups.
"""
checkSameHashAndSegments(dch2);
if (numOwners != dch2.getNumOwners()) {
throw new IllegalArgumentException("The consistent hash objects must have the same number of owners");
}
List<Address> unionMembers = new ArrayList<>(this.members);
mergeLists(unionMembers, dch2.getMembers());
List<Address>[] unionSegmentOwners = new List[segmentOwners.length];
for (int i = 0; i < segmentOwners.length; i++) {
unionSegmentOwners[i] = new ArrayList<>(locateOwnersForSegment(i));
mergeLists(unionSegmentOwners[i], dch2.locateOwnersForSegment(i));
}
Map<Address, Float> unionCapacityFactors = unionCapacityFactors(dch2);
return new DefaultConsistentHash(hashFunction, numOwners, unionSegmentOwners.length, unionMembers, unionCapacityFactors, unionSegmentOwners);
} | java | public DefaultConsistentHash union(DefaultConsistentHash dch2) {
checkSameHashAndSegments(dch2);
if (numOwners != dch2.getNumOwners()) {
throw new IllegalArgumentException("The consistent hash objects must have the same number of owners");
}
List<Address> unionMembers = new ArrayList<>(this.members);
mergeLists(unionMembers, dch2.getMembers());
List<Address>[] unionSegmentOwners = new List[segmentOwners.length];
for (int i = 0; i < segmentOwners.length; i++) {
unionSegmentOwners[i] = new ArrayList<>(locateOwnersForSegment(i));
mergeLists(unionSegmentOwners[i], dch2.locateOwnersForSegment(i));
}
Map<Address, Float> unionCapacityFactors = unionCapacityFactors(dch2);
return new DefaultConsistentHash(hashFunction, numOwners, unionSegmentOwners.length, unionMembers, unionCapacityFactors, unionSegmentOwners);
} | [
"public",
"DefaultConsistentHash",
"union",
"(",
"DefaultConsistentHash",
"dch2",
")",
"{",
"checkSameHashAndSegments",
"(",
"dch2",
")",
";",
"if",
"(",
"numOwners",
"!=",
"dch2",
".",
"getNumOwners",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The consistent hash objects must have the same number of owners\"",
")",
";",
"}",
"List",
"<",
"Address",
">",
"unionMembers",
"=",
"new",
"ArrayList",
"<>",
"(",
"this",
".",
"members",
")",
";",
"mergeLists",
"(",
"unionMembers",
",",
"dch2",
".",
"getMembers",
"(",
")",
")",
";",
"List",
"<",
"Address",
">",
"[",
"]",
"unionSegmentOwners",
"=",
"new",
"List",
"[",
"segmentOwners",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"segmentOwners",
".",
"length",
";",
"i",
"++",
")",
"{",
"unionSegmentOwners",
"[",
"i",
"]",
"=",
"new",
"ArrayList",
"<>",
"(",
"locateOwnersForSegment",
"(",
"i",
")",
")",
";",
"mergeLists",
"(",
"unionSegmentOwners",
"[",
"i",
"]",
",",
"dch2",
".",
"locateOwnersForSegment",
"(",
"i",
")",
")",
";",
"}",
"Map",
"<",
"Address",
",",
"Float",
">",
"unionCapacityFactors",
"=",
"unionCapacityFactors",
"(",
"dch2",
")",
";",
"return",
"new",
"DefaultConsistentHash",
"(",
"hashFunction",
",",
"numOwners",
",",
"unionSegmentOwners",
".",
"length",
",",
"unionMembers",
",",
"unionCapacityFactors",
",",
"unionSegmentOwners",
")",
";",
"}"
] | Merges two consistent hash objects that have the same number of segments, numOwners and hash function.
For each segment, the primary owner of the first CH has priority, the other primary owners become backups. | [
"Merges",
"two",
"consistent",
"hash",
"objects",
"that",
"have",
"the",
"same",
"number",
"of",
"segments",
"numOwners",
"and",
"hash",
"function",
".",
"For",
"each",
"segment",
"the",
"primary",
"owner",
"of",
"the",
"first",
"CH",
"has",
"priority",
"the",
"other",
"primary",
"owners",
"become",
"backups",
"."
] | train | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/distribution/ch/impl/DefaultConsistentHash.java#L241-L258 |
pushtorefresh/storio | storio-sqlite/src/main/java/com/pushtorefresh/storio3/sqlite/operations/put/PutResult.java | PutResult.newInsertResult | @NonNull
public static PutResult newInsertResult(
long insertedId,
@NonNull Set<String> affectedTables,
@Nullable String... affectedTags
) {
"""
Creates {@link PutResult} of insert.
@param insertedId id of new row.
@param affectedTables tables that were affected.
@param affectedTags notification tags that were affected.
@return new {@link PutResult} instance.
"""
return newInsertResult(insertedId, affectedTables, nonNullSet(affectedTags));
} | java | @NonNull
public static PutResult newInsertResult(
long insertedId,
@NonNull Set<String> affectedTables,
@Nullable String... affectedTags
) {
return newInsertResult(insertedId, affectedTables, nonNullSet(affectedTags));
} | [
"@",
"NonNull",
"public",
"static",
"PutResult",
"newInsertResult",
"(",
"long",
"insertedId",
",",
"@",
"NonNull",
"Set",
"<",
"String",
">",
"affectedTables",
",",
"@",
"Nullable",
"String",
"...",
"affectedTags",
")",
"{",
"return",
"newInsertResult",
"(",
"insertedId",
",",
"affectedTables",
",",
"nonNullSet",
"(",
"affectedTags",
")",
")",
";",
"}"
] | Creates {@link PutResult} of insert.
@param insertedId id of new row.
@param affectedTables tables that were affected.
@param affectedTags notification tags that were affected.
@return new {@link PutResult} instance. | [
"Creates",
"{",
"@link",
"PutResult",
"}",
"of",
"insert",
"."
] | train | https://github.com/pushtorefresh/storio/blob/58f53d81bcc7b069c8bb271c46a90e37775abe8d/storio-sqlite/src/main/java/com/pushtorefresh/storio3/sqlite/operations/put/PutResult.java#L89-L96 |
datumbox/datumbox-framework | datumbox-framework-core/src/main/java/com/datumbox/framework/core/mathematics/distances/Distance.java | Distance.manhattanWeighted | public static double manhattanWeighted(AssociativeArray a1, AssociativeArray a2, Map<Object, Double> columnWeights) {
"""
Estimates the weighted manhattan distance of two Associative Arrays.
@param a1
@param a2
@param columnWeights
@return
"""
Map<Object, Double> columnDistances = columnDistances(a1, a2, columnWeights.keySet());
double distance = 0.0;
for(Map.Entry<Object, Double> entry : columnDistances.entrySet()) {
distance+=Math.abs(entry.getValue())*columnWeights.get(entry.getKey());
}
return distance;
} | java | public static double manhattanWeighted(AssociativeArray a1, AssociativeArray a2, Map<Object, Double> columnWeights) {
Map<Object, Double> columnDistances = columnDistances(a1, a2, columnWeights.keySet());
double distance = 0.0;
for(Map.Entry<Object, Double> entry : columnDistances.entrySet()) {
distance+=Math.abs(entry.getValue())*columnWeights.get(entry.getKey());
}
return distance;
} | [
"public",
"static",
"double",
"manhattanWeighted",
"(",
"AssociativeArray",
"a1",
",",
"AssociativeArray",
"a2",
",",
"Map",
"<",
"Object",
",",
"Double",
">",
"columnWeights",
")",
"{",
"Map",
"<",
"Object",
",",
"Double",
">",
"columnDistances",
"=",
"columnDistances",
"(",
"a1",
",",
"a2",
",",
"columnWeights",
".",
"keySet",
"(",
")",
")",
";",
"double",
"distance",
"=",
"0.0",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Object",
",",
"Double",
">",
"entry",
":",
"columnDistances",
".",
"entrySet",
"(",
")",
")",
"{",
"distance",
"+=",
"Math",
".",
"abs",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
"*",
"columnWeights",
".",
"get",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
";",
"}",
"return",
"distance",
";",
"}"
] | Estimates the weighted manhattan distance of two Associative Arrays.
@param a1
@param a2
@param columnWeights
@return | [
"Estimates",
"the",
"weighted",
"manhattan",
"distance",
"of",
"two",
"Associative",
"Arrays",
"."
] | train | https://github.com/datumbox/datumbox-framework/blob/909dff0476e80834f05ecdde0624dd2390e9b0ca/datumbox-framework-core/src/main/java/com/datumbox/framework/core/mathematics/distances/Distance.java#L94-L103 |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/internal/failover/AbstractMastersListener.java | AbstractMastersListener.relaunchOperation | public HandleErrorResult relaunchOperation(Method method, Object[] args)
throws IllegalAccessException, InvocationTargetException {
"""
After a failover that has bean done, relaunch the operation that was in progress. In case of
special operation that crash server, doesn't relaunched it;
@param method the methode accessed
@param args the parameters
@return An object that indicate the result or that the exception as to be thrown
@throws IllegalAccessException if the initial call is not permit
@throws InvocationTargetException if there is any error relaunching initial method
"""
HandleErrorResult handleErrorResult = new HandleErrorResult(true);
if (method != null) {
switch (method.getName()) {
case "executeQuery":
if (args[2] instanceof String) {
String query = ((String) args[2]).toUpperCase(Locale.ROOT);
if (!"ALTER SYSTEM CRASH".equals(query)
&& !query.startsWith("KILL")) {
logger.debug("relaunch query to new connection {}",
((currentProtocol != null) ? "(conn=" + currentProtocol.getServerThreadId() + ")"
: ""));
handleErrorResult.resultObject = method.invoke(currentProtocol, args);
handleErrorResult.mustThrowError = false;
}
}
break;
case "executePreparedQuery":
//the statementId has been discarded with previous session
try {
boolean mustBeOnMaster = (Boolean) args[0];
ServerPrepareResult oldServerPrepareResult = (ServerPrepareResult) args[1];
ServerPrepareResult serverPrepareResult = currentProtocol
.prepare(oldServerPrepareResult.getSql(), mustBeOnMaster);
oldServerPrepareResult.failover(serverPrepareResult.getStatementId(), currentProtocol);
logger.debug("relaunch query to new connection "
+ ((currentProtocol != null) ? "server thread id " + currentProtocol
.getServerThreadId() : ""));
handleErrorResult.resultObject = method.invoke(currentProtocol, args);
handleErrorResult.mustThrowError = false;
} catch (Exception e) {
//if retry prepare fail, discard error. execution error will indicate the error.
}
break;
default:
handleErrorResult.resultObject = method.invoke(currentProtocol, args);
handleErrorResult.mustThrowError = false;
break;
}
}
return handleErrorResult;
} | java | public HandleErrorResult relaunchOperation(Method method, Object[] args)
throws IllegalAccessException, InvocationTargetException {
HandleErrorResult handleErrorResult = new HandleErrorResult(true);
if (method != null) {
switch (method.getName()) {
case "executeQuery":
if (args[2] instanceof String) {
String query = ((String) args[2]).toUpperCase(Locale.ROOT);
if (!"ALTER SYSTEM CRASH".equals(query)
&& !query.startsWith("KILL")) {
logger.debug("relaunch query to new connection {}",
((currentProtocol != null) ? "(conn=" + currentProtocol.getServerThreadId() + ")"
: ""));
handleErrorResult.resultObject = method.invoke(currentProtocol, args);
handleErrorResult.mustThrowError = false;
}
}
break;
case "executePreparedQuery":
//the statementId has been discarded with previous session
try {
boolean mustBeOnMaster = (Boolean) args[0];
ServerPrepareResult oldServerPrepareResult = (ServerPrepareResult) args[1];
ServerPrepareResult serverPrepareResult = currentProtocol
.prepare(oldServerPrepareResult.getSql(), mustBeOnMaster);
oldServerPrepareResult.failover(serverPrepareResult.getStatementId(), currentProtocol);
logger.debug("relaunch query to new connection "
+ ((currentProtocol != null) ? "server thread id " + currentProtocol
.getServerThreadId() : ""));
handleErrorResult.resultObject = method.invoke(currentProtocol, args);
handleErrorResult.mustThrowError = false;
} catch (Exception e) {
//if retry prepare fail, discard error. execution error will indicate the error.
}
break;
default:
handleErrorResult.resultObject = method.invoke(currentProtocol, args);
handleErrorResult.mustThrowError = false;
break;
}
}
return handleErrorResult;
} | [
"public",
"HandleErrorResult",
"relaunchOperation",
"(",
"Method",
"method",
",",
"Object",
"[",
"]",
"args",
")",
"throws",
"IllegalAccessException",
",",
"InvocationTargetException",
"{",
"HandleErrorResult",
"handleErrorResult",
"=",
"new",
"HandleErrorResult",
"(",
"true",
")",
";",
"if",
"(",
"method",
"!=",
"null",
")",
"{",
"switch",
"(",
"method",
".",
"getName",
"(",
")",
")",
"{",
"case",
"\"executeQuery\"",
":",
"if",
"(",
"args",
"[",
"2",
"]",
"instanceof",
"String",
")",
"{",
"String",
"query",
"=",
"(",
"(",
"String",
")",
"args",
"[",
"2",
"]",
")",
".",
"toUpperCase",
"(",
"Locale",
".",
"ROOT",
")",
";",
"if",
"(",
"!",
"\"ALTER SYSTEM CRASH\"",
".",
"equals",
"(",
"query",
")",
"&&",
"!",
"query",
".",
"startsWith",
"(",
"\"KILL\"",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"relaunch query to new connection {}\"",
",",
"(",
"(",
"currentProtocol",
"!=",
"null",
")",
"?",
"\"(conn=\"",
"+",
"currentProtocol",
".",
"getServerThreadId",
"(",
")",
"+",
"\")\"",
":",
"\"\"",
")",
")",
";",
"handleErrorResult",
".",
"resultObject",
"=",
"method",
".",
"invoke",
"(",
"currentProtocol",
",",
"args",
")",
";",
"handleErrorResult",
".",
"mustThrowError",
"=",
"false",
";",
"}",
"}",
"break",
";",
"case",
"\"executePreparedQuery\"",
":",
"//the statementId has been discarded with previous session",
"try",
"{",
"boolean",
"mustBeOnMaster",
"=",
"(",
"Boolean",
")",
"args",
"[",
"0",
"]",
";",
"ServerPrepareResult",
"oldServerPrepareResult",
"=",
"(",
"ServerPrepareResult",
")",
"args",
"[",
"1",
"]",
";",
"ServerPrepareResult",
"serverPrepareResult",
"=",
"currentProtocol",
".",
"prepare",
"(",
"oldServerPrepareResult",
".",
"getSql",
"(",
")",
",",
"mustBeOnMaster",
")",
";",
"oldServerPrepareResult",
".",
"failover",
"(",
"serverPrepareResult",
".",
"getStatementId",
"(",
")",
",",
"currentProtocol",
")",
";",
"logger",
".",
"debug",
"(",
"\"relaunch query to new connection \"",
"+",
"(",
"(",
"currentProtocol",
"!=",
"null",
")",
"?",
"\"server thread id \"",
"+",
"currentProtocol",
".",
"getServerThreadId",
"(",
")",
":",
"\"\"",
")",
")",
";",
"handleErrorResult",
".",
"resultObject",
"=",
"method",
".",
"invoke",
"(",
"currentProtocol",
",",
"args",
")",
";",
"handleErrorResult",
".",
"mustThrowError",
"=",
"false",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"//if retry prepare fail, discard error. execution error will indicate the error.",
"}",
"break",
";",
"default",
":",
"handleErrorResult",
".",
"resultObject",
"=",
"method",
".",
"invoke",
"(",
"currentProtocol",
",",
"args",
")",
";",
"handleErrorResult",
".",
"mustThrowError",
"=",
"false",
";",
"break",
";",
"}",
"}",
"return",
"handleErrorResult",
";",
"}"
] | After a failover that has bean done, relaunch the operation that was in progress. In case of
special operation that crash server, doesn't relaunched it;
@param method the methode accessed
@param args the parameters
@return An object that indicate the result or that the exception as to be thrown
@throws IllegalAccessException if the initial call is not permit
@throws InvocationTargetException if there is any error relaunching initial method | [
"After",
"a",
"failover",
"that",
"has",
"bean",
"done",
"relaunch",
"the",
"operation",
"that",
"was",
"in",
"progress",
".",
"In",
"case",
"of",
"special",
"operation",
"that",
"crash",
"server",
"doesn",
"t",
"relaunched",
"it",
";"
] | train | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/failover/AbstractMastersListener.java#L306-L351 |
springfox/springfox | springfox-spring-web/src/main/java/springfox/documentation/spring/web/paths/DefaultPathProvider.java | DefaultPathProvider.getResourceListingPath | @Override
public String getResourceListingPath(String groupName, String apiDeclaration) {
"""
Corresponds to the path attribute of a swagger Resource Object (within a Resource Listing).
<p>
This method builds a URL based off of
@param groupName the group name for this Resource Object e.g. 'default'
@param apiDeclaration the identifier for the api declaration e.g 'business-controller'
@return the resource listing path
@see DefaultPathProvider#getDocumentationPath()
by appending the swagger group and apiDeclaration
"""
String candidate = agnosticUriComponentBuilder(getDocumentationPath())
.pathSegment(groupName, apiDeclaration)
.build()
.toString();
return removeAdjacentForwardSlashes(candidate);
} | java | @Override
public String getResourceListingPath(String groupName, String apiDeclaration) {
String candidate = agnosticUriComponentBuilder(getDocumentationPath())
.pathSegment(groupName, apiDeclaration)
.build()
.toString();
return removeAdjacentForwardSlashes(candidate);
} | [
"@",
"Override",
"public",
"String",
"getResourceListingPath",
"(",
"String",
"groupName",
",",
"String",
"apiDeclaration",
")",
"{",
"String",
"candidate",
"=",
"agnosticUriComponentBuilder",
"(",
"getDocumentationPath",
"(",
")",
")",
".",
"pathSegment",
"(",
"groupName",
",",
"apiDeclaration",
")",
".",
"build",
"(",
")",
".",
"toString",
"(",
")",
";",
"return",
"removeAdjacentForwardSlashes",
"(",
"candidate",
")",
";",
"}"
] | Corresponds to the path attribute of a swagger Resource Object (within a Resource Listing).
<p>
This method builds a URL based off of
@param groupName the group name for this Resource Object e.g. 'default'
@param apiDeclaration the identifier for the api declaration e.g 'business-controller'
@return the resource listing path
@see DefaultPathProvider#getDocumentationPath()
by appending the swagger group and apiDeclaration | [
"Corresponds",
"to",
"the",
"path",
"attribute",
"of",
"a",
"swagger",
"Resource",
"Object",
"(",
"within",
"a",
"Resource",
"Listing",
")",
".",
"<p",
">",
"This",
"method",
"builds",
"a",
"URL",
"based",
"off",
"of"
] | train | https://github.com/springfox/springfox/blob/e40e2d6f4b345ffa35cd5c0ca7a12589036acaf7/springfox-spring-web/src/main/java/springfox/documentation/spring/web/paths/DefaultPathProvider.java#L71-L78 |
facebookarchive/hadoop-20 | src/mapred/org/apache/hadoop/mapred/JobTracker.java | JobTracker.addJob | protected synchronized JobStatus addJob(JobID jobId, JobInProgress job) {
"""
Adds a job to the jobtracker. Make sure that the checks are inplace before
adding a job. This is the core job submission logic
@param jobId The id for the job submitted which needs to be added
"""
totalSubmissions++;
synchronized (jobs) {
synchronized (taskScheduler) {
jobs.put(job.getProfile().getJobID(), job);
for (JobInProgressListener listener : jobInProgressListeners) {
try {
listener.jobAdded(job);
} catch (IOException ioe) {
LOG.warn("Failed to add and so skipping the job : "
+ job.getJobID() + ". Exception : " + ioe);
}
}
}
}
myInstrumentation.submitJob(job.getJobConf(), jobId);
String jobName = job.getJobConf().getJobName();
int jobNameLen = 64;
if (jobName.length() > jobNameLen) {
jobName = jobName.substring(0, jobNameLen); // Truncate for logging.
}
LOG.info("Job " + jobId + "(" + jobName +
") added successfully for user '" + job.getJobConf().getUser() +
"' to queue '" + job.getJobConf().getQueueName() + "'" +
", source " + job.getJobConf().getJobSource());
return job.getStatus();
} | java | protected synchronized JobStatus addJob(JobID jobId, JobInProgress job) {
totalSubmissions++;
synchronized (jobs) {
synchronized (taskScheduler) {
jobs.put(job.getProfile().getJobID(), job);
for (JobInProgressListener listener : jobInProgressListeners) {
try {
listener.jobAdded(job);
} catch (IOException ioe) {
LOG.warn("Failed to add and so skipping the job : "
+ job.getJobID() + ". Exception : " + ioe);
}
}
}
}
myInstrumentation.submitJob(job.getJobConf(), jobId);
String jobName = job.getJobConf().getJobName();
int jobNameLen = 64;
if (jobName.length() > jobNameLen) {
jobName = jobName.substring(0, jobNameLen); // Truncate for logging.
}
LOG.info("Job " + jobId + "(" + jobName +
") added successfully for user '" + job.getJobConf().getUser() +
"' to queue '" + job.getJobConf().getQueueName() + "'" +
", source " + job.getJobConf().getJobSource());
return job.getStatus();
} | [
"protected",
"synchronized",
"JobStatus",
"addJob",
"(",
"JobID",
"jobId",
",",
"JobInProgress",
"job",
")",
"{",
"totalSubmissions",
"++",
";",
"synchronized",
"(",
"jobs",
")",
"{",
"synchronized",
"(",
"taskScheduler",
")",
"{",
"jobs",
".",
"put",
"(",
"job",
".",
"getProfile",
"(",
")",
".",
"getJobID",
"(",
")",
",",
"job",
")",
";",
"for",
"(",
"JobInProgressListener",
"listener",
":",
"jobInProgressListeners",
")",
"{",
"try",
"{",
"listener",
".",
"jobAdded",
"(",
"job",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Failed to add and so skipping the job : \"",
"+",
"job",
".",
"getJobID",
"(",
")",
"+",
"\". Exception : \"",
"+",
"ioe",
")",
";",
"}",
"}",
"}",
"}",
"myInstrumentation",
".",
"submitJob",
"(",
"job",
".",
"getJobConf",
"(",
")",
",",
"jobId",
")",
";",
"String",
"jobName",
"=",
"job",
".",
"getJobConf",
"(",
")",
".",
"getJobName",
"(",
")",
";",
"int",
"jobNameLen",
"=",
"64",
";",
"if",
"(",
"jobName",
".",
"length",
"(",
")",
">",
"jobNameLen",
")",
"{",
"jobName",
"=",
"jobName",
".",
"substring",
"(",
"0",
",",
"jobNameLen",
")",
";",
"// Truncate for logging.",
"}",
"LOG",
".",
"info",
"(",
"\"Job \"",
"+",
"jobId",
"+",
"\"(\"",
"+",
"jobName",
"+",
"\") added successfully for user '\"",
"+",
"job",
".",
"getJobConf",
"(",
")",
".",
"getUser",
"(",
")",
"+",
"\"' to queue '\"",
"+",
"job",
".",
"getJobConf",
"(",
")",
".",
"getQueueName",
"(",
")",
"+",
"\"'\"",
"+",
"\", source \"",
"+",
"job",
".",
"getJobConf",
"(",
")",
".",
"getJobSource",
"(",
")",
")",
";",
"return",
"job",
".",
"getStatus",
"(",
")",
";",
"}"
] | Adds a job to the jobtracker. Make sure that the checks are inplace before
adding a job. This is the core job submission logic
@param jobId The id for the job submitted which needs to be added | [
"Adds",
"a",
"job",
"to",
"the",
"jobtracker",
".",
"Make",
"sure",
"that",
"the",
"checks",
"are",
"inplace",
"before",
"adding",
"a",
"job",
".",
"This",
"is",
"the",
"core",
"job",
"submission",
"logic"
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/mapred/org/apache/hadoop/mapred/JobTracker.java#L3173-L3200 |
orbisgis/h2gis | h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/ST_AsGeoJSON.java | ST_AsGeoJSON.toGeojsonCoordinates | public static void toGeojsonCoordinates(Coordinate[] coords, StringBuilder sb) {
"""
Convert a jts array of coordinates to a GeoJSON coordinates
representation.
Syntax:
[[X1,Y1],[X2,Y2]]
@param coords
@param sb
"""
sb.append("[");
for (int i = 0; i < coords.length; i++) {
toGeojsonCoordinate(coords[i], sb);
if (i < coords.length - 1) {
sb.append(",");
}
}
sb.append("]");
} | java | public static void toGeojsonCoordinates(Coordinate[] coords, StringBuilder sb) {
sb.append("[");
for (int i = 0; i < coords.length; i++) {
toGeojsonCoordinate(coords[i], sb);
if (i < coords.length - 1) {
sb.append(",");
}
}
sb.append("]");
} | [
"public",
"static",
"void",
"toGeojsonCoordinates",
"(",
"Coordinate",
"[",
"]",
"coords",
",",
"StringBuilder",
"sb",
")",
"{",
"sb",
".",
"append",
"(",
"\"[\"",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"coords",
".",
"length",
";",
"i",
"++",
")",
"{",
"toGeojsonCoordinate",
"(",
"coords",
"[",
"i",
"]",
",",
"sb",
")",
";",
"if",
"(",
"i",
"<",
"coords",
".",
"length",
"-",
"1",
")",
"{",
"sb",
".",
"append",
"(",
"\",\"",
")",
";",
"}",
"}",
"sb",
".",
"append",
"(",
"\"]\"",
")",
";",
"}"
] | Convert a jts array of coordinates to a GeoJSON coordinates
representation.
Syntax:
[[X1,Y1],[X2,Y2]]
@param coords
@param sb | [
"Convert",
"a",
"jts",
"array",
"of",
"coordinates",
"to",
"a",
"GeoJSON",
"coordinates",
"representation",
"."
] | train | https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/geojson/ST_AsGeoJSON.java#L285-L294 |
liaochong/spring-boot-starter-converter | src/main/java/com/github/liaochong/converter/core/BeanConverter.java | BeanConverter.convert | public static <T, U> U convert(T source, Class<U> targetClass) {
"""
单个Bean转换
@param source 被转换对象
@param targetClass 需要转换到的类型
@param <T> 转换前的类型
@param <U> 转换后的类型
@return 结果
"""
return BeanConvertStrategy.convertBean(source, targetClass);
} | java | public static <T, U> U convert(T source, Class<U> targetClass) {
return BeanConvertStrategy.convertBean(source, targetClass);
} | [
"public",
"static",
"<",
"T",
",",
"U",
">",
"U",
"convert",
"(",
"T",
"source",
",",
"Class",
"<",
"U",
">",
"targetClass",
")",
"{",
"return",
"BeanConvertStrategy",
".",
"convertBean",
"(",
"source",
",",
"targetClass",
")",
";",
"}"
] | 单个Bean转换
@param source 被转换对象
@param targetClass 需要转换到的类型
@param <T> 转换前的类型
@param <U> 转换后的类型
@return 结果 | [
"单个Bean转换"
] | train | https://github.com/liaochong/spring-boot-starter-converter/blob/a36bea44bd23330a6f43b0372906a804a09285c5/src/main/java/com/github/liaochong/converter/core/BeanConverter.java#L125-L127 |
skuzzle/TinyPlugz | tiny-plugz/src/main/java/de/skuzzle/tinyplugz/util/ReflectionUtil.java | ReflectionUtil.createInstance | public static <T> T createInstance(Object source, Class<T> base,
ClassLoader classLoader) {
"""
Creates or returns an instance of an arbitrary type which is a sub type
of given {@code base} class. If the source object already is an instance
of {@code base}, then it is returned. If the source object is a
{@link Class} object, its no-argument default constructor will be called
and the resulting object returned. If the source is a String it is taken
to be the full qualified name of a class which is then loaded using the
given ClassLoader prior to calling its default constructor.
@param source Either a String, a Class or a ready to use object.
@param base A super type of the object to create.
@param classLoader The ClassLoader that should be used to load the class
in case the {@code source} parameter is a String.
@return The obtained object.
@throws TinyPlugzException If anything goes wrong in the process
described above.
"""
Require.nonNull(source, "source");
Require.nonNull(base, "base");
Require.nonNull(classLoader, "classLoader");
if (source instanceof Class<?>) {
return fromClass(base, (Class<?>) source);
} else if (source instanceof String) {
try {
final Class<?> concrete = classLoader.loadClass(source.toString());
return fromClass(base, concrete);
} catch (ClassNotFoundException e) {
throw new TinyPlugzException(e);
}
} else if (base.isInstance(source)) {
return base.cast(source);
} else {
throw new TinyPlugzException(String.format("'%s' is not valid for '%s'",
source, base.getName()));
}
} | java | public static <T> T createInstance(Object source, Class<T> base,
ClassLoader classLoader) {
Require.nonNull(source, "source");
Require.nonNull(base, "base");
Require.nonNull(classLoader, "classLoader");
if (source instanceof Class<?>) {
return fromClass(base, (Class<?>) source);
} else if (source instanceof String) {
try {
final Class<?> concrete = classLoader.loadClass(source.toString());
return fromClass(base, concrete);
} catch (ClassNotFoundException e) {
throw new TinyPlugzException(e);
}
} else if (base.isInstance(source)) {
return base.cast(source);
} else {
throw new TinyPlugzException(String.format("'%s' is not valid for '%s'",
source, base.getName()));
}
} | [
"public",
"static",
"<",
"T",
">",
"T",
"createInstance",
"(",
"Object",
"source",
",",
"Class",
"<",
"T",
">",
"base",
",",
"ClassLoader",
"classLoader",
")",
"{",
"Require",
".",
"nonNull",
"(",
"source",
",",
"\"source\"",
")",
";",
"Require",
".",
"nonNull",
"(",
"base",
",",
"\"base\"",
")",
";",
"Require",
".",
"nonNull",
"(",
"classLoader",
",",
"\"classLoader\"",
")",
";",
"if",
"(",
"source",
"instanceof",
"Class",
"<",
"?",
">",
")",
"{",
"return",
"fromClass",
"(",
"base",
",",
"(",
"Class",
"<",
"?",
">",
")",
"source",
")",
";",
"}",
"else",
"if",
"(",
"source",
"instanceof",
"String",
")",
"{",
"try",
"{",
"final",
"Class",
"<",
"?",
">",
"concrete",
"=",
"classLoader",
".",
"loadClass",
"(",
"source",
".",
"toString",
"(",
")",
")",
";",
"return",
"fromClass",
"(",
"base",
",",
"concrete",
")",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"e",
")",
"{",
"throw",
"new",
"TinyPlugzException",
"(",
"e",
")",
";",
"}",
"}",
"else",
"if",
"(",
"base",
".",
"isInstance",
"(",
"source",
")",
")",
"{",
"return",
"base",
".",
"cast",
"(",
"source",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"TinyPlugzException",
"(",
"String",
".",
"format",
"(",
"\"'%s' is not valid for '%s'\"",
",",
"source",
",",
"base",
".",
"getName",
"(",
")",
")",
")",
";",
"}",
"}"
] | Creates or returns an instance of an arbitrary type which is a sub type
of given {@code base} class. If the source object already is an instance
of {@code base}, then it is returned. If the source object is a
{@link Class} object, its no-argument default constructor will be called
and the resulting object returned. If the source is a String it is taken
to be the full qualified name of a class which is then loaded using the
given ClassLoader prior to calling its default constructor.
@param source Either a String, a Class or a ready to use object.
@param base A super type of the object to create.
@param classLoader The ClassLoader that should be used to load the class
in case the {@code source} parameter is a String.
@return The obtained object.
@throws TinyPlugzException If anything goes wrong in the process
described above. | [
"Creates",
"or",
"returns",
"an",
"instance",
"of",
"an",
"arbitrary",
"type",
"which",
"is",
"a",
"sub",
"type",
"of",
"given",
"{",
"@code",
"base",
"}",
"class",
".",
"If",
"the",
"source",
"object",
"already",
"is",
"an",
"instance",
"of",
"{",
"@code",
"base",
"}",
"then",
"it",
"is",
"returned",
".",
"If",
"the",
"source",
"object",
"is",
"a",
"{",
"@link",
"Class",
"}",
"object",
"its",
"no",
"-",
"argument",
"default",
"constructor",
"will",
"be",
"called",
"and",
"the",
"resulting",
"object",
"returned",
".",
"If",
"the",
"source",
"is",
"a",
"String",
"it",
"is",
"taken",
"to",
"be",
"the",
"full",
"qualified",
"name",
"of",
"a",
"class",
"which",
"is",
"then",
"loaded",
"using",
"the",
"given",
"ClassLoader",
"prior",
"to",
"calling",
"its",
"default",
"constructor",
"."
] | train | https://github.com/skuzzle/TinyPlugz/blob/739858ed0ba5a0c75b6ccf18df9a4d5612374a4b/tiny-plugz/src/main/java/de/skuzzle/tinyplugz/util/ReflectionUtil.java#L36-L57 |
google/error-prone-javac | src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Module.java | Module.isOpen | public boolean isOpen(String pn, String target) {
"""
Tests if the package of the given name is open to the target
in a qualified fashion.
"""
return isOpen(pn)
|| opens.containsKey(pn) && opens.get(pn).contains(target);
} | java | public boolean isOpen(String pn, String target) {
return isOpen(pn)
|| opens.containsKey(pn) && opens.get(pn).contains(target);
} | [
"public",
"boolean",
"isOpen",
"(",
"String",
"pn",
",",
"String",
"target",
")",
"{",
"return",
"isOpen",
"(",
"pn",
")",
"||",
"opens",
".",
"containsKey",
"(",
"pn",
")",
"&&",
"opens",
".",
"get",
"(",
"pn",
")",
".",
"contains",
"(",
"target",
")",
";",
"}"
] | Tests if the package of the given name is open to the target
in a qualified fashion. | [
"Tests",
"if",
"the",
"package",
"of",
"the",
"given",
"name",
"is",
"open",
"to",
"the",
"target",
"in",
"a",
"qualified",
"fashion",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Module.java#L172-L175 |
jronrun/benayn | benayn-ustyle/src/main/java/com/benayn/ustyle/thirdparty/Uris.java | Uris.replaceHost | public static URI replaceHost(final URI uri, final String newHost, final boolean strict) throws URISyntaxException {
"""
Returns a new URI with the host portion replaced by the new host portion
@param uri the uri to replace the host in
@param newHost the new host to replace with
@param strict whether or not to perform strict escaping. (defaults to false)
@return the new URI with everything the same except for the host being replaced
@throws URISyntaxException if the newly-created URI is malformed.
"""
final URI hostUri = newUri(newHost, strict);
return newUri(uri.toString().replaceFirst(Pattern.quote(uri.getHost()),
Matcher.quoteReplacement(hostUri.getHost())), strict);
} | java | public static URI replaceHost(final URI uri, final String newHost, final boolean strict) throws URISyntaxException {
final URI hostUri = newUri(newHost, strict);
return newUri(uri.toString().replaceFirst(Pattern.quote(uri.getHost()),
Matcher.quoteReplacement(hostUri.getHost())), strict);
} | [
"public",
"static",
"URI",
"replaceHost",
"(",
"final",
"URI",
"uri",
",",
"final",
"String",
"newHost",
",",
"final",
"boolean",
"strict",
")",
"throws",
"URISyntaxException",
"{",
"final",
"URI",
"hostUri",
"=",
"newUri",
"(",
"newHost",
",",
"strict",
")",
";",
"return",
"newUri",
"(",
"uri",
".",
"toString",
"(",
")",
".",
"replaceFirst",
"(",
"Pattern",
".",
"quote",
"(",
"uri",
".",
"getHost",
"(",
")",
")",
",",
"Matcher",
".",
"quoteReplacement",
"(",
"hostUri",
".",
"getHost",
"(",
")",
")",
")",
",",
"strict",
")",
";",
"}"
] | Returns a new URI with the host portion replaced by the new host portion
@param uri the uri to replace the host in
@param newHost the new host to replace with
@param strict whether or not to perform strict escaping. (defaults to false)
@return the new URI with everything the same except for the host being replaced
@throws URISyntaxException if the newly-created URI is malformed. | [
"Returns",
"a",
"new",
"URI",
"with",
"the",
"host",
"portion",
"replaced",
"by",
"the",
"new",
"host",
"portion"
] | train | https://github.com/jronrun/benayn/blob/7585152e10e4cac07b4274c65f1c72ad7061ae69/benayn-ustyle/src/main/java/com/benayn/ustyle/thirdparty/Uris.java#L401-L405 |
Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/animation/GVRPose.java | GVRPose.setWorldRotation | public boolean setWorldRotation(int boneindex, float x, float y, float z, float w) {
"""
Sets the world rotation for the designated bone.
<p>
This function recomputes the local bone rotation and the world bone position.
@param boneindex zero based index of bone to set matrix for.
@param x,y,z,w quaternion with new rotation.
@see #getWorldRotation
@see #setLocalRotation
@see #getWorldMatrix
@see #getWorldPositions
"""
if (mSkeleton.isLocked(boneindex))
{
return false;
}
Bone bone = mBones[boneindex];
bone.setWorldRotation(x, y, z, w);
bone.Changed |= WORLD_ROT;
if (mSkeleton.getParentBoneIndex(boneindex) < 0)
{
bone.LocalMatrix.set3x3(bone.WorldMatrix);
}
else
{
mNeedSync = true;
}
if (sDebug)
{
Log.d("BONE", "%s WorldRotation: rot = (%f, %f, %f, %f)",
mSkeleton.getBoneName(boneindex), x, y, z, w);
}
return true;
} | java | public boolean setWorldRotation(int boneindex, float x, float y, float z, float w)
{
if (mSkeleton.isLocked(boneindex))
{
return false;
}
Bone bone = mBones[boneindex];
bone.setWorldRotation(x, y, z, w);
bone.Changed |= WORLD_ROT;
if (mSkeleton.getParentBoneIndex(boneindex) < 0)
{
bone.LocalMatrix.set3x3(bone.WorldMatrix);
}
else
{
mNeedSync = true;
}
if (sDebug)
{
Log.d("BONE", "%s WorldRotation: rot = (%f, %f, %f, %f)",
mSkeleton.getBoneName(boneindex), x, y, z, w);
}
return true;
} | [
"public",
"boolean",
"setWorldRotation",
"(",
"int",
"boneindex",
",",
"float",
"x",
",",
"float",
"y",
",",
"float",
"z",
",",
"float",
"w",
")",
"{",
"if",
"(",
"mSkeleton",
".",
"isLocked",
"(",
"boneindex",
")",
")",
"{",
"return",
"false",
";",
"}",
"Bone",
"bone",
"=",
"mBones",
"[",
"boneindex",
"]",
";",
"bone",
".",
"setWorldRotation",
"(",
"x",
",",
"y",
",",
"z",
",",
"w",
")",
";",
"bone",
".",
"Changed",
"|=",
"WORLD_ROT",
";",
"if",
"(",
"mSkeleton",
".",
"getParentBoneIndex",
"(",
"boneindex",
")",
"<",
"0",
")",
"{",
"bone",
".",
"LocalMatrix",
".",
"set3x3",
"(",
"bone",
".",
"WorldMatrix",
")",
";",
"}",
"else",
"{",
"mNeedSync",
"=",
"true",
";",
"}",
"if",
"(",
"sDebug",
")",
"{",
"Log",
".",
"d",
"(",
"\"BONE\"",
",",
"\"%s WorldRotation: rot = (%f, %f, %f, %f)\"",
",",
"mSkeleton",
".",
"getBoneName",
"(",
"boneindex",
")",
",",
"x",
",",
"y",
",",
"z",
",",
"w",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Sets the world rotation for the designated bone.
<p>
This function recomputes the local bone rotation and the world bone position.
@param boneindex zero based index of bone to set matrix for.
@param x,y,z,w quaternion with new rotation.
@see #getWorldRotation
@see #setLocalRotation
@see #getWorldMatrix
@see #getWorldPositions | [
"Sets",
"the",
"world",
"rotation",
"for",
"the",
"designated",
"bone",
".",
"<p",
">",
"This",
"function",
"recomputes",
"the",
"local",
"bone",
"rotation",
"and",
"the",
"world",
"bone",
"position",
"."
] | train | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/animation/GVRPose.java#L453-L477 |
jenkinsci/jenkins | core/src/main/java/jenkins/diagnostics/SecurityIsOffMonitor.java | SecurityIsOffMonitor.doAct | @RequirePOST
public void doAct(StaplerRequest req, StaplerResponse rsp) throws IOException {
"""
Depending on whether the user said "yes" or "no", send him to the right place.
"""
if(req.hasParameter("no")) {
disable(true);
rsp.sendRedirect(req.getContextPath()+"/manage");
} else {
rsp.sendRedirect(req.getContextPath()+"/configureSecurity");
}
} | java | @RequirePOST
public void doAct(StaplerRequest req, StaplerResponse rsp) throws IOException {
if(req.hasParameter("no")) {
disable(true);
rsp.sendRedirect(req.getContextPath()+"/manage");
} else {
rsp.sendRedirect(req.getContextPath()+"/configureSecurity");
}
} | [
"@",
"RequirePOST",
"public",
"void",
"doAct",
"(",
"StaplerRequest",
"req",
",",
"StaplerResponse",
"rsp",
")",
"throws",
"IOException",
"{",
"if",
"(",
"req",
".",
"hasParameter",
"(",
"\"no\"",
")",
")",
"{",
"disable",
"(",
"true",
")",
";",
"rsp",
".",
"sendRedirect",
"(",
"req",
".",
"getContextPath",
"(",
")",
"+",
"\"/manage\"",
")",
";",
"}",
"else",
"{",
"rsp",
".",
"sendRedirect",
"(",
"req",
".",
"getContextPath",
"(",
")",
"+",
"\"/configureSecurity\"",
")",
";",
"}",
"}"
] | Depending on whether the user said "yes" or "no", send him to the right place. | [
"Depending",
"on",
"whether",
"the",
"user",
"said",
"yes",
"or",
"no",
"send",
"him",
"to",
"the",
"right",
"place",
"."
] | train | https://github.com/jenkinsci/jenkins/blob/44c4d3989232082c254d27ae360aa810669f44b7/core/src/main/java/jenkins/diagnostics/SecurityIsOffMonitor.java#L38-L46 |
liferay/com-liferay-commerce | commerce-product-api/src/main/java/com/liferay/commerce/product/model/CPOptionValueWrapper.java | CPOptionValueWrapper.getName | @Override
public String getName(String languageId, boolean useDefault) {
"""
Returns the localized name of this cp option value in the language, optionally using the default language if no localization exists for the requested language.
@param languageId the ID of the language
@param useDefault whether to use the default language if no localization exists for the requested language
@return the localized name of this cp option value
"""
return _cpOptionValue.getName(languageId, useDefault);
} | java | @Override
public String getName(String languageId, boolean useDefault) {
return _cpOptionValue.getName(languageId, useDefault);
} | [
"@",
"Override",
"public",
"String",
"getName",
"(",
"String",
"languageId",
",",
"boolean",
"useDefault",
")",
"{",
"return",
"_cpOptionValue",
".",
"getName",
"(",
"languageId",
",",
"useDefault",
")",
";",
"}"
] | Returns the localized name of this cp option value in the language, optionally using the default language if no localization exists for the requested language.
@param languageId the ID of the language
@param useDefault whether to use the default language if no localization exists for the requested language
@return the localized name of this cp option value | [
"Returns",
"the",
"localized",
"name",
"of",
"this",
"cp",
"option",
"value",
"in",
"the",
"language",
"optionally",
"using",
"the",
"default",
"language",
"if",
"no",
"localization",
"exists",
"for",
"the",
"requested",
"language",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-product-api/src/main/java/com/liferay/commerce/product/model/CPOptionValueWrapper.java#L341-L344 |
rhuss/jolokia | agent/core/src/main/java/org/jolokia/handler/ExecHandler.java | ExecHandler.verifyArguments | private void verifyArguments(JmxExecRequest request, OperationAndParamType pTypes, int pNrParams, List<Object> pArgs) {
"""
check whether the given arguments are compatible with the signature and if not so, raise an excepton
"""
if ( (pNrParams > 0 && pArgs == null) || (pArgs != null && pArgs.size() != pNrParams)) {
throw new IllegalArgumentException("Invalid number of operation arguments. Operation " +
request.getOperation() + " on " + request.getObjectName() + " requires " + pTypes.paramClasses.length +
" parameters, not " + (pArgs == null ? 0 : pArgs.size()) + " as given");
}
} | java | private void verifyArguments(JmxExecRequest request, OperationAndParamType pTypes, int pNrParams, List<Object> pArgs) {
if ( (pNrParams > 0 && pArgs == null) || (pArgs != null && pArgs.size() != pNrParams)) {
throw new IllegalArgumentException("Invalid number of operation arguments. Operation " +
request.getOperation() + " on " + request.getObjectName() + " requires " + pTypes.paramClasses.length +
" parameters, not " + (pArgs == null ? 0 : pArgs.size()) + " as given");
}
} | [
"private",
"void",
"verifyArguments",
"(",
"JmxExecRequest",
"request",
",",
"OperationAndParamType",
"pTypes",
",",
"int",
"pNrParams",
",",
"List",
"<",
"Object",
">",
"pArgs",
")",
"{",
"if",
"(",
"(",
"pNrParams",
">",
"0",
"&&",
"pArgs",
"==",
"null",
")",
"||",
"(",
"pArgs",
"!=",
"null",
"&&",
"pArgs",
".",
"size",
"(",
")",
"!=",
"pNrParams",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid number of operation arguments. Operation \"",
"+",
"request",
".",
"getOperation",
"(",
")",
"+",
"\" on \"",
"+",
"request",
".",
"getObjectName",
"(",
")",
"+",
"\" requires \"",
"+",
"pTypes",
".",
"paramClasses",
".",
"length",
"+",
"\" parameters, not \"",
"+",
"(",
"pArgs",
"==",
"null",
"?",
"0",
":",
"pArgs",
".",
"size",
"(",
")",
")",
"+",
"\" as given\"",
")",
";",
"}",
"}"
] | check whether the given arguments are compatible with the signature and if not so, raise an excepton | [
"check",
"whether",
"the",
"given",
"arguments",
"are",
"compatible",
"with",
"the",
"signature",
"and",
"if",
"not",
"so",
"raise",
"an",
"excepton"
] | train | https://github.com/rhuss/jolokia/blob/dc95e7bef859b1829776c5a84c8f7738f5d7d9c3/agent/core/src/main/java/org/jolokia/handler/ExecHandler.java#L102-L108 |
apache/incubator-atlas | client/src/main/java/org/apache/atlas/AtlasClient.java | AtlasClient.getEntityAuditEvents | public List<EntityAuditEvent> getEntityAuditEvents(String entityId, short numResults)
throws AtlasServiceException {
"""
Get the latest numResults entity audit events in decreasing order of timestamp for the given entity id
@param entityId entity id
@param numResults number of results to be returned
@return list of audit events for the entity id
@throws AtlasServiceException
"""
return getEntityAuditEvents(entityId, null, numResults);
} | java | public List<EntityAuditEvent> getEntityAuditEvents(String entityId, short numResults)
throws AtlasServiceException {
return getEntityAuditEvents(entityId, null, numResults);
} | [
"public",
"List",
"<",
"EntityAuditEvent",
">",
"getEntityAuditEvents",
"(",
"String",
"entityId",
",",
"short",
"numResults",
")",
"throws",
"AtlasServiceException",
"{",
"return",
"getEntityAuditEvents",
"(",
"entityId",
",",
"null",
",",
"numResults",
")",
";",
"}"
] | Get the latest numResults entity audit events in decreasing order of timestamp for the given entity id
@param entityId entity id
@param numResults number of results to be returned
@return list of audit events for the entity id
@throws AtlasServiceException | [
"Get",
"the",
"latest",
"numResults",
"entity",
"audit",
"events",
"in",
"decreasing",
"order",
"of",
"timestamp",
"for",
"the",
"given",
"entity",
"id"
] | train | https://github.com/apache/incubator-atlas/blob/e0d2cdc27c32742ebecd24db4cca62dc04dcdf4b/client/src/main/java/org/apache/atlas/AtlasClient.java#L774-L777 |
albfernandez/itext2 | src/main/java/com/lowagie/text/Table.java | Table.addCell | public void addCell(String content, Point location) throws BadElementException {
"""
Adds a <CODE>Cell</CODE> to the <CODE>Table</CODE>.
<P>
This is a shortcut for <CODE>addCell(Cell cell, Point location)</CODE>.
The <CODE>String</CODE> will be converted to a <CODE>Cell</CODE>.
@param content a <CODE>String</CODE>
@param location a <CODE>Point</CODE>
@throws BadElementException this should never happen
"""
addCell(new Phrase(content), location);
} | java | public void addCell(String content, Point location) throws BadElementException {
addCell(new Phrase(content), location);
} | [
"public",
"void",
"addCell",
"(",
"String",
"content",
",",
"Point",
"location",
")",
"throws",
"BadElementException",
"{",
"addCell",
"(",
"new",
"Phrase",
"(",
"content",
")",
",",
"location",
")",
";",
"}"
] | Adds a <CODE>Cell</CODE> to the <CODE>Table</CODE>.
<P>
This is a shortcut for <CODE>addCell(Cell cell, Point location)</CODE>.
The <CODE>String</CODE> will be converted to a <CODE>Cell</CODE>.
@param content a <CODE>String</CODE>
@param location a <CODE>Point</CODE>
@throws BadElementException this should never happen | [
"Adds",
"a",
"<CODE",
">",
"Cell<",
"/",
"CODE",
">",
"to",
"the",
"<CODE",
">",
"Table<",
"/",
"CODE",
">",
".",
"<P",
">",
"This",
"is",
"a",
"shortcut",
"for",
"<CODE",
">",
"addCell",
"(",
"Cell",
"cell",
"Point",
"location",
")",
"<",
"/",
"CODE",
">",
".",
"The",
"<CODE",
">",
"String<",
"/",
"CODE",
">",
"will",
"be",
"converted",
"to",
"a",
"<CODE",
">",
"Cell<",
"/",
"CODE",
">",
"."
] | train | https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/Table.java#L785-L787 |
beihaifeiwu/dolphin | dolphin-mybatis-generator/src/main/java/com/freetmp/mbg/formatter/StringHelper.java | StringHelper.collapseQualifierBase | public static String collapseQualifierBase(String name, String qualifierBase) {
"""
Cross between {@link #collapse} and {@link #partiallyUnqualify}. Functions much like {@link #collapse}
except that only the qualifierBase is collapsed. For example, with a base of 'org.hibernate' the name
'org.hibernate.internal.util.StringHelper' would become 'o.h.util.StringHelper'.
@param name The (potentially) qualified name.
@param qualifierBase The qualifier base.
@return The name itself if it does not begin with the qualifierBase, or the properly collapsed form otherwise.
"""
if (name == null || !name.startsWith(qualifierBase)) {
return collapse(name);
}
return collapseQualifier(qualifierBase, true) + name.substring(qualifierBase.length());
} | java | public static String collapseQualifierBase(String name, String qualifierBase) {
if (name == null || !name.startsWith(qualifierBase)) {
return collapse(name);
}
return collapseQualifier(qualifierBase, true) + name.substring(qualifierBase.length());
} | [
"public",
"static",
"String",
"collapseQualifierBase",
"(",
"String",
"name",
",",
"String",
"qualifierBase",
")",
"{",
"if",
"(",
"name",
"==",
"null",
"||",
"!",
"name",
".",
"startsWith",
"(",
"qualifierBase",
")",
")",
"{",
"return",
"collapse",
"(",
"name",
")",
";",
"}",
"return",
"collapseQualifier",
"(",
"qualifierBase",
",",
"true",
")",
"+",
"name",
".",
"substring",
"(",
"qualifierBase",
".",
"length",
"(",
")",
")",
";",
"}"
] | Cross between {@link #collapse} and {@link #partiallyUnqualify}. Functions much like {@link #collapse}
except that only the qualifierBase is collapsed. For example, with a base of 'org.hibernate' the name
'org.hibernate.internal.util.StringHelper' would become 'o.h.util.StringHelper'.
@param name The (potentially) qualified name.
@param qualifierBase The qualifier base.
@return The name itself if it does not begin with the qualifierBase, or the properly collapsed form otherwise. | [
"Cross",
"between",
"{",
"@link",
"#collapse",
"}",
"and",
"{",
"@link",
"#partiallyUnqualify",
"}",
".",
"Functions",
"much",
"like",
"{",
"@link",
"#collapse",
"}",
"except",
"that",
"only",
"the",
"qualifierBase",
"is",
"collapsed",
".",
"For",
"example",
"with",
"a",
"base",
"of",
"org",
".",
"hibernate",
"the",
"name",
"org",
".",
"hibernate",
".",
"internal",
".",
"util",
".",
"StringHelper",
"would",
"become",
"o",
".",
"h",
".",
"util",
".",
"StringHelper",
"."
] | train | https://github.com/beihaifeiwu/dolphin/blob/b100579cc6986dce5eba5593ebb5fbae7bad9d1a/dolphin-mybatis-generator/src/main/java/com/freetmp/mbg/formatter/StringHelper.java#L286-L291 |
spring-projects/spring-social | spring-social-web/src/main/java/org/springframework/social/connect/web/ProviderSignInController.java | ProviderSignInController.oauth1Callback | @RequestMapping(value="/ {
"""
Process the authentication callback from an OAuth 1 service provider.
Called after the member authorizes the authentication, generally done once by having he or she click "Allow" in their web browser at the provider's site.
Handles the provider sign-in callback by first determining if a local user account is associated with the connected provider account.
If so, signs the local user in by delegating to {@link SignInAdapter#signIn(String, Connection, NativeWebRequest)}
If not, redirects the user to a signup page to create a new account with {@link ProviderSignInAttempt} context exposed in the HttpSession.
@param providerId the provider ID to authorize against
@param request the request
@return a RedirectView to the provider's authorization page or to the application's signin page if there is an error
@see ProviderSignInAttempt
@see ProviderSignInUtils
"""providerId}", method=RequestMethod.GET, params="oauth_token")
public RedirectView oauth1Callback(@PathVariable String providerId, NativeWebRequest request) {
try {
OAuth1ConnectionFactory<?> connectionFactory = (OAuth1ConnectionFactory<?>) connectionFactoryLocator.getConnectionFactory(providerId);
Connection<?> connection = connectSupport.completeConnection(connectionFactory, request);
return handleSignIn(connection, connectionFactory, request);
} catch (Exception e) {
logger.error("Exception while completing OAuth 1.0(a) connection: ", e);
return redirect(URIBuilder.fromUri(signInUrl).queryParam("error", "provider").build().toString());
}
} | java | @RequestMapping(value="/{providerId}", method=RequestMethod.GET, params="oauth_token")
public RedirectView oauth1Callback(@PathVariable String providerId, NativeWebRequest request) {
try {
OAuth1ConnectionFactory<?> connectionFactory = (OAuth1ConnectionFactory<?>) connectionFactoryLocator.getConnectionFactory(providerId);
Connection<?> connection = connectSupport.completeConnection(connectionFactory, request);
return handleSignIn(connection, connectionFactory, request);
} catch (Exception e) {
logger.error("Exception while completing OAuth 1.0(a) connection: ", e);
return redirect(URIBuilder.fromUri(signInUrl).queryParam("error", "provider").build().toString());
}
} | [
"@",
"RequestMapping",
"(",
"value",
"=",
"\"/{providerId}\"",
",",
"method",
"=",
"RequestMethod",
".",
"GET",
",",
"params",
"=",
"\"oauth_token\"",
")",
"public",
"RedirectView",
"oauth1Callback",
"(",
"@",
"PathVariable",
"String",
"providerId",
",",
"NativeWebRequest",
"request",
")",
"{",
"try",
"{",
"OAuth1ConnectionFactory",
"<",
"?",
">",
"connectionFactory",
"=",
"(",
"OAuth1ConnectionFactory",
"<",
"?",
">",
")",
"connectionFactoryLocator",
".",
"getConnectionFactory",
"(",
"providerId",
")",
";",
"Connection",
"<",
"?",
">",
"connection",
"=",
"connectSupport",
".",
"completeConnection",
"(",
"connectionFactory",
",",
"request",
")",
";",
"return",
"handleSignIn",
"(",
"connection",
",",
"connectionFactory",
",",
"request",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Exception while completing OAuth 1.0(a) connection: \"",
",",
"e",
")",
";",
"return",
"redirect",
"(",
"URIBuilder",
".",
"fromUri",
"(",
"signInUrl",
")",
".",
"queryParam",
"(",
"\"error\"",
",",
"\"provider\"",
")",
".",
"build",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"}"
] | Process the authentication callback from an OAuth 1 service provider.
Called after the member authorizes the authentication, generally done once by having he or she click "Allow" in their web browser at the provider's site.
Handles the provider sign-in callback by first determining if a local user account is associated with the connected provider account.
If so, signs the local user in by delegating to {@link SignInAdapter#signIn(String, Connection, NativeWebRequest)}
If not, redirects the user to a signup page to create a new account with {@link ProviderSignInAttempt} context exposed in the HttpSession.
@param providerId the provider ID to authorize against
@param request the request
@return a RedirectView to the provider's authorization page or to the application's signin page if there is an error
@see ProviderSignInAttempt
@see ProviderSignInUtils | [
"Process",
"the",
"authentication",
"callback",
"from",
"an",
"OAuth",
"1",
"service",
"provider",
".",
"Called",
"after",
"the",
"member",
"authorizes",
"the",
"authentication",
"generally",
"done",
"once",
"by",
"having",
"he",
"or",
"she",
"click",
"Allow",
"in",
"their",
"web",
"browser",
"at",
"the",
"provider",
"s",
"site",
".",
"Handles",
"the",
"provider",
"sign",
"-",
"in",
"callback",
"by",
"first",
"determining",
"if",
"a",
"local",
"user",
"account",
"is",
"associated",
"with",
"the",
"connected",
"provider",
"account",
".",
"If",
"so",
"signs",
"the",
"local",
"user",
"in",
"by",
"delegating",
"to",
"{"
] | train | https://github.com/spring-projects/spring-social/blob/e41cfecb288022b83c79413b58f52511c3c9d4fc/spring-social-web/src/main/java/org/springframework/social/connect/web/ProviderSignInController.java#L199-L209 |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/ReidSolomonCodes.java | ReidSolomonCodes.computeECC | public void computeECC( GrowQueue_I8 input , GrowQueue_I8 output ) {
"""
Given the input message compute the error correction code for it
@param input Input message. Modified internally then returned to its initial state
@param output error correction code
"""
int N = generator.size-1;
input.extend(input.size+N);
Arrays.fill(input.data,input.size-N,input.size,(byte)0);
math.polyDivide(input,generator,tmp0,output);
input.size -= N;
} | java | public void computeECC( GrowQueue_I8 input , GrowQueue_I8 output ) {
int N = generator.size-1;
input.extend(input.size+N);
Arrays.fill(input.data,input.size-N,input.size,(byte)0);
math.polyDivide(input,generator,tmp0,output);
input.size -= N;
} | [
"public",
"void",
"computeECC",
"(",
"GrowQueue_I8",
"input",
",",
"GrowQueue_I8",
"output",
")",
"{",
"int",
"N",
"=",
"generator",
".",
"size",
"-",
"1",
";",
"input",
".",
"extend",
"(",
"input",
".",
"size",
"+",
"N",
")",
";",
"Arrays",
".",
"fill",
"(",
"input",
".",
"data",
",",
"input",
".",
"size",
"-",
"N",
",",
"input",
".",
"size",
",",
"(",
"byte",
")",
"0",
")",
";",
"math",
".",
"polyDivide",
"(",
"input",
",",
"generator",
",",
"tmp0",
",",
"output",
")",
";",
"input",
".",
"size",
"-=",
"N",
";",
"}"
] | Given the input message compute the error correction code for it
@param input Input message. Modified internally then returned to its initial state
@param output error correction code | [
"Given",
"the",
"input",
"message",
"compute",
"the",
"error",
"correction",
"code",
"for",
"it"
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/ReidSolomonCodes.java#L62-L71 |
OpenLiberty/open-liberty | dev/com.ibm.ws.kernel.feature.core/src/com/ibm/ws/kernel/feature/internal/subsystem/KernelFeatureDefinitionImpl.java | KernelFeatureDefinitionImpl.getAllKernelFeatures | public static Collection<ProvisioningFeatureDefinition> getAllKernelFeatures(BundleContext ctx,
WsLocationAdmin locationService) {
"""
Get ALL kernel feature definitions (in active use or not). Minify requires this to ensure
that optional kernel features like binaryLogging are not minified out.
This list is not cached.
@param bundleContext
@param locationService
@return
"""
return getKernelFeatures(ctx, locationService, true);
} | java | public static Collection<ProvisioningFeatureDefinition> getAllKernelFeatures(BundleContext ctx,
WsLocationAdmin locationService) {
return getKernelFeatures(ctx, locationService, true);
} | [
"public",
"static",
"Collection",
"<",
"ProvisioningFeatureDefinition",
">",
"getAllKernelFeatures",
"(",
"BundleContext",
"ctx",
",",
"WsLocationAdmin",
"locationService",
")",
"{",
"return",
"getKernelFeatures",
"(",
"ctx",
",",
"locationService",
",",
"true",
")",
";",
"}"
] | Get ALL kernel feature definitions (in active use or not). Minify requires this to ensure
that optional kernel features like binaryLogging are not minified out.
This list is not cached.
@param bundleContext
@param locationService
@return | [
"Get",
"ALL",
"kernel",
"feature",
"definitions",
"(",
"in",
"active",
"use",
"or",
"not",
")",
".",
"Minify",
"requires",
"this",
"to",
"ensure",
"that",
"optional",
"kernel",
"features",
"like",
"binaryLogging",
"are",
"not",
"minified",
"out",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.kernel.feature.core/src/com/ibm/ws/kernel/feature/internal/subsystem/KernelFeatureDefinitionImpl.java#L83-L86 |
albfernandez/itext2 | src/main/java/com/lowagie/text/pdf/PdfContentByte.java | PdfContentByte.setRGBColorFillF | public void setRGBColorFillF(float red, float green, float blue) {
"""
Changes the current color for filling paths (device dependent colors!).
<P>
Sets the color space to <B>DeviceRGB</B> (or the <B>DefaultRGB</B> color space),
and sets the color to use for filling paths.</P>
<P>
Following the PDF manual, each operand must be a number between 0 (minimum intensity) and
1 (maximum intensity).</P>
@param red the intensity of red. A value between 0 and 1
@param green the intensity of green. A value between 0 and 1
@param blue the intensity of blue. A value between 0 and 1
"""
HelperRGB(red, green, blue);
content.append(" rg").append_i(separator);
} | java | public void setRGBColorFillF(float red, float green, float blue) {
HelperRGB(red, green, blue);
content.append(" rg").append_i(separator);
} | [
"public",
"void",
"setRGBColorFillF",
"(",
"float",
"red",
",",
"float",
"green",
",",
"float",
"blue",
")",
"{",
"HelperRGB",
"(",
"red",
",",
"green",
",",
"blue",
")",
";",
"content",
".",
"append",
"(",
"\" rg\"",
")",
".",
"append_i",
"(",
"separator",
")",
";",
"}"
] | Changes the current color for filling paths (device dependent colors!).
<P>
Sets the color space to <B>DeviceRGB</B> (or the <B>DefaultRGB</B> color space),
and sets the color to use for filling paths.</P>
<P>
Following the PDF manual, each operand must be a number between 0 (minimum intensity) and
1 (maximum intensity).</P>
@param red the intensity of red. A value between 0 and 1
@param green the intensity of green. A value between 0 and 1
@param blue the intensity of blue. A value between 0 and 1 | [
"Changes",
"the",
"current",
"color",
"for",
"filling",
"paths",
"(",
"device",
"dependent",
"colors!",
")",
".",
"<P",
">",
"Sets",
"the",
"color",
"space",
"to",
"<B",
">",
"DeviceRGB<",
"/",
"B",
">",
"(",
"or",
"the",
"<B",
">",
"DefaultRGB<",
"/",
"B",
">",
"color",
"space",
")",
"and",
"sets",
"the",
"color",
"to",
"use",
"for",
"filling",
"paths",
".",
"<",
"/",
"P",
">",
"<P",
">",
"Following",
"the",
"PDF",
"manual",
"each",
"operand",
"must",
"be",
"a",
"number",
"between",
"0",
"(",
"minimum",
"intensity",
")",
"and",
"1",
"(",
"maximum",
"intensity",
")",
".",
"<",
"/",
"P",
">"
] | train | https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/pdf/PdfContentByte.java#L568-L571 |
riversun/string-grabber | src/main/java/org/riversun/string_grabber/StringCropper.java | StringCropper.removeTail | public String removeTail(String srcStr, int charCount) {
"""
Return the rest of the string that is cropped the number of chars from
the end of string
@param srcStr
@param charCount
@return
"""
return getLeftOf(srcStr, srcStr.length() - charCount);
} | java | public String removeTail(String srcStr, int charCount) {
return getLeftOf(srcStr, srcStr.length() - charCount);
} | [
"public",
"String",
"removeTail",
"(",
"String",
"srcStr",
",",
"int",
"charCount",
")",
"{",
"return",
"getLeftOf",
"(",
"srcStr",
",",
"srcStr",
".",
"length",
"(",
")",
"-",
"charCount",
")",
";",
"}"
] | Return the rest of the string that is cropped the number of chars from
the end of string
@param srcStr
@param charCount
@return | [
"Return",
"the",
"rest",
"of",
"the",
"string",
"that",
"is",
"cropped",
"the",
"number",
"of",
"chars",
"from",
"the",
"end",
"of",
"string"
] | train | https://github.com/riversun/string-grabber/blob/b5aadc21fe15f50d35392188dec6ab81dcf8d464/src/main/java/org/riversun/string_grabber/StringCropper.java#L419-L421 |
census-instrumentation/opencensus-java | contrib/dropwizard/src/main/java/io/opencensus/contrib/dropwizard/DropWizardMetrics.java | DropWizardMetrics.collectMeter | private Metric collectMeter(String dropwizardName, Meter meter) {
"""
Returns a {@code Metric} collected from {@link Meter}.
@param dropwizardName the metric name.
@param meter the meter object to collect
@return a {@code Metric}.
"""
String metricName = DropWizardUtils.generateFullMetricName(dropwizardName, "meter");
String metricDescription = DropWizardUtils.generateFullMetricDescription(dropwizardName, meter);
MetricDescriptor metricDescriptor =
MetricDescriptor.create(
metricName,
metricDescription,
DEFAULT_UNIT,
Type.CUMULATIVE_INT64,
Collections.<LabelKey>emptyList());
TimeSeries timeSeries =
TimeSeries.createWithOnePoint(
Collections.<LabelValue>emptyList(),
Point.create(Value.longValue(meter.getCount()), clock.now()),
cumulativeStartTimestamp);
return Metric.createWithOneTimeSeries(metricDescriptor, timeSeries);
} | java | private Metric collectMeter(String dropwizardName, Meter meter) {
String metricName = DropWizardUtils.generateFullMetricName(dropwizardName, "meter");
String metricDescription = DropWizardUtils.generateFullMetricDescription(dropwizardName, meter);
MetricDescriptor metricDescriptor =
MetricDescriptor.create(
metricName,
metricDescription,
DEFAULT_UNIT,
Type.CUMULATIVE_INT64,
Collections.<LabelKey>emptyList());
TimeSeries timeSeries =
TimeSeries.createWithOnePoint(
Collections.<LabelValue>emptyList(),
Point.create(Value.longValue(meter.getCount()), clock.now()),
cumulativeStartTimestamp);
return Metric.createWithOneTimeSeries(metricDescriptor, timeSeries);
} | [
"private",
"Metric",
"collectMeter",
"(",
"String",
"dropwizardName",
",",
"Meter",
"meter",
")",
"{",
"String",
"metricName",
"=",
"DropWizardUtils",
".",
"generateFullMetricName",
"(",
"dropwizardName",
",",
"\"meter\"",
")",
";",
"String",
"metricDescription",
"=",
"DropWizardUtils",
".",
"generateFullMetricDescription",
"(",
"dropwizardName",
",",
"meter",
")",
";",
"MetricDescriptor",
"metricDescriptor",
"=",
"MetricDescriptor",
".",
"create",
"(",
"metricName",
",",
"metricDescription",
",",
"DEFAULT_UNIT",
",",
"Type",
".",
"CUMULATIVE_INT64",
",",
"Collections",
".",
"<",
"LabelKey",
">",
"emptyList",
"(",
")",
")",
";",
"TimeSeries",
"timeSeries",
"=",
"TimeSeries",
".",
"createWithOnePoint",
"(",
"Collections",
".",
"<",
"LabelValue",
">",
"emptyList",
"(",
")",
",",
"Point",
".",
"create",
"(",
"Value",
".",
"longValue",
"(",
"meter",
".",
"getCount",
"(",
")",
")",
",",
"clock",
".",
"now",
"(",
")",
")",
",",
"cumulativeStartTimestamp",
")",
";",
"return",
"Metric",
".",
"createWithOneTimeSeries",
"(",
"metricDescriptor",
",",
"timeSeries",
")",
";",
"}"
] | Returns a {@code Metric} collected from {@link Meter}.
@param dropwizardName the metric name.
@param meter the meter object to collect
@return a {@code Metric}. | [
"Returns",
"a",
"{",
"@code",
"Metric",
"}",
"collected",
"from",
"{",
"@link",
"Meter",
"}",
"."
] | train | https://github.com/census-instrumentation/opencensus-java/blob/deefac9bed77e40a2297bff1ca5ec5aa48a5f755/contrib/dropwizard/src/main/java/io/opencensus/contrib/dropwizard/DropWizardMetrics.java#L168-L186 |
lucee/Lucee | core/src/main/java/lucee/runtime/op/Caster.java | Caster.toList | public static List toList(Object o, List defaultValue) {
"""
cast a Object to a Array Object
@param o Object to cast
@param defaultValue
@return casted Array
"""
return toList(o, false, defaultValue);
} | java | public static List toList(Object o, List defaultValue) {
return toList(o, false, defaultValue);
} | [
"public",
"static",
"List",
"toList",
"(",
"Object",
"o",
",",
"List",
"defaultValue",
")",
"{",
"return",
"toList",
"(",
"o",
",",
"false",
",",
"defaultValue",
")",
";",
"}"
] | cast a Object to a Array Object
@param o Object to cast
@param defaultValue
@return casted Array | [
"cast",
"a",
"Object",
"to",
"a",
"Array",
"Object"
] | train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/runtime/op/Caster.java#L2195-L2197 |
zutnop/telekom-workflow-engine | telekom-workflow-engine/src/main/java/ee/telekom/workflow/graph/node/gateway/AbstractConditionalGateway.java | AbstractConditionalGateway.addCondition | public void addCondition( Condition condition, String transitionName ) {
"""
A <code>null</code> condition is interpreted as a <i>default</i> condition.
"""
conditions.add( Pair.of( condition, transitionName ) );
} | java | public void addCondition( Condition condition, String transitionName ){
conditions.add( Pair.of( condition, transitionName ) );
} | [
"public",
"void",
"addCondition",
"(",
"Condition",
"condition",
",",
"String",
"transitionName",
")",
"{",
"conditions",
".",
"add",
"(",
"Pair",
".",
"of",
"(",
"condition",
",",
"transitionName",
")",
")",
";",
"}"
] | A <code>null</code> condition is interpreted as a <i>default</i> condition. | [
"A",
"<code",
">",
"null<",
"/",
"code",
">",
"condition",
"is",
"interpreted",
"as",
"a",
"<i",
">",
"default<",
"/",
"i",
">",
"condition",
"."
] | train | https://github.com/zutnop/telekom-workflow-engine/blob/f471f1f94013b3e2d56b4c9380e86e3a92c2ee29/telekom-workflow-engine/src/main/java/ee/telekom/workflow/graph/node/gateway/AbstractConditionalGateway.java#L33-L35 |
alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/message/netty/StormClientHandler.java | StormClientHandler.channelConnected | @Override
public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent event) {
"""
Sometime when connecting to a bad channel which isn't writable, this method will be called
"""
// register the newly established channel
Channel channel = event.getChannel();
LOG.info("connection established to :{}, local port:{}", client.getRemoteAddr(), channel.getLocalAddress());
client.connectChannel(ctx.getChannel());
client.handleResponse(ctx.getChannel(), null);
} | java | @Override
public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent event) {
// register the newly established channel
Channel channel = event.getChannel();
LOG.info("connection established to :{}, local port:{}", client.getRemoteAddr(), channel.getLocalAddress());
client.connectChannel(ctx.getChannel());
client.handleResponse(ctx.getChannel(), null);
} | [
"@",
"Override",
"public",
"void",
"channelConnected",
"(",
"ChannelHandlerContext",
"ctx",
",",
"ChannelStateEvent",
"event",
")",
"{",
"// register the newly established channel",
"Channel",
"channel",
"=",
"event",
".",
"getChannel",
"(",
")",
";",
"LOG",
".",
"info",
"(",
"\"connection established to :{}, local port:{}\"",
",",
"client",
".",
"getRemoteAddr",
"(",
")",
",",
"channel",
".",
"getLocalAddress",
"(",
")",
")",
";",
"client",
".",
"connectChannel",
"(",
"ctx",
".",
"getChannel",
"(",
")",
")",
";",
"client",
".",
"handleResponse",
"(",
"ctx",
".",
"getChannel",
"(",
")",
",",
"null",
")",
";",
"}"
] | Sometime when connecting to a bad channel which isn't writable, this method will be called | [
"Sometime",
"when",
"connecting",
"to",
"a",
"bad",
"channel",
"which",
"isn",
"t",
"writable",
"this",
"method",
"will",
"be",
"called"
] | train | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/message/netty/StormClientHandler.java#L53-L61 |
zaproxy/zaproxy | src/org/parosproxy/paros/view/MainFooterPanel.java | MainFooterPanel.createAlertLabel | private JLabel createAlertLabel(String toolTipText, URL imageUrl) throws NullPointerException {
"""
Creates a {@code JLabel} with text "0", an {@code ImageIcon} created from
the specified URL, the specified tool tip text and an empty border that
takes up 5 pixels to the right and left of the {@code JLabel}.
@param toolTipText
the tool tip text, if toolTipText is {@code null} no tool tip
is displayed
@param imageUrl
the URL to the image
@throws NullPointerException
if imageUrl is {@code null}.
@return the {@code JLabel} object
@see JLabel#setToolTipText(String)
"""
JLabel label = new JLabel("0", DisplayUtils.getScaledIcon(new ImageIcon(imageUrl)), JLabel.LEADING);
label.setToolTipText(toolTipText);
label.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
return label;
} | java | private JLabel createAlertLabel(String toolTipText, URL imageUrl) throws NullPointerException {
JLabel label = new JLabel("0", DisplayUtils.getScaledIcon(new ImageIcon(imageUrl)), JLabel.LEADING);
label.setToolTipText(toolTipText);
label.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
return label;
} | [
"private",
"JLabel",
"createAlertLabel",
"(",
"String",
"toolTipText",
",",
"URL",
"imageUrl",
")",
"throws",
"NullPointerException",
"{",
"JLabel",
"label",
"=",
"new",
"JLabel",
"(",
"\"0\"",
",",
"DisplayUtils",
".",
"getScaledIcon",
"(",
"new",
"ImageIcon",
"(",
"imageUrl",
")",
")",
",",
"JLabel",
".",
"LEADING",
")",
";",
"label",
".",
"setToolTipText",
"(",
"toolTipText",
")",
";",
"label",
".",
"setBorder",
"(",
"BorderFactory",
".",
"createEmptyBorder",
"(",
"0",
",",
"5",
",",
"0",
",",
"5",
")",
")",
";",
"return",
"label",
";",
"}"
] | Creates a {@code JLabel} with text "0", an {@code ImageIcon} created from
the specified URL, the specified tool tip text and an empty border that
takes up 5 pixels to the right and left of the {@code JLabel}.
@param toolTipText
the tool tip text, if toolTipText is {@code null} no tool tip
is displayed
@param imageUrl
the URL to the image
@throws NullPointerException
if imageUrl is {@code null}.
@return the {@code JLabel} object
@see JLabel#setToolTipText(String) | [
"Creates",
"a",
"{",
"@code",
"JLabel",
"}",
"with",
"text",
"0",
"an",
"{",
"@code",
"ImageIcon",
"}",
"created",
"from",
"the",
"specified",
"URL",
"the",
"specified",
"tool",
"tip",
"text",
"and",
"an",
"empty",
"border",
"that",
"takes",
"up",
"5",
"pixels",
"to",
"the",
"right",
"and",
"left",
"of",
"the",
"{",
"@code",
"JLabel",
"}",
"."
] | train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/parosproxy/paros/view/MainFooterPanel.java#L221-L227 |
Azure/azure-sdk-for-java | appservice/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/appservice/v2016_09_01/implementation/AppServiceEnvironmentsInner.java | AppServiceEnvironmentsInner.listCapacitiesAsync | public Observable<Page<StampCapacityInner>> listCapacitiesAsync(final String resourceGroupName, final String name) {
"""
Get the used, available, and total worker capacity an App Service Environment.
Get the used, available, and total worker capacity an App Service Environment.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param name Name of the App Service Environment.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<StampCapacityInner> object
"""
return listCapacitiesWithServiceResponseAsync(resourceGroupName, name)
.map(new Func1<ServiceResponse<Page<StampCapacityInner>>, Page<StampCapacityInner>>() {
@Override
public Page<StampCapacityInner> call(ServiceResponse<Page<StampCapacityInner>> response) {
return response.body();
}
});
} | java | public Observable<Page<StampCapacityInner>> listCapacitiesAsync(final String resourceGroupName, final String name) {
return listCapacitiesWithServiceResponseAsync(resourceGroupName, name)
.map(new Func1<ServiceResponse<Page<StampCapacityInner>>, Page<StampCapacityInner>>() {
@Override
public Page<StampCapacityInner> call(ServiceResponse<Page<StampCapacityInner>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Page",
"<",
"StampCapacityInner",
">",
">",
"listCapacitiesAsync",
"(",
"final",
"String",
"resourceGroupName",
",",
"final",
"String",
"name",
")",
"{",
"return",
"listCapacitiesWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"name",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"StampCapacityInner",
">",
">",
",",
"Page",
"<",
"StampCapacityInner",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Page",
"<",
"StampCapacityInner",
">",
"call",
"(",
"ServiceResponse",
"<",
"Page",
"<",
"StampCapacityInner",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Get the used, available, and total worker capacity an App Service Environment.
Get the used, available, and total worker capacity an App Service Environment.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param name Name of the App Service Environment.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<StampCapacityInner> object | [
"Get",
"the",
"used",
"available",
"and",
"total",
"worker",
"capacity",
"an",
"App",
"Service",
"Environment",
".",
"Get",
"the",
"used",
"available",
"and",
"total",
"worker",
"capacity",
"an",
"App",
"Service",
"Environment",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/appservice/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/appservice/v2016_09_01/implementation/AppServiceEnvironmentsInner.java#L1339-L1347 |
lucee/Lucee | core/src/main/java/lucee/runtime/coder/Base64Coder.java | Base64Coder.decodeToString | public static String decodeToString(String encoded, String charset) throws CoderException, UnsupportedEncodingException {
"""
decodes a Base64 String to a Plain String
@param encoded
@return
@throws ExpressionException
"""
byte[] dec = decode(Caster.toString(encoded, null));
return new String(dec, charset);
} | java | public static String decodeToString(String encoded, String charset) throws CoderException, UnsupportedEncodingException {
byte[] dec = decode(Caster.toString(encoded, null));
return new String(dec, charset);
} | [
"public",
"static",
"String",
"decodeToString",
"(",
"String",
"encoded",
",",
"String",
"charset",
")",
"throws",
"CoderException",
",",
"UnsupportedEncodingException",
"{",
"byte",
"[",
"]",
"dec",
"=",
"decode",
"(",
"Caster",
".",
"toString",
"(",
"encoded",
",",
"null",
")",
")",
";",
"return",
"new",
"String",
"(",
"dec",
",",
"charset",
")",
";",
"}"
] | decodes a Base64 String to a Plain String
@param encoded
@return
@throws ExpressionException | [
"decodes",
"a",
"Base64",
"String",
"to",
"a",
"Plain",
"String"
] | train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/runtime/coder/Base64Coder.java#L39-L42 |
brianwhu/xillium | base/src/main/java/org/xillium/base/beans/Strings.java | Strings.toLowerCamelCase | public static String toLowerCamelCase(String text, char separator) {
"""
Converts a word sequence into a single camel-case word that starts with a lowercase letter.
@param text - a word sequence with the given separator
@param separator - a word separator
@return a single camel-case word
"""
char[] chars = text.toCharArray();
int base = 0, top = 0;
do {
while (top < chars.length && chars[top] != separator) {
chars[base++] = Character.toLowerCase(chars[top++]);
}
while (top < chars.length && chars[top] == separator) {
++top;
}
if (top < chars.length) {
chars[base++] = Character.toUpperCase(chars[top++]);
}
} while (top < chars.length);
return new String(chars, 0, base);
} | java | public static String toLowerCamelCase(String text, char separator) {
char[] chars = text.toCharArray();
int base = 0, top = 0;
do {
while (top < chars.length && chars[top] != separator) {
chars[base++] = Character.toLowerCase(chars[top++]);
}
while (top < chars.length && chars[top] == separator) {
++top;
}
if (top < chars.length) {
chars[base++] = Character.toUpperCase(chars[top++]);
}
} while (top < chars.length);
return new String(chars, 0, base);
} | [
"public",
"static",
"String",
"toLowerCamelCase",
"(",
"String",
"text",
",",
"char",
"separator",
")",
"{",
"char",
"[",
"]",
"chars",
"=",
"text",
".",
"toCharArray",
"(",
")",
";",
"int",
"base",
"=",
"0",
",",
"top",
"=",
"0",
";",
"do",
"{",
"while",
"(",
"top",
"<",
"chars",
".",
"length",
"&&",
"chars",
"[",
"top",
"]",
"!=",
"separator",
")",
"{",
"chars",
"[",
"base",
"++",
"]",
"=",
"Character",
".",
"toLowerCase",
"(",
"chars",
"[",
"top",
"++",
"]",
")",
";",
"}",
"while",
"(",
"top",
"<",
"chars",
".",
"length",
"&&",
"chars",
"[",
"top",
"]",
"==",
"separator",
")",
"{",
"++",
"top",
";",
"}",
"if",
"(",
"top",
"<",
"chars",
".",
"length",
")",
"{",
"chars",
"[",
"base",
"++",
"]",
"=",
"Character",
".",
"toUpperCase",
"(",
"chars",
"[",
"top",
"++",
"]",
")",
";",
"}",
"}",
"while",
"(",
"top",
"<",
"chars",
".",
"length",
")",
";",
"return",
"new",
"String",
"(",
"chars",
",",
"0",
",",
"base",
")",
";",
"}"
] | Converts a word sequence into a single camel-case word that starts with a lowercase letter.
@param text - a word sequence with the given separator
@param separator - a word separator
@return a single camel-case word | [
"Converts",
"a",
"word",
"sequence",
"into",
"a",
"single",
"camel",
"-",
"case",
"word",
"that",
"starts",
"with",
"a",
"lowercase",
"letter",
"."
] | train | https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/base/src/main/java/org/xillium/base/beans/Strings.java#L108-L125 |
haifengl/smile | core/src/main/java/smile/vq/NeuralMap.java | NeuralMap.partition | public int partition(int k, int minPts) {
"""
Clustering neurons into k clusters.
@param k the number of clusters.
@param minPts a neuron will be treated as outlier if the number of its
points is less than minPts.
@return the number of non-outlier leaves.
"""
List<Neuron> data = new ArrayList<>();
for (Neuron neuron : neurons) {
neuron.y = OUTLIER;
if (neuron.n >= minPts) {
data.add(neuron);
}
}
double[][] proximity = new double[data.size()][];
for (int i = 0; i < data.size(); i++) {
proximity[i] = new double[i + 1];
for (int j = 0; j < i; j++) {
proximity[i][j] = Math.distance(data.get(i).w, data.get(j).w);
}
}
Linkage linkage = new UPGMALinkage(proximity);
HierarchicalClustering hc = new HierarchicalClustering(linkage);
int[] y = hc.partition(k);
for (int i = 0; i < data.size(); i++) {
data.get(i).y = y[i];
}
return data.size();
} | java | public int partition(int k, int minPts) {
List<Neuron> data = new ArrayList<>();
for (Neuron neuron : neurons) {
neuron.y = OUTLIER;
if (neuron.n >= minPts) {
data.add(neuron);
}
}
double[][] proximity = new double[data.size()][];
for (int i = 0; i < data.size(); i++) {
proximity[i] = new double[i + 1];
for (int j = 0; j < i; j++) {
proximity[i][j] = Math.distance(data.get(i).w, data.get(j).w);
}
}
Linkage linkage = new UPGMALinkage(proximity);
HierarchicalClustering hc = new HierarchicalClustering(linkage);
int[] y = hc.partition(k);
for (int i = 0; i < data.size(); i++) {
data.get(i).y = y[i];
}
return data.size();
} | [
"public",
"int",
"partition",
"(",
"int",
"k",
",",
"int",
"minPts",
")",
"{",
"List",
"<",
"Neuron",
">",
"data",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"Neuron",
"neuron",
":",
"neurons",
")",
"{",
"neuron",
".",
"y",
"=",
"OUTLIER",
";",
"if",
"(",
"neuron",
".",
"n",
">=",
"minPts",
")",
"{",
"data",
".",
"add",
"(",
"neuron",
")",
";",
"}",
"}",
"double",
"[",
"]",
"[",
"]",
"proximity",
"=",
"new",
"double",
"[",
"data",
".",
"size",
"(",
")",
"]",
"[",
"",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"data",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"proximity",
"[",
"i",
"]",
"=",
"new",
"double",
"[",
"i",
"+",
"1",
"]",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"i",
";",
"j",
"++",
")",
"{",
"proximity",
"[",
"i",
"]",
"[",
"j",
"]",
"=",
"Math",
".",
"distance",
"(",
"data",
".",
"get",
"(",
"i",
")",
".",
"w",
",",
"data",
".",
"get",
"(",
"j",
")",
".",
"w",
")",
";",
"}",
"}",
"Linkage",
"linkage",
"=",
"new",
"UPGMALinkage",
"(",
"proximity",
")",
";",
"HierarchicalClustering",
"hc",
"=",
"new",
"HierarchicalClustering",
"(",
"linkage",
")",
";",
"int",
"[",
"]",
"y",
"=",
"hc",
".",
"partition",
"(",
"k",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"data",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"data",
".",
"get",
"(",
"i",
")",
".",
"y",
"=",
"y",
"[",
"i",
"]",
";",
"}",
"return",
"data",
".",
"size",
"(",
")",
";",
"}"
] | Clustering neurons into k clusters.
@param k the number of clusters.
@param minPts a neuron will be treated as outlier if the number of its
points is less than minPts.
@return the number of non-outlier leaves. | [
"Clustering",
"neurons",
"into",
"k",
"clusters",
"."
] | train | https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/vq/NeuralMap.java#L571-L597 |
CenturyLinkCloud/mdw | mdw-services/src/com/centurylink/mdw/services/event/EventServicesImpl.java | EventServicesImpl.getActivityInstance | public ActivityInstance getActivityInstance(Long pActivityInstId)
throws ProcessException, DataAccessException {
"""
Returns the ActivityInstance identified by the passed in Id
@param pActivityInstId
@return ActivityInstance
"""
ActivityInstance ai;
TransactionWrapper transaction = null;
EngineDataAccessDB edao = new EngineDataAccessDB();
try {
transaction = edao.startTransaction();
ai = edao.getActivityInstance(pActivityInstId);
} catch (SQLException e) {
throw new ProcessException(0, "Failed to get activity instance", e);
} finally {
edao.stopTransaction(transaction);
}
return ai;
} | java | public ActivityInstance getActivityInstance(Long pActivityInstId)
throws ProcessException, DataAccessException {
ActivityInstance ai;
TransactionWrapper transaction = null;
EngineDataAccessDB edao = new EngineDataAccessDB();
try {
transaction = edao.startTransaction();
ai = edao.getActivityInstance(pActivityInstId);
} catch (SQLException e) {
throw new ProcessException(0, "Failed to get activity instance", e);
} finally {
edao.stopTransaction(transaction);
}
return ai;
} | [
"public",
"ActivityInstance",
"getActivityInstance",
"(",
"Long",
"pActivityInstId",
")",
"throws",
"ProcessException",
",",
"DataAccessException",
"{",
"ActivityInstance",
"ai",
";",
"TransactionWrapper",
"transaction",
"=",
"null",
";",
"EngineDataAccessDB",
"edao",
"=",
"new",
"EngineDataAccessDB",
"(",
")",
";",
"try",
"{",
"transaction",
"=",
"edao",
".",
"startTransaction",
"(",
")",
";",
"ai",
"=",
"edao",
".",
"getActivityInstance",
"(",
"pActivityInstId",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"throw",
"new",
"ProcessException",
"(",
"0",
",",
"\"Failed to get activity instance\"",
",",
"e",
")",
";",
"}",
"finally",
"{",
"edao",
".",
"stopTransaction",
"(",
"transaction",
")",
";",
"}",
"return",
"ai",
";",
"}"
] | Returns the ActivityInstance identified by the passed in Id
@param pActivityInstId
@return ActivityInstance | [
"Returns",
"the",
"ActivityInstance",
"identified",
"by",
"the",
"passed",
"in",
"Id"
] | train | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-services/src/com/centurylink/mdw/services/event/EventServicesImpl.java#L441-L455 |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/edge/GradientToEdgeFeatures.java | GradientToEdgeFeatures.direction | static public void direction(GrayF32 derivX , GrayF32 derivY , GrayF32 angle ) {
"""
Computes the edge orientation using the {@link Math#atan} function.
@param derivX Derivative along x-axis. Not modified.
@param derivY Derivative along y-axis. Not modified.
@param angle Edge orientation in radians (-pi/2 to pi/2).
"""
InputSanityCheck.checkSameShape(derivX,derivY);
angle.reshape(derivX.width,derivX.height);
if(BoofConcurrency.USE_CONCURRENT ) {
ImplGradientToEdgeFeatures_MT.direction(derivX,derivY,angle);
} else {
ImplGradientToEdgeFeatures.direction(derivX,derivY,angle);
}
} | java | static public void direction(GrayF32 derivX , GrayF32 derivY , GrayF32 angle )
{
InputSanityCheck.checkSameShape(derivX,derivY);
angle.reshape(derivX.width,derivX.height);
if(BoofConcurrency.USE_CONCURRENT ) {
ImplGradientToEdgeFeatures_MT.direction(derivX,derivY,angle);
} else {
ImplGradientToEdgeFeatures.direction(derivX,derivY,angle);
}
} | [
"static",
"public",
"void",
"direction",
"(",
"GrayF32",
"derivX",
",",
"GrayF32",
"derivY",
",",
"GrayF32",
"angle",
")",
"{",
"InputSanityCheck",
".",
"checkSameShape",
"(",
"derivX",
",",
"derivY",
")",
";",
"angle",
".",
"reshape",
"(",
"derivX",
".",
"width",
",",
"derivX",
".",
"height",
")",
";",
"if",
"(",
"BoofConcurrency",
".",
"USE_CONCURRENT",
")",
"{",
"ImplGradientToEdgeFeatures_MT",
".",
"direction",
"(",
"derivX",
",",
"derivY",
",",
"angle",
")",
";",
"}",
"else",
"{",
"ImplGradientToEdgeFeatures",
".",
"direction",
"(",
"derivX",
",",
"derivY",
",",
"angle",
")",
";",
"}",
"}"
] | Computes the edge orientation using the {@link Math#atan} function.
@param derivX Derivative along x-axis. Not modified.
@param derivY Derivative along y-axis. Not modified.
@param angle Edge orientation in radians (-pi/2 to pi/2). | [
"Computes",
"the",
"edge",
"orientation",
"using",
"the",
"{",
"@link",
"Math#atan",
"}",
"function",
"."
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/edge/GradientToEdgeFeatures.java#L99-L109 |
hyperledger/fabric-sdk-java | src/main/java/org/hyperledger/fabric/sdk/ChaincodeCollectionConfiguration.java | ChaincodeCollectionConfiguration.fromYamlFile | public static ChaincodeCollectionConfiguration fromYamlFile(File configFile) throws InvalidArgumentException, IOException, ChaincodeCollectionConfigurationException {
"""
Creates a new ChaincodeCollectionConfiguration instance configured with details supplied in a YAML file.
@param configFile The file containing the network configuration
@return A new ChaincodeCollectionConfiguration instance
@throws InvalidArgumentException
@throws IOException
"""
return fromFile(configFile, false);
} | java | public static ChaincodeCollectionConfiguration fromYamlFile(File configFile) throws InvalidArgumentException, IOException, ChaincodeCollectionConfigurationException {
return fromFile(configFile, false);
} | [
"public",
"static",
"ChaincodeCollectionConfiguration",
"fromYamlFile",
"(",
"File",
"configFile",
")",
"throws",
"InvalidArgumentException",
",",
"IOException",
",",
"ChaincodeCollectionConfigurationException",
"{",
"return",
"fromFile",
"(",
"configFile",
",",
"false",
")",
";",
"}"
] | Creates a new ChaincodeCollectionConfiguration instance configured with details supplied in a YAML file.
@param configFile The file containing the network configuration
@return A new ChaincodeCollectionConfiguration instance
@throws InvalidArgumentException
@throws IOException | [
"Creates",
"a",
"new",
"ChaincodeCollectionConfiguration",
"instance",
"configured",
"with",
"details",
"supplied",
"in",
"a",
"YAML",
"file",
"."
] | train | https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/ChaincodeCollectionConfiguration.java#L88-L90 |
phax/ph-commons | ph-xml/src/main/java/com/helger/xml/microdom/serialize/MicroWriter.java | MicroWriter.getNodeAsString | @Nullable
public static String getNodeAsString (@Nonnull final IMicroNode aNode) {
"""
Convert the passed micro node to an XML string using
{@link XMLWriterSettings#DEFAULT_XML_SETTINGS}. This is a specialized
version of {@link #getNodeAsString(IMicroNode, IXMLWriterSettings)}.
@param aNode
The node to be converted to a string. May not be <code>null</code> .
@return The string representation of the passed node.
@since 8.6.3
"""
return getNodeAsString (aNode, XMLWriterSettings.DEFAULT_XML_SETTINGS);
} | java | @Nullable
public static String getNodeAsString (@Nonnull final IMicroNode aNode)
{
return getNodeAsString (aNode, XMLWriterSettings.DEFAULT_XML_SETTINGS);
} | [
"@",
"Nullable",
"public",
"static",
"String",
"getNodeAsString",
"(",
"@",
"Nonnull",
"final",
"IMicroNode",
"aNode",
")",
"{",
"return",
"getNodeAsString",
"(",
"aNode",
",",
"XMLWriterSettings",
".",
"DEFAULT_XML_SETTINGS",
")",
";",
"}"
] | Convert the passed micro node to an XML string using
{@link XMLWriterSettings#DEFAULT_XML_SETTINGS}. This is a specialized
version of {@link #getNodeAsString(IMicroNode, IXMLWriterSettings)}.
@param aNode
The node to be converted to a string. May not be <code>null</code> .
@return The string representation of the passed node.
@since 8.6.3 | [
"Convert",
"the",
"passed",
"micro",
"node",
"to",
"an",
"XML",
"string",
"using",
"{",
"@link",
"XMLWriterSettings#DEFAULT_XML_SETTINGS",
"}",
".",
"This",
"is",
"a",
"specialized",
"version",
"of",
"{",
"@link",
"#getNodeAsString",
"(",
"IMicroNode",
"IXMLWriterSettings",
")",
"}",
"."
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-xml/src/main/java/com/helger/xml/microdom/serialize/MicroWriter.java#L292-L296 |
santhosh-tekuri/jlibs | core/src/main/java/jlibs/core/lang/BeanUtil.java | BeanUtil.getGetterMethod | public static Method getGetterMethod(Class<?> beanClass, String property) {
"""
Returns getter method for <code>property</code> in specified <code>beanClass</code>
@param beanClass bean class
@param property name of the property
@return getter method. null if <code>property</code> is not found
@see #getGetterMethod(Class, String, Class)
"""
try{
return beanClass.getMethod(GET+getMethodSuffix(property));
}catch(NoSuchMethodException ex1){
try{
return beanClass.getMethod(IS+getMethodSuffix(property));
}catch(NoSuchMethodException ex2){
return null;
}
}
} | java | public static Method getGetterMethod(Class<?> beanClass, String property){
try{
return beanClass.getMethod(GET+getMethodSuffix(property));
}catch(NoSuchMethodException ex1){
try{
return beanClass.getMethod(IS+getMethodSuffix(property));
}catch(NoSuchMethodException ex2){
return null;
}
}
} | [
"public",
"static",
"Method",
"getGetterMethod",
"(",
"Class",
"<",
"?",
">",
"beanClass",
",",
"String",
"property",
")",
"{",
"try",
"{",
"return",
"beanClass",
".",
"getMethod",
"(",
"GET",
"+",
"getMethodSuffix",
"(",
"property",
")",
")",
";",
"}",
"catch",
"(",
"NoSuchMethodException",
"ex1",
")",
"{",
"try",
"{",
"return",
"beanClass",
".",
"getMethod",
"(",
"IS",
"+",
"getMethodSuffix",
"(",
"property",
")",
")",
";",
"}",
"catch",
"(",
"NoSuchMethodException",
"ex2",
")",
"{",
"return",
"null",
";",
"}",
"}",
"}"
] | Returns getter method for <code>property</code> in specified <code>beanClass</code>
@param beanClass bean class
@param property name of the property
@return getter method. null if <code>property</code> is not found
@see #getGetterMethod(Class, String, Class) | [
"Returns",
"getter",
"method",
"for",
"<code",
">",
"property<",
"/",
"code",
">",
"in",
"specified",
"<code",
">",
"beanClass<",
"/",
"code",
">"
] | train | https://github.com/santhosh-tekuri/jlibs/blob/59c28719f054123cf778278154e1b92e943ad232/core/src/main/java/jlibs/core/lang/BeanUtil.java#L97-L107 |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/plan/PlanNode.java | PlanNode.findAllAtOrBelow | public List<PlanNode> findAllAtOrBelow( Traversal order,
Type firstTypeToFind,
Type... additionalTypesToFind ) {
"""
Find all of the nodes with one of the specified types that are at or below this node.
@param order the order to traverse; may not be null
@param firstTypeToFind the first type of node to find; may not be null
@param additionalTypesToFind the additional types of node to find; may not be null
@return the collection of nodes that are at or below this node that all have one of the supplied types; never null but
possibly empty
"""
return findAllAtOrBelow(order, EnumSet.of(firstTypeToFind, additionalTypesToFind));
} | java | public List<PlanNode> findAllAtOrBelow( Traversal order,
Type firstTypeToFind,
Type... additionalTypesToFind ) {
return findAllAtOrBelow(order, EnumSet.of(firstTypeToFind, additionalTypesToFind));
} | [
"public",
"List",
"<",
"PlanNode",
">",
"findAllAtOrBelow",
"(",
"Traversal",
"order",
",",
"Type",
"firstTypeToFind",
",",
"Type",
"...",
"additionalTypesToFind",
")",
"{",
"return",
"findAllAtOrBelow",
"(",
"order",
",",
"EnumSet",
".",
"of",
"(",
"firstTypeToFind",
",",
"additionalTypesToFind",
")",
")",
";",
"}"
] | Find all of the nodes with one of the specified types that are at or below this node.
@param order the order to traverse; may not be null
@param firstTypeToFind the first type of node to find; may not be null
@param additionalTypesToFind the additional types of node to find; may not be null
@return the collection of nodes that are at or below this node that all have one of the supplied types; never null but
possibly empty | [
"Find",
"all",
"of",
"the",
"nodes",
"with",
"one",
"of",
"the",
"specified",
"types",
"that",
"are",
"at",
"or",
"below",
"this",
"node",
"."
] | train | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/plan/PlanNode.java#L1399-L1403 |
awslabs/amazon-sqs-java-extended-client-lib | src/main/java/com/amazon/sqs/javamessaging/ExtendedClientConfiguration.java | ExtendedClientConfiguration.setLargePayloadSupportEnabled | public void setLargePayloadSupportEnabled(AmazonS3 s3, String s3BucketName) {
"""
Enables support for large-payload messages.
@param s3
Amazon S3 client which is going to be used for storing
large-payload messages.
@param s3BucketName
Name of the bucket which is going to be used for storing
large-payload messages. The bucket must be already created and
configured in s3.
"""
if (s3 == null || s3BucketName == null) {
String errorMessage = "S3 client and/or S3 bucket name cannot be null.";
LOG.error(errorMessage);
throw new AmazonClientException(errorMessage);
}
if (isLargePayloadSupportEnabled()) {
LOG.warn("Large-payload support is already enabled. Overwriting AmazonS3Client and S3BucketName.");
}
this.s3 = s3;
this.s3BucketName = s3BucketName;
largePayloadSupport = true;
LOG.info("Large-payload support enabled.");
} | java | public void setLargePayloadSupportEnabled(AmazonS3 s3, String s3BucketName) {
if (s3 == null || s3BucketName == null) {
String errorMessage = "S3 client and/or S3 bucket name cannot be null.";
LOG.error(errorMessage);
throw new AmazonClientException(errorMessage);
}
if (isLargePayloadSupportEnabled()) {
LOG.warn("Large-payload support is already enabled. Overwriting AmazonS3Client and S3BucketName.");
}
this.s3 = s3;
this.s3BucketName = s3BucketName;
largePayloadSupport = true;
LOG.info("Large-payload support enabled.");
} | [
"public",
"void",
"setLargePayloadSupportEnabled",
"(",
"AmazonS3",
"s3",
",",
"String",
"s3BucketName",
")",
"{",
"if",
"(",
"s3",
"==",
"null",
"||",
"s3BucketName",
"==",
"null",
")",
"{",
"String",
"errorMessage",
"=",
"\"S3 client and/or S3 bucket name cannot be null.\"",
";",
"LOG",
".",
"error",
"(",
"errorMessage",
")",
";",
"throw",
"new",
"AmazonClientException",
"(",
"errorMessage",
")",
";",
"}",
"if",
"(",
"isLargePayloadSupportEnabled",
"(",
")",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Large-payload support is already enabled. Overwriting AmazonS3Client and S3BucketName.\"",
")",
";",
"}",
"this",
".",
"s3",
"=",
"s3",
";",
"this",
".",
"s3BucketName",
"=",
"s3BucketName",
";",
"largePayloadSupport",
"=",
"true",
";",
"LOG",
".",
"info",
"(",
"\"Large-payload support enabled.\"",
")",
";",
"}"
] | Enables support for large-payload messages.
@param s3
Amazon S3 client which is going to be used for storing
large-payload messages.
@param s3BucketName
Name of the bucket which is going to be used for storing
large-payload messages. The bucket must be already created and
configured in s3. | [
"Enables",
"support",
"for",
"large",
"-",
"payload",
"messages",
"."
] | train | https://github.com/awslabs/amazon-sqs-java-extended-client-lib/blob/df0c6251b99e682d6179938fe784590e662b84ea/src/main/java/com/amazon/sqs/javamessaging/ExtendedClientConfiguration.java#L64-L77 |
apache/groovy | src/main/java/org/codehaus/groovy/runtime/powerassert/SourceText.java | SourceText.getNormalizedColumn | public int getNormalizedColumn(int line, int column) {
"""
Returns the column in <tt>getNormalizedText()</tt> corresponding
to the given line and column in the original source text. The
first character in the normalized text has column 1.
@param line a line number
@param column a column number
@return the column in getNormalizedText() corresponding to the given line
and column in the original source text
"""
int deltaLine = line - firstLine;
if (deltaLine < 0 || deltaLine >= lineOffsets.size()) // wrong line information
return -1;
int deltaColumn = column - lineOffsets.get(deltaLine);
if (deltaColumn < 0) // wrong column information
return -1;
return textOffsets.get(deltaLine) + deltaColumn;
} | java | public int getNormalizedColumn(int line, int column) {
int deltaLine = line - firstLine;
if (deltaLine < 0 || deltaLine >= lineOffsets.size()) // wrong line information
return -1;
int deltaColumn = column - lineOffsets.get(deltaLine);
if (deltaColumn < 0) // wrong column information
return -1;
return textOffsets.get(deltaLine) + deltaColumn;
} | [
"public",
"int",
"getNormalizedColumn",
"(",
"int",
"line",
",",
"int",
"column",
")",
"{",
"int",
"deltaLine",
"=",
"line",
"-",
"firstLine",
";",
"if",
"(",
"deltaLine",
"<",
"0",
"||",
"deltaLine",
">=",
"lineOffsets",
".",
"size",
"(",
")",
")",
"// wrong line information",
"return",
"-",
"1",
";",
"int",
"deltaColumn",
"=",
"column",
"-",
"lineOffsets",
".",
"get",
"(",
"deltaLine",
")",
";",
"if",
"(",
"deltaColumn",
"<",
"0",
")",
"// wrong column information",
"return",
"-",
"1",
";",
"return",
"textOffsets",
".",
"get",
"(",
"deltaLine",
")",
"+",
"deltaColumn",
";",
"}"
] | Returns the column in <tt>getNormalizedText()</tt> corresponding
to the given line and column in the original source text. The
first character in the normalized text has column 1.
@param line a line number
@param column a column number
@return the column in getNormalizedText() corresponding to the given line
and column in the original source text | [
"Returns",
"the",
"column",
"in",
"<tt",
">",
"getNormalizedText",
"()",
"<",
"/",
"tt",
">",
"corresponding",
"to",
"the",
"given",
"line",
"and",
"column",
"in",
"the",
"original",
"source",
"text",
".",
"The",
"first",
"character",
"in",
"the",
"normalized",
"text",
"has",
"column",
"1",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/powerassert/SourceText.java#L100-L109 |
Azure/azure-sdk-for-java | redis/resource-manager/v2017_10_01/src/main/java/com/microsoft/azure/management/redis/v2017_10_01/implementation/RedisInner.java | RedisInner.exportData | public void exportData(String resourceGroupName, String name, ExportRDBParameters parameters) {
"""
Export data from the redis cache to blobs in a container.
@param resourceGroupName The name of the resource group.
@param name The name of the Redis cache.
@param parameters Parameters for Redis export 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
"""
exportDataWithServiceResponseAsync(resourceGroupName, name, parameters).toBlocking().last().body();
} | java | public void exportData(String resourceGroupName, String name, ExportRDBParameters parameters) {
exportDataWithServiceResponseAsync(resourceGroupName, name, parameters).toBlocking().last().body();
} | [
"public",
"void",
"exportData",
"(",
"String",
"resourceGroupName",
",",
"String",
"name",
",",
"ExportRDBParameters",
"parameters",
")",
"{",
"exportDataWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"name",
",",
"parameters",
")",
".",
"toBlocking",
"(",
")",
".",
"last",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Export data from the redis cache to blobs in a container.
@param resourceGroupName The name of the resource group.
@param name The name of the Redis cache.
@param parameters Parameters for Redis export 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 | [
"Export",
"data",
"from",
"the",
"redis",
"cache",
"to",
"blobs",
"in",
"a",
"container",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/redis/resource-manager/v2017_10_01/src/main/java/com/microsoft/azure/management/redis/v2017_10_01/implementation/RedisInner.java#L1508-L1510 |
boncey/Flickr4Java | src/main/java/com/flickr4java/flickr/REST.java | REST.setProxy | public void setProxy(String proxyHost, int proxyPort, String username, String password) {
"""
Set a proxy with authentication for REST-requests.
@param proxyHost
@param proxyPort
@param username
@param password
"""
setProxy(proxyHost, proxyPort);
proxyAuth = true;
proxyUser = username;
proxyPassword = password;
} | java | public void setProxy(String proxyHost, int proxyPort, String username, String password) {
setProxy(proxyHost, proxyPort);
proxyAuth = true;
proxyUser = username;
proxyPassword = password;
} | [
"public",
"void",
"setProxy",
"(",
"String",
"proxyHost",
",",
"int",
"proxyPort",
",",
"String",
"username",
",",
"String",
"password",
")",
"{",
"setProxy",
"(",
"proxyHost",
",",
"proxyPort",
")",
";",
"proxyAuth",
"=",
"true",
";",
"proxyUser",
"=",
"username",
";",
"proxyPassword",
"=",
"password",
";",
"}"
] | Set a proxy with authentication for REST-requests.
@param proxyHost
@param proxyPort
@param username
@param password | [
"Set",
"a",
"proxy",
"with",
"authentication",
"for",
"REST",
"-",
"requests",
"."
] | train | https://github.com/boncey/Flickr4Java/blob/f66987ba0e360e5fb7730efbbb8c51f3d978fc25/src/main/java/com/flickr4java/flickr/REST.java#L119-L124 |
czyzby/gdx-lml | kiwi/src/main/java/com/github/czyzby/kiwi/util/gdx/reflection/Reflection.java | Reflection.newInstance | public static <Type> Type newInstance(final Class<Type> ofClass, final Type defaultValue) {
"""
Allows to gracefully create a new instance of class, without having to try-catch exceptions.
@param ofClass instance of this class will be constructed using reflection.
@param defaultValue will be returned if unable to construct new instance.
@return a new instance of passed class or default value.
@param <Type> type of constructed value.
"""
try {
return ClassReflection.newInstance(ofClass);
} catch (final Throwable exception) {
Exceptions.ignore(exception);
return defaultValue;
}
} | java | public static <Type> Type newInstance(final Class<Type> ofClass, final Type defaultValue) {
try {
return ClassReflection.newInstance(ofClass);
} catch (final Throwable exception) {
Exceptions.ignore(exception);
return defaultValue;
}
} | [
"public",
"static",
"<",
"Type",
">",
"Type",
"newInstance",
"(",
"final",
"Class",
"<",
"Type",
">",
"ofClass",
",",
"final",
"Type",
"defaultValue",
")",
"{",
"try",
"{",
"return",
"ClassReflection",
".",
"newInstance",
"(",
"ofClass",
")",
";",
"}",
"catch",
"(",
"final",
"Throwable",
"exception",
")",
"{",
"Exceptions",
".",
"ignore",
"(",
"exception",
")",
";",
"return",
"defaultValue",
";",
"}",
"}"
] | Allows to gracefully create a new instance of class, without having to try-catch exceptions.
@param ofClass instance of this class will be constructed using reflection.
@param defaultValue will be returned if unable to construct new instance.
@return a new instance of passed class or default value.
@param <Type> type of constructed value. | [
"Allows",
"to",
"gracefully",
"create",
"a",
"new",
"instance",
"of",
"class",
"without",
"having",
"to",
"try",
"-",
"catch",
"exceptions",
"."
] | train | https://github.com/czyzby/gdx-lml/blob/7623b322e6afe49ad4dd636c80c230150a1cfa4e/kiwi/src/main/java/com/github/czyzby/kiwi/util/gdx/reflection/Reflection.java#L52-L59 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.