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
|
---|---|---|---|---|---|---|---|---|---|---|
alkacon/opencms-core | src/org/opencms/ui/components/extensions/CmsGwtDialogExtension.java | CmsGwtDialogExtension.getPublishData | protected CmsPublishData getPublishData(CmsProject project, List<CmsResource> directPublishResources) {
"""
Gets the publish data for the given resources.<p>
@param directPublishResources the resources to publish
@param project the project for which to open the dialog
@return the publish data for the resources
"""
CmsPublishService publishService = new CmsPublishService();
CmsObject cms = A_CmsUI.getCmsObject();
publishService.setCms(cms);
List<String> pathList = new ArrayList<String>();
if (directPublishResources != null) {
for (CmsResource resource : directPublishResources) {
pathList.add(cms.getSitePath(resource));
}
}
publishService.setRequest((HttpServletRequest)(VaadinService.getCurrentRequest()));
try {
return publishService.getPublishData(
cms,
new HashMap<String, String>()/*params*/,
null/*workflowId*/,
project != null ? project.getUuid().toString() : null /*projectParam*/,
pathList,
null/*closelink*/,
false/*confirmation*/);
} catch (Exception e) {
LOG.error(e.getLocalizedMessage(), e);
return null;
}
} | java | protected CmsPublishData getPublishData(CmsProject project, List<CmsResource> directPublishResources) {
CmsPublishService publishService = new CmsPublishService();
CmsObject cms = A_CmsUI.getCmsObject();
publishService.setCms(cms);
List<String> pathList = new ArrayList<String>();
if (directPublishResources != null) {
for (CmsResource resource : directPublishResources) {
pathList.add(cms.getSitePath(resource));
}
}
publishService.setRequest((HttpServletRequest)(VaadinService.getCurrentRequest()));
try {
return publishService.getPublishData(
cms,
new HashMap<String, String>()/*params*/,
null/*workflowId*/,
project != null ? project.getUuid().toString() : null /*projectParam*/,
pathList,
null/*closelink*/,
false/*confirmation*/);
} catch (Exception e) {
LOG.error(e.getLocalizedMessage(), e);
return null;
}
} | [
"protected",
"CmsPublishData",
"getPublishData",
"(",
"CmsProject",
"project",
",",
"List",
"<",
"CmsResource",
">",
"directPublishResources",
")",
"{",
"CmsPublishService",
"publishService",
"=",
"new",
"CmsPublishService",
"(",
")",
";",
"CmsObject",
"cms",
"=",
"A_CmsUI",
".",
"getCmsObject",
"(",
")",
";",
"publishService",
".",
"setCms",
"(",
"cms",
")",
";",
"List",
"<",
"String",
">",
"pathList",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"if",
"(",
"directPublishResources",
"!=",
"null",
")",
"{",
"for",
"(",
"CmsResource",
"resource",
":",
"directPublishResources",
")",
"{",
"pathList",
".",
"add",
"(",
"cms",
".",
"getSitePath",
"(",
"resource",
")",
")",
";",
"}",
"}",
"publishService",
".",
"setRequest",
"(",
"(",
"HttpServletRequest",
")",
"(",
"VaadinService",
".",
"getCurrentRequest",
"(",
")",
")",
")",
";",
"try",
"{",
"return",
"publishService",
".",
"getPublishData",
"(",
"cms",
",",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
"/*params*/",
",",
"null",
"/*workflowId*/",
",",
"project",
"!=",
"null",
"?",
"project",
".",
"getUuid",
"(",
")",
".",
"toString",
"(",
")",
":",
"null",
"/*projectParam*/",
",",
"pathList",
",",
"null",
"/*closelink*/",
",",
"false",
"/*confirmation*/",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"e",
".",
"getLocalizedMessage",
"(",
")",
",",
"e",
")",
";",
"return",
"null",
";",
"}",
"}"
] | Gets the publish data for the given resources.<p>
@param directPublishResources the resources to publish
@param project the project for which to open the dialog
@return the publish data for the resources | [
"Gets",
"the",
"publish",
"data",
"for",
"the",
"given",
"resources",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/components/extensions/CmsGwtDialogExtension.java#L283-L308 |
lkwg82/enforcer-rules | src/main/java/org/apache/maven/plugins/enforcer/utils/EnforcerRuleUtils.java | EnforcerRuleUtils.getModelsRecursively | public List<Model> getModelsRecursively ( String groupId, String artifactId, String version, File pom )
throws ArtifactResolutionException, ArtifactNotFoundException, IOException, XmlPullParserException {
"""
This method loops through all the parents, getting
each pom model and then its parent.
@param groupId the group id
@param artifactId the artifact id
@param version the version
@param pom the pom
@return the models recursively
@throws ArtifactResolutionException the artifact resolution exception
@throws ArtifactNotFoundException the artifact not found exception
@throws IOException Signals that an I/O exception has occurred.
@throws XmlPullParserException the xml pull parser exception
"""
List<Model> models = null;
Model model = getPomModel( groupId, artifactId, version, pom );
Parent parent = model.getParent();
// recurse into the parent
if ( parent != null )
{
// get the relative path
String relativePath = parent.getRelativePath();
if ( StringUtils.isEmpty( relativePath ) )
{
relativePath = "../pom.xml";
}
// calculate the recursive path
File parentPom = new File( pom.getParent(), relativePath );
// if relative path is a directory, append pom.xml
if ( parentPom.isDirectory() )
{
parentPom = new File( parentPom, "pom.xml" );
}
models = getModelsRecursively( parent.getGroupId(), parent.getArtifactId(), parent.getVersion(), parentPom );
}
else
{
// only create it here since I'm not at the top
models = new ArrayList<Model>();
}
models.add( model );
return models;
} | java | public List<Model> getModelsRecursively ( String groupId, String artifactId, String version, File pom )
throws ArtifactResolutionException, ArtifactNotFoundException, IOException, XmlPullParserException
{
List<Model> models = null;
Model model = getPomModel( groupId, artifactId, version, pom );
Parent parent = model.getParent();
// recurse into the parent
if ( parent != null )
{
// get the relative path
String relativePath = parent.getRelativePath();
if ( StringUtils.isEmpty( relativePath ) )
{
relativePath = "../pom.xml";
}
// calculate the recursive path
File parentPom = new File( pom.getParent(), relativePath );
// if relative path is a directory, append pom.xml
if ( parentPom.isDirectory() )
{
parentPom = new File( parentPom, "pom.xml" );
}
models = getModelsRecursively( parent.getGroupId(), parent.getArtifactId(), parent.getVersion(), parentPom );
}
else
{
// only create it here since I'm not at the top
models = new ArrayList<Model>();
}
models.add( model );
return models;
} | [
"public",
"List",
"<",
"Model",
">",
"getModelsRecursively",
"(",
"String",
"groupId",
",",
"String",
"artifactId",
",",
"String",
"version",
",",
"File",
"pom",
")",
"throws",
"ArtifactResolutionException",
",",
"ArtifactNotFoundException",
",",
"IOException",
",",
"XmlPullParserException",
"{",
"List",
"<",
"Model",
">",
"models",
"=",
"null",
";",
"Model",
"model",
"=",
"getPomModel",
"(",
"groupId",
",",
"artifactId",
",",
"version",
",",
"pom",
")",
";",
"Parent",
"parent",
"=",
"model",
".",
"getParent",
"(",
")",
";",
"// recurse into the parent",
"if",
"(",
"parent",
"!=",
"null",
")",
"{",
"// get the relative path",
"String",
"relativePath",
"=",
"parent",
".",
"getRelativePath",
"(",
")",
";",
"if",
"(",
"StringUtils",
".",
"isEmpty",
"(",
"relativePath",
")",
")",
"{",
"relativePath",
"=",
"\"../pom.xml\"",
";",
"}",
"// calculate the recursive path",
"File",
"parentPom",
"=",
"new",
"File",
"(",
"pom",
".",
"getParent",
"(",
")",
",",
"relativePath",
")",
";",
"// if relative path is a directory, append pom.xml",
"if",
"(",
"parentPom",
".",
"isDirectory",
"(",
")",
")",
"{",
"parentPom",
"=",
"new",
"File",
"(",
"parentPom",
",",
"\"pom.xml\"",
")",
";",
"}",
"models",
"=",
"getModelsRecursively",
"(",
"parent",
".",
"getGroupId",
"(",
")",
",",
"parent",
".",
"getArtifactId",
"(",
")",
",",
"parent",
".",
"getVersion",
"(",
")",
",",
"parentPom",
")",
";",
"}",
"else",
"{",
"// only create it here since I'm not at the top",
"models",
"=",
"new",
"ArrayList",
"<",
"Model",
">",
"(",
")",
";",
"}",
"models",
".",
"add",
"(",
"model",
")",
";",
"return",
"models",
";",
"}"
] | This method loops through all the parents, getting
each pom model and then its parent.
@param groupId the group id
@param artifactId the artifact id
@param version the version
@param pom the pom
@return the models recursively
@throws ArtifactResolutionException the artifact resolution exception
@throws ArtifactNotFoundException the artifact not found exception
@throws IOException Signals that an I/O exception has occurred.
@throws XmlPullParserException the xml pull parser exception | [
"This",
"method",
"loops",
"through",
"all",
"the",
"parents",
"getting",
"each",
"pom",
"model",
"and",
"then",
"its",
"parent",
"."
] | train | https://github.com/lkwg82/enforcer-rules/blob/fa2d309af7907b17fc8eaf386f8056d77b654749/src/main/java/org/apache/maven/plugins/enforcer/utils/EnforcerRuleUtils.java#L237-L273 |
apache/incubator-gobblin | gobblin-config-management/gobblin-config-core/src/main/java/org/apache/gobblin/config/store/hdfs/SimpleHadoopFilesystemConfigStore.java | SimpleHadoopFilesystemConfigStore.getOwnConfig | @Override
public Config getOwnConfig(ConfigKeyPath configKey, String version) throws VersionDoesNotExistException {
"""
Retrieves the {@link Config} for the given {@link ConfigKeyPath} by reading the {@link #MAIN_CONF_FILE_NAME}
associated with the dataset specified by the given {@link ConfigKeyPath}. If the {@link Path} described by the
{@link ConfigKeyPath} does not exist then an empty {@link Config} is returned.
@param configKey the config key path whose properties are needed.
@param version the configuration version in the configuration store.
@return a {@link Config} for the given configKey.
@throws VersionDoesNotExistException if the version specified cannot be found in the {@link ConfigStore}.
"""
Preconditions.checkNotNull(configKey, "configKey cannot be null!");
Preconditions.checkArgument(!Strings.isNullOrEmpty(version), "version cannot be null or empty!");
Path datasetDir = getDatasetDirForKey(configKey, version);
Path mainConfFile = new Path(datasetDir, MAIN_CONF_FILE_NAME);
try {
if (!this.fs.exists(mainConfFile)) {
return ConfigFactory.empty();
}
FileStatus configFileStatus = this.fs.getFileStatus(mainConfFile);
if (!configFileStatus.isDirectory()) {
try (InputStream mainConfInputStream = this.fs.open(configFileStatus.getPath())) {
return ConfigFactory.parseReader(new InputStreamReader(mainConfInputStream, Charsets.UTF_8));
}
}
return ConfigFactory.empty();
} catch (IOException e) {
throw new RuntimeException(String.format("Error while getting config for configKey: \"%s\"", configKey), e);
}
} | java | @Override
public Config getOwnConfig(ConfigKeyPath configKey, String version) throws VersionDoesNotExistException {
Preconditions.checkNotNull(configKey, "configKey cannot be null!");
Preconditions.checkArgument(!Strings.isNullOrEmpty(version), "version cannot be null or empty!");
Path datasetDir = getDatasetDirForKey(configKey, version);
Path mainConfFile = new Path(datasetDir, MAIN_CONF_FILE_NAME);
try {
if (!this.fs.exists(mainConfFile)) {
return ConfigFactory.empty();
}
FileStatus configFileStatus = this.fs.getFileStatus(mainConfFile);
if (!configFileStatus.isDirectory()) {
try (InputStream mainConfInputStream = this.fs.open(configFileStatus.getPath())) {
return ConfigFactory.parseReader(new InputStreamReader(mainConfInputStream, Charsets.UTF_8));
}
}
return ConfigFactory.empty();
} catch (IOException e) {
throw new RuntimeException(String.format("Error while getting config for configKey: \"%s\"", configKey), e);
}
} | [
"@",
"Override",
"public",
"Config",
"getOwnConfig",
"(",
"ConfigKeyPath",
"configKey",
",",
"String",
"version",
")",
"throws",
"VersionDoesNotExistException",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"configKey",
",",
"\"configKey cannot be null!\"",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"!",
"Strings",
".",
"isNullOrEmpty",
"(",
"version",
")",
",",
"\"version cannot be null or empty!\"",
")",
";",
"Path",
"datasetDir",
"=",
"getDatasetDirForKey",
"(",
"configKey",
",",
"version",
")",
";",
"Path",
"mainConfFile",
"=",
"new",
"Path",
"(",
"datasetDir",
",",
"MAIN_CONF_FILE_NAME",
")",
";",
"try",
"{",
"if",
"(",
"!",
"this",
".",
"fs",
".",
"exists",
"(",
"mainConfFile",
")",
")",
"{",
"return",
"ConfigFactory",
".",
"empty",
"(",
")",
";",
"}",
"FileStatus",
"configFileStatus",
"=",
"this",
".",
"fs",
".",
"getFileStatus",
"(",
"mainConfFile",
")",
";",
"if",
"(",
"!",
"configFileStatus",
".",
"isDirectory",
"(",
")",
")",
"{",
"try",
"(",
"InputStream",
"mainConfInputStream",
"=",
"this",
".",
"fs",
".",
"open",
"(",
"configFileStatus",
".",
"getPath",
"(",
")",
")",
")",
"{",
"return",
"ConfigFactory",
".",
"parseReader",
"(",
"new",
"InputStreamReader",
"(",
"mainConfInputStream",
",",
"Charsets",
".",
"UTF_8",
")",
")",
";",
"}",
"}",
"return",
"ConfigFactory",
".",
"empty",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"String",
".",
"format",
"(",
"\"Error while getting config for configKey: \\\"%s\\\"\"",
",",
"configKey",
")",
",",
"e",
")",
";",
"}",
"}"
] | Retrieves the {@link Config} for the given {@link ConfigKeyPath} by reading the {@link #MAIN_CONF_FILE_NAME}
associated with the dataset specified by the given {@link ConfigKeyPath}. If the {@link Path} described by the
{@link ConfigKeyPath} does not exist then an empty {@link Config} is returned.
@param configKey the config key path whose properties are needed.
@param version the configuration version in the configuration store.
@return a {@link Config} for the given configKey.
@throws VersionDoesNotExistException if the version specified cannot be found in the {@link ConfigStore}. | [
"Retrieves",
"the",
"{",
"@link",
"Config",
"}",
"for",
"the",
"given",
"{",
"@link",
"ConfigKeyPath",
"}",
"by",
"reading",
"the",
"{",
"@link",
"#MAIN_CONF_FILE_NAME",
"}",
"associated",
"with",
"the",
"dataset",
"specified",
"by",
"the",
"given",
"{",
"@link",
"ConfigKeyPath",
"}",
".",
"If",
"the",
"{",
"@link",
"Path",
"}",
"described",
"by",
"the",
"{",
"@link",
"ConfigKeyPath",
"}",
"does",
"not",
"exist",
"then",
"an",
"empty",
"{",
"@link",
"Config",
"}",
"is",
"returned",
"."
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-config-management/gobblin-config-core/src/main/java/org/apache/gobblin/config/store/hdfs/SimpleHadoopFilesystemConfigStore.java#L345-L368 |
TheHolyWaffle/League-of-Legends-XMPP-Chat-Library | src/main/java/com/github/theholywaffle/lolchatapi/LolChat.java | LolChat.addFriendByName | public boolean addFriendByName(String name, FriendGroup friendGroup) {
"""
Sends an friend request to an other user. An Riot API key is required for
this.
@param name
The name of the Friend you want to add (case insensitive)
@param friendGroup
The FriendGroup you want to put this user in.
@return True if succesful otherwise false.
"""
if (getRiotApi() != null) {
try {
final StringBuilder buf = new StringBuilder();
buf.append("sum");
buf.append(getRiotApi().getSummonerId(name));
buf.append("@pvp.net");
addFriendById(buf.toString(), name, friendGroup);
return true;
} catch (IOException | URISyntaxException e) {
e.printStackTrace();
return false;
}
}
return false;
} | java | public boolean addFriendByName(String name, FriendGroup friendGroup) {
if (getRiotApi() != null) {
try {
final StringBuilder buf = new StringBuilder();
buf.append("sum");
buf.append(getRiotApi().getSummonerId(name));
buf.append("@pvp.net");
addFriendById(buf.toString(), name, friendGroup);
return true;
} catch (IOException | URISyntaxException e) {
e.printStackTrace();
return false;
}
}
return false;
} | [
"public",
"boolean",
"addFriendByName",
"(",
"String",
"name",
",",
"FriendGroup",
"friendGroup",
")",
"{",
"if",
"(",
"getRiotApi",
"(",
")",
"!=",
"null",
")",
"{",
"try",
"{",
"final",
"StringBuilder",
"buf",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"buf",
".",
"append",
"(",
"\"sum\"",
")",
";",
"buf",
".",
"append",
"(",
"getRiotApi",
"(",
")",
".",
"getSummonerId",
"(",
"name",
")",
")",
";",
"buf",
".",
"append",
"(",
"\"@pvp.net\"",
")",
";",
"addFriendById",
"(",
"buf",
".",
"toString",
"(",
")",
",",
"name",
",",
"friendGroup",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"IOException",
"|",
"URISyntaxException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"return",
"false",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Sends an friend request to an other user. An Riot API key is required for
this.
@param name
The name of the Friend you want to add (case insensitive)
@param friendGroup
The FriendGroup you want to put this user in.
@return True if succesful otherwise false. | [
"Sends",
"an",
"friend",
"request",
"to",
"an",
"other",
"user",
".",
"An",
"Riot",
"API",
"key",
"is",
"required",
"for",
"this",
"."
] | train | https://github.com/TheHolyWaffle/League-of-Legends-XMPP-Chat-Library/blob/5e4d87d0c054ff2f6510545b0e9f838338695c70/src/main/java/com/github/theholywaffle/lolchatapi/LolChat.java#L266-L281 |
hawkular/hawkular-apm | api/src/main/java/org/hawkular/apm/api/services/ConfigurationLoader.java | ConfigurationLoader.getConfiguration | public static CollectorConfiguration getConfiguration(String type) {
"""
This method returns the collector configuration.
@param type The type, or null if default (jvm)
@return The collection configuration
"""
return loadConfig(PropertyUtil.getProperty(HAWKULAR_APM_CONFIG, DEFAULT_URI), type);
} | java | public static CollectorConfiguration getConfiguration(String type) {
return loadConfig(PropertyUtil.getProperty(HAWKULAR_APM_CONFIG, DEFAULT_URI), type);
} | [
"public",
"static",
"CollectorConfiguration",
"getConfiguration",
"(",
"String",
"type",
")",
"{",
"return",
"loadConfig",
"(",
"PropertyUtil",
".",
"getProperty",
"(",
"HAWKULAR_APM_CONFIG",
",",
"DEFAULT_URI",
")",
",",
"type",
")",
";",
"}"
] | This method returns the collector configuration.
@param type The type, or null if default (jvm)
@return The collection configuration | [
"This",
"method",
"returns",
"the",
"collector",
"configuration",
"."
] | train | https://github.com/hawkular/hawkular-apm/blob/57a4df0611b359597626563ea5f9ac64d4bb2533/api/src/main/java/org/hawkular/apm/api/services/ConfigurationLoader.java#L66-L68 |
google/closure-compiler | src/com/google/javascript/jscomp/LateEs6ToEs3Converter.java | LateEs6ToEs3Converter.visitMemberFunctionDefInObjectLit | private void visitMemberFunctionDefInObjectLit(Node n, Node parent) {
"""
Converts a member definition in an object literal to an ES3 key/value pair.
Member definitions in classes are handled in {@link Es6RewriteClass}.
"""
String name = n.getString();
Node nameNode = n.getFirstFirstChild();
Node stringKey = withType(IR.stringKey(name, n.getFirstChild().detach()), n.getJSType());
stringKey.setJSDocInfo(n.getJSDocInfo());
parent.replaceChild(n, stringKey);
stringKey.useSourceInfoFrom(nameNode);
compiler.reportChangeToEnclosingScope(stringKey);
} | java | private void visitMemberFunctionDefInObjectLit(Node n, Node parent) {
String name = n.getString();
Node nameNode = n.getFirstFirstChild();
Node stringKey = withType(IR.stringKey(name, n.getFirstChild().detach()), n.getJSType());
stringKey.setJSDocInfo(n.getJSDocInfo());
parent.replaceChild(n, stringKey);
stringKey.useSourceInfoFrom(nameNode);
compiler.reportChangeToEnclosingScope(stringKey);
} | [
"private",
"void",
"visitMemberFunctionDefInObjectLit",
"(",
"Node",
"n",
",",
"Node",
"parent",
")",
"{",
"String",
"name",
"=",
"n",
".",
"getString",
"(",
")",
";",
"Node",
"nameNode",
"=",
"n",
".",
"getFirstFirstChild",
"(",
")",
";",
"Node",
"stringKey",
"=",
"withType",
"(",
"IR",
".",
"stringKey",
"(",
"name",
",",
"n",
".",
"getFirstChild",
"(",
")",
".",
"detach",
"(",
")",
")",
",",
"n",
".",
"getJSType",
"(",
")",
")",
";",
"stringKey",
".",
"setJSDocInfo",
"(",
"n",
".",
"getJSDocInfo",
"(",
")",
")",
";",
"parent",
".",
"replaceChild",
"(",
"n",
",",
"stringKey",
")",
";",
"stringKey",
".",
"useSourceInfoFrom",
"(",
"nameNode",
")",
";",
"compiler",
".",
"reportChangeToEnclosingScope",
"(",
"stringKey",
")",
";",
"}"
] | Converts a member definition in an object literal to an ES3 key/value pair.
Member definitions in classes are handled in {@link Es6RewriteClass}. | [
"Converts",
"a",
"member",
"definition",
"in",
"an",
"object",
"literal",
"to",
"an",
"ES3",
"key",
"/",
"value",
"pair",
".",
"Member",
"definitions",
"in",
"classes",
"are",
"handled",
"in",
"{"
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/LateEs6ToEs3Converter.java#L133-L141 |
mnlipp/jgrapes | org.jgrapes.io/src/org/jgrapes/net/TcpConnector.java | TcpConnector.onOpenConnection | @Handler
public void onOpenConnection(OpenTcpConnection event) {
"""
Opens a connection to the end point specified in the event.
@param event the event
"""
try {
SocketChannel socketChannel = SocketChannel.open(event.address());
channels.add(new TcpChannelImpl(socketChannel));
} catch (ConnectException e) {
fire(new ConnectError(event, "Connection refused.", e));
} catch (IOException e) {
fire(new ConnectError(event, "Failed to open TCP connection.", e));
}
} | java | @Handler
public void onOpenConnection(OpenTcpConnection event) {
try {
SocketChannel socketChannel = SocketChannel.open(event.address());
channels.add(new TcpChannelImpl(socketChannel));
} catch (ConnectException e) {
fire(new ConnectError(event, "Connection refused.", e));
} catch (IOException e) {
fire(new ConnectError(event, "Failed to open TCP connection.", e));
}
} | [
"@",
"Handler",
"public",
"void",
"onOpenConnection",
"(",
"OpenTcpConnection",
"event",
")",
"{",
"try",
"{",
"SocketChannel",
"socketChannel",
"=",
"SocketChannel",
".",
"open",
"(",
"event",
".",
"address",
"(",
")",
")",
";",
"channels",
".",
"add",
"(",
"new",
"TcpChannelImpl",
"(",
"socketChannel",
")",
")",
";",
"}",
"catch",
"(",
"ConnectException",
"e",
")",
"{",
"fire",
"(",
"new",
"ConnectError",
"(",
"event",
",",
"\"Connection refused.\"",
",",
"e",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"fire",
"(",
"new",
"ConnectError",
"(",
"event",
",",
"\"Failed to open TCP connection.\"",
",",
"e",
")",
")",
";",
"}",
"}"
] | Opens a connection to the end point specified in the event.
@param event the event | [
"Opens",
"a",
"connection",
"to",
"the",
"end",
"point",
"specified",
"in",
"the",
"event",
"."
] | train | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.io/src/org/jgrapes/net/TcpConnector.java#L85-L95 |
lightblueseas/file-worker | src/main/java/de/alpharogroup/file/write/WriteFileExtensions.java | WriteFileExtensions.write2FileWithBuffer | public static void write2FileWithBuffer(final String inputFile, final String outputFile)
throws FileNotFoundException, IOException {
"""
The Method write2FileWithBuffer() copy the content from one file to another. It use a buffer
as the name says.
@param inputFile
The Path to the File and name from the file from where we read.
@param outputFile
The Path to the File and name from the file from where we want to write.
@throws FileNotFoundException
is thrown if an attempt to open the file denoted by a specified pathname has
failed.
@throws IOException
Signals that an I/O exception has occurred.
"""
try (InputStream inputStream = StreamExtensions.getInputStream(new File(inputFile));
OutputStream outputStream = StreamExtensions.getOutputStream(new File(outputFile));)
{
WriteFileExtensions.write(inputStream, outputStream);
}
} | java | public static void write2FileWithBuffer(final String inputFile, final String outputFile)
throws FileNotFoundException, IOException
{
try (InputStream inputStream = StreamExtensions.getInputStream(new File(inputFile));
OutputStream outputStream = StreamExtensions.getOutputStream(new File(outputFile));)
{
WriteFileExtensions.write(inputStream, outputStream);
}
} | [
"public",
"static",
"void",
"write2FileWithBuffer",
"(",
"final",
"String",
"inputFile",
",",
"final",
"String",
"outputFile",
")",
"throws",
"FileNotFoundException",
",",
"IOException",
"{",
"try",
"(",
"InputStream",
"inputStream",
"=",
"StreamExtensions",
".",
"getInputStream",
"(",
"new",
"File",
"(",
"inputFile",
")",
")",
";",
"OutputStream",
"outputStream",
"=",
"StreamExtensions",
".",
"getOutputStream",
"(",
"new",
"File",
"(",
"outputFile",
")",
")",
";",
")",
"{",
"WriteFileExtensions",
".",
"write",
"(",
"inputStream",
",",
"outputStream",
")",
";",
"}",
"}"
] | The Method write2FileWithBuffer() copy the content from one file to another. It use a buffer
as the name says.
@param inputFile
The Path to the File and name from the file from where we read.
@param outputFile
The Path to the File and name from the file from where we want to write.
@throws FileNotFoundException
is thrown if an attempt to open the file denoted by a specified pathname has
failed.
@throws IOException
Signals that an I/O exception has occurred. | [
"The",
"Method",
"write2FileWithBuffer",
"()",
"copy",
"the",
"content",
"from",
"one",
"file",
"to",
"another",
".",
"It",
"use",
"a",
"buffer",
"as",
"the",
"name",
"says",
"."
] | train | https://github.com/lightblueseas/file-worker/blob/2c81de10fb5d68de64c1abc3ed64ca681ce76da8/src/main/java/de/alpharogroup/file/write/WriteFileExtensions.java#L160-L168 |
zaproxy/zaproxy | src/org/zaproxy/zap/extension/script/ExtensionScript.java | ExtensionScript.handleScriptException | private void handleScriptException(ScriptWrapper script, Writer writer, Exception exception) {
"""
Handles exceptions thrown by scripts.
<p>
The given {@code exception} (if of type {@code ScriptException} the cause will be used instead) will be written to the
given {@code writer} and the given {@code script} will be disabled and flagged that has an error.
@param script the script that resulted in an exception, must not be {@code null}
@param writer the writer associated with the script, must not be {@code null}
@param exception the exception thrown , must not be {@code null}
@see #setError(ScriptWrapper, Exception)
@see #setEnabled(ScriptWrapper, boolean)
@see ScriptException
"""
Exception cause = exception;
if (cause instanceof ScriptException && cause.getCause() instanceof Exception) {
// Dereference one level
cause = (Exception) cause.getCause();
}
try {
writer.append(cause.toString());
} catch (IOException ignore) {
logger.error(cause.getMessage(), cause);
}
this.setError(script, cause);
this.setEnabled(script, false);
} | java | private void handleScriptException(ScriptWrapper script, Writer writer, Exception exception) {
Exception cause = exception;
if (cause instanceof ScriptException && cause.getCause() instanceof Exception) {
// Dereference one level
cause = (Exception) cause.getCause();
}
try {
writer.append(cause.toString());
} catch (IOException ignore) {
logger.error(cause.getMessage(), cause);
}
this.setError(script, cause);
this.setEnabled(script, false);
} | [
"private",
"void",
"handleScriptException",
"(",
"ScriptWrapper",
"script",
",",
"Writer",
"writer",
",",
"Exception",
"exception",
")",
"{",
"Exception",
"cause",
"=",
"exception",
";",
"if",
"(",
"cause",
"instanceof",
"ScriptException",
"&&",
"cause",
".",
"getCause",
"(",
")",
"instanceof",
"Exception",
")",
"{",
"// Dereference one level\r",
"cause",
"=",
"(",
"Exception",
")",
"cause",
".",
"getCause",
"(",
")",
";",
"}",
"try",
"{",
"writer",
".",
"append",
"(",
"cause",
".",
"toString",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"ignore",
")",
"{",
"logger",
".",
"error",
"(",
"cause",
".",
"getMessage",
"(",
")",
",",
"cause",
")",
";",
"}",
"this",
".",
"setError",
"(",
"script",
",",
"cause",
")",
";",
"this",
".",
"setEnabled",
"(",
"script",
",",
"false",
")",
";",
"}"
] | Handles exceptions thrown by scripts.
<p>
The given {@code exception} (if of type {@code ScriptException} the cause will be used instead) will be written to the
given {@code writer} and the given {@code script} will be disabled and flagged that has an error.
@param script the script that resulted in an exception, must not be {@code null}
@param writer the writer associated with the script, must not be {@code null}
@param exception the exception thrown , must not be {@code null}
@see #setError(ScriptWrapper, Exception)
@see #setEnabled(ScriptWrapper, boolean)
@see ScriptException | [
"Handles",
"exceptions",
"thrown",
"by",
"scripts",
".",
"<p",
">",
"The",
"given",
"{",
"@code",
"exception",
"}",
"(",
"if",
"of",
"type",
"{",
"@code",
"ScriptException",
"}",
"the",
"cause",
"will",
"be",
"used",
"instead",
")",
"will",
"be",
"written",
"to",
"the",
"given",
"{",
"@code",
"writer",
"}",
"and",
"the",
"given",
"{",
"@code",
"script",
"}",
"will",
"be",
"disabled",
"and",
"flagged",
"that",
"has",
"an",
"error",
"."
] | train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/zaproxy/zap/extension/script/ExtensionScript.java#L1363-L1376 |
infinispan/infinispan | atomic-factory/src/main/java/org/infinispan/atomic/AtomicObjectFactory.java | AtomicObjectFactory.disposeInstanceOf | public void disposeInstanceOf(Class<?> clazz, Object key, boolean keepPersistent)
throws InvalidCacheUsageException {
"""
Remove the object stored at <i>key</i>from the local state.
If flag <i>keepPersistent</i> is set, a persistent copy of the current state of the object is also stored in the cache.
@param clazz a class object
@param key the key to use in order to store the object.
@param keepPersistent indicates that a persistent copy is stored in the cache or not.
"""
ContainerSignature signature = new ContainerSignature(clazz,key);
if (log.isDebugEnabled()) log.debugf("Disposing %s",signature.toString());
Container container;
synchronized (registeredContainers) {
container = registeredContainers.get(signature);
if( container == null )
return;
if( ! container.getClazz().equals(clazz) )
throw new InvalidCacheUsageException("The object is not of the right class.");
registeredContainers.remove(signature);
}
try {
container.dispose(keepPersistent);
} catch (Exception e) {
e.printStackTrace();
throw new InvalidCacheUsageException("Error while disposing object " + key);
}
} | java | public void disposeInstanceOf(Class<?> clazz, Object key, boolean keepPersistent)
throws InvalidCacheUsageException {
ContainerSignature signature = new ContainerSignature(clazz,key);
if (log.isDebugEnabled()) log.debugf("Disposing %s",signature.toString());
Container container;
synchronized (registeredContainers) {
container = registeredContainers.get(signature);
if( container == null )
return;
if( ! container.getClazz().equals(clazz) )
throw new InvalidCacheUsageException("The object is not of the right class.");
registeredContainers.remove(signature);
}
try {
container.dispose(keepPersistent);
} catch (Exception e) {
e.printStackTrace();
throw new InvalidCacheUsageException("Error while disposing object " + key);
}
} | [
"public",
"void",
"disposeInstanceOf",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"Object",
"key",
",",
"boolean",
"keepPersistent",
")",
"throws",
"InvalidCacheUsageException",
"{",
"ContainerSignature",
"signature",
"=",
"new",
"ContainerSignature",
"(",
"clazz",
",",
"key",
")",
";",
"if",
"(",
"log",
".",
"isDebugEnabled",
"(",
")",
")",
"log",
".",
"debugf",
"(",
"\"Disposing %s\"",
",",
"signature",
".",
"toString",
"(",
")",
")",
";",
"Container",
"container",
";",
"synchronized",
"(",
"registeredContainers",
")",
"{",
"container",
"=",
"registeredContainers",
".",
"get",
"(",
"signature",
")",
";",
"if",
"(",
"container",
"==",
"null",
")",
"return",
";",
"if",
"(",
"!",
"container",
".",
"getClazz",
"(",
")",
".",
"equals",
"(",
"clazz",
")",
")",
"throw",
"new",
"InvalidCacheUsageException",
"(",
"\"The object is not of the right class.\"",
")",
";",
"registeredContainers",
".",
"remove",
"(",
"signature",
")",
";",
"}",
"try",
"{",
"container",
".",
"dispose",
"(",
"keepPersistent",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"throw",
"new",
"InvalidCacheUsageException",
"(",
"\"Error while disposing object \"",
"+",
"key",
")",
";",
"}",
"}"
] | Remove the object stored at <i>key</i>from the local state.
If flag <i>keepPersistent</i> is set, a persistent copy of the current state of the object is also stored in the cache.
@param clazz a class object
@param key the key to use in order to store the object.
@param keepPersistent indicates that a persistent copy is stored in the cache or not. | [
"Remove",
"the",
"object",
"stored",
"at",
"<i",
">",
"key<",
"/",
"i",
">",
"from",
"the",
"local",
"state",
".",
"If",
"flag",
"<i",
">",
"keepPersistent<",
"/",
"i",
">",
"is",
"set",
"a",
"persistent",
"copy",
"of",
"the",
"current",
"state",
"of",
"the",
"object",
"is",
"also",
"stored",
"in",
"the",
"cache",
"."
] | train | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/atomic-factory/src/main/java/org/infinispan/atomic/AtomicObjectFactory.java#L246-L268 |
ozimov/cirneco | hamcrest/hamcrest-matchers/src/main/java/it/ozimov/cirneco/hamcrest/throwable/ExpectedException.java | ExpectedException.exceptionWithMessage | public static Matcher<Throwable> exceptionWithMessage(Class<? extends Throwable> type, String expectedMessage) {
"""
Creates a matcher for a {@link Throwable} that matches when the provided {@code Throwable} instance is the same or a subtype
of the given class and has the same message in the error message or the message is contained in the error message
"""
return new ExpectedException(type, expectedMessage);
} | java | public static Matcher<Throwable> exceptionWithMessage(Class<? extends Throwable> type, String expectedMessage) {
return new ExpectedException(type, expectedMessage);
} | [
"public",
"static",
"Matcher",
"<",
"Throwable",
">",
"exceptionWithMessage",
"(",
"Class",
"<",
"?",
"extends",
"Throwable",
">",
"type",
",",
"String",
"expectedMessage",
")",
"{",
"return",
"new",
"ExpectedException",
"(",
"type",
",",
"expectedMessage",
")",
";",
"}"
] | Creates a matcher for a {@link Throwable} that matches when the provided {@code Throwable} instance is the same or a subtype
of the given class and has the same message in the error message or the message is contained in the error message | [
"Creates",
"a",
"matcher",
"for",
"a",
"{"
] | train | https://github.com/ozimov/cirneco/blob/78ad782da0a2256634cfbebb2f97ed78c993b999/hamcrest/hamcrest-matchers/src/main/java/it/ozimov/cirneco/hamcrest/throwable/ExpectedException.java#L40-L42 |
pkiraly/metadata-qa-api | src/main/java/de/gwdg/metadataqa/api/abbreviation/AbbreviationManager.java | AbbreviationManager.getPath | private Path getPath(String fileName)
throws IOException, URISyntaxException {
"""
A get a java.nio.file.Path object from a file name.
@param fileName The file name
@return The Path object
@throws IOException
@throws URISyntaxException
"""
Path path;
URL url = getClass().getClassLoader().getResource(fileName);
if (url == null) {
throw new IOException(String.format("File %s is not existing", fileName));
}
URI uri = url.toURI();
Map<String, String> env = new HashMap<>();
if (uri.toString().contains("!")) {
String[] parts = uri.toString().split("!");
if (fs == null) {
fs = FileSystems.newFileSystem(URI.create(parts[0]), env);
}
path = fs.getPath(parts[1]);
} else {
path = Paths.get(uri);
}
return path;
} | java | private Path getPath(String fileName)
throws IOException, URISyntaxException {
Path path;
URL url = getClass().getClassLoader().getResource(fileName);
if (url == null) {
throw new IOException(String.format("File %s is not existing", fileName));
}
URI uri = url.toURI();
Map<String, String> env = new HashMap<>();
if (uri.toString().contains("!")) {
String[] parts = uri.toString().split("!");
if (fs == null) {
fs = FileSystems.newFileSystem(URI.create(parts[0]), env);
}
path = fs.getPath(parts[1]);
} else {
path = Paths.get(uri);
}
return path;
} | [
"private",
"Path",
"getPath",
"(",
"String",
"fileName",
")",
"throws",
"IOException",
",",
"URISyntaxException",
"{",
"Path",
"path",
";",
"URL",
"url",
"=",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
")",
".",
"getResource",
"(",
"fileName",
")",
";",
"if",
"(",
"url",
"==",
"null",
")",
"{",
"throw",
"new",
"IOException",
"(",
"String",
".",
"format",
"(",
"\"File %s is not existing\"",
",",
"fileName",
")",
")",
";",
"}",
"URI",
"uri",
"=",
"url",
".",
"toURI",
"(",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"env",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"if",
"(",
"uri",
".",
"toString",
"(",
")",
".",
"contains",
"(",
"\"!\"",
")",
")",
"{",
"String",
"[",
"]",
"parts",
"=",
"uri",
".",
"toString",
"(",
")",
".",
"split",
"(",
"\"!\"",
")",
";",
"if",
"(",
"fs",
"==",
"null",
")",
"{",
"fs",
"=",
"FileSystems",
".",
"newFileSystem",
"(",
"URI",
".",
"create",
"(",
"parts",
"[",
"0",
"]",
")",
",",
"env",
")",
";",
"}",
"path",
"=",
"fs",
".",
"getPath",
"(",
"parts",
"[",
"1",
"]",
")",
";",
"}",
"else",
"{",
"path",
"=",
"Paths",
".",
"get",
"(",
"uri",
")",
";",
"}",
"return",
"path",
";",
"}"
] | A get a java.nio.file.Path object from a file name.
@param fileName The file name
@return The Path object
@throws IOException
@throws URISyntaxException | [
"A",
"get",
"a",
"java",
".",
"nio",
".",
"file",
".",
"Path",
"object",
"from",
"a",
"file",
"name",
"."
] | train | https://github.com/pkiraly/metadata-qa-api/blob/622a69e7c1628ccf64047070817ecfaa68f15b1d/src/main/java/de/gwdg/metadataqa/api/abbreviation/AbbreviationManager.java#L155-L174 |
xwiki/xwiki-commons | xwiki-commons-core/xwiki-commons-extension/xwiki-commons-extension-api/src/main/java/org/xwiki/extension/repository/internal/installed/DefaultInstalledExtensionRepository.java | DefaultInstalledExtensionRepository.addInstalledExtension | private void addInstalledExtension(DefaultInstalledExtension installedExtension, String namespace) {
"""
Register a newly installed extension in backward dependencies map.
@param installedExtension the installed extension to register
@param namespace the namespace
"""
addCachedExtension(installedExtension);
boolean isValid = installedExtension.isValid(namespace);
// Register the extension in the installed extensions for the provided namespace
addInstalledFeatureToCache(installedExtension.getId(), namespace, installedExtension, isValid);
// Add virtual extensions
for (ExtensionId feature : installedExtension.getExtensionFeatures()) {
addInstalledFeatureToCache(feature, namespace, installedExtension, isValid);
}
if (this.updateBackwardDependencies) {
// Recalculate backward dependencies index
updateMissingBackwardDependencies();
}
} | java | private void addInstalledExtension(DefaultInstalledExtension installedExtension, String namespace)
{
addCachedExtension(installedExtension);
boolean isValid = installedExtension.isValid(namespace);
// Register the extension in the installed extensions for the provided namespace
addInstalledFeatureToCache(installedExtension.getId(), namespace, installedExtension, isValid);
// Add virtual extensions
for (ExtensionId feature : installedExtension.getExtensionFeatures()) {
addInstalledFeatureToCache(feature, namespace, installedExtension, isValid);
}
if (this.updateBackwardDependencies) {
// Recalculate backward dependencies index
updateMissingBackwardDependencies();
}
} | [
"private",
"void",
"addInstalledExtension",
"(",
"DefaultInstalledExtension",
"installedExtension",
",",
"String",
"namespace",
")",
"{",
"addCachedExtension",
"(",
"installedExtension",
")",
";",
"boolean",
"isValid",
"=",
"installedExtension",
".",
"isValid",
"(",
"namespace",
")",
";",
"// Register the extension in the installed extensions for the provided namespace",
"addInstalledFeatureToCache",
"(",
"installedExtension",
".",
"getId",
"(",
")",
",",
"namespace",
",",
"installedExtension",
",",
"isValid",
")",
";",
"// Add virtual extensions",
"for",
"(",
"ExtensionId",
"feature",
":",
"installedExtension",
".",
"getExtensionFeatures",
"(",
")",
")",
"{",
"addInstalledFeatureToCache",
"(",
"feature",
",",
"namespace",
",",
"installedExtension",
",",
"isValid",
")",
";",
"}",
"if",
"(",
"this",
".",
"updateBackwardDependencies",
")",
"{",
"// Recalculate backward dependencies index",
"updateMissingBackwardDependencies",
"(",
")",
";",
"}",
"}"
] | Register a newly installed extension in backward dependencies map.
@param installedExtension the installed extension to register
@param namespace the namespace | [
"Register",
"a",
"newly",
"installed",
"extension",
"in",
"backward",
"dependencies",
"map",
"."
] | train | https://github.com/xwiki/xwiki-commons/blob/5374d8c6d966588c1eac7392c83da610dfb9f129/xwiki-commons-core/xwiki-commons-extension/xwiki-commons-extension-api/src/main/java/org/xwiki/extension/repository/internal/installed/DefaultInstalledExtensionRepository.java#L551-L569 |
liyiorg/weixin-popular | src/main/java/weixin/popular/api/WxaAPI.java | WxaAPI.modify_domain | public static ModifyDomainResult modify_domain(String access_token,ModifyDomain modifyDomain) {
"""
修改服务器地址
@since 2.8.9
@param access_token access_token
@param modifyDomain modifyDomain
@return result
"""
String json = JsonUtil.toJSONString(modifyDomain);
HttpUriRequest httpUriRequest = RequestBuilder.post()
.setHeader(jsonHeader)
.setUri(BASE_URI + "/wxa/modify_domain")
.addParameter(PARAM_ACCESS_TOKEN, API.accessToken(access_token))
.setEntity(new StringEntity(json,Charset.forName("utf-8")))
.build();
return LocalHttpClient.executeJsonResult(httpUriRequest,ModifyDomainResult.class);
} | java | public static ModifyDomainResult modify_domain(String access_token,ModifyDomain modifyDomain){
String json = JsonUtil.toJSONString(modifyDomain);
HttpUriRequest httpUriRequest = RequestBuilder.post()
.setHeader(jsonHeader)
.setUri(BASE_URI + "/wxa/modify_domain")
.addParameter(PARAM_ACCESS_TOKEN, API.accessToken(access_token))
.setEntity(new StringEntity(json,Charset.forName("utf-8")))
.build();
return LocalHttpClient.executeJsonResult(httpUriRequest,ModifyDomainResult.class);
} | [
"public",
"static",
"ModifyDomainResult",
"modify_domain",
"(",
"String",
"access_token",
",",
"ModifyDomain",
"modifyDomain",
")",
"{",
"String",
"json",
"=",
"JsonUtil",
".",
"toJSONString",
"(",
"modifyDomain",
")",
";",
"HttpUriRequest",
"httpUriRequest",
"=",
"RequestBuilder",
".",
"post",
"(",
")",
".",
"setHeader",
"(",
"jsonHeader",
")",
".",
"setUri",
"(",
"BASE_URI",
"+",
"\"/wxa/modify_domain\"",
")",
".",
"addParameter",
"(",
"PARAM_ACCESS_TOKEN",
",",
"API",
".",
"accessToken",
"(",
"access_token",
")",
")",
".",
"setEntity",
"(",
"new",
"StringEntity",
"(",
"json",
",",
"Charset",
".",
"forName",
"(",
"\"utf-8\"",
")",
")",
")",
".",
"build",
"(",
")",
";",
"return",
"LocalHttpClient",
".",
"executeJsonResult",
"(",
"httpUriRequest",
",",
"ModifyDomainResult",
".",
"class",
")",
";",
"}"
] | 修改服务器地址
@since 2.8.9
@param access_token access_token
@param modifyDomain modifyDomain
@return result | [
"修改服务器地址"
] | train | https://github.com/liyiorg/weixin-popular/blob/c64255292d41463bdb671938feaabf42a335d82c/src/main/java/weixin/popular/api/WxaAPI.java#L64-L73 |
OpenLiberty/open-liberty | dev/com.ibm.ws.transaction.cdi/src/com/ibm/tx/jta/cdi/interceptors/Required.java | Required.required | @AroundInvoke
public Object required(final InvocationContext context) throws Exception {
"""
<p>If called outside a transaction context, the interceptor must begin a new
JTA transaction, the managed bean method execution must then continue
inside this transaction context, and the transaction must be completed by
the interceptor.</p>
<p>If called inside a transaction context, the managed bean
method execution must then continue inside this transaction context.</p>
"""
return runUnderUOWManagingEnablement(UOWSynchronizationRegistry.UOW_TYPE_GLOBAL_TRANSACTION, true, context, "REQUIRED");
} | java | @AroundInvoke
public Object required(final InvocationContext context) throws Exception {
return runUnderUOWManagingEnablement(UOWSynchronizationRegistry.UOW_TYPE_GLOBAL_TRANSACTION, true, context, "REQUIRED");
} | [
"@",
"AroundInvoke",
"public",
"Object",
"required",
"(",
"final",
"InvocationContext",
"context",
")",
"throws",
"Exception",
"{",
"return",
"runUnderUOWManagingEnablement",
"(",
"UOWSynchronizationRegistry",
".",
"UOW_TYPE_GLOBAL_TRANSACTION",
",",
"true",
",",
"context",
",",
"\"REQUIRED\"",
")",
";",
"}"
] | <p>If called outside a transaction context, the interceptor must begin a new
JTA transaction, the managed bean method execution must then continue
inside this transaction context, and the transaction must be completed by
the interceptor.</p>
<p>If called inside a transaction context, the managed bean
method execution must then continue inside this transaction context.</p> | [
"<p",
">",
"If",
"called",
"outside",
"a",
"transaction",
"context",
"the",
"interceptor",
"must",
"begin",
"a",
"new",
"JTA",
"transaction",
"the",
"managed",
"bean",
"method",
"execution",
"must",
"then",
"continue",
"inside",
"this",
"transaction",
"context",
"and",
"the",
"transaction",
"must",
"be",
"completed",
"by",
"the",
"interceptor",
".",
"<",
"/",
"p",
">",
"<p",
">",
"If",
"called",
"inside",
"a",
"transaction",
"context",
"the",
"managed",
"bean",
"method",
"execution",
"must",
"then",
"continue",
"inside",
"this",
"transaction",
"context",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.transaction.cdi/src/com/ibm/tx/jta/cdi/interceptors/Required.java#L37-L42 |
hector-client/hector | object-mapper/src/main/java/me/prettyprint/hom/HectorObjectMapper.java | HectorObjectMapper.getObject | public <T, I> T getObject(Keyspace keyspace, String colFamName, I pkObj) {
"""
Retrieve columns from cassandra keyspace and column family, instantiate a
new object of required type, and then map them to the object's properties.
@param <T>
@param keyspace
@param colFamName
@param pkObj
@return
"""
if (null == pkObj) {
throw new IllegalArgumentException("object ID cannot be null or empty");
}
CFMappingDef<T> cfMapDef = cacheMgr.getCfMapDef(colFamName, true);
byte[] colFamKey = generateColumnFamilyKeyFromPkObj(cfMapDef, pkObj);
SliceQuery<byte[], String, byte[]> q = HFactory.createSliceQuery(keyspace,
BytesArraySerializer.get(), StringSerializer.get(), BytesArraySerializer.get());
q.setColumnFamily(colFamName);
q.setKey(colFamKey);
// if no anonymous handler then use specific columns
if (cfMapDef.isColumnSliceRequired()) {
q.setColumnNames(cfMapDef.getSliceColumnNameArr());
} else {
q.setRange("", "", false, maxNumColumns);
}
QueryResult<ColumnSlice<String, byte[]>> result = q.execute();
if (null == result || null == result.get()) {
return null;
}
T obj = createObject(cfMapDef, pkObj, result.get());
return obj;
} | java | public <T, I> T getObject(Keyspace keyspace, String colFamName, I pkObj) {
if (null == pkObj) {
throw new IllegalArgumentException("object ID cannot be null or empty");
}
CFMappingDef<T> cfMapDef = cacheMgr.getCfMapDef(colFamName, true);
byte[] colFamKey = generateColumnFamilyKeyFromPkObj(cfMapDef, pkObj);
SliceQuery<byte[], String, byte[]> q = HFactory.createSliceQuery(keyspace,
BytesArraySerializer.get(), StringSerializer.get(), BytesArraySerializer.get());
q.setColumnFamily(colFamName);
q.setKey(colFamKey);
// if no anonymous handler then use specific columns
if (cfMapDef.isColumnSliceRequired()) {
q.setColumnNames(cfMapDef.getSliceColumnNameArr());
} else {
q.setRange("", "", false, maxNumColumns);
}
QueryResult<ColumnSlice<String, byte[]>> result = q.execute();
if (null == result || null == result.get()) {
return null;
}
T obj = createObject(cfMapDef, pkObj, result.get());
return obj;
} | [
"public",
"<",
"T",
",",
"I",
">",
"T",
"getObject",
"(",
"Keyspace",
"keyspace",
",",
"String",
"colFamName",
",",
"I",
"pkObj",
")",
"{",
"if",
"(",
"null",
"==",
"pkObj",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"object ID cannot be null or empty\"",
")",
";",
"}",
"CFMappingDef",
"<",
"T",
">",
"cfMapDef",
"=",
"cacheMgr",
".",
"getCfMapDef",
"(",
"colFamName",
",",
"true",
")",
";",
"byte",
"[",
"]",
"colFamKey",
"=",
"generateColumnFamilyKeyFromPkObj",
"(",
"cfMapDef",
",",
"pkObj",
")",
";",
"SliceQuery",
"<",
"byte",
"[",
"]",
",",
"String",
",",
"byte",
"[",
"]",
">",
"q",
"=",
"HFactory",
".",
"createSliceQuery",
"(",
"keyspace",
",",
"BytesArraySerializer",
".",
"get",
"(",
")",
",",
"StringSerializer",
".",
"get",
"(",
")",
",",
"BytesArraySerializer",
".",
"get",
"(",
")",
")",
";",
"q",
".",
"setColumnFamily",
"(",
"colFamName",
")",
";",
"q",
".",
"setKey",
"(",
"colFamKey",
")",
";",
"// if no anonymous handler then use specific columns",
"if",
"(",
"cfMapDef",
".",
"isColumnSliceRequired",
"(",
")",
")",
"{",
"q",
".",
"setColumnNames",
"(",
"cfMapDef",
".",
"getSliceColumnNameArr",
"(",
")",
")",
";",
"}",
"else",
"{",
"q",
".",
"setRange",
"(",
"\"\"",
",",
"\"\"",
",",
"false",
",",
"maxNumColumns",
")",
";",
"}",
"QueryResult",
"<",
"ColumnSlice",
"<",
"String",
",",
"byte",
"[",
"]",
">",
">",
"result",
"=",
"q",
".",
"execute",
"(",
")",
";",
"if",
"(",
"null",
"==",
"result",
"||",
"null",
"==",
"result",
".",
"get",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"T",
"obj",
"=",
"createObject",
"(",
"cfMapDef",
",",
"pkObj",
",",
"result",
".",
"get",
"(",
")",
")",
";",
"return",
"obj",
";",
"}"
] | Retrieve columns from cassandra keyspace and column family, instantiate a
new object of required type, and then map them to the object's properties.
@param <T>
@param keyspace
@param colFamName
@param pkObj
@return | [
"Retrieve",
"columns",
"from",
"cassandra",
"keyspace",
"and",
"column",
"family",
"instantiate",
"a",
"new",
"object",
"of",
"required",
"type",
"and",
"then",
"map",
"them",
"to",
"the",
"object",
"s",
"properties",
"."
] | train | https://github.com/hector-client/hector/blob/a302e68ca8d91b45d332e8c9afd7d98030b54de1/object-mapper/src/main/java/me/prettyprint/hom/HectorObjectMapper.java#L79-L107 |
abel533/EasyXls | src/main/java/com/github/abel533/easyxls/EasyXls.java | EasyXls.list2Xls | public static boolean list2Xls(ExcelConfig config, List<?> list, String filePath, String fileName) throws Exception {
"""
导出list对象到excel
@param config 配置
@param list 导出的list
@param filePath 保存xls路径
@param fileName 保存xls文件名
@return 处理结果,true成功,false失败
@throws Exception
"""
return XlsUtil.list2Xls(config, list, filePath, fileName);
} | java | public static boolean list2Xls(ExcelConfig config, List<?> list, String filePath, String fileName) throws Exception {
return XlsUtil.list2Xls(config, list, filePath, fileName);
} | [
"public",
"static",
"boolean",
"list2Xls",
"(",
"ExcelConfig",
"config",
",",
"List",
"<",
"?",
">",
"list",
",",
"String",
"filePath",
",",
"String",
"fileName",
")",
"throws",
"Exception",
"{",
"return",
"XlsUtil",
".",
"list2Xls",
"(",
"config",
",",
"list",
",",
"filePath",
",",
"fileName",
")",
";",
"}"
] | 导出list对象到excel
@param config 配置
@param list 导出的list
@param filePath 保存xls路径
@param fileName 保存xls文件名
@return 处理结果,true成功,false失败
@throws Exception | [
"导出list对象到excel"
] | train | https://github.com/abel533/EasyXls/blob/f73be23745c2180d7c0b8f0a510e72e61cc37d5d/src/main/java/com/github/abel533/easyxls/EasyXls.java#L96-L98 |
apache/incubator-gobblin | gobblin-config-management/gobblin-config-client/src/main/java/org/apache/gobblin/config/client/ConfigClient.java | ConfigClient.getConfig | public Config getConfig(URI configKeyUri)
throws ConfigStoreFactoryDoesNotExistsException, ConfigStoreCreationException, VersionDoesNotExistException {
"""
Get the resolved {@link Config} based on the input URI.
@param configKeyUri - The URI for the configuration key. There are two types of URI:
1. URI missing authority and configuration store root , for example "etl-hdfs:///datasets/a1/a2". It will get
the configuration based on the default {@link ConfigStore} in etl-hdfs {@link ConfigStoreFactory}
2. Complete URI: for example "etl-hdfs://eat1-nertznn01.grid.linkedin.com:9000/user/mitu/HdfsBasedConfigTest/"
@return the resolved {@link Config} based on the input URI.
@throws ConfigStoreFactoryDoesNotExistsException: if missing scheme name or the scheme name is invalid
@throws ConfigStoreCreationException: Specified {@link ConfigStoreFactory} can not create required {@link ConfigStore}
@throws VersionDoesNotExistException: Required version does not exist anymore ( may get deleted by retention job )
"""
return getConfig(configKeyUri, Optional.<Config>absent());
} | java | public Config getConfig(URI configKeyUri)
throws ConfigStoreFactoryDoesNotExistsException, ConfigStoreCreationException, VersionDoesNotExistException {
return getConfig(configKeyUri, Optional.<Config>absent());
} | [
"public",
"Config",
"getConfig",
"(",
"URI",
"configKeyUri",
")",
"throws",
"ConfigStoreFactoryDoesNotExistsException",
",",
"ConfigStoreCreationException",
",",
"VersionDoesNotExistException",
"{",
"return",
"getConfig",
"(",
"configKeyUri",
",",
"Optional",
".",
"<",
"Config",
">",
"absent",
"(",
")",
")",
";",
"}"
] | Get the resolved {@link Config} based on the input URI.
@param configKeyUri - The URI for the configuration key. There are two types of URI:
1. URI missing authority and configuration store root , for example "etl-hdfs:///datasets/a1/a2". It will get
the configuration based on the default {@link ConfigStore} in etl-hdfs {@link ConfigStoreFactory}
2. Complete URI: for example "etl-hdfs://eat1-nertznn01.grid.linkedin.com:9000/user/mitu/HdfsBasedConfigTest/"
@return the resolved {@link Config} based on the input URI.
@throws ConfigStoreFactoryDoesNotExistsException: if missing scheme name or the scheme name is invalid
@throws ConfigStoreCreationException: Specified {@link ConfigStoreFactory} can not create required {@link ConfigStore}
@throws VersionDoesNotExistException: Required version does not exist anymore ( may get deleted by retention job ) | [
"Get",
"the",
"resolved",
"{",
"@link",
"Config",
"}",
"based",
"on",
"the",
"input",
"URI",
"."
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-config-management/gobblin-config-client/src/main/java/org/apache/gobblin/config/client/ConfigClient.java#L118-L121 |
grails/grails-core | grails-web-common/src/main/groovy/org/grails/web/util/WebUtils.java | WebUtils.toQueryString | @SuppressWarnings("rawtypes")
public static String toQueryString(Map params, String encoding) throws UnsupportedEncodingException {
"""
Converts the given params into a query string started with ?
@param params The params
@param encoding The encoding to use
@return The query string
@throws UnsupportedEncodingException If the given encoding is not supported
"""
if (encoding == null) encoding = "UTF-8";
StringBuilder queryString = new StringBuilder("?");
for (Iterator i = params.entrySet().iterator(); i.hasNext();) {
Map.Entry entry = (Map.Entry) i.next();
boolean hasMore = i.hasNext();
boolean wasAppended = appendEntry(entry, queryString, encoding, "");
if (hasMore && wasAppended) queryString.append('&');
}
return queryString.toString();
} | java | @SuppressWarnings("rawtypes")
public static String toQueryString(Map params, String encoding) throws UnsupportedEncodingException {
if (encoding == null) encoding = "UTF-8";
StringBuilder queryString = new StringBuilder("?");
for (Iterator i = params.entrySet().iterator(); i.hasNext();) {
Map.Entry entry = (Map.Entry) i.next();
boolean hasMore = i.hasNext();
boolean wasAppended = appendEntry(entry, queryString, encoding, "");
if (hasMore && wasAppended) queryString.append('&');
}
return queryString.toString();
} | [
"@",
"SuppressWarnings",
"(",
"\"rawtypes\"",
")",
"public",
"static",
"String",
"toQueryString",
"(",
"Map",
"params",
",",
"String",
"encoding",
")",
"throws",
"UnsupportedEncodingException",
"{",
"if",
"(",
"encoding",
"==",
"null",
")",
"encoding",
"=",
"\"UTF-8\"",
";",
"StringBuilder",
"queryString",
"=",
"new",
"StringBuilder",
"(",
"\"?\"",
")",
";",
"for",
"(",
"Iterator",
"i",
"=",
"params",
".",
"entrySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"i",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"Map",
".",
"Entry",
"entry",
"=",
"(",
"Map",
".",
"Entry",
")",
"i",
".",
"next",
"(",
")",
";",
"boolean",
"hasMore",
"=",
"i",
".",
"hasNext",
"(",
")",
";",
"boolean",
"wasAppended",
"=",
"appendEntry",
"(",
"entry",
",",
"queryString",
",",
"encoding",
",",
"\"\"",
")",
";",
"if",
"(",
"hasMore",
"&&",
"wasAppended",
")",
"queryString",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"return",
"queryString",
".",
"toString",
"(",
")",
";",
"}"
] | Converts the given params into a query string started with ?
@param params The params
@param encoding The encoding to use
@return The query string
@throws UnsupportedEncodingException If the given encoding is not supported | [
"Converts",
"the",
"given",
"params",
"into",
"a",
"query",
"string",
"started",
"with",
"?"
] | train | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-common/src/main/groovy/org/grails/web/util/WebUtils.java#L332-L344 |
UrielCh/ovh-java-sdk | ovh-java-sdk-hostingweb/src/main/java/net/minidev/ovh/api/ApiOvhHostingweb.java | ApiOvhHostingweb.serviceName_ownLogs_id_userLogs_login_DELETE | public String serviceName_ownLogs_id_userLogs_login_DELETE(String serviceName, Long id, String login) throws IOException {
"""
Delete the userLogs
REST: DELETE /hosting/web/{serviceName}/ownLogs/{id}/userLogs/{login}
@param serviceName [required] The internal name of your hosting
@param id [required] Id of the object
@param login [required] The userLogs login used to connect to logs.ovh.net
"""
String qPath = "/hosting/web/{serviceName}/ownLogs/{id}/userLogs/{login}";
StringBuilder sb = path(qPath, serviceName, id, login);
String resp = exec(qPath, "DELETE", sb.toString(), null);
return convertTo(resp, String.class);
} | java | public String serviceName_ownLogs_id_userLogs_login_DELETE(String serviceName, Long id, String login) throws IOException {
String qPath = "/hosting/web/{serviceName}/ownLogs/{id}/userLogs/{login}";
StringBuilder sb = path(qPath, serviceName, id, login);
String resp = exec(qPath, "DELETE", sb.toString(), null);
return convertTo(resp, String.class);
} | [
"public",
"String",
"serviceName_ownLogs_id_userLogs_login_DELETE",
"(",
"String",
"serviceName",
",",
"Long",
"id",
",",
"String",
"login",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/hosting/web/{serviceName}/ownLogs/{id}/userLogs/{login}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"id",
",",
"login",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"DELETE\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"String",
".",
"class",
")",
";",
"}"
] | Delete the userLogs
REST: DELETE /hosting/web/{serviceName}/ownLogs/{id}/userLogs/{login}
@param serviceName [required] The internal name of your hosting
@param id [required] Id of the object
@param login [required] The userLogs login used to connect to logs.ovh.net | [
"Delete",
"the",
"userLogs"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-hostingweb/src/main/java/net/minidev/ovh/api/ApiOvhHostingweb.java#L1034-L1039 |
fuinorg/event-store-commons | spi/src/main/java/org/fuin/esc/spi/SimpleSerializerDeserializerRegistry.java | SimpleSerializerDeserializerRegistry.addDeserializer | public final void addDeserializer(@NotNull final SerializedDataType type, final String contentType,
@NotNull final Deserializer deserializer) {
"""
Adds a new deserializer to the registry.
@param type
Type of the data.
@param contentType
Content type like "application/xml" or "application/json" (without parameters - Only base
type).
@param deserializer
Deserializer.
"""
Contract.requireArgNotNull("type", type);
Contract.requireArgNotNull("contentType", contentType);
Contract.requireArgNotNull("deserializer", deserializer);
final Key key = new Key(type, contentType);
desMap.put(key, deserializer);
} | java | public final void addDeserializer(@NotNull final SerializedDataType type, final String contentType,
@NotNull final Deserializer deserializer) {
Contract.requireArgNotNull("type", type);
Contract.requireArgNotNull("contentType", contentType);
Contract.requireArgNotNull("deserializer", deserializer);
final Key key = new Key(type, contentType);
desMap.put(key, deserializer);
} | [
"public",
"final",
"void",
"addDeserializer",
"(",
"@",
"NotNull",
"final",
"SerializedDataType",
"type",
",",
"final",
"String",
"contentType",
",",
"@",
"NotNull",
"final",
"Deserializer",
"deserializer",
")",
"{",
"Contract",
".",
"requireArgNotNull",
"(",
"\"type\"",
",",
"type",
")",
";",
"Contract",
".",
"requireArgNotNull",
"(",
"\"contentType\"",
",",
"contentType",
")",
";",
"Contract",
".",
"requireArgNotNull",
"(",
"\"deserializer\"",
",",
"deserializer",
")",
";",
"final",
"Key",
"key",
"=",
"new",
"Key",
"(",
"type",
",",
"contentType",
")",
";",
"desMap",
".",
"put",
"(",
"key",
",",
"deserializer",
")",
";",
"}"
] | Adds a new deserializer to the registry.
@param type
Type of the data.
@param contentType
Content type like "application/xml" or "application/json" (without parameters - Only base
type).
@param deserializer
Deserializer. | [
"Adds",
"a",
"new",
"deserializer",
"to",
"the",
"registry",
"."
] | train | https://github.com/fuinorg/event-store-commons/blob/ea175582d8cda2b5a6d2fe52bbb2f1c183eee77c/spi/src/main/java/org/fuin/esc/spi/SimpleSerializerDeserializerRegistry.java#L78-L88 |
sarl/sarl | main/externalmaven/io.sarl.maven.docs.generator/src/main/java/io/sarl/maven/docs/markdown/MarkdownParser.java | MarkdownParser.computeHeaderId | public static String computeHeaderId(String headerNumber, String headerText) {
"""
Create the id of a section header.
<p>The ID format follows the ReadCarpet standards.
@param headerNumber the number of the header, or {@code null}.
@param headerText the section header text.
@return the identifier.
"""
final String fullText = Strings.emptyIfNull(headerNumber) + " " + Strings.emptyIfNull(headerText); //$NON-NLS-1$
return computeHeaderId(fullText);
} | java | public static String computeHeaderId(String headerNumber, String headerText) {
final String fullText = Strings.emptyIfNull(headerNumber) + " " + Strings.emptyIfNull(headerText); //$NON-NLS-1$
return computeHeaderId(fullText);
} | [
"public",
"static",
"String",
"computeHeaderId",
"(",
"String",
"headerNumber",
",",
"String",
"headerText",
")",
"{",
"final",
"String",
"fullText",
"=",
"Strings",
".",
"emptyIfNull",
"(",
"headerNumber",
")",
"+",
"\" \"",
"+",
"Strings",
".",
"emptyIfNull",
"(",
"headerText",
")",
";",
"//$NON-NLS-1$",
"return",
"computeHeaderId",
"(",
"fullText",
")",
";",
"}"
] | Create the id of a section header.
<p>The ID format follows the ReadCarpet standards.
@param headerNumber the number of the header, or {@code null}.
@param headerText the section header text.
@return the identifier. | [
"Create",
"the",
"id",
"of",
"a",
"section",
"header",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/externalmaven/io.sarl.maven.docs.generator/src/main/java/io/sarl/maven/docs/markdown/MarkdownParser.java#L878-L881 |
Netflix/astyanax | astyanax-recipes/src/main/java/com/netflix/astyanax/recipes/locks/OneStepDistributedRowLock.java | OneStepDistributedRowLock.fillReleaseMutation | public void fillReleaseMutation(MutationBatch m, boolean excludeCurrentLock) {
"""
Fill a mutation that will release the locks. This may be used from a
separate recipe to release multiple locks.
@param m
"""
// Add the deletes to the end of the mutation
ColumnListMutation<C> row = m.withRow(columnFamily, key);
for (C c : locksToDelete) {
row.deleteColumn(c);
}
if (!excludeCurrentLock && lockColumn != null)
row.deleteColumn(lockColumn);
locksToDelete.clear();
lockColumn = null;
} | java | public void fillReleaseMutation(MutationBatch m, boolean excludeCurrentLock) {
// Add the deletes to the end of the mutation
ColumnListMutation<C> row = m.withRow(columnFamily, key);
for (C c : locksToDelete) {
row.deleteColumn(c);
}
if (!excludeCurrentLock && lockColumn != null)
row.deleteColumn(lockColumn);
locksToDelete.clear();
lockColumn = null;
} | [
"public",
"void",
"fillReleaseMutation",
"(",
"MutationBatch",
"m",
",",
"boolean",
"excludeCurrentLock",
")",
"{",
"// Add the deletes to the end of the mutation",
"ColumnListMutation",
"<",
"C",
">",
"row",
"=",
"m",
".",
"withRow",
"(",
"columnFamily",
",",
"key",
")",
";",
"for",
"(",
"C",
"c",
":",
"locksToDelete",
")",
"{",
"row",
".",
"deleteColumn",
"(",
"c",
")",
";",
"}",
"if",
"(",
"!",
"excludeCurrentLock",
"&&",
"lockColumn",
"!=",
"null",
")",
"row",
".",
"deleteColumn",
"(",
"lockColumn",
")",
";",
"locksToDelete",
".",
"clear",
"(",
")",
";",
"lockColumn",
"=",
"null",
";",
"}"
] | Fill a mutation that will release the locks. This may be used from a
separate recipe to release multiple locks.
@param m | [
"Fill",
"a",
"mutation",
"that",
"will",
"release",
"the",
"locks",
".",
"This",
"may",
"be",
"used",
"from",
"a",
"separate",
"recipe",
"to",
"release",
"multiple",
"locks",
"."
] | train | https://github.com/Netflix/astyanax/blob/bcc3fd26e2dda05a923751aa32b139f6209fecdf/astyanax-recipes/src/main/java/com/netflix/astyanax/recipes/locks/OneStepDistributedRowLock.java#L441-L451 |
offbynull/coroutines | instrumenter/src/main/java/com/offbynull/coroutines/instrumenter/generators/GenericGenerators.java | GenericGenerators.saveVar | public static InsnList saveVar(Variable variable) {
"""
Pops the stack in to the the local variable table. You may run in to problems if the item on top of the stack isn't of the same type
as the variable it's being put in to.
@param variable variable within the local variable table to save to
@return instructions to pop an item off the top of the stack and save it to {@code variable}
@throws NullPointerException if any argument is {@code null}
@throws IllegalArgumentException if {@code variable} has been released
"""
Validate.notNull(variable);
InsnList ret = new InsnList();
switch (variable.getType().getSort()) {
case Type.BOOLEAN:
case Type.BYTE:
case Type.CHAR:
case Type.SHORT:
case Type.INT:
ret.add(new VarInsnNode(Opcodes.ISTORE, variable.getIndex()));
break;
case Type.LONG:
ret.add(new VarInsnNode(Opcodes.LSTORE, variable.getIndex()));
break;
case Type.FLOAT:
ret.add(new VarInsnNode(Opcodes.FSTORE, variable.getIndex()));
break;
case Type.DOUBLE:
ret.add(new VarInsnNode(Opcodes.DSTORE, variable.getIndex()));
break;
case Type.OBJECT:
case Type.ARRAY:
ret.add(new VarInsnNode(Opcodes.ASTORE, variable.getIndex()));
break;
default:
throw new IllegalStateException(); // should never happen, there is code in Variable/VariableTable to make sure invalid
// types aren't set
}
return ret;
} | java | public static InsnList saveVar(Variable variable) {
Validate.notNull(variable);
InsnList ret = new InsnList();
switch (variable.getType().getSort()) {
case Type.BOOLEAN:
case Type.BYTE:
case Type.CHAR:
case Type.SHORT:
case Type.INT:
ret.add(new VarInsnNode(Opcodes.ISTORE, variable.getIndex()));
break;
case Type.LONG:
ret.add(new VarInsnNode(Opcodes.LSTORE, variable.getIndex()));
break;
case Type.FLOAT:
ret.add(new VarInsnNode(Opcodes.FSTORE, variable.getIndex()));
break;
case Type.DOUBLE:
ret.add(new VarInsnNode(Opcodes.DSTORE, variable.getIndex()));
break;
case Type.OBJECT:
case Type.ARRAY:
ret.add(new VarInsnNode(Opcodes.ASTORE, variable.getIndex()));
break;
default:
throw new IllegalStateException(); // should never happen, there is code in Variable/VariableTable to make sure invalid
// types aren't set
}
return ret;
} | [
"public",
"static",
"InsnList",
"saveVar",
"(",
"Variable",
"variable",
")",
"{",
"Validate",
".",
"notNull",
"(",
"variable",
")",
";",
"InsnList",
"ret",
"=",
"new",
"InsnList",
"(",
")",
";",
"switch",
"(",
"variable",
".",
"getType",
"(",
")",
".",
"getSort",
"(",
")",
")",
"{",
"case",
"Type",
".",
"BOOLEAN",
":",
"case",
"Type",
".",
"BYTE",
":",
"case",
"Type",
".",
"CHAR",
":",
"case",
"Type",
".",
"SHORT",
":",
"case",
"Type",
".",
"INT",
":",
"ret",
".",
"add",
"(",
"new",
"VarInsnNode",
"(",
"Opcodes",
".",
"ISTORE",
",",
"variable",
".",
"getIndex",
"(",
")",
")",
")",
";",
"break",
";",
"case",
"Type",
".",
"LONG",
":",
"ret",
".",
"add",
"(",
"new",
"VarInsnNode",
"(",
"Opcodes",
".",
"LSTORE",
",",
"variable",
".",
"getIndex",
"(",
")",
")",
")",
";",
"break",
";",
"case",
"Type",
".",
"FLOAT",
":",
"ret",
".",
"add",
"(",
"new",
"VarInsnNode",
"(",
"Opcodes",
".",
"FSTORE",
",",
"variable",
".",
"getIndex",
"(",
")",
")",
")",
";",
"break",
";",
"case",
"Type",
".",
"DOUBLE",
":",
"ret",
".",
"add",
"(",
"new",
"VarInsnNode",
"(",
"Opcodes",
".",
"DSTORE",
",",
"variable",
".",
"getIndex",
"(",
")",
")",
")",
";",
"break",
";",
"case",
"Type",
".",
"OBJECT",
":",
"case",
"Type",
".",
"ARRAY",
":",
"ret",
".",
"add",
"(",
"new",
"VarInsnNode",
"(",
"Opcodes",
".",
"ASTORE",
",",
"variable",
".",
"getIndex",
"(",
")",
")",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"IllegalStateException",
"(",
")",
";",
"// should never happen, there is code in Variable/VariableTable to make sure invalid",
"// types aren't set",
"}",
"return",
"ret",
";",
"}"
] | Pops the stack in to the the local variable table. You may run in to problems if the item on top of the stack isn't of the same type
as the variable it's being put in to.
@param variable variable within the local variable table to save to
@return instructions to pop an item off the top of the stack and save it to {@code variable}
@throws NullPointerException if any argument is {@code null}
@throws IllegalArgumentException if {@code variable} has been released | [
"Pops",
"the",
"stack",
"in",
"to",
"the",
"the",
"local",
"variable",
"table",
".",
"You",
"may",
"run",
"in",
"to",
"problems",
"if",
"the",
"item",
"on",
"top",
"of",
"the",
"stack",
"isn",
"t",
"of",
"the",
"same",
"type",
"as",
"the",
"variable",
"it",
"s",
"being",
"put",
"in",
"to",
"."
] | train | https://github.com/offbynull/coroutines/blob/b1b83c293945f53a2f63fca8f15a53e88b796bf5/instrumenter/src/main/java/com/offbynull/coroutines/instrumenter/generators/GenericGenerators.java#L431-L462 |
mongodb/stitch-android-sdk | core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DocumentVersionInfo.java | DocumentVersionInfo.getVersionedFilter | static BsonDocument getVersionedFilter(
@Nonnull final BsonValue documentId,
@Nullable final BsonValue version
) {
"""
Returns a query filter for the given document _id and version. The version is allowed to be
null. The query will match only if there is either no version on the document in the database
in question if we have no reference of the version or if the version matches the database's
version.
@param documentId the _id of the document.
@param version the expected version of the document, if any.
@return a query filter for the given document _id and version for a remote operation.
"""
final BsonDocument filter = new BsonDocument("_id", documentId);
if (version == null) {
filter.put(DOCUMENT_VERSION_FIELD, new BsonDocument("$exists", BsonBoolean.FALSE));
} else {
filter.put(DOCUMENT_VERSION_FIELD, version);
}
return filter;
} | java | static BsonDocument getVersionedFilter(
@Nonnull final BsonValue documentId,
@Nullable final BsonValue version
) {
final BsonDocument filter = new BsonDocument("_id", documentId);
if (version == null) {
filter.put(DOCUMENT_VERSION_FIELD, new BsonDocument("$exists", BsonBoolean.FALSE));
} else {
filter.put(DOCUMENT_VERSION_FIELD, version);
}
return filter;
} | [
"static",
"BsonDocument",
"getVersionedFilter",
"(",
"@",
"Nonnull",
"final",
"BsonValue",
"documentId",
",",
"@",
"Nullable",
"final",
"BsonValue",
"version",
")",
"{",
"final",
"BsonDocument",
"filter",
"=",
"new",
"BsonDocument",
"(",
"\"_id\"",
",",
"documentId",
")",
";",
"if",
"(",
"version",
"==",
"null",
")",
"{",
"filter",
".",
"put",
"(",
"DOCUMENT_VERSION_FIELD",
",",
"new",
"BsonDocument",
"(",
"\"$exists\"",
",",
"BsonBoolean",
".",
"FALSE",
")",
")",
";",
"}",
"else",
"{",
"filter",
".",
"put",
"(",
"DOCUMENT_VERSION_FIELD",
",",
"version",
")",
";",
"}",
"return",
"filter",
";",
"}"
] | Returns a query filter for the given document _id and version. The version is allowed to be
null. The query will match only if there is either no version on the document in the database
in question if we have no reference of the version or if the version matches the database's
version.
@param documentId the _id of the document.
@param version the expected version of the document, if any.
@return a query filter for the given document _id and version for a remote operation. | [
"Returns",
"a",
"query",
"filter",
"for",
"the",
"given",
"document",
"_id",
"and",
"version",
".",
"The",
"version",
"is",
"allowed",
"to",
"be",
"null",
".",
"The",
"query",
"will",
"match",
"only",
"if",
"there",
"is",
"either",
"no",
"version",
"on",
"the",
"document",
"in",
"the",
"database",
"in",
"question",
"if",
"we",
"have",
"no",
"reference",
"of",
"the",
"version",
"or",
"if",
"the",
"version",
"matches",
"the",
"database",
"s",
"version",
"."
] | train | https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/services/mongodb-remote/src/main/java/com/mongodb/stitch/core/services/mongodb/remote/sync/internal/DocumentVersionInfo.java#L242-L253 |
geomajas/geomajas-project-client-gwt | client/src/main/java/org/geomajas/gwt/client/spatial/geometry/GeometryFactory.java | GeometryFactory.createLinearRing | public LinearRing createLinearRing(Coordinate[] coordinates) {
"""
Create a new {@link LinearRing}, given an array of coordinates.
@param coordinates
An array of {@link Coordinate} objects. This function checks if the array is closed, and does so
itself if needed.
@return Returns a {@link LinearRing} object.
"""
if (coordinates == null || coordinates.length == 0) {
return new LinearRing(srid, precision);
}
boolean isClosed = true;
if (coordinates.length == 1 || !coordinates[0].equals(coordinates[coordinates.length - 1])) {
isClosed = false;
}
Coordinate[] clones;
if (isClosed) {
clones = new Coordinate[coordinates.length];
} else {
clones = new Coordinate[coordinates.length + 1];
}
for (int i = 0; i < coordinates.length; i++) {
clones[i] = (Coordinate) coordinates[i].clone();
}
if (!isClosed) {
clones[coordinates.length] = (Coordinate) clones[0].clone();
}
return new LinearRing(srid, precision, clones);
} | java | public LinearRing createLinearRing(Coordinate[] coordinates) {
if (coordinates == null || coordinates.length == 0) {
return new LinearRing(srid, precision);
}
boolean isClosed = true;
if (coordinates.length == 1 || !coordinates[0].equals(coordinates[coordinates.length - 1])) {
isClosed = false;
}
Coordinate[] clones;
if (isClosed) {
clones = new Coordinate[coordinates.length];
} else {
clones = new Coordinate[coordinates.length + 1];
}
for (int i = 0; i < coordinates.length; i++) {
clones[i] = (Coordinate) coordinates[i].clone();
}
if (!isClosed) {
clones[coordinates.length] = (Coordinate) clones[0].clone();
}
return new LinearRing(srid, precision, clones);
} | [
"public",
"LinearRing",
"createLinearRing",
"(",
"Coordinate",
"[",
"]",
"coordinates",
")",
"{",
"if",
"(",
"coordinates",
"==",
"null",
"||",
"coordinates",
".",
"length",
"==",
"0",
")",
"{",
"return",
"new",
"LinearRing",
"(",
"srid",
",",
"precision",
")",
";",
"}",
"boolean",
"isClosed",
"=",
"true",
";",
"if",
"(",
"coordinates",
".",
"length",
"==",
"1",
"||",
"!",
"coordinates",
"[",
"0",
"]",
".",
"equals",
"(",
"coordinates",
"[",
"coordinates",
".",
"length",
"-",
"1",
"]",
")",
")",
"{",
"isClosed",
"=",
"false",
";",
"}",
"Coordinate",
"[",
"]",
"clones",
";",
"if",
"(",
"isClosed",
")",
"{",
"clones",
"=",
"new",
"Coordinate",
"[",
"coordinates",
".",
"length",
"]",
";",
"}",
"else",
"{",
"clones",
"=",
"new",
"Coordinate",
"[",
"coordinates",
".",
"length",
"+",
"1",
"]",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"coordinates",
".",
"length",
";",
"i",
"++",
")",
"{",
"clones",
"[",
"i",
"]",
"=",
"(",
"Coordinate",
")",
"coordinates",
"[",
"i",
"]",
".",
"clone",
"(",
")",
";",
"}",
"if",
"(",
"!",
"isClosed",
")",
"{",
"clones",
"[",
"coordinates",
".",
"length",
"]",
"=",
"(",
"Coordinate",
")",
"clones",
"[",
"0",
"]",
".",
"clone",
"(",
")",
";",
"}",
"return",
"new",
"LinearRing",
"(",
"srid",
",",
"precision",
",",
"clones",
")",
";",
"}"
] | Create a new {@link LinearRing}, given an array of coordinates.
@param coordinates
An array of {@link Coordinate} objects. This function checks if the array is closed, and does so
itself if needed.
@return Returns a {@link LinearRing} object. | [
"Create",
"a",
"new",
"{",
"@link",
"LinearRing",
"}",
"given",
"an",
"array",
"of",
"coordinates",
"."
] | train | https://github.com/geomajas/geomajas-project-client-gwt/blob/1c1adc48deb192ed825265eebcc74d70bbf45670/client/src/main/java/org/geomajas/gwt/client/spatial/geometry/GeometryFactory.java#L127-L149 |
phax/ph-oton | ph-oton-uictrls/src/main/java/com/helger/photon/uictrls/fineupload/FineUploaderBasic.java | FineUploaderBasic.addParams | @Nonnull
public FineUploaderBasic addParams (@Nullable final Map <String, String> aParams) {
"""
These parameters are sent with the request to the endpoint specified in the
action option.
@param aParams
New parameters to be added.
@return this
"""
m_aRequestParams.addAll (aParams);
return this;
} | java | @Nonnull
public FineUploaderBasic addParams (@Nullable final Map <String, String> aParams)
{
m_aRequestParams.addAll (aParams);
return this;
} | [
"@",
"Nonnull",
"public",
"FineUploaderBasic",
"addParams",
"(",
"@",
"Nullable",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"aParams",
")",
"{",
"m_aRequestParams",
".",
"addAll",
"(",
"aParams",
")",
";",
"return",
"this",
";",
"}"
] | These parameters are sent with the request to the endpoint specified in the
action option.
@param aParams
New parameters to be added.
@return this | [
"These",
"parameters",
"are",
"sent",
"with",
"the",
"request",
"to",
"the",
"endpoint",
"specified",
"in",
"the",
"action",
"option",
"."
] | train | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-uictrls/src/main/java/com/helger/photon/uictrls/fineupload/FineUploaderBasic.java#L182-L187 |
sshtools/j2ssh-maverick | j2ssh-maverick/src/main/java/com/sshtools/sftp/SftpSubsystemChannel.java | SftpSubsystemChannel.postReadRequest | public UnsignedInteger32 postReadRequest(byte[] handle, long offset, int len)
throws SftpStatusException, SshException {
"""
Post a read request to the server and return the request id; this is used
to optimize file downloads. In normal operation the files are transfered
by using a synchronous set of requests, however this slows the download
as the client has to wait for the servers response before sending another
request.
@param handle
@param offset
@param len
@return UnsignedInteger32
@throws SshException
"""
try {
UnsignedInteger32 requestId = nextRequestId();
Packet msg = createPacket();
msg.write(SSH_FXP_READ);
msg.writeInt(requestId.longValue());
msg.writeBinaryString(handle);
msg.writeUINT64(offset);
msg.writeInt(len);
sendMessage(msg);
return requestId;
} catch (SshIOException ex) {
throw ex.getRealException();
} catch (IOException ex) {
throw new SshException(ex);
}
} | java | public UnsignedInteger32 postReadRequest(byte[] handle, long offset, int len)
throws SftpStatusException, SshException {
try {
UnsignedInteger32 requestId = nextRequestId();
Packet msg = createPacket();
msg.write(SSH_FXP_READ);
msg.writeInt(requestId.longValue());
msg.writeBinaryString(handle);
msg.writeUINT64(offset);
msg.writeInt(len);
sendMessage(msg);
return requestId;
} catch (SshIOException ex) {
throw ex.getRealException();
} catch (IOException ex) {
throw new SshException(ex);
}
} | [
"public",
"UnsignedInteger32",
"postReadRequest",
"(",
"byte",
"[",
"]",
"handle",
",",
"long",
"offset",
",",
"int",
"len",
")",
"throws",
"SftpStatusException",
",",
"SshException",
"{",
"try",
"{",
"UnsignedInteger32",
"requestId",
"=",
"nextRequestId",
"(",
")",
";",
"Packet",
"msg",
"=",
"createPacket",
"(",
")",
";",
"msg",
".",
"write",
"(",
"SSH_FXP_READ",
")",
";",
"msg",
".",
"writeInt",
"(",
"requestId",
".",
"longValue",
"(",
")",
")",
";",
"msg",
".",
"writeBinaryString",
"(",
"handle",
")",
";",
"msg",
".",
"writeUINT64",
"(",
"offset",
")",
";",
"msg",
".",
"writeInt",
"(",
"len",
")",
";",
"sendMessage",
"(",
"msg",
")",
";",
"return",
"requestId",
";",
"}",
"catch",
"(",
"SshIOException",
"ex",
")",
"{",
"throw",
"ex",
".",
"getRealException",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"throw",
"new",
"SshException",
"(",
"ex",
")",
";",
"}",
"}"
] | Post a read request to the server and return the request id; this is used
to optimize file downloads. In normal operation the files are transfered
by using a synchronous set of requests, however this slows the download
as the client has to wait for the servers response before sending another
request.
@param handle
@param offset
@param len
@return UnsignedInteger32
@throws SshException | [
"Post",
"a",
"read",
"request",
"to",
"the",
"server",
"and",
"return",
"the",
"request",
"id",
";",
"this",
"is",
"used",
"to",
"optimize",
"file",
"downloads",
".",
"In",
"normal",
"operation",
"the",
"files",
"are",
"transfered",
"by",
"using",
"a",
"synchronous",
"set",
"of",
"requests",
"however",
"this",
"slows",
"the",
"download",
"as",
"the",
"client",
"has",
"to",
"wait",
"for",
"the",
"servers",
"response",
"before",
"sending",
"another",
"request",
"."
] | train | https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/sftp/SftpSubsystemChannel.java#L1081-L1101 |
upwork/java-upwork | src/com/Upwork/api/Routers/Reports/Time.java | Time.getByCompany | public JSONObject getByCompany(String company, HashMap<String, String> params) throws JSONException {
"""
Generating Company Wide Reports
@param company Company ID
@param params Parameters
@throws JSONException If error occurred
@return {@link JSONObject}
"""
return _getByType(company, null, null, params, false);
} | java | public JSONObject getByCompany(String company, HashMap<String, String> params) throws JSONException {
return _getByType(company, null, null, params, false);
} | [
"public",
"JSONObject",
"getByCompany",
"(",
"String",
"company",
",",
"HashMap",
"<",
"String",
",",
"String",
">",
"params",
")",
"throws",
"JSONException",
"{",
"return",
"_getByType",
"(",
"company",
",",
"null",
",",
"null",
",",
"params",
",",
"false",
")",
";",
"}"
] | Generating Company Wide Reports
@param company Company ID
@param params Parameters
@throws JSONException If error occurred
@return {@link JSONObject} | [
"Generating",
"Company",
"Wide",
"Reports"
] | train | https://github.com/upwork/java-upwork/blob/342297161503a74e9e0bddbd381ab5eebf4dc454/src/com/Upwork/api/Routers/Reports/Time.java#L118-L120 |
code4everything/util | src/main/java/com/zhazhapan/util/NetUtils.java | NetUtils.clearCookie | public static boolean clearCookie(Cookie[] cookies, HttpServletResponse response) {
"""
清除所有Cookie
@param cookies {@link Cookie}
@param response {@link HttpServletResponse}
@return {@link Boolean}
@since 1.0.8
"""
if (Checker.isNotEmpty(cookies)) {
for (Cookie cookie : cookies) {
removeCookie(cookie, response);
}
return true;
}
return false;
} | java | public static boolean clearCookie(Cookie[] cookies, HttpServletResponse response) {
if (Checker.isNotEmpty(cookies)) {
for (Cookie cookie : cookies) {
removeCookie(cookie, response);
}
return true;
}
return false;
} | [
"public",
"static",
"boolean",
"clearCookie",
"(",
"Cookie",
"[",
"]",
"cookies",
",",
"HttpServletResponse",
"response",
")",
"{",
"if",
"(",
"Checker",
".",
"isNotEmpty",
"(",
"cookies",
")",
")",
"{",
"for",
"(",
"Cookie",
"cookie",
":",
"cookies",
")",
"{",
"removeCookie",
"(",
"cookie",
",",
"response",
")",
";",
"}",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | 清除所有Cookie
@param cookies {@link Cookie}
@param response {@link HttpServletResponse}
@return {@link Boolean}
@since 1.0.8 | [
"清除所有Cookie"
] | train | https://github.com/code4everything/util/blob/1fc9f0ead1108f4d7208ba7c000df4244f708418/src/main/java/com/zhazhapan/util/NetUtils.java#L497-L505 |
OpenLiberty/open-liberty | dev/com.ibm.ws.org.apache.jasper.el/src/org/apache/el/util/ReflectionUtil.java | ReflectionUtil.isCoercibleFrom | private static boolean isCoercibleFrom(EvaluationContext ctx, Object src, Class<?> target) {
"""
/*
This class duplicates code in javax.el.Util. When making changes keep
the code in sync.
"""
// TODO: This isn't pretty but it works. Significant refactoring would
// be required to avoid the exception.
try {
ELSupport.coerceToType(ctx, src, target);
} catch (ELException e) {
return false;
}
return true;
} | java | private static boolean isCoercibleFrom(EvaluationContext ctx, Object src, Class<?> target) {
// TODO: This isn't pretty but it works. Significant refactoring would
// be required to avoid the exception.
try {
ELSupport.coerceToType(ctx, src, target);
} catch (ELException e) {
return false;
}
return true;
} | [
"private",
"static",
"boolean",
"isCoercibleFrom",
"(",
"EvaluationContext",
"ctx",
",",
"Object",
"src",
",",
"Class",
"<",
"?",
">",
"target",
")",
"{",
"// TODO: This isn't pretty but it works. Significant refactoring would",
"// be required to avoid the exception.",
"try",
"{",
"ELSupport",
".",
"coerceToType",
"(",
"ctx",
",",
"src",
",",
"target",
")",
";",
"}",
"catch",
"(",
"ELException",
"e",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | /*
This class duplicates code in javax.el.Util. When making changes keep
the code in sync. | [
"/",
"*",
"This",
"class",
"duplicates",
"code",
"in",
"javax",
".",
"el",
".",
"Util",
".",
"When",
"making",
"changes",
"keep",
"the",
"code",
"in",
"sync",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.org.apache.jasper.el/src/org/apache/el/util/ReflectionUtil.java#L401-L410 |
albfernandez/itext2 | src/main/java/com/lowagie/text/pdf/PdfPRow.java | PdfPRow.setExtraHeight | public void setExtraHeight(int cell, float height) {
"""
Sets an extra height for a cell.
@param cell the index of the cell that needs an extra height
@param height the extra height
@since 2.1.6
"""
if (cell < 0 || cell >= cells.length)
return;
extraHeights[cell] = height;
} | java | public void setExtraHeight(int cell, float height) {
if (cell < 0 || cell >= cells.length)
return;
extraHeights[cell] = height;
} | [
"public",
"void",
"setExtraHeight",
"(",
"int",
"cell",
",",
"float",
"height",
")",
"{",
"if",
"(",
"cell",
"<",
"0",
"||",
"cell",
">=",
"cells",
".",
"length",
")",
"return",
";",
"extraHeights",
"[",
"cell",
"]",
"=",
"height",
";",
"}"
] | Sets an extra height for a cell.
@param cell the index of the cell that needs an extra height
@param height the extra height
@since 2.1.6 | [
"Sets",
"an",
"extra",
"height",
"for",
"a",
"cell",
"."
] | train | https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/pdf/PdfPRow.java#L169-L173 |
Whiley/WhileyCompiler | src/main/java/wyc/io/WhileyFileParser.java | WhileyFileParser.parseTypeDeclaration | public Decl.Type parseTypeDeclaration(Tuple<Modifier> modifiers) {
"""
Parse a type declaration in a Whiley source file, which has the form:
<pre>
"type" Identifier "is" TypePattern ("where" Expr)*
</pre>
Here, the type pattern specifies a type which may additionally be adorned
with variable names. The "where" clause is optional and is often referred
to as the type's "constraint". Variables defined within the type pattern
may be used within this constraint expressions. A simple example to
illustrate is:
<pre>
type nat is (int x) where x >= 0
</pre>
Here, we are defining a <i>constrained type</i> called <code>nat</code>
which represents the set of natural numbers (i.e the non-negative
integers). Type declarations may also have modifiers, such as
<code>public</code> and <code>private</code>.
@see wyil.lang.WyilFile.Type
@param modifiers
--- The list of modifiers for this declaration (which were
already parsed before this method was called).
"""
int start = index;
EnclosingScope scope = new EnclosingScope();
//
match(Identifier); // type
// Parse type name
Identifier name = parseIdentifier();
// Parse templare variables
Tuple<Template.Variable> template = parseOptionalTemplate(scope);
match(Is);
// Parse the type pattern
Decl.Variable var = parseOptionalParameter(scope);
addFieldAliases(var, scope);
Tuple<Expr> invariant = parseInvariant(scope, Where);
int end = index;
matchEndLine();
return annotateSourceLocation(new Decl.Type(modifiers, name, template, var, invariant), start);
} | java | public Decl.Type parseTypeDeclaration(Tuple<Modifier> modifiers) {
int start = index;
EnclosingScope scope = new EnclosingScope();
//
match(Identifier); // type
// Parse type name
Identifier name = parseIdentifier();
// Parse templare variables
Tuple<Template.Variable> template = parseOptionalTemplate(scope);
match(Is);
// Parse the type pattern
Decl.Variable var = parseOptionalParameter(scope);
addFieldAliases(var, scope);
Tuple<Expr> invariant = parseInvariant(scope, Where);
int end = index;
matchEndLine();
return annotateSourceLocation(new Decl.Type(modifiers, name, template, var, invariant), start);
} | [
"public",
"Decl",
".",
"Type",
"parseTypeDeclaration",
"(",
"Tuple",
"<",
"Modifier",
">",
"modifiers",
")",
"{",
"int",
"start",
"=",
"index",
";",
"EnclosingScope",
"scope",
"=",
"new",
"EnclosingScope",
"(",
")",
";",
"//",
"match",
"(",
"Identifier",
")",
";",
"// type",
"// Parse type name",
"Identifier",
"name",
"=",
"parseIdentifier",
"(",
")",
";",
"// Parse templare variables",
"Tuple",
"<",
"Template",
".",
"Variable",
">",
"template",
"=",
"parseOptionalTemplate",
"(",
"scope",
")",
";",
"match",
"(",
"Is",
")",
";",
"// Parse the type pattern",
"Decl",
".",
"Variable",
"var",
"=",
"parseOptionalParameter",
"(",
"scope",
")",
";",
"addFieldAliases",
"(",
"var",
",",
"scope",
")",
";",
"Tuple",
"<",
"Expr",
">",
"invariant",
"=",
"parseInvariant",
"(",
"scope",
",",
"Where",
")",
";",
"int",
"end",
"=",
"index",
";",
"matchEndLine",
"(",
")",
";",
"return",
"annotateSourceLocation",
"(",
"new",
"Decl",
".",
"Type",
"(",
"modifiers",
",",
"name",
",",
"template",
",",
"var",
",",
"invariant",
")",
",",
"start",
")",
";",
"}"
] | Parse a type declaration in a Whiley source file, which has the form:
<pre>
"type" Identifier "is" TypePattern ("where" Expr)*
</pre>
Here, the type pattern specifies a type which may additionally be adorned
with variable names. The "where" clause is optional and is often referred
to as the type's "constraint". Variables defined within the type pattern
may be used within this constraint expressions. A simple example to
illustrate is:
<pre>
type nat is (int x) where x >= 0
</pre>
Here, we are defining a <i>constrained type</i> called <code>nat</code>
which represents the set of natural numbers (i.e the non-negative
integers). Type declarations may also have modifiers, such as
<code>public</code> and <code>private</code>.
@see wyil.lang.WyilFile.Type
@param modifiers
--- The list of modifiers for this declaration (which were
already parsed before this method was called). | [
"Parse",
"a",
"type",
"declaration",
"in",
"a",
"Whiley",
"source",
"file",
"which",
"has",
"the",
"form",
":"
] | train | https://github.com/Whiley/WhileyCompiler/blob/680f8a657d3fc286f8cc422755988b6d74ab3f4c/src/main/java/wyc/io/WhileyFileParser.java#L466-L483 |
gallandarakhneorg/afc | maven/maventools/src/main/java/org/arakhne/maven/AbstractArakhneMojo.java | AbstractArakhneMojo.createArtifact | public final Artifact createArtifact(String groupId, String artifactId, String version, String scope, String type) {
"""
Create an artifact from the given values.
@param groupId group id.
@param artifactId artifact id.
@param version version number.
@param scope artifact scope.
@param type artifact type.
@return the artifact
"""
VersionRange versionRange = null;
if (version != null) {
versionRange = VersionRange.createFromVersion(version);
}
String desiredScope = scope;
if (Artifact.SCOPE_TEST.equals(desiredScope)) {
desiredScope = Artifact.SCOPE_TEST;
}
if (Artifact.SCOPE_PROVIDED.equals(desiredScope)) {
desiredScope = Artifact.SCOPE_PROVIDED;
}
if (Artifact.SCOPE_SYSTEM.equals(desiredScope)) {
// system scopes come through unchanged...
desiredScope = Artifact.SCOPE_SYSTEM;
}
final ArtifactHandler handler = getArtifactHandlerManager().getArtifactHandler(type);
return new org.apache.maven.artifact.DefaultArtifact(
groupId, artifactId, versionRange,
desiredScope, type, null,
handler, false);
} | java | public final Artifact createArtifact(String groupId, String artifactId, String version, String scope, String type) {
VersionRange versionRange = null;
if (version != null) {
versionRange = VersionRange.createFromVersion(version);
}
String desiredScope = scope;
if (Artifact.SCOPE_TEST.equals(desiredScope)) {
desiredScope = Artifact.SCOPE_TEST;
}
if (Artifact.SCOPE_PROVIDED.equals(desiredScope)) {
desiredScope = Artifact.SCOPE_PROVIDED;
}
if (Artifact.SCOPE_SYSTEM.equals(desiredScope)) {
// system scopes come through unchanged...
desiredScope = Artifact.SCOPE_SYSTEM;
}
final ArtifactHandler handler = getArtifactHandlerManager().getArtifactHandler(type);
return new org.apache.maven.artifact.DefaultArtifact(
groupId, artifactId, versionRange,
desiredScope, type, null,
handler, false);
} | [
"public",
"final",
"Artifact",
"createArtifact",
"(",
"String",
"groupId",
",",
"String",
"artifactId",
",",
"String",
"version",
",",
"String",
"scope",
",",
"String",
"type",
")",
"{",
"VersionRange",
"versionRange",
"=",
"null",
";",
"if",
"(",
"version",
"!=",
"null",
")",
"{",
"versionRange",
"=",
"VersionRange",
".",
"createFromVersion",
"(",
"version",
")",
";",
"}",
"String",
"desiredScope",
"=",
"scope",
";",
"if",
"(",
"Artifact",
".",
"SCOPE_TEST",
".",
"equals",
"(",
"desiredScope",
")",
")",
"{",
"desiredScope",
"=",
"Artifact",
".",
"SCOPE_TEST",
";",
"}",
"if",
"(",
"Artifact",
".",
"SCOPE_PROVIDED",
".",
"equals",
"(",
"desiredScope",
")",
")",
"{",
"desiredScope",
"=",
"Artifact",
".",
"SCOPE_PROVIDED",
";",
"}",
"if",
"(",
"Artifact",
".",
"SCOPE_SYSTEM",
".",
"equals",
"(",
"desiredScope",
")",
")",
"{",
"// system scopes come through unchanged...",
"desiredScope",
"=",
"Artifact",
".",
"SCOPE_SYSTEM",
";",
"}",
"final",
"ArtifactHandler",
"handler",
"=",
"getArtifactHandlerManager",
"(",
")",
".",
"getArtifactHandler",
"(",
"type",
")",
";",
"return",
"new",
"org",
".",
"apache",
".",
"maven",
".",
"artifact",
".",
"DefaultArtifact",
"(",
"groupId",
",",
"artifactId",
",",
"versionRange",
",",
"desiredScope",
",",
"type",
",",
"null",
",",
"handler",
",",
"false",
")",
";",
"}"
] | Create an artifact from the given values.
@param groupId group id.
@param artifactId artifact id.
@param version version number.
@param scope artifact scope.
@param type artifact type.
@return the artifact | [
"Create",
"an",
"artifact",
"from",
"the",
"given",
"values",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/maven/maventools/src/main/java/org/arakhne/maven/AbstractArakhneMojo.java#L987-L1013 |
samskivert/samskivert | src/main/java/com/samskivert/util/ArrayUtil.java | ArrayUtil.append | public static <T extends Object> T[] append (T[] values, T value) {
"""
Creates a new array one larger than the supplied array and with the
specified value inserted into the last slot. The type of the values
array will be preserved.
"""
return insert(values, value, values.length);
} | java | public static <T extends Object> T[] append (T[] values, T value)
{
return insert(values, value, values.length);
} | [
"public",
"static",
"<",
"T",
"extends",
"Object",
">",
"T",
"[",
"]",
"append",
"(",
"T",
"[",
"]",
"values",
",",
"T",
"value",
")",
"{",
"return",
"insert",
"(",
"values",
",",
"value",
",",
"values",
".",
"length",
")",
";",
"}"
] | Creates a new array one larger than the supplied array and with the
specified value inserted into the last slot. The type of the values
array will be preserved. | [
"Creates",
"a",
"new",
"array",
"one",
"larger",
"than",
"the",
"supplied",
"array",
"and",
"with",
"the",
"specified",
"value",
"inserted",
"into",
"the",
"last",
"slot",
".",
"The",
"type",
"of",
"the",
"values",
"array",
"will",
"be",
"preserved",
"."
] | train | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/ArrayUtil.java#L847-L850 |
liferay/com-liferay-commerce | commerce-notification-service/src/main/java/com/liferay/commerce/notification/service/persistence/impl/CommerceNotificationAttachmentPersistenceImpl.java | CommerceNotificationAttachmentPersistenceImpl.removeByUuid_C | @Override
public void removeByUuid_C(String uuid, long companyId) {
"""
Removes all the commerce notification attachments where uuid = ? and companyId = ? from the database.
@param uuid the uuid
@param companyId the company ID
"""
for (CommerceNotificationAttachment commerceNotificationAttachment : findByUuid_C(
uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(commerceNotificationAttachment);
}
} | java | @Override
public void removeByUuid_C(String uuid, long companyId) {
for (CommerceNotificationAttachment commerceNotificationAttachment : findByUuid_C(
uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(commerceNotificationAttachment);
}
} | [
"@",
"Override",
"public",
"void",
"removeByUuid_C",
"(",
"String",
"uuid",
",",
"long",
"companyId",
")",
"{",
"for",
"(",
"CommerceNotificationAttachment",
"commerceNotificationAttachment",
":",
"findByUuid_C",
"(",
"uuid",
",",
"companyId",
",",
"QueryUtil",
".",
"ALL_POS",
",",
"QueryUtil",
".",
"ALL_POS",
",",
"null",
")",
")",
"{",
"remove",
"(",
"commerceNotificationAttachment",
")",
";",
"}",
"}"
] | Removes all the commerce notification attachments where uuid = ? and companyId = ? from the database.
@param uuid the uuid
@param companyId the company ID | [
"Removes",
"all",
"the",
"commerce",
"notification",
"attachments",
"where",
"uuid",
"=",
"?",
";",
"and",
"companyId",
"=",
"?",
";",
"from",
"the",
"database",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-notification-service/src/main/java/com/liferay/commerce/notification/service/persistence/impl/CommerceNotificationAttachmentPersistenceImpl.java#L1433-L1439 |
unbescape/unbescape | src/main/java/org/unbescape/xml/XmlEscape.java | XmlEscape.unescapeXml | public static void unescapeXml(final String text, final Writer writer)
throws IOException {
"""
<p>
Perform an XML <strong>unescape</strong> operation on a <tt>String</tt> input,
writing results to a <tt>Writer</tt>.
</p>
<p>
No additional configuration arguments are required. Unescape operations
will always perform <em>complete</em> XML 1.0/1.1 unescape of CERs, decimal
and hexadecimal references.
</p>
<p>
This method is <strong>thread-safe</strong>.
</p>
@param text the <tt>String</tt> to be unescaped.
@param writer the <tt>java.io.Writer</tt> to which the unescaped result will be written. Nothing will
be written at all to this writer if input is <tt>null</tt>.
@throws IOException if an input/output exception occurs
@since 1.1.2
"""
if (writer == null) {
throw new IllegalArgumentException("Argument 'writer' cannot be null");
}
if (text == null) {
return;
}
if (text.indexOf('&') < 0) {
// Fail fast, avoid more complex (and less JIT-table) method to execute if not needed
writer.write(text);
return;
}
// The chosen symbols (1.0 or 1.1) don't really matter, as both contain the same CERs
XmlEscapeUtil.unescape(new InternalStringReader(text), writer, XmlEscapeSymbols.XML11_SYMBOLS);
} | java | public static void unescapeXml(final String text, final Writer writer)
throws IOException {
if (writer == null) {
throw new IllegalArgumentException("Argument 'writer' cannot be null");
}
if (text == null) {
return;
}
if (text.indexOf('&') < 0) {
// Fail fast, avoid more complex (and less JIT-table) method to execute if not needed
writer.write(text);
return;
}
// The chosen symbols (1.0 or 1.1) don't really matter, as both contain the same CERs
XmlEscapeUtil.unescape(new InternalStringReader(text), writer, XmlEscapeSymbols.XML11_SYMBOLS);
} | [
"public",
"static",
"void",
"unescapeXml",
"(",
"final",
"String",
"text",
",",
"final",
"Writer",
"writer",
")",
"throws",
"IOException",
"{",
"if",
"(",
"writer",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Argument 'writer' cannot be null\"",
")",
";",
"}",
"if",
"(",
"text",
"==",
"null",
")",
"{",
"return",
";",
"}",
"if",
"(",
"text",
".",
"indexOf",
"(",
"'",
"'",
")",
"<",
"0",
")",
"{",
"// Fail fast, avoid more complex (and less JIT-table) method to execute if not needed",
"writer",
".",
"write",
"(",
"text",
")",
";",
"return",
";",
"}",
"// The chosen symbols (1.0 or 1.1) don't really matter, as both contain the same CERs",
"XmlEscapeUtil",
".",
"unescape",
"(",
"new",
"InternalStringReader",
"(",
"text",
")",
",",
"writer",
",",
"XmlEscapeSymbols",
".",
"XML11_SYMBOLS",
")",
";",
"}"
] | <p>
Perform an XML <strong>unescape</strong> operation on a <tt>String</tt> input,
writing results to a <tt>Writer</tt>.
</p>
<p>
No additional configuration arguments are required. Unescape operations
will always perform <em>complete</em> XML 1.0/1.1 unescape of CERs, decimal
and hexadecimal references.
</p>
<p>
This method is <strong>thread-safe</strong>.
</p>
@param text the <tt>String</tt> to be unescaped.
@param writer the <tt>java.io.Writer</tt> to which the unescaped result will be written. Nothing will
be written at all to this writer if input is <tt>null</tt>.
@throws IOException if an input/output exception occurs
@since 1.1.2 | [
"<p",
">",
"Perform",
"an",
"XML",
"<strong",
">",
"unescape<",
"/",
"strong",
">",
"operation",
"on",
"a",
"<tt",
">",
"String<",
"/",
"tt",
">",
"input",
"writing",
"results",
"to",
"a",
"<tt",
">",
"Writer<",
"/",
"tt",
">",
".",
"<",
"/",
"p",
">",
"<p",
">",
"No",
"additional",
"configuration",
"arguments",
"are",
"required",
".",
"Unescape",
"operations",
"will",
"always",
"perform",
"<em",
">",
"complete<",
"/",
"em",
">",
"XML",
"1",
".",
"0",
"/",
"1",
".",
"1",
"unescape",
"of",
"CERs",
"decimal",
"and",
"hexadecimal",
"references",
".",
"<",
"/",
"p",
">",
"<p",
">",
"This",
"method",
"is",
"<strong",
">",
"thread",
"-",
"safe<",
"/",
"strong",
">",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/unbescape/unbescape/blob/ec5435fb3508c2eed25d8165dc27ded2602cae13/src/main/java/org/unbescape/xml/XmlEscape.java#L2348-L2366 |
linroid/FilterMenu | library/src/main/java/com/linroid/filtermenu/library/FilterMenuLayout.java | FilterMenuLayout.findMidnormalPoint | private static Point findMidnormalPoint(Point center, Point a, Point b, Rect area, int radius) {
"""
find the middle point of two intersect points in circle,only one point will be correct
@param center
@param a
@param b
@param area
@param radius
@return
"""
if (a.y == b.y) {
//top
if (a.y < center.y) {
return new Point((a.x + b.x) / 2, center.y + radius);
}
//bottom
return new Point((a.x + b.x) / 2, center.y - radius);
}
if (a.x == b.x) {
//left
if (a.x < center.x) {
return new Point(center.x + radius, (a.y + b.y) / 2);
}
//right
return new Point(center.x - radius, (a.y + b.y) / 2);
}
//slope of line ab
double abSlope = (a.y - b.y) / (a.x - b.x * 1.0);
//slope of midnormal
double midnormalSlope = -1.0 / abSlope;
double radian = Math.tan(midnormalSlope);
int dy = (int) (radius * Math.sin(radian));
int dx = (int) (radius * Math.cos(radian));
Point point = new Point(center.x + dx, center.y + dy);
if (!inArea(point, area, 0)) {
point = new Point(center.x - dx, center.y - dy);
}
return point;
} | java | private static Point findMidnormalPoint(Point center, Point a, Point b, Rect area, int radius) {
if (a.y == b.y) {
//top
if (a.y < center.y) {
return new Point((a.x + b.x) / 2, center.y + radius);
}
//bottom
return new Point((a.x + b.x) / 2, center.y - radius);
}
if (a.x == b.x) {
//left
if (a.x < center.x) {
return new Point(center.x + radius, (a.y + b.y) / 2);
}
//right
return new Point(center.x - radius, (a.y + b.y) / 2);
}
//slope of line ab
double abSlope = (a.y - b.y) / (a.x - b.x * 1.0);
//slope of midnormal
double midnormalSlope = -1.0 / abSlope;
double radian = Math.tan(midnormalSlope);
int dy = (int) (radius * Math.sin(radian));
int dx = (int) (radius * Math.cos(radian));
Point point = new Point(center.x + dx, center.y + dy);
if (!inArea(point, area, 0)) {
point = new Point(center.x - dx, center.y - dy);
}
return point;
} | [
"private",
"static",
"Point",
"findMidnormalPoint",
"(",
"Point",
"center",
",",
"Point",
"a",
",",
"Point",
"b",
",",
"Rect",
"area",
",",
"int",
"radius",
")",
"{",
"if",
"(",
"a",
".",
"y",
"==",
"b",
".",
"y",
")",
"{",
"//top",
"if",
"(",
"a",
".",
"y",
"<",
"center",
".",
"y",
")",
"{",
"return",
"new",
"Point",
"(",
"(",
"a",
".",
"x",
"+",
"b",
".",
"x",
")",
"/",
"2",
",",
"center",
".",
"y",
"+",
"radius",
")",
";",
"}",
"//bottom",
"return",
"new",
"Point",
"(",
"(",
"a",
".",
"x",
"+",
"b",
".",
"x",
")",
"/",
"2",
",",
"center",
".",
"y",
"-",
"radius",
")",
";",
"}",
"if",
"(",
"a",
".",
"x",
"==",
"b",
".",
"x",
")",
"{",
"//left",
"if",
"(",
"a",
".",
"x",
"<",
"center",
".",
"x",
")",
"{",
"return",
"new",
"Point",
"(",
"center",
".",
"x",
"+",
"radius",
",",
"(",
"a",
".",
"y",
"+",
"b",
".",
"y",
")",
"/",
"2",
")",
";",
"}",
"//right",
"return",
"new",
"Point",
"(",
"center",
".",
"x",
"-",
"radius",
",",
"(",
"a",
".",
"y",
"+",
"b",
".",
"y",
")",
"/",
"2",
")",
";",
"}",
"//slope of line ab",
"double",
"abSlope",
"=",
"(",
"a",
".",
"y",
"-",
"b",
".",
"y",
")",
"/",
"(",
"a",
".",
"x",
"-",
"b",
".",
"x",
"*",
"1.0",
")",
";",
"//slope of midnormal",
"double",
"midnormalSlope",
"=",
"-",
"1.0",
"/",
"abSlope",
";",
"double",
"radian",
"=",
"Math",
".",
"tan",
"(",
"midnormalSlope",
")",
";",
"int",
"dy",
"=",
"(",
"int",
")",
"(",
"radius",
"*",
"Math",
".",
"sin",
"(",
"radian",
")",
")",
";",
"int",
"dx",
"=",
"(",
"int",
")",
"(",
"radius",
"*",
"Math",
".",
"cos",
"(",
"radian",
")",
")",
";",
"Point",
"point",
"=",
"new",
"Point",
"(",
"center",
".",
"x",
"+",
"dx",
",",
"center",
".",
"y",
"+",
"dy",
")",
";",
"if",
"(",
"!",
"inArea",
"(",
"point",
",",
"area",
",",
"0",
")",
")",
"{",
"point",
"=",
"new",
"Point",
"(",
"center",
".",
"x",
"-",
"dx",
",",
"center",
".",
"y",
"-",
"dy",
")",
";",
"}",
"return",
"point",
";",
"}"
] | find the middle point of two intersect points in circle,only one point will be correct
@param center
@param a
@param b
@param area
@param radius
@return | [
"find",
"the",
"middle",
"point",
"of",
"two",
"intersect",
"points",
"in",
"circle",
"only",
"one",
"point",
"will",
"be",
"correct"
] | train | https://github.com/linroid/FilterMenu/blob/5a6e5472631c2304b71a51034683f38271962ef5/library/src/main/java/com/linroid/filtermenu/library/FilterMenuLayout.java#L164-L194 |
spring-projects/spring-hateoas | src/main/java/org/springframework/hateoas/server/mvc/RepresentationModelProcessorInvoker.java | RepresentationModelProcessorInvoker.invokeProcessorsFor | private Object invokeProcessorsFor(Object value, ResolvableType type) {
"""
Invokes all registered {@link RepresentationModelProcessor}s registered for the given {@link ResolvableType}.
@param value the object to process
@param type
@return
"""
Object currentValue = value;
// Process actual value
for (RepresentationModelProcessorInvoker.ProcessorWrapper wrapper : this.processors) {
if (wrapper.supports(type, currentValue)) {
currentValue = wrapper.invokeProcessor(currentValue);
}
}
return currentValue;
} | java | private Object invokeProcessorsFor(Object value, ResolvableType type) {
Object currentValue = value;
// Process actual value
for (RepresentationModelProcessorInvoker.ProcessorWrapper wrapper : this.processors) {
if (wrapper.supports(type, currentValue)) {
currentValue = wrapper.invokeProcessor(currentValue);
}
}
return currentValue;
} | [
"private",
"Object",
"invokeProcessorsFor",
"(",
"Object",
"value",
",",
"ResolvableType",
"type",
")",
"{",
"Object",
"currentValue",
"=",
"value",
";",
"// Process actual value",
"for",
"(",
"RepresentationModelProcessorInvoker",
".",
"ProcessorWrapper",
"wrapper",
":",
"this",
".",
"processors",
")",
"{",
"if",
"(",
"wrapper",
".",
"supports",
"(",
"type",
",",
"currentValue",
")",
")",
"{",
"currentValue",
"=",
"wrapper",
".",
"invokeProcessor",
"(",
"currentValue",
")",
";",
"}",
"}",
"return",
"currentValue",
";",
"}"
] | Invokes all registered {@link RepresentationModelProcessor}s registered for the given {@link ResolvableType}.
@param value the object to process
@param type
@return | [
"Invokes",
"all",
"registered",
"{",
"@link",
"RepresentationModelProcessor",
"}",
"s",
"registered",
"for",
"the",
"given",
"{",
"@link",
"ResolvableType",
"}",
"."
] | train | https://github.com/spring-projects/spring-hateoas/blob/70ebff9309f086cd8d6a97daf67e0dc215c87d9c/src/main/java/org/springframework/hateoas/server/mvc/RepresentationModelProcessorInvoker.java#L152-L164 |
haifengl/smile | plot/src/main/java/smile/plot/Graphics.java | Graphics.drawTextBaseRatio | public void drawTextBaseRatio(String label, double horizontalReference, double verticalReference, double rotation, double[] coord) {
"""
Draw a string with given reference point and rotation angle. (0.5, 0.5)
is center, (0, 0) is lower left, (1, 0) is upper left, etc.
The angle of rotation is in radians. The logical are proportional to
the base coordinates.
"""
int[] sc = projection.screenProjectionBaseRatio(coord);
int x = sc[0];
int y = sc[1];
AffineTransform transform = g2d.getTransform();
// Corner offset adjustment : Text Offset is used Here
FontRenderContext frc = g2d.getFontRenderContext();
Font font = g2d.getFont();
double w = font.getStringBounds(label, frc).getWidth();
double h = font.getSize2D();
if (rotation != 0) {
g2d.rotate(rotation, x, y);
}
x -= (int) (w * horizontalReference);
y += (int) (h * verticalReference);
g2d.drawString(label, x, y);
g2d.setTransform(transform);
} | java | public void drawTextBaseRatio(String label, double horizontalReference, double verticalReference, double rotation, double[] coord) {
int[] sc = projection.screenProjectionBaseRatio(coord);
int x = sc[0];
int y = sc[1];
AffineTransform transform = g2d.getTransform();
// Corner offset adjustment : Text Offset is used Here
FontRenderContext frc = g2d.getFontRenderContext();
Font font = g2d.getFont();
double w = font.getStringBounds(label, frc).getWidth();
double h = font.getSize2D();
if (rotation != 0) {
g2d.rotate(rotation, x, y);
}
x -= (int) (w * horizontalReference);
y += (int) (h * verticalReference);
g2d.drawString(label, x, y);
g2d.setTransform(transform);
} | [
"public",
"void",
"drawTextBaseRatio",
"(",
"String",
"label",
",",
"double",
"horizontalReference",
",",
"double",
"verticalReference",
",",
"double",
"rotation",
",",
"double",
"[",
"]",
"coord",
")",
"{",
"int",
"[",
"]",
"sc",
"=",
"projection",
".",
"screenProjectionBaseRatio",
"(",
"coord",
")",
";",
"int",
"x",
"=",
"sc",
"[",
"0",
"]",
";",
"int",
"y",
"=",
"sc",
"[",
"1",
"]",
";",
"AffineTransform",
"transform",
"=",
"g2d",
".",
"getTransform",
"(",
")",
";",
"// Corner offset adjustment : Text Offset is used Here",
"FontRenderContext",
"frc",
"=",
"g2d",
".",
"getFontRenderContext",
"(",
")",
";",
"Font",
"font",
"=",
"g2d",
".",
"getFont",
"(",
")",
";",
"double",
"w",
"=",
"font",
".",
"getStringBounds",
"(",
"label",
",",
"frc",
")",
".",
"getWidth",
"(",
")",
";",
"double",
"h",
"=",
"font",
".",
"getSize2D",
"(",
")",
";",
"if",
"(",
"rotation",
"!=",
"0",
")",
"{",
"g2d",
".",
"rotate",
"(",
"rotation",
",",
"x",
",",
"y",
")",
";",
"}",
"x",
"-=",
"(",
"int",
")",
"(",
"w",
"*",
"horizontalReference",
")",
";",
"y",
"+=",
"(",
"int",
")",
"(",
"h",
"*",
"verticalReference",
")",
";",
"g2d",
".",
"drawString",
"(",
"label",
",",
"x",
",",
"y",
")",
";",
"g2d",
".",
"setTransform",
"(",
"transform",
")",
";",
"}"
] | Draw a string with given reference point and rotation angle. (0.5, 0.5)
is center, (0, 0) is lower left, (1, 0) is upper left, etc.
The angle of rotation is in radians. The logical are proportional to
the base coordinates. | [
"Draw",
"a",
"string",
"with",
"given",
"reference",
"point",
"and",
"rotation",
"angle",
".",
"(",
"0",
".",
"5",
"0",
".",
"5",
")",
"is",
"center",
"(",
"0",
"0",
")",
"is",
"lower",
"left",
"(",
"1",
"0",
")",
"is",
"upper",
"left",
"etc",
".",
"The",
"angle",
"of",
"rotation",
"is",
"in",
"radians",
".",
"The",
"logical",
"are",
"proportional",
"to",
"the",
"base",
"coordinates",
"."
] | train | https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/plot/src/main/java/smile/plot/Graphics.java#L274-L297 |
fcrepo3/fcrepo | fcrepo-common/src/main/java/org/fcrepo/common/policy/XacmlName.java | XacmlName.looselyMatches | public boolean looselyMatches(String in, boolean tryFirstLocalNameChar) {
"""
Does the given string loosely match this name? Either: 1) It matches
localName (case insensitive) 2) It matches uri (case sensitive) if
(firstLocalNameChar == true): 3) It is one character long, and that
character matches the first character of localName (case insensitive)
"""
if (in == null || in.length() == 0) {
return false;
}
if (in.equalsIgnoreCase(localName)) {
return true;
}
if (in.equals(uri)) {
return true;
}
if (tryFirstLocalNameChar
&& in.length() == 1
&& in.toUpperCase().charAt(0) == localName.toUpperCase()
.charAt(0)) {
return true;
}
return false;
} | java | public boolean looselyMatches(String in, boolean tryFirstLocalNameChar) {
if (in == null || in.length() == 0) {
return false;
}
if (in.equalsIgnoreCase(localName)) {
return true;
}
if (in.equals(uri)) {
return true;
}
if (tryFirstLocalNameChar
&& in.length() == 1
&& in.toUpperCase().charAt(0) == localName.toUpperCase()
.charAt(0)) {
return true;
}
return false;
} | [
"public",
"boolean",
"looselyMatches",
"(",
"String",
"in",
",",
"boolean",
"tryFirstLocalNameChar",
")",
"{",
"if",
"(",
"in",
"==",
"null",
"||",
"in",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"in",
".",
"equalsIgnoreCase",
"(",
"localName",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"in",
".",
"equals",
"(",
"uri",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"tryFirstLocalNameChar",
"&&",
"in",
".",
"length",
"(",
")",
"==",
"1",
"&&",
"in",
".",
"toUpperCase",
"(",
")",
".",
"charAt",
"(",
"0",
")",
"==",
"localName",
".",
"toUpperCase",
"(",
")",
".",
"charAt",
"(",
"0",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Does the given string loosely match this name? Either: 1) It matches
localName (case insensitive) 2) It matches uri (case sensitive) if
(firstLocalNameChar == true): 3) It is one character long, and that
character matches the first character of localName (case insensitive) | [
"Does",
"the",
"given",
"string",
"loosely",
"match",
"this",
"name?",
"Either",
":",
"1",
")",
"It",
"matches",
"localName",
"(",
"case",
"insensitive",
")",
"2",
")",
"It",
"matches",
"uri",
"(",
"case",
"sensitive",
")",
"if",
"(",
"firstLocalNameChar",
"==",
"true",
")",
":",
"3",
")",
"It",
"is",
"one",
"character",
"long",
"and",
"that",
"character",
"matches",
"the",
"first",
"character",
"of",
"localName",
"(",
"case",
"insensitive",
")"
] | train | https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-common/src/main/java/org/fcrepo/common/policy/XacmlName.java#L66-L83 |
alkacon/opencms-core | src-gwt/org/opencms/gwt/client/ui/CmsMessageWidget.java | CmsMessageWidget.setIcon | public void setIcon(FontOpenCms icon, String color) {
"""
Sets the icon CSS class.<p>
@param icon the icon
@param color the icon color
"""
if (icon != null) {
m_iconCell.setInnerHTML(icon.getHtml(32, color));
} else {
m_iconCell.setInnerHTML("");
}
} | java | public void setIcon(FontOpenCms icon, String color) {
if (icon != null) {
m_iconCell.setInnerHTML(icon.getHtml(32, color));
} else {
m_iconCell.setInnerHTML("");
}
} | [
"public",
"void",
"setIcon",
"(",
"FontOpenCms",
"icon",
",",
"String",
"color",
")",
"{",
"if",
"(",
"icon",
"!=",
"null",
")",
"{",
"m_iconCell",
".",
"setInnerHTML",
"(",
"icon",
".",
"getHtml",
"(",
"32",
",",
"color",
")",
")",
";",
"}",
"else",
"{",
"m_iconCell",
".",
"setInnerHTML",
"(",
"\"\"",
")",
";",
"}",
"}"
] | Sets the icon CSS class.<p>
@param icon the icon
@param color the icon color | [
"Sets",
"the",
"icon",
"CSS",
"class",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/gwt/client/ui/CmsMessageWidget.java#L76-L83 |
b3log/latke | latke-core/src/main/java/org/json/JSONArray.java | JSONArray.optNumber | public Number optNumber(int index, Number defaultValue) {
"""
Get an optional {@link Number} value associated with a key, or the default if there
is no such key or if the value is not a number. If the value is a string,
an attempt will be made to evaluate it as a number ({@link BigDecimal}). This method
would be used in cases where type coercion of the number value is unwanted.
@param index
The index must be between 0 and length() - 1.
@param defaultValue
The default.
@return An object which is the value.
"""
Object val = this.opt(index);
if (JSONObject.NULL.equals(val)) {
return defaultValue;
}
if (val instanceof Number){
return (Number) val;
}
if (val instanceof String) {
try {
return JSONObject.stringToNumber((String) val);
} catch (Exception e) {
return defaultValue;
}
}
return defaultValue;
} | java | public Number optNumber(int index, Number defaultValue) {
Object val = this.opt(index);
if (JSONObject.NULL.equals(val)) {
return defaultValue;
}
if (val instanceof Number){
return (Number) val;
}
if (val instanceof String) {
try {
return JSONObject.stringToNumber((String) val);
} catch (Exception e) {
return defaultValue;
}
}
return defaultValue;
} | [
"public",
"Number",
"optNumber",
"(",
"int",
"index",
",",
"Number",
"defaultValue",
")",
"{",
"Object",
"val",
"=",
"this",
".",
"opt",
"(",
"index",
")",
";",
"if",
"(",
"JSONObject",
".",
"NULL",
".",
"equals",
"(",
"val",
")",
")",
"{",
"return",
"defaultValue",
";",
"}",
"if",
"(",
"val",
"instanceof",
"Number",
")",
"{",
"return",
"(",
"Number",
")",
"val",
";",
"}",
"if",
"(",
"val",
"instanceof",
"String",
")",
"{",
"try",
"{",
"return",
"JSONObject",
".",
"stringToNumber",
"(",
"(",
"String",
")",
"val",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"defaultValue",
";",
"}",
"}",
"return",
"defaultValue",
";",
"}"
] | Get an optional {@link Number} value associated with a key, or the default if there
is no such key or if the value is not a number. If the value is a string,
an attempt will be made to evaluate it as a number ({@link BigDecimal}). This method
would be used in cases where type coercion of the number value is unwanted.
@param index
The index must be between 0 and length() - 1.
@param defaultValue
The default.
@return An object which is the value. | [
"Get",
"an",
"optional",
"{",
"@link",
"Number",
"}",
"value",
"associated",
"with",
"a",
"key",
"or",
"the",
"default",
"if",
"there",
"is",
"no",
"such",
"key",
"or",
"if",
"the",
"value",
"is",
"not",
"a",
"number",
".",
"If",
"the",
"value",
"is",
"a",
"string",
"an",
"attempt",
"will",
"be",
"made",
"to",
"evaluate",
"it",
"as",
"a",
"number",
"(",
"{",
"@link",
"BigDecimal",
"}",
")",
".",
"This",
"method",
"would",
"be",
"used",
"in",
"cases",
"where",
"type",
"coercion",
"of",
"the",
"number",
"value",
"is",
"unwanted",
"."
] | train | https://github.com/b3log/latke/blob/f7e08a47eeecea5f7c94006382c24f353585de33/latke-core/src/main/java/org/json/JSONArray.java#L818-L835 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/string/StringHelper.java | StringHelper.getWithLeading | @Nonnull
public static String getWithLeading (@Nullable final String sSrc, @Nonnegative final int nMinLen, final char cFront) {
"""
Get a string that is filled at the beginning with the passed character until
the minimum length is reached. If the input string is empty, the result is a
string with the provided len only consisting of the passed characters. If the
input String is longer than the provided length, it is returned unchanged.
@param sSrc
Source string. May be <code>null</code>.
@param nMinLen
Minimum length. Should be > 0.
@param cFront
The character to be used at the beginning
@return A non-<code>null</code> string that has at least nLen chars
"""
return _getWithLeadingOrTrailing (sSrc, nMinLen, cFront, true);
} | java | @Nonnull
public static String getWithLeading (@Nullable final String sSrc, @Nonnegative final int nMinLen, final char cFront)
{
return _getWithLeadingOrTrailing (sSrc, nMinLen, cFront, true);
} | [
"@",
"Nonnull",
"public",
"static",
"String",
"getWithLeading",
"(",
"@",
"Nullable",
"final",
"String",
"sSrc",
",",
"@",
"Nonnegative",
"final",
"int",
"nMinLen",
",",
"final",
"char",
"cFront",
")",
"{",
"return",
"_getWithLeadingOrTrailing",
"(",
"sSrc",
",",
"nMinLen",
",",
"cFront",
",",
"true",
")",
";",
"}"
] | Get a string that is filled at the beginning with the passed character until
the minimum length is reached. If the input string is empty, the result is a
string with the provided len only consisting of the passed characters. If the
input String is longer than the provided length, it is returned unchanged.
@param sSrc
Source string. May be <code>null</code>.
@param nMinLen
Minimum length. Should be > 0.
@param cFront
The character to be used at the beginning
@return A non-<code>null</code> string that has at least nLen chars | [
"Get",
"a",
"string",
"that",
"is",
"filled",
"at",
"the",
"beginning",
"with",
"the",
"passed",
"character",
"until",
"the",
"minimum",
"length",
"is",
"reached",
".",
"If",
"the",
"input",
"string",
"is",
"empty",
"the",
"result",
"is",
"a",
"string",
"with",
"the",
"provided",
"len",
"only",
"consisting",
"of",
"the",
"passed",
"characters",
".",
"If",
"the",
"input",
"String",
"is",
"longer",
"than",
"the",
"provided",
"length",
"it",
"is",
"returned",
"unchanged",
"."
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/string/StringHelper.java#L500-L504 |
pietermartin/sqlg | sqlg-core/src/main/java/org/umlg/sqlg/sql/parse/ColumnList.java | ColumnList.getAlias | public String getAlias(SchemaTableTree stt, String column) {
"""
get an alias if the column is already in the list
@param stt
@param column
@return
"""
return getAlias(stt.getSchemaTable(), column, stt.getStepDepth());
} | java | public String getAlias(SchemaTableTree stt, String column) {
return getAlias(stt.getSchemaTable(), column, stt.getStepDepth());
} | [
"public",
"String",
"getAlias",
"(",
"SchemaTableTree",
"stt",
",",
"String",
"column",
")",
"{",
"return",
"getAlias",
"(",
"stt",
".",
"getSchemaTable",
"(",
")",
",",
"column",
",",
"stt",
".",
"getStepDepth",
"(",
")",
")",
";",
"}"
] | get an alias if the column is already in the list
@param stt
@param column
@return | [
"get",
"an",
"alias",
"if",
"the",
"column",
"is",
"already",
"in",
"the",
"list"
] | train | https://github.com/pietermartin/sqlg/blob/c1845a1b31328a5ffda646873b0369ee72af56a7/sqlg-core/src/main/java/org/umlg/sqlg/sql/parse/ColumnList.java#L165-L167 |
apache/groovy | subprojects/groovy-dateutil/src/main/java/org/apache/groovy/dateutil/extensions/DateUtilExtensions.java | DateUtilExtensions.copyWith | public static Date copyWith(Date self, Map<Object, Integer> updates) {
"""
Support creating a new Date having similar properties to
an existing Date (which remains unaltered) but with
some fields updated according to a Map of changes.
<p>
Example usage:
<pre>
import static java.util.Calendar.YEAR
def today = new Date()
def nextYear = today[YEAR] + 1
def oneYearFromNow = today.copyWith(year: nextYear)
println today
println oneYearFromNow
</pre>
@param self A Date
@param updates A Map of Calendar keys and values
@return The newly created Date
@see java.util.Calendar#set(int, int)
@see #set(java.util.Date, java.util.Map)
@see #copyWith(java.util.Calendar, java.util.Map)
@since 2.2.0
"""
Calendar cal = Calendar.getInstance();
cal.setTime(self);
set(cal, updates);
return cal.getTime();
} | java | public static Date copyWith(Date self, Map<Object, Integer> updates) {
Calendar cal = Calendar.getInstance();
cal.setTime(self);
set(cal, updates);
return cal.getTime();
} | [
"public",
"static",
"Date",
"copyWith",
"(",
"Date",
"self",
",",
"Map",
"<",
"Object",
",",
"Integer",
">",
"updates",
")",
"{",
"Calendar",
"cal",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"cal",
".",
"setTime",
"(",
"self",
")",
";",
"set",
"(",
"cal",
",",
"updates",
")",
";",
"return",
"cal",
".",
"getTime",
"(",
")",
";",
"}"
] | Support creating a new Date having similar properties to
an existing Date (which remains unaltered) but with
some fields updated according to a Map of changes.
<p>
Example usage:
<pre>
import static java.util.Calendar.YEAR
def today = new Date()
def nextYear = today[YEAR] + 1
def oneYearFromNow = today.copyWith(year: nextYear)
println today
println oneYearFromNow
</pre>
@param self A Date
@param updates A Map of Calendar keys and values
@return The newly created Date
@see java.util.Calendar#set(int, int)
@see #set(java.util.Date, java.util.Map)
@see #copyWith(java.util.Calendar, java.util.Map)
@since 2.2.0 | [
"Support",
"creating",
"a",
"new",
"Date",
"having",
"similar",
"properties",
"to",
"an",
"existing",
"Date",
"(",
"which",
"remains",
"unaltered",
")",
"but",
"with",
"some",
"fields",
"updated",
"according",
"to",
"a",
"Map",
"of",
"changes",
".",
"<p",
">",
"Example",
"usage",
":",
"<pre",
">",
"import",
"static",
"java",
".",
"util",
".",
"Calendar",
".",
"YEAR",
"def",
"today",
"=",
"new",
"Date",
"()",
"def",
"nextYear",
"=",
"today",
"[",
"YEAR",
"]",
"+",
"1",
"def",
"oneYearFromNow",
"=",
"today",
".",
"copyWith",
"(",
"year",
":",
"nextYear",
")",
"println",
"today",
"println",
"oneYearFromNow",
"<",
"/",
"pre",
">"
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-dateutil/src/main/java/org/apache/groovy/dateutil/extensions/DateUtilExtensions.java#L280-L285 |
svenkubiak/mangooio | mangooio-core/src/main/java/io/mangoo/routing/bindings/Validator.java | Validator.expectMatch | public void expectMatch(String name, String anotherName) {
"""
Validates to fields to (case-insensitive) match
@param name The field to check
@param anotherName The field to check against
"""
expectMatch(name, anotherName, messages.get(Validation.MATCH_KEY.name(), name, anotherName));
} | java | public void expectMatch(String name, String anotherName) {
expectMatch(name, anotherName, messages.get(Validation.MATCH_KEY.name(), name, anotherName));
} | [
"public",
"void",
"expectMatch",
"(",
"String",
"name",
",",
"String",
"anotherName",
")",
"{",
"expectMatch",
"(",
"name",
",",
"anotherName",
",",
"messages",
".",
"get",
"(",
"Validation",
".",
"MATCH_KEY",
".",
"name",
"(",
")",
",",
"name",
",",
"anotherName",
")",
")",
";",
"}"
] | Validates to fields to (case-insensitive) match
@param name The field to check
@param anotherName The field to check against | [
"Validates",
"to",
"fields",
"to",
"(",
"case",
"-",
"insensitive",
")",
"match"
] | train | https://github.com/svenkubiak/mangooio/blob/b3beb6d09510dbbab0ed947d5069c463e1fda6e7/mangooio-core/src/main/java/io/mangoo/routing/bindings/Validator.java#L197-L199 |
BBN-E/bue-common-open | gnuplot-util/src/main/java/com/bbn/runjobs/GraphRunJobsDependencies.java | GraphRunJobsDependencies.findExecutableOnSystemPath | private static Optional<File> findExecutableOnSystemPath(final String executableName) {
"""
warning: this will fail if the user has an escape path separator in a path
"""
for (final String pathPath : Splitter.on(File.pathSeparator).split(System.getenv("PATH"))) {
final File probeFile = new File(pathPath, executableName);
if (probeFile.isFile() && java.nio.file.Files.isExecutable(probeFile.toPath())) {
return Optional.of(probeFile);
}
}
return Optional.absent();
} | java | private static Optional<File> findExecutableOnSystemPath(final String executableName) {
for (final String pathPath : Splitter.on(File.pathSeparator).split(System.getenv("PATH"))) {
final File probeFile = new File(pathPath, executableName);
if (probeFile.isFile() && java.nio.file.Files.isExecutable(probeFile.toPath())) {
return Optional.of(probeFile);
}
}
return Optional.absent();
} | [
"private",
"static",
"Optional",
"<",
"File",
">",
"findExecutableOnSystemPath",
"(",
"final",
"String",
"executableName",
")",
"{",
"for",
"(",
"final",
"String",
"pathPath",
":",
"Splitter",
".",
"on",
"(",
"File",
".",
"pathSeparator",
")",
".",
"split",
"(",
"System",
".",
"getenv",
"(",
"\"PATH\"",
")",
")",
")",
"{",
"final",
"File",
"probeFile",
"=",
"new",
"File",
"(",
"pathPath",
",",
"executableName",
")",
";",
"if",
"(",
"probeFile",
".",
"isFile",
"(",
")",
"&&",
"java",
".",
"nio",
".",
"file",
".",
"Files",
".",
"isExecutable",
"(",
"probeFile",
".",
"toPath",
"(",
")",
")",
")",
"{",
"return",
"Optional",
".",
"of",
"(",
"probeFile",
")",
";",
"}",
"}",
"return",
"Optional",
".",
"absent",
"(",
")",
";",
"}"
] | warning: this will fail if the user has an escape path separator in a path | [
"warning",
":",
"this",
"will",
"fail",
"if",
"the",
"user",
"has",
"an",
"escape",
"path",
"separator",
"in",
"a",
"path"
] | train | https://github.com/BBN-E/bue-common-open/blob/d618652674d647867306e2e4b987a21b7c29c015/gnuplot-util/src/main/java/com/bbn/runjobs/GraphRunJobsDependencies.java#L85-L93 |
samskivert/samskivert | src/main/java/com/samskivert/util/Collections.java | Collections.getSortedIterator | public static <T extends Comparable<? super T>> Iterator<T> getSortedIterator (Iterable<T> coll) {
"""
Get an Iterator over the supplied Collection that returns the elements in their natural
order.
"""
return getSortedIterator(coll.iterator(), new Comparator<T>() {
public int compare (T o1, T o2) {
if (o1 == o2) { // catches null == null
return 0;
} else if (o1 == null) {
return 1;
} else if (o2 == null) {
return -1;
}
return o1.compareTo(o2); // null-free
}
});
} | java | public static <T extends Comparable<? super T>> Iterator<T> getSortedIterator (Iterable<T> coll)
{
return getSortedIterator(coll.iterator(), new Comparator<T>() {
public int compare (T o1, T o2) {
if (o1 == o2) { // catches null == null
return 0;
} else if (o1 == null) {
return 1;
} else if (o2 == null) {
return -1;
}
return o1.compareTo(o2); // null-free
}
});
} | [
"public",
"static",
"<",
"T",
"extends",
"Comparable",
"<",
"?",
"super",
"T",
">",
">",
"Iterator",
"<",
"T",
">",
"getSortedIterator",
"(",
"Iterable",
"<",
"T",
">",
"coll",
")",
"{",
"return",
"getSortedIterator",
"(",
"coll",
".",
"iterator",
"(",
")",
",",
"new",
"Comparator",
"<",
"T",
">",
"(",
")",
"{",
"public",
"int",
"compare",
"(",
"T",
"o1",
",",
"T",
"o2",
")",
"{",
"if",
"(",
"o1",
"==",
"o2",
")",
"{",
"// catches null == null",
"return",
"0",
";",
"}",
"else",
"if",
"(",
"o1",
"==",
"null",
")",
"{",
"return",
"1",
";",
"}",
"else",
"if",
"(",
"o2",
"==",
"null",
")",
"{",
"return",
"-",
"1",
";",
"}",
"return",
"o1",
".",
"compareTo",
"(",
"o2",
")",
";",
"// null-free",
"}",
"}",
")",
";",
"}"
] | Get an Iterator over the supplied Collection that returns the elements in their natural
order. | [
"Get",
"an",
"Iterator",
"over",
"the",
"supplied",
"Collection",
"that",
"returns",
"the",
"elements",
"in",
"their",
"natural",
"order",
"."
] | train | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Collections.java#L36-L50 |
raydac/java-comment-preprocessor | jcp/src/main/java/com/igormaznitsa/jcp/expression/ExpressionTreeElement.java | ExpressionTreeElement.addElementToNextFreeSlot | private void addElementToNextFreeSlot(@Nonnull final ExpressionTreeElement element) {
"""
Add an expression element into the next free child slot
@param element an element to be added, must not be null
"""
if (element == null) {
throw new PreprocessorException("[Expression]Element is null", this.sourceString, this.includeStack, null);
}
if (childElements.length == 0) {
throw new PreprocessorException("[Expression]Unexpected element, may be unknown function [" + savedItem.toString() + ']', this.sourceString, this.includeStack, null);
} else if (isFull()) {
throw new PreprocessorException("[Expression]There is not any possibility to add new argument [" + savedItem.toString() + ']', this.sourceString, this.includeStack, null);
} else {
childElements[nextChildSlot++] = element;
}
element.parentTreeElement = this;
} | java | private void addElementToNextFreeSlot(@Nonnull final ExpressionTreeElement element) {
if (element == null) {
throw new PreprocessorException("[Expression]Element is null", this.sourceString, this.includeStack, null);
}
if (childElements.length == 0) {
throw new PreprocessorException("[Expression]Unexpected element, may be unknown function [" + savedItem.toString() + ']', this.sourceString, this.includeStack, null);
} else if (isFull()) {
throw new PreprocessorException("[Expression]There is not any possibility to add new argument [" + savedItem.toString() + ']', this.sourceString, this.includeStack, null);
} else {
childElements[nextChildSlot++] = element;
}
element.parentTreeElement = this;
} | [
"private",
"void",
"addElementToNextFreeSlot",
"(",
"@",
"Nonnull",
"final",
"ExpressionTreeElement",
"element",
")",
"{",
"if",
"(",
"element",
"==",
"null",
")",
"{",
"throw",
"new",
"PreprocessorException",
"(",
"\"[Expression]Element is null\"",
",",
"this",
".",
"sourceString",
",",
"this",
".",
"includeStack",
",",
"null",
")",
";",
"}",
"if",
"(",
"childElements",
".",
"length",
"==",
"0",
")",
"{",
"throw",
"new",
"PreprocessorException",
"(",
"\"[Expression]Unexpected element, may be unknown function [\"",
"+",
"savedItem",
".",
"toString",
"(",
")",
"+",
"'",
"'",
",",
"this",
".",
"sourceString",
",",
"this",
".",
"includeStack",
",",
"null",
")",
";",
"}",
"else",
"if",
"(",
"isFull",
"(",
")",
")",
"{",
"throw",
"new",
"PreprocessorException",
"(",
"\"[Expression]There is not any possibility to add new argument [\"",
"+",
"savedItem",
".",
"toString",
"(",
")",
"+",
"'",
"'",
",",
"this",
".",
"sourceString",
",",
"this",
".",
"includeStack",
",",
"null",
")",
";",
"}",
"else",
"{",
"childElements",
"[",
"nextChildSlot",
"++",
"]",
"=",
"element",
";",
"}",
"element",
".",
"parentTreeElement",
"=",
"this",
";",
"}"
] | Add an expression element into the next free child slot
@param element an element to be added, must not be null | [
"Add",
"an",
"expression",
"element",
"into",
"the",
"next",
"free",
"child",
"slot"
] | train | https://github.com/raydac/java-comment-preprocessor/blob/83ac87b575ac084914d77695a8c8673de3b8300c/jcp/src/main/java/com/igormaznitsa/jcp/expression/ExpressionTreeElement.java#L347-L360 |
alkacon/opencms-core | src/org/opencms/search/fields/CmsSearchFieldConfiguration.java | CmsSearchFieldConfiguration.getLocaleExtendedName | public static final String getLocaleExtendedName(String lookup, String locale) {
"""
Returns the locale extended name for the given lookup String.<p>
@param lookup the lookup String
@param locale the locale
@return the locale extended name for the given lookup String
"""
StringBuffer result = new StringBuffer(32);
result.append(lookup);
result.append('_');
result.append(locale);
return result.toString();
} | java | public static final String getLocaleExtendedName(String lookup, String locale) {
StringBuffer result = new StringBuffer(32);
result.append(lookup);
result.append('_');
result.append(locale);
return result.toString();
} | [
"public",
"static",
"final",
"String",
"getLocaleExtendedName",
"(",
"String",
"lookup",
",",
"String",
"locale",
")",
"{",
"StringBuffer",
"result",
"=",
"new",
"StringBuffer",
"(",
"32",
")",
";",
"result",
".",
"append",
"(",
"lookup",
")",
";",
"result",
".",
"append",
"(",
"'",
"'",
")",
";",
"result",
".",
"append",
"(",
"locale",
")",
";",
"return",
"result",
".",
"toString",
"(",
")",
";",
"}"
] | Returns the locale extended name for the given lookup String.<p>
@param lookup the lookup String
@param locale the locale
@return the locale extended name for the given lookup String | [
"Returns",
"the",
"locale",
"extended",
"name",
"for",
"the",
"given",
"lookup",
"String",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/search/fields/CmsSearchFieldConfiguration.java#L111-L118 |
alibaba/canal | client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/config/common/MutablePropertySources.java | MutablePropertySources.addAtIndex | private void addAtIndex(int index, PropertySource<?> propertySource) {
"""
Add the given property source at a particular index in the list.
"""
removeIfPresent(propertySource);
this.propertySourceList.add(index, propertySource);
} | java | private void addAtIndex(int index, PropertySource<?> propertySource) {
removeIfPresent(propertySource);
this.propertySourceList.add(index, propertySource);
} | [
"private",
"void",
"addAtIndex",
"(",
"int",
"index",
",",
"PropertySource",
"<",
"?",
">",
"propertySource",
")",
"{",
"removeIfPresent",
"(",
"propertySource",
")",
";",
"this",
".",
"propertySourceList",
".",
"add",
"(",
"index",
",",
"propertySource",
")",
";",
"}"
] | Add the given property source at a particular index in the list. | [
"Add",
"the",
"given",
"property",
"source",
"at",
"a",
"particular",
"index",
"in",
"the",
"list",
"."
] | train | https://github.com/alibaba/canal/blob/8f088cddc0755f4350c5aaae95c6e4002d90a40f/client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/config/common/MutablePropertySources.java#L202-L205 |
UrielCh/ovh-java-sdk | ovh-java-sdk-emailpro/src/main/java/net/minidev/ovh/api/ApiOvhEmailpro.java | ApiOvhEmailpro.service_domain_domainName_GET | public OvhDomain service_domain_domainName_GET(String service, String domainName) throws IOException {
"""
Get this object properties
REST: GET /email/pro/{service}/domain/{domainName}
@param service [required] The internal name of your pro organization
@param domainName [required] Domain name
API beta
"""
String qPath = "/email/pro/{service}/domain/{domainName}";
StringBuilder sb = path(qPath, service, domainName);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhDomain.class);
} | java | public OvhDomain service_domain_domainName_GET(String service, String domainName) throws IOException {
String qPath = "/email/pro/{service}/domain/{domainName}";
StringBuilder sb = path(qPath, service, domainName);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhDomain.class);
} | [
"public",
"OvhDomain",
"service_domain_domainName_GET",
"(",
"String",
"service",
",",
"String",
"domainName",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/email/pro/{service}/domain/{domainName}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"service",
",",
"domainName",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhDomain",
".",
"class",
")",
";",
"}"
] | Get this object properties
REST: GET /email/pro/{service}/domain/{domainName}
@param service [required] The internal name of your pro organization
@param domainName [required] Domain name
API beta | [
"Get",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-emailpro/src/main/java/net/minidev/ovh/api/ApiOvhEmailpro.java#L857-L862 |
google/error-prone-javac | src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlWriter.java | HtmlWriter.getBody | public HtmlTree getBody(boolean includeScript, String title) {
"""
Returns an HtmlTree for the BODY tag.
@param includeScript set true if printing windowtitle script
@param title title for the window
@return an HtmlTree for the BODY tag
"""
HtmlTree body = new HtmlTree(HtmlTag.BODY);
// Set window title string which is later printed
this.winTitle = title;
// Don't print windowtitle script for overview-frame, allclasses-frame
// and package-frame
if (includeScript) {
this.script = getWinTitleScript();
body.addContent(script);
Content noScript = HtmlTree.NOSCRIPT(
HtmlTree.DIV(configuration.getContent("doclet.No_Script_Message")));
body.addContent(noScript);
}
return body;
} | java | public HtmlTree getBody(boolean includeScript, String title) {
HtmlTree body = new HtmlTree(HtmlTag.BODY);
// Set window title string which is later printed
this.winTitle = title;
// Don't print windowtitle script for overview-frame, allclasses-frame
// and package-frame
if (includeScript) {
this.script = getWinTitleScript();
body.addContent(script);
Content noScript = HtmlTree.NOSCRIPT(
HtmlTree.DIV(configuration.getContent("doclet.No_Script_Message")));
body.addContent(noScript);
}
return body;
} | [
"public",
"HtmlTree",
"getBody",
"(",
"boolean",
"includeScript",
",",
"String",
"title",
")",
"{",
"HtmlTree",
"body",
"=",
"new",
"HtmlTree",
"(",
"HtmlTag",
".",
"BODY",
")",
";",
"// Set window title string which is later printed",
"this",
".",
"winTitle",
"=",
"title",
";",
"// Don't print windowtitle script for overview-frame, allclasses-frame",
"// and package-frame",
"if",
"(",
"includeScript",
")",
"{",
"this",
".",
"script",
"=",
"getWinTitleScript",
"(",
")",
";",
"body",
".",
"addContent",
"(",
"script",
")",
";",
"Content",
"noScript",
"=",
"HtmlTree",
".",
"NOSCRIPT",
"(",
"HtmlTree",
".",
"DIV",
"(",
"configuration",
".",
"getContent",
"(",
"\"doclet.No_Script_Message\"",
")",
")",
")",
";",
"body",
".",
"addContent",
"(",
"noScript",
")",
";",
"}",
"return",
"body",
";",
"}"
] | Returns an HtmlTree for the BODY tag.
@param includeScript set true if printing windowtitle script
@param title title for the window
@return an HtmlTree for the BODY tag | [
"Returns",
"an",
"HtmlTree",
"for",
"the",
"BODY",
"tag",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlWriter.java#L312-L326 |
ManfredTremmel/gwt-commons-lang3 | src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java | MethodUtils.invokeMethod | public static Object invokeMethod(final Object object, final String methodName) throws NoSuchMethodException,
IllegalAccessException, InvocationTargetException {
"""
<p>Invokes a named method without parameters.</p>
<p>This method delegates the method search to {@link #getMatchingAccessibleMethod(Class, String, Class[])}.</p>
<p>This is a convenient wrapper for
{@link #invokeMethod(Object object,String methodName, Object[] args, Class[] parameterTypes)}.
</p>
@param object invoke method on this object
@param methodName get method with this name
@return The value returned by the invoked method
@throws NoSuchMethodException if there is no such accessible method
@throws InvocationTargetException wraps an exception thrown by the method invoked
@throws IllegalAccessException if the requested method is not accessible via reflection
@since 3.4
"""
return invokeMethod(object, methodName, ArrayUtils.EMPTY_OBJECT_ARRAY, null);
} | java | public static Object invokeMethod(final Object object, final String methodName) throws NoSuchMethodException,
IllegalAccessException, InvocationTargetException {
return invokeMethod(object, methodName, ArrayUtils.EMPTY_OBJECT_ARRAY, null);
} | [
"public",
"static",
"Object",
"invokeMethod",
"(",
"final",
"Object",
"object",
",",
"final",
"String",
"methodName",
")",
"throws",
"NoSuchMethodException",
",",
"IllegalAccessException",
",",
"InvocationTargetException",
"{",
"return",
"invokeMethod",
"(",
"object",
",",
"methodName",
",",
"ArrayUtils",
".",
"EMPTY_OBJECT_ARRAY",
",",
"null",
")",
";",
"}"
] | <p>Invokes a named method without parameters.</p>
<p>This method delegates the method search to {@link #getMatchingAccessibleMethod(Class, String, Class[])}.</p>
<p>This is a convenient wrapper for
{@link #invokeMethod(Object object,String methodName, Object[] args, Class[] parameterTypes)}.
</p>
@param object invoke method on this object
@param methodName get method with this name
@return The value returned by the invoked method
@throws NoSuchMethodException if there is no such accessible method
@throws InvocationTargetException wraps an exception thrown by the method invoked
@throws IllegalAccessException if the requested method is not accessible via reflection
@since 3.4 | [
"<p",
">",
"Invokes",
"a",
"named",
"method",
"without",
"parameters",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java#L96-L99 |
Samsung/GearVRf | GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/WidgetFactory.java | WidgetFactory.createWidgetFromModel | @SuppressWarnings("WeakerAccess")
public static Widget createWidgetFromModel(final GVRContext gvrContext,
final String modelFile, Class<? extends Widget> widgetClass)
throws InstantiationException, IOException {
"""
Create a {@link Widget} of the specified {@code widgetClass} to wrap the
root {@link GVRSceneObject} of the scene graph loaded from a file.
@param gvrContext
The {@link GVRContext} to load the model into.
@param modelFile
The asset file to load the model from.
@param widgetClass
The {@linkplain Class} of the {@code Widget} to wrap the root
{@code GVRSceneObject} with.
@return A new {@code AbsoluteLayout} instance.
@throws InstantiationException
If the {@code Widget} can't be instantiated for any reason.
@throws IOException
If the model file can't be read.
"""
GVRSceneObject rootNode = loadModel(gvrContext, modelFile);
return createWidget(rootNode, widgetClass);
} | java | @SuppressWarnings("WeakerAccess")
public static Widget createWidgetFromModel(final GVRContext gvrContext,
final String modelFile, Class<? extends Widget> widgetClass)
throws InstantiationException, IOException {
GVRSceneObject rootNode = loadModel(gvrContext, modelFile);
return createWidget(rootNode, widgetClass);
} | [
"@",
"SuppressWarnings",
"(",
"\"WeakerAccess\"",
")",
"public",
"static",
"Widget",
"createWidgetFromModel",
"(",
"final",
"GVRContext",
"gvrContext",
",",
"final",
"String",
"modelFile",
",",
"Class",
"<",
"?",
"extends",
"Widget",
">",
"widgetClass",
")",
"throws",
"InstantiationException",
",",
"IOException",
"{",
"GVRSceneObject",
"rootNode",
"=",
"loadModel",
"(",
"gvrContext",
",",
"modelFile",
")",
";",
"return",
"createWidget",
"(",
"rootNode",
",",
"widgetClass",
")",
";",
"}"
] | Create a {@link Widget} of the specified {@code widgetClass} to wrap the
root {@link GVRSceneObject} of the scene graph loaded from a file.
@param gvrContext
The {@link GVRContext} to load the model into.
@param modelFile
The asset file to load the model from.
@param widgetClass
The {@linkplain Class} of the {@code Widget} to wrap the root
{@code GVRSceneObject} with.
@return A new {@code AbsoluteLayout} instance.
@throws InstantiationException
If the {@code Widget} can't be instantiated for any reason.
@throws IOException
If the model file can't be read. | [
"Create",
"a",
"{",
"@link",
"Widget",
"}",
"of",
"the",
"specified",
"{",
"@code",
"widgetClass",
"}",
"to",
"wrap",
"the",
"root",
"{",
"@link",
"GVRSceneObject",
"}",
"of",
"the",
"scene",
"graph",
"loaded",
"from",
"a",
"file",
"."
] | train | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/widgetLib/src/org/gearvrf/widgetlib/widget/WidgetFactory.java#L178-L184 |
mozilla/rhino | toolsrc/org/mozilla/javascript/tools/debugger/Main.java | Main.mainEmbedded | public static Main mainEmbedded(ContextFactory factory,
Scriptable scope,
String title) {
"""
Entry point for embedded applications. This method attaches
to the given {@link ContextFactory} with the given scope. No
I/O redirection is performed as with {@link #main(String[])}.
"""
return mainEmbeddedImpl(factory, scope, title);
} | java | public static Main mainEmbedded(ContextFactory factory,
Scriptable scope,
String title) {
return mainEmbeddedImpl(factory, scope, title);
} | [
"public",
"static",
"Main",
"mainEmbedded",
"(",
"ContextFactory",
"factory",
",",
"Scriptable",
"scope",
",",
"String",
"title",
")",
"{",
"return",
"mainEmbeddedImpl",
"(",
"factory",
",",
"scope",
",",
"title",
")",
";",
"}"
] | Entry point for embedded applications. This method attaches
to the given {@link ContextFactory} with the given scope. No
I/O redirection is performed as with {@link #main(String[])}. | [
"Entry",
"point",
"for",
"embedded",
"applications",
".",
"This",
"method",
"attaches",
"to",
"the",
"given",
"{"
] | train | https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/toolsrc/org/mozilla/javascript/tools/debugger/Main.java#L251-L255 |
UrielCh/ovh-java-sdk | ovh-java-sdk-packxdsl/src/main/java/net/minidev/ovh/api/ApiOvhPackxdsl.java | ApiOvhPackxdsl.packName_resiliationFollowUp_GET | public OvhResiliationFollowUpDetail packName_resiliationFollowUp_GET(String packName) throws IOException {
"""
Get information about the ongoing resiliation
REST: GET /pack/xdsl/{packName}/resiliationFollowUp
@param packName [required] The internal name of your pack
"""
String qPath = "/pack/xdsl/{packName}/resiliationFollowUp";
StringBuilder sb = path(qPath, packName);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhResiliationFollowUpDetail.class);
} | java | public OvhResiliationFollowUpDetail packName_resiliationFollowUp_GET(String packName) throws IOException {
String qPath = "/pack/xdsl/{packName}/resiliationFollowUp";
StringBuilder sb = path(qPath, packName);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhResiliationFollowUpDetail.class);
} | [
"public",
"OvhResiliationFollowUpDetail",
"packName_resiliationFollowUp_GET",
"(",
"String",
"packName",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/pack/xdsl/{packName}/resiliationFollowUp\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"packName",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhResiliationFollowUpDetail",
".",
"class",
")",
";",
"}"
] | Get information about the ongoing resiliation
REST: GET /pack/xdsl/{packName}/resiliationFollowUp
@param packName [required] The internal name of your pack | [
"Get",
"information",
"about",
"the",
"ongoing",
"resiliation"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-packxdsl/src/main/java/net/minidev/ovh/api/ApiOvhPackxdsl.java#L72-L77 |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/clusterframework/types/SlotProfile.java | SlotProfile.priorAllocation | public static SlotProfile priorAllocation(ResourceProfile resourceProfile, Collection<AllocationID> priorAllocations) {
"""
Returns a slot profile for the given resource profile and the prior allocations.
@param resourceProfile specifying the slot requirements
@param priorAllocations specifying the prior allocations
@return Slot profile with the given resource profile and prior allocations
"""
return new SlotProfile(resourceProfile, Collections.emptyList(), priorAllocations);
} | java | public static SlotProfile priorAllocation(ResourceProfile resourceProfile, Collection<AllocationID> priorAllocations) {
return new SlotProfile(resourceProfile, Collections.emptyList(), priorAllocations);
} | [
"public",
"static",
"SlotProfile",
"priorAllocation",
"(",
"ResourceProfile",
"resourceProfile",
",",
"Collection",
"<",
"AllocationID",
">",
"priorAllocations",
")",
"{",
"return",
"new",
"SlotProfile",
"(",
"resourceProfile",
",",
"Collections",
".",
"emptyList",
"(",
")",
",",
"priorAllocations",
")",
";",
"}"
] | Returns a slot profile for the given resource profile and the prior allocations.
@param resourceProfile specifying the slot requirements
@param priorAllocations specifying the prior allocations
@return Slot profile with the given resource profile and prior allocations | [
"Returns",
"a",
"slot",
"profile",
"for",
"the",
"given",
"resource",
"profile",
"and",
"the",
"prior",
"allocations",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/clusterframework/types/SlotProfile.java#L143-L145 |
exoplatform/jcr | exo.jcr.framework.command/src/main/java/org/exoplatform/frameworks/jcr/command/JCRCommandHelper.java | JCRCommandHelper.createResourceFile | public static Node createResourceFile(Node parentNode, String relPath, Object data, String mimeType)
throws Exception {
"""
creates nt:file node and fills it with incoming data
@param parentNode
@param relPath
@param data
@param mimeType
@return
@throws Exception
"""
Node file = parentNode.addNode(relPath, "nt:file");
Node contentNode = file.addNode("jcr:content", "nt:resource");
if (data instanceof InputStream)
contentNode.setProperty("jcr:data", (InputStream)data);
else if (data instanceof String)
contentNode.setProperty("jcr:data", (String)data);
// else if(data instanceof BinaryValue)
// contentNode.setProperty("jcr:data", (BinaryValue)data);
else
throw new Exception("Invalid object for jcr:data " + data);
contentNode.setProperty("jcr:mimeType", mimeType);
contentNode.setProperty("jcr:lastModified", Calendar.getInstance());
return file;
} | java | public static Node createResourceFile(Node parentNode, String relPath, Object data, String mimeType)
throws Exception
{
Node file = parentNode.addNode(relPath, "nt:file");
Node contentNode = file.addNode("jcr:content", "nt:resource");
if (data instanceof InputStream)
contentNode.setProperty("jcr:data", (InputStream)data);
else if (data instanceof String)
contentNode.setProperty("jcr:data", (String)data);
// else if(data instanceof BinaryValue)
// contentNode.setProperty("jcr:data", (BinaryValue)data);
else
throw new Exception("Invalid object for jcr:data " + data);
contentNode.setProperty("jcr:mimeType", mimeType);
contentNode.setProperty("jcr:lastModified", Calendar.getInstance());
return file;
} | [
"public",
"static",
"Node",
"createResourceFile",
"(",
"Node",
"parentNode",
",",
"String",
"relPath",
",",
"Object",
"data",
",",
"String",
"mimeType",
")",
"throws",
"Exception",
"{",
"Node",
"file",
"=",
"parentNode",
".",
"addNode",
"(",
"relPath",
",",
"\"nt:file\"",
")",
";",
"Node",
"contentNode",
"=",
"file",
".",
"addNode",
"(",
"\"jcr:content\"",
",",
"\"nt:resource\"",
")",
";",
"if",
"(",
"data",
"instanceof",
"InputStream",
")",
"contentNode",
".",
"setProperty",
"(",
"\"jcr:data\"",
",",
"(",
"InputStream",
")",
"data",
")",
";",
"else",
"if",
"(",
"data",
"instanceof",
"String",
")",
"contentNode",
".",
"setProperty",
"(",
"\"jcr:data\"",
",",
"(",
"String",
")",
"data",
")",
";",
"// else if(data instanceof BinaryValue)",
"// contentNode.setProperty(\"jcr:data\", (BinaryValue)data);",
"else",
"throw",
"new",
"Exception",
"(",
"\"Invalid object for jcr:data \"",
"+",
"data",
")",
";",
"contentNode",
".",
"setProperty",
"(",
"\"jcr:mimeType\"",
",",
"mimeType",
")",
";",
"contentNode",
".",
"setProperty",
"(",
"\"jcr:lastModified\"",
",",
"Calendar",
".",
"getInstance",
"(",
")",
")",
";",
"return",
"file",
";",
"}"
] | creates nt:file node and fills it with incoming data
@param parentNode
@param relPath
@param data
@param mimeType
@return
@throws Exception | [
"creates",
"nt",
":",
"file",
"node",
"and",
"fills",
"it",
"with",
"incoming",
"data"
] | train | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.framework.command/src/main/java/org/exoplatform/frameworks/jcr/command/JCRCommandHelper.java#L49-L69 |
magro/memcached-session-manager | core/src/main/java/de/javakaffee/web/msm/TranscoderService.java | TranscoderService.encodeNum | public static int encodeNum( final long num, final byte[] data, final int beginIndex, final int maxBytes ) {
"""
Convert a number to bytes (with length of maxBytes) and write bytes into
the provided byte[] data starting at the specified beginIndex.
@param num
the number to encode
@param data
the byte array into that the number is encoded
@param beginIndex
the beginning index of data where to start encoding,
inclusive.
@param maxBytes
the number of bytes to store for the number
@return the next beginIndex (<code>beginIndex + maxBytes</code>).
"""
for ( int i = 0; i < maxBytes; i++ ) {
final int pos = maxBytes - i - 1; // the position of the byte in the number
final int idx = beginIndex + pos; // the index in the data array
data[idx] = (byte) ( ( num >> ( 8 * i ) ) & 0xff );
}
return beginIndex + maxBytes;
} | java | public static int encodeNum( final long num, final byte[] data, final int beginIndex, final int maxBytes ) {
for ( int i = 0; i < maxBytes; i++ ) {
final int pos = maxBytes - i - 1; // the position of the byte in the number
final int idx = beginIndex + pos; // the index in the data array
data[idx] = (byte) ( ( num >> ( 8 * i ) ) & 0xff );
}
return beginIndex + maxBytes;
} | [
"public",
"static",
"int",
"encodeNum",
"(",
"final",
"long",
"num",
",",
"final",
"byte",
"[",
"]",
"data",
",",
"final",
"int",
"beginIndex",
",",
"final",
"int",
"maxBytes",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"maxBytes",
";",
"i",
"++",
")",
"{",
"final",
"int",
"pos",
"=",
"maxBytes",
"-",
"i",
"-",
"1",
";",
"// the position of the byte in the number",
"final",
"int",
"idx",
"=",
"beginIndex",
"+",
"pos",
";",
"// the index in the data array",
"data",
"[",
"idx",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"num",
">>",
"(",
"8",
"*",
"i",
")",
")",
"&",
"0xff",
")",
";",
"}",
"return",
"beginIndex",
"+",
"maxBytes",
";",
"}"
] | Convert a number to bytes (with length of maxBytes) and write bytes into
the provided byte[] data starting at the specified beginIndex.
@param num
the number to encode
@param data
the byte array into that the number is encoded
@param beginIndex
the beginning index of data where to start encoding,
inclusive.
@param maxBytes
the number of bytes to store for the number
@return the next beginIndex (<code>beginIndex + maxBytes</code>). | [
"Convert",
"a",
"number",
"to",
"bytes",
"(",
"with",
"length",
"of",
"maxBytes",
")",
"and",
"write",
"bytes",
"into",
"the",
"provided",
"byte",
"[]",
"data",
"starting",
"at",
"the",
"specified",
"beginIndex",
"."
] | train | https://github.com/magro/memcached-session-manager/blob/716e147c9840ab10298c4d2b9edd0662058331e6/core/src/main/java/de/javakaffee/web/msm/TranscoderService.java#L500-L507 |
haraldk/TwelveMonkeys | imageio/imageio-clippath/src/main/java/com/twelvemonkeys/imageio/path/Paths.java | Paths.readClipped | public static BufferedImage readClipped(final ImageInputStream stream) throws IOException {
"""
Reads the clipping path from the given input stream, if any,
and applies it to the first image in the stream.
If no path was found, the image is returned without any clipping.
Supports PSD, JPEG and TIFF as container formats for Photoshop resources.
@param stream the stream to read from, not {@code null}
@return the clipped image
@throws IOException if a general I/O exception occurs during reading.
@throws javax.imageio.IIOException if the input contains a bad image or path data.
@throws java.lang.IllegalArgumentException is {@code stream} is {@code null}.
"""
Shape clip = readPath(stream);
stream.seek(0);
BufferedImage image = ImageIO.read(stream);
if (clip == null) {
return image;
}
return applyClippingPath(clip, image);
} | java | public static BufferedImage readClipped(final ImageInputStream stream) throws IOException {
Shape clip = readPath(stream);
stream.seek(0);
BufferedImage image = ImageIO.read(stream);
if (clip == null) {
return image;
}
return applyClippingPath(clip, image);
} | [
"public",
"static",
"BufferedImage",
"readClipped",
"(",
"final",
"ImageInputStream",
"stream",
")",
"throws",
"IOException",
"{",
"Shape",
"clip",
"=",
"readPath",
"(",
"stream",
")",
";",
"stream",
".",
"seek",
"(",
"0",
")",
";",
"BufferedImage",
"image",
"=",
"ImageIO",
".",
"read",
"(",
"stream",
")",
";",
"if",
"(",
"clip",
"==",
"null",
")",
"{",
"return",
"image",
";",
"}",
"return",
"applyClippingPath",
"(",
"clip",
",",
"image",
")",
";",
"}"
] | Reads the clipping path from the given input stream, if any,
and applies it to the first image in the stream.
If no path was found, the image is returned without any clipping.
Supports PSD, JPEG and TIFF as container formats for Photoshop resources.
@param stream the stream to read from, not {@code null}
@return the clipped image
@throws IOException if a general I/O exception occurs during reading.
@throws javax.imageio.IIOException if the input contains a bad image or path data.
@throws java.lang.IllegalArgumentException is {@code stream} is {@code null}. | [
"Reads",
"the",
"clipping",
"path",
"from",
"the",
"given",
"input",
"stream",
"if",
"any",
"and",
"applies",
"it",
"to",
"the",
"first",
"image",
"in",
"the",
"stream",
".",
"If",
"no",
"path",
"was",
"found",
"the",
"image",
"is",
"returned",
"without",
"any",
"clipping",
".",
"Supports",
"PSD",
"JPEG",
"and",
"TIFF",
"as",
"container",
"formats",
"for",
"Photoshop",
"resources",
"."
] | train | https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/imageio/imageio-clippath/src/main/java/com/twelvemonkeys/imageio/path/Paths.java#L244-L255 |
mygreen/excel-cellformatter | src/main/java/com/github/mygreen/cellformatter/lang/Utils.java | Utils.equalsAnyIgnoreCase | public static boolean equalsAnyIgnoreCase(final String str, final String[] list) {
"""
大文字・小文字を無視して、何れかの文字と等しいか。
<pre>
Utils.equalsAnyIgnoreCase("abc", null) = false
Utils.equalsAnyIgnoreCase("abc", new String[]{}) = false
Utils.equalsAnyIgnoreCase(null, new String[]{"abc"}) = false
Utils.equalsAnyIgnoreCase("", new String[]{""}) = true
</pre>
@param str
@param list
@return
"""
if(str == null) {
return false;
}
if(list == null || list.length == 0) {
return false;
}
for(String item : list) {
if(str.equalsIgnoreCase(item)) {
return true;
}
}
return false;
} | java | public static boolean equalsAnyIgnoreCase(final String str, final String[] list) {
if(str == null) {
return false;
}
if(list == null || list.length == 0) {
return false;
}
for(String item : list) {
if(str.equalsIgnoreCase(item)) {
return true;
}
}
return false;
} | [
"public",
"static",
"boolean",
"equalsAnyIgnoreCase",
"(",
"final",
"String",
"str",
",",
"final",
"String",
"[",
"]",
"list",
")",
"{",
"if",
"(",
"str",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"list",
"==",
"null",
"||",
"list",
".",
"length",
"==",
"0",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"String",
"item",
":",
"list",
")",
"{",
"if",
"(",
"str",
".",
"equalsIgnoreCase",
"(",
"item",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | 大文字・小文字を無視して、何れかの文字と等しいか。
<pre>
Utils.equalsAnyIgnoreCase("abc", null) = false
Utils.equalsAnyIgnoreCase("abc", new String[]{}) = false
Utils.equalsAnyIgnoreCase(null, new String[]{"abc"}) = false
Utils.equalsAnyIgnoreCase("", new String[]{""}) = true
</pre>
@param str
@param list
@return | [
"大文字・小文字を無視して、何れかの文字と等しいか。",
"<pre",
">",
"Utils",
".",
"equalsAnyIgnoreCase",
"(",
"abc",
"null",
")",
"=",
"false",
"Utils",
".",
"equalsAnyIgnoreCase",
"(",
"abc",
"new",
"String",
"[]",
"{}",
")",
"=",
"false",
"Utils",
".",
"equalsAnyIgnoreCase",
"(",
"null",
"new",
"String",
"[]",
"{",
"abc",
"}",
")",
"=",
"false",
"Utils",
".",
"equalsAnyIgnoreCase",
"(",
"new",
"String",
"[]",
"{",
"}",
")",
"=",
"true",
"<",
"/",
"pre",
">"
] | train | https://github.com/mygreen/excel-cellformatter/blob/e802af273d49889500591e03799c9262cbf29185/src/main/java/com/github/mygreen/cellformatter/lang/Utils.java#L212-L230 |
SonarSource/sonarqube | sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/CharsetValidation.java | CharsetValidation.tryDecode | public boolean tryDecode(byte[] bytes, @Nullable Charset charset) {
"""
Tries to use the given charset to decode the byte array.
@return true if decoding succeeded, false if there was a decoding error.
"""
if (charset == null) {
return false;
}
CharsetDecoder decoder = charset.newDecoder()
.onMalformedInput(CodingErrorAction.REPORT)
.onUnmappableCharacter(CodingErrorAction.REPORT);
try {
decoder.decode(ByteBuffer.wrap(bytes));
} catch (CharacterCodingException e) {
return false;
}
return true;
} | java | public boolean tryDecode(byte[] bytes, @Nullable Charset charset) {
if (charset == null) {
return false;
}
CharsetDecoder decoder = charset.newDecoder()
.onMalformedInput(CodingErrorAction.REPORT)
.onUnmappableCharacter(CodingErrorAction.REPORT);
try {
decoder.decode(ByteBuffer.wrap(bytes));
} catch (CharacterCodingException e) {
return false;
}
return true;
} | [
"public",
"boolean",
"tryDecode",
"(",
"byte",
"[",
"]",
"bytes",
",",
"@",
"Nullable",
"Charset",
"charset",
")",
"{",
"if",
"(",
"charset",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"CharsetDecoder",
"decoder",
"=",
"charset",
".",
"newDecoder",
"(",
")",
".",
"onMalformedInput",
"(",
"CodingErrorAction",
".",
"REPORT",
")",
".",
"onUnmappableCharacter",
"(",
"CodingErrorAction",
".",
"REPORT",
")",
";",
"try",
"{",
"decoder",
".",
"decode",
"(",
"ByteBuffer",
".",
"wrap",
"(",
"bytes",
")",
")",
";",
"}",
"catch",
"(",
"CharacterCodingException",
"e",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Tries to use the given charset to decode the byte array.
@return true if decoding succeeded, false if there was a decoding error. | [
"Tries",
"to",
"use",
"the",
"given",
"charset",
"to",
"decode",
"the",
"byte",
"array",
"."
] | train | https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/CharsetValidation.java#L248-L262 |
finmath/finmath-lib | src/main/java6/net/finmath/montecarlo/interestrate/modelplugins/AbstractLIBORCovarianceModel.java | AbstractLIBORCovarianceModel.getCovariance | public RandomVariableInterface getCovariance(double time, int component1, int component2, RandomVariableInterface[] realizationAtTimeIndex) {
"""
Returns the instantaneous covariance calculated from factor loadings.
@param time The time <i>t</i> at which covariance is requested.
@param component1 Index of component <i>i</i>.
@param component2 Index of component <i>j</i>.
@param realizationAtTimeIndex The realization of the stochastic process.
@return The instantaneous covariance between component <i>i</i> and <i>j</i>.
"""
int timeIndex = timeDiscretization.getTimeIndex(time);
if(timeIndex < 0) {
timeIndex = Math.abs(timeIndex)-2;
}
return getCovariance(timeIndex, component1, component2, realizationAtTimeIndex);
} | java | public RandomVariableInterface getCovariance(double time, int component1, int component2, RandomVariableInterface[] realizationAtTimeIndex) {
int timeIndex = timeDiscretization.getTimeIndex(time);
if(timeIndex < 0) {
timeIndex = Math.abs(timeIndex)-2;
}
return getCovariance(timeIndex, component1, component2, realizationAtTimeIndex);
} | [
"public",
"RandomVariableInterface",
"getCovariance",
"(",
"double",
"time",
",",
"int",
"component1",
",",
"int",
"component2",
",",
"RandomVariableInterface",
"[",
"]",
"realizationAtTimeIndex",
")",
"{",
"int",
"timeIndex",
"=",
"timeDiscretization",
".",
"getTimeIndex",
"(",
"time",
")",
";",
"if",
"(",
"timeIndex",
"<",
"0",
")",
"{",
"timeIndex",
"=",
"Math",
".",
"abs",
"(",
"timeIndex",
")",
"-",
"2",
";",
"}",
"return",
"getCovariance",
"(",
"timeIndex",
",",
"component1",
",",
"component2",
",",
"realizationAtTimeIndex",
")",
";",
"}"
] | Returns the instantaneous covariance calculated from factor loadings.
@param time The time <i>t</i> at which covariance is requested.
@param component1 Index of component <i>i</i>.
@param component2 Index of component <i>j</i>.
@param realizationAtTimeIndex The realization of the stochastic process.
@return The instantaneous covariance between component <i>i</i> and <i>j</i>. | [
"Returns",
"the",
"instantaneous",
"covariance",
"calculated",
"from",
"factor",
"loadings",
"."
] | train | https://github.com/finmath/finmath-lib/blob/a3c067d52dd33feb97d851df6cab130e4116759f/src/main/java6/net/finmath/montecarlo/interestrate/modelplugins/AbstractLIBORCovarianceModel.java#L127-L134 |
b3dgs/lionengine | lionengine-audio-sc68/src/main/java/com/b3dgs/lionengine/audio/sc68/Sc68Format.java | Sc68Format.loadLibrary | private static Sc68Binding loadLibrary() {
"""
Load the library.
@return The library binding.
@throws LionEngineException If error on loading.
"""
try
{
Verbose.info("Load library: ", LIBRARY_NAME);
final Sc68Binding binding = Native.loadLibrary(LIBRARY_NAME, Sc68Binding.class);
Verbose.info("Library ", LIBRARY_NAME, " loaded");
return binding;
}
catch (final LinkageError exception)
{
throw new LionEngineException(exception, ERROR_LOAD_LIBRARY + LIBRARY_NAME);
}
} | java | private static Sc68Binding loadLibrary()
{
try
{
Verbose.info("Load library: ", LIBRARY_NAME);
final Sc68Binding binding = Native.loadLibrary(LIBRARY_NAME, Sc68Binding.class);
Verbose.info("Library ", LIBRARY_NAME, " loaded");
return binding;
}
catch (final LinkageError exception)
{
throw new LionEngineException(exception, ERROR_LOAD_LIBRARY + LIBRARY_NAME);
}
} | [
"private",
"static",
"Sc68Binding",
"loadLibrary",
"(",
")",
"{",
"try",
"{",
"Verbose",
".",
"info",
"(",
"\"Load library: \"",
",",
"LIBRARY_NAME",
")",
";",
"final",
"Sc68Binding",
"binding",
"=",
"Native",
".",
"loadLibrary",
"(",
"LIBRARY_NAME",
",",
"Sc68Binding",
".",
"class",
")",
";",
"Verbose",
".",
"info",
"(",
"\"Library \"",
",",
"LIBRARY_NAME",
",",
"\" loaded\"",
")",
";",
"return",
"binding",
";",
"}",
"catch",
"(",
"final",
"LinkageError",
"exception",
")",
"{",
"throw",
"new",
"LionEngineException",
"(",
"exception",
",",
"ERROR_LOAD_LIBRARY",
"+",
"LIBRARY_NAME",
")",
";",
"}",
"}"
] | Load the library.
@return The library binding.
@throws LionEngineException If error on loading. | [
"Load",
"the",
"library",
"."
] | train | https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-audio-sc68/src/main/java/com/b3dgs/lionengine/audio/sc68/Sc68Format.java#L77-L90 |
b3dgs/lionengine | lionengine-game/src/main/java/com/b3dgs/lionengine/game/feature/tile/map/collision/MapTileCollisionComputer.java | MapTileCollisionComputer.computeCollision | private CollisionResult computeCollision(CollisionCategory category, double ox, double oy, double x, double y) {
"""
Compute the collision from current location.
@param category The collision category.
@param ox The current horizontal location.
@param oy The current vertical location.
@param x The current horizontal location.
@param y The current vertical location.
@return The computed collision result, <code>null</code> if none.
"""
final Tile tile = map.getTileAt(getPositionToSide(ox, x), getPositionToSide(oy, y));
if (tile != null)
{
final TileCollision tileCollision = tile.getFeature(TileCollision.class);
if (containsCollisionFormula(tileCollision, category))
{
final Double cx = getCollisionX(category, tileCollision, x, y);
final Double cy = getCollisionY(category, tileCollision, x, y);
// CHECKSTYLE IGNORE LINE: NestedIfDepth
if (cx != null || cy != null)
{
return new CollisionResult(cx, cy, tile);
}
}
}
return null;
} | java | private CollisionResult computeCollision(CollisionCategory category, double ox, double oy, double x, double y)
{
final Tile tile = map.getTileAt(getPositionToSide(ox, x), getPositionToSide(oy, y));
if (tile != null)
{
final TileCollision tileCollision = tile.getFeature(TileCollision.class);
if (containsCollisionFormula(tileCollision, category))
{
final Double cx = getCollisionX(category, tileCollision, x, y);
final Double cy = getCollisionY(category, tileCollision, x, y);
// CHECKSTYLE IGNORE LINE: NestedIfDepth
if (cx != null || cy != null)
{
return new CollisionResult(cx, cy, tile);
}
}
}
return null;
} | [
"private",
"CollisionResult",
"computeCollision",
"(",
"CollisionCategory",
"category",
",",
"double",
"ox",
",",
"double",
"oy",
",",
"double",
"x",
",",
"double",
"y",
")",
"{",
"final",
"Tile",
"tile",
"=",
"map",
".",
"getTileAt",
"(",
"getPositionToSide",
"(",
"ox",
",",
"x",
")",
",",
"getPositionToSide",
"(",
"oy",
",",
"y",
")",
")",
";",
"if",
"(",
"tile",
"!=",
"null",
")",
"{",
"final",
"TileCollision",
"tileCollision",
"=",
"tile",
".",
"getFeature",
"(",
"TileCollision",
".",
"class",
")",
";",
"if",
"(",
"containsCollisionFormula",
"(",
"tileCollision",
",",
"category",
")",
")",
"{",
"final",
"Double",
"cx",
"=",
"getCollisionX",
"(",
"category",
",",
"tileCollision",
",",
"x",
",",
"y",
")",
";",
"final",
"Double",
"cy",
"=",
"getCollisionY",
"(",
"category",
",",
"tileCollision",
",",
"x",
",",
"y",
")",
";",
"// CHECKSTYLE IGNORE LINE: NestedIfDepth\r",
"if",
"(",
"cx",
"!=",
"null",
"||",
"cy",
"!=",
"null",
")",
"{",
"return",
"new",
"CollisionResult",
"(",
"cx",
",",
"cy",
",",
"tile",
")",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] | Compute the collision from current location.
@param category The collision category.
@param ox The current horizontal location.
@param oy The current vertical location.
@param x The current horizontal location.
@param y The current vertical location.
@return The computed collision result, <code>null</code> if none. | [
"Compute",
"the",
"collision",
"from",
"current",
"location",
"."
] | train | https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-game/src/main/java/com/b3dgs/lionengine/game/feature/tile/map/collision/MapTileCollisionComputer.java#L271-L289 |
zaproxy/zaproxy | src/org/zaproxy/zap/extension/script/ExtensionScript.java | ExtensionScript.loadScript | public ScriptWrapper loadScript(ScriptWrapper script, Charset charset) throws IOException {
"""
Loads the script from the file, using the given charset.
@param script the ScriptWrapper to be loaded (read script from file).
@param charset the charset to use when reading the script from the file.
@return the {@code ScriptWrapper} with the actual script read from the file.
@throws IOException if an error occurred while reading the script from the file.
@throws IllegalArgumentException if the {@code script} or the {@code charset} is {@code null}.
@since 2.7.0
@see #loadScript(ScriptWrapper)
"""
if (script == null) {
throw new IllegalArgumentException("Parameter script must not be null.");
}
if (charset == null) {
throw new IllegalArgumentException("Parameter charset must not be null.");
}
script.loadScript(charset);
if (script.getType() == null) {
// This happens when scripts are loaded from the configs as the types
// may well not have been registered at that stage
script.setType(this.getScriptType(script.getTypeName()));
}
return script;
} | java | public ScriptWrapper loadScript(ScriptWrapper script, Charset charset) throws IOException {
if (script == null) {
throw new IllegalArgumentException("Parameter script must not be null.");
}
if (charset == null) {
throw new IllegalArgumentException("Parameter charset must not be null.");
}
script.loadScript(charset);
if (script.getType() == null) {
// This happens when scripts are loaded from the configs as the types
// may well not have been registered at that stage
script.setType(this.getScriptType(script.getTypeName()));
}
return script;
} | [
"public",
"ScriptWrapper",
"loadScript",
"(",
"ScriptWrapper",
"script",
",",
"Charset",
"charset",
")",
"throws",
"IOException",
"{",
"if",
"(",
"script",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter script must not be null.\"",
")",
";",
"}",
"if",
"(",
"charset",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter charset must not be null.\"",
")",
";",
"}",
"script",
".",
"loadScript",
"(",
"charset",
")",
";",
"if",
"(",
"script",
".",
"getType",
"(",
")",
"==",
"null",
")",
"{",
"// This happens when scripts are loaded from the configs as the types \r",
"// may well not have been registered at that stage\r",
"script",
".",
"setType",
"(",
"this",
".",
"getScriptType",
"(",
"script",
".",
"getTypeName",
"(",
")",
")",
")",
";",
"}",
"return",
"script",
";",
"}"
] | Loads the script from the file, using the given charset.
@param script the ScriptWrapper to be loaded (read script from file).
@param charset the charset to use when reading the script from the file.
@return the {@code ScriptWrapper} with the actual script read from the file.
@throws IOException if an error occurred while reading the script from the file.
@throws IllegalArgumentException if the {@code script} or the {@code charset} is {@code null}.
@since 2.7.0
@see #loadScript(ScriptWrapper) | [
"Loads",
"the",
"script",
"from",
"the",
"file",
"using",
"the",
"given",
"charset",
"."
] | train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/zaproxy/zap/extension/script/ExtensionScript.java#L1155-L1170 |
deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/util/NDArrayMath.java | NDArrayMath.vectorsPerSlice | public static long vectorsPerSlice(INDArray arr, int... rank) {
"""
The number of vectors
in each slice of an ndarray.
@param arr the array to
get the number
of vectors per slice for
@param rank the dimensions to get the number of vectors per slice for
@return the number of vectors per slice
"""
if (arr.rank() > 2) {
return arr.size(-2) * arr.size(-1);
}
return arr.size(-1);
} | java | public static long vectorsPerSlice(INDArray arr, int... rank) {
if (arr.rank() > 2) {
return arr.size(-2) * arr.size(-1);
}
return arr.size(-1);
} | [
"public",
"static",
"long",
"vectorsPerSlice",
"(",
"INDArray",
"arr",
",",
"int",
"...",
"rank",
")",
"{",
"if",
"(",
"arr",
".",
"rank",
"(",
")",
">",
"2",
")",
"{",
"return",
"arr",
".",
"size",
"(",
"-",
"2",
")",
"*",
"arr",
".",
"size",
"(",
"-",
"1",
")",
";",
"}",
"return",
"arr",
".",
"size",
"(",
"-",
"1",
")",
";",
"}"
] | The number of vectors
in each slice of an ndarray.
@param arr the array to
get the number
of vectors per slice for
@param rank the dimensions to get the number of vectors per slice for
@return the number of vectors per slice | [
"The",
"number",
"of",
"vectors",
"in",
"each",
"slice",
"of",
"an",
"ndarray",
"."
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/util/NDArrayMath.java#L144-L151 |
jenkinsci/github-plugin | src/main/java/org/jenkinsci/plugins/github/status/sources/misc/BetterThanOrEqualBuildResult.java | BetterThanOrEqualBuildResult.betterThanOrEqualTo | public static BetterThanOrEqualBuildResult betterThanOrEqualTo(Result result, GHCommitState state, String msg) {
"""
Convenient way to reuse logic of checking for the build status
@param result to check against
@param state state to set
@param msg message to set. Can contain env vars
@return new instance of this conditional result
"""
BetterThanOrEqualBuildResult conditional = new BetterThanOrEqualBuildResult();
conditional.setResult(result.toString());
conditional.setState(state.name());
conditional.setMessage(msg);
return conditional;
} | java | public static BetterThanOrEqualBuildResult betterThanOrEqualTo(Result result, GHCommitState state, String msg) {
BetterThanOrEqualBuildResult conditional = new BetterThanOrEqualBuildResult();
conditional.setResult(result.toString());
conditional.setState(state.name());
conditional.setMessage(msg);
return conditional;
} | [
"public",
"static",
"BetterThanOrEqualBuildResult",
"betterThanOrEqualTo",
"(",
"Result",
"result",
",",
"GHCommitState",
"state",
",",
"String",
"msg",
")",
"{",
"BetterThanOrEqualBuildResult",
"conditional",
"=",
"new",
"BetterThanOrEqualBuildResult",
"(",
")",
";",
"conditional",
".",
"setResult",
"(",
"result",
".",
"toString",
"(",
")",
")",
";",
"conditional",
".",
"setState",
"(",
"state",
".",
"name",
"(",
")",
")",
";",
"conditional",
".",
"setMessage",
"(",
"msg",
")",
";",
"return",
"conditional",
";",
"}"
] | Convenient way to reuse logic of checking for the build status
@param result to check against
@param state state to set
@param msg message to set. Can contain env vars
@return new instance of this conditional result | [
"Convenient",
"way",
"to",
"reuse",
"logic",
"of",
"checking",
"for",
"the",
"build",
"status"
] | train | https://github.com/jenkinsci/github-plugin/blob/4e05b9aeb488af5342c78f78aa3c55114e8d462a/src/main/java/org/jenkinsci/plugins/github/status/sources/misc/BetterThanOrEqualBuildResult.java#L61-L67 |
biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/xtal/CrystalBuilder.java | CrystalBuilder.expandNcsOps | public static void expandNcsOps(Structure structure, Map<String,String> chainOrigNames, Map<String,Matrix4d> chainNcsOps) {
"""
Apply the NCS operators in the given Structure adding new chains as needed.
All chains are (re)assigned ids of the form: original_chain_id+ncs_operator_index+{@value #NCS_CHAINID_SUFFIX_CHAR}.
@param structure
the structure to expand
@param chainOrigNames
new chain names mapped to the original chain names
@param chainNcsOps
new chain names mapped to the ncs operators that was used to generate them
@since 5.0.0
"""
PDBCrystallographicInfo xtalInfo = structure.getCrystallographicInfo();
if (xtalInfo ==null) return;
if (xtalInfo.getNcsOperators()==null || xtalInfo.getNcsOperators().length==0)
return;
List<Chain> chainsToAdd = new ArrayList<>();
Matrix4d identity = new Matrix4d();
identity.setIdentity();
Matrix4d[] ncsOps = xtalInfo.getNcsOperators();
for (Chain c:structure.getChains()) {
String cOrigId = c.getId();
String cOrigName = c.getName();
for (int iOperator = 0; iOperator < ncsOps.length; iOperator++) {
Matrix4d m = ncsOps[iOperator];
Chain clonedChain = (Chain)c.clone();
String newChainId = cOrigId+(iOperator+1)+NCS_CHAINID_SUFFIX_CHAR;
String newChainName = cOrigName+(iOperator+1)+NCS_CHAINID_SUFFIX_CHAR;
clonedChain.setId(newChainId);
clonedChain.setName(newChainName);
setChainIdsInResidueNumbers(clonedChain, newChainName);
Calc.transform(clonedChain, m);
chainsToAdd.add(clonedChain);
c.getEntityInfo().addChain(clonedChain);
chainOrigNames.put(newChainName,cOrigName);
chainNcsOps.put(newChainName,m);
}
chainNcsOps.put(cOrigName,identity);
chainOrigNames.put(cOrigName,cOrigName);
}
chainsToAdd.forEach(structure::addChain);
} | java | public static void expandNcsOps(Structure structure, Map<String,String> chainOrigNames, Map<String,Matrix4d> chainNcsOps) {
PDBCrystallographicInfo xtalInfo = structure.getCrystallographicInfo();
if (xtalInfo ==null) return;
if (xtalInfo.getNcsOperators()==null || xtalInfo.getNcsOperators().length==0)
return;
List<Chain> chainsToAdd = new ArrayList<>();
Matrix4d identity = new Matrix4d();
identity.setIdentity();
Matrix4d[] ncsOps = xtalInfo.getNcsOperators();
for (Chain c:structure.getChains()) {
String cOrigId = c.getId();
String cOrigName = c.getName();
for (int iOperator = 0; iOperator < ncsOps.length; iOperator++) {
Matrix4d m = ncsOps[iOperator];
Chain clonedChain = (Chain)c.clone();
String newChainId = cOrigId+(iOperator+1)+NCS_CHAINID_SUFFIX_CHAR;
String newChainName = cOrigName+(iOperator+1)+NCS_CHAINID_SUFFIX_CHAR;
clonedChain.setId(newChainId);
clonedChain.setName(newChainName);
setChainIdsInResidueNumbers(clonedChain, newChainName);
Calc.transform(clonedChain, m);
chainsToAdd.add(clonedChain);
c.getEntityInfo().addChain(clonedChain);
chainOrigNames.put(newChainName,cOrigName);
chainNcsOps.put(newChainName,m);
}
chainNcsOps.put(cOrigName,identity);
chainOrigNames.put(cOrigName,cOrigName);
}
chainsToAdd.forEach(structure::addChain);
} | [
"public",
"static",
"void",
"expandNcsOps",
"(",
"Structure",
"structure",
",",
"Map",
"<",
"String",
",",
"String",
">",
"chainOrigNames",
",",
"Map",
"<",
"String",
",",
"Matrix4d",
">",
"chainNcsOps",
")",
"{",
"PDBCrystallographicInfo",
"xtalInfo",
"=",
"structure",
".",
"getCrystallographicInfo",
"(",
")",
";",
"if",
"(",
"xtalInfo",
"==",
"null",
")",
"return",
";",
"if",
"(",
"xtalInfo",
".",
"getNcsOperators",
"(",
")",
"==",
"null",
"||",
"xtalInfo",
".",
"getNcsOperators",
"(",
")",
".",
"length",
"==",
"0",
")",
"return",
";",
"List",
"<",
"Chain",
">",
"chainsToAdd",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"Matrix4d",
"identity",
"=",
"new",
"Matrix4d",
"(",
")",
";",
"identity",
".",
"setIdentity",
"(",
")",
";",
"Matrix4d",
"[",
"]",
"ncsOps",
"=",
"xtalInfo",
".",
"getNcsOperators",
"(",
")",
";",
"for",
"(",
"Chain",
"c",
":",
"structure",
".",
"getChains",
"(",
")",
")",
"{",
"String",
"cOrigId",
"=",
"c",
".",
"getId",
"(",
")",
";",
"String",
"cOrigName",
"=",
"c",
".",
"getName",
"(",
")",
";",
"for",
"(",
"int",
"iOperator",
"=",
"0",
";",
"iOperator",
"<",
"ncsOps",
".",
"length",
";",
"iOperator",
"++",
")",
"{",
"Matrix4d",
"m",
"=",
"ncsOps",
"[",
"iOperator",
"]",
";",
"Chain",
"clonedChain",
"=",
"(",
"Chain",
")",
"c",
".",
"clone",
"(",
")",
";",
"String",
"newChainId",
"=",
"cOrigId",
"+",
"(",
"iOperator",
"+",
"1",
")",
"+",
"NCS_CHAINID_SUFFIX_CHAR",
";",
"String",
"newChainName",
"=",
"cOrigName",
"+",
"(",
"iOperator",
"+",
"1",
")",
"+",
"NCS_CHAINID_SUFFIX_CHAR",
";",
"clonedChain",
".",
"setId",
"(",
"newChainId",
")",
";",
"clonedChain",
".",
"setName",
"(",
"newChainName",
")",
";",
"setChainIdsInResidueNumbers",
"(",
"clonedChain",
",",
"newChainName",
")",
";",
"Calc",
".",
"transform",
"(",
"clonedChain",
",",
"m",
")",
";",
"chainsToAdd",
".",
"add",
"(",
"clonedChain",
")",
";",
"c",
".",
"getEntityInfo",
"(",
")",
".",
"addChain",
"(",
"clonedChain",
")",
";",
"chainOrigNames",
".",
"put",
"(",
"newChainName",
",",
"cOrigName",
")",
";",
"chainNcsOps",
".",
"put",
"(",
"newChainName",
",",
"m",
")",
";",
"}",
"chainNcsOps",
".",
"put",
"(",
"cOrigName",
",",
"identity",
")",
";",
"chainOrigNames",
".",
"put",
"(",
"cOrigName",
",",
"cOrigName",
")",
";",
"}",
"chainsToAdd",
".",
"forEach",
"(",
"structure",
"::",
"addChain",
")",
";",
"}"
] | Apply the NCS operators in the given Structure adding new chains as needed.
All chains are (re)assigned ids of the form: original_chain_id+ncs_operator_index+{@value #NCS_CHAINID_SUFFIX_CHAR}.
@param structure
the structure to expand
@param chainOrigNames
new chain names mapped to the original chain names
@param chainNcsOps
new chain names mapped to the ncs operators that was used to generate them
@since 5.0.0 | [
"Apply",
"the",
"NCS",
"operators",
"in",
"the",
"given",
"Structure",
"adding",
"new",
"chains",
"as",
"needed",
".",
"All",
"chains",
"are",
"(",
"re",
")",
"assigned",
"ids",
"of",
"the",
"form",
":",
"original_chain_id",
"+",
"ncs_operator_index",
"+",
"{"
] | train | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/xtal/CrystalBuilder.java#L569-L611 |
brunocvcunha/inutils4j | src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java | DateUtils.rollYears | public static java.sql.Date rollYears(java.util.Date startDate, int years) {
"""
Roll the years forward or backward.
@param startDate - The start date
@param years - Negative to rollbackwards.
"""
return rollDate(startDate, Calendar.YEAR, years);
} | java | public static java.sql.Date rollYears(java.util.Date startDate, int years) {
return rollDate(startDate, Calendar.YEAR, years);
} | [
"public",
"static",
"java",
".",
"sql",
".",
"Date",
"rollYears",
"(",
"java",
".",
"util",
".",
"Date",
"startDate",
",",
"int",
"years",
")",
"{",
"return",
"rollDate",
"(",
"startDate",
",",
"Calendar",
".",
"YEAR",
",",
"years",
")",
";",
"}"
] | Roll the years forward or backward.
@param startDate - The start date
@param years - Negative to rollbackwards. | [
"Roll",
"the",
"years",
"forward",
"or",
"backward",
"."
] | train | https://github.com/brunocvcunha/inutils4j/blob/223c4443c2cee662576ce644e552588fa114aa94/src/main/java/org/brunocvcunha/inutils4j/thirdparty/DateUtils.java#L182-L184 |
googleads/googleads-java-lib | modules/ads_lib/src/main/java/com/google/api/ads/common/lib/factory/helper/BaseAdsServiceClientFactoryHelper.java | BaseAdsServiceClientFactoryHelper.createServiceDescriptor | @Override
public D createServiceDescriptor(Class<?> interfaceClass, String version) {
"""
Creates an {@link AdsServiceDescriptor} for a specified service.
@param interfaceClass the ads service that we want a descriptor for
@param version the version of the service
@return a descriptor of the requested service
"""
return adsServiceDescriptorFactory.create(interfaceClass, version);
} | java | @Override
public D createServiceDescriptor(Class<?> interfaceClass, String version) {
return adsServiceDescriptorFactory.create(interfaceClass, version);
} | [
"@",
"Override",
"public",
"D",
"createServiceDescriptor",
"(",
"Class",
"<",
"?",
">",
"interfaceClass",
",",
"String",
"version",
")",
"{",
"return",
"adsServiceDescriptorFactory",
".",
"create",
"(",
"interfaceClass",
",",
"version",
")",
";",
"}"
] | Creates an {@link AdsServiceDescriptor} for a specified service.
@param interfaceClass the ads service that we want a descriptor for
@param version the version of the service
@return a descriptor of the requested service | [
"Creates",
"an",
"{",
"@link",
"AdsServiceDescriptor",
"}",
"for",
"a",
"specified",
"service",
"."
] | train | https://github.com/googleads/googleads-java-lib/blob/967957cc4f6076514e3a7926fe653e4f1f7cc9c9/modules/ads_lib/src/main/java/com/google/api/ads/common/lib/factory/helper/BaseAdsServiceClientFactoryHelper.java#L96-L99 |
puniverse/capsule | capsule-util/src/main/java/co/paralleluniverse/capsule/Jar.java | Jar.addEntry | public Jar addEntry(String path, InputStream is) throws IOException {
"""
Adds an entry to this JAR.
@param path the entry's path within the JAR
@param is the entry's content
@return {@code this}
"""
beginWriting();
addEntry(jos, path, is);
return this;
} | java | public Jar addEntry(String path, InputStream is) throws IOException {
beginWriting();
addEntry(jos, path, is);
return this;
} | [
"public",
"Jar",
"addEntry",
"(",
"String",
"path",
",",
"InputStream",
"is",
")",
"throws",
"IOException",
"{",
"beginWriting",
"(",
")",
";",
"addEntry",
"(",
"jos",
",",
"path",
",",
"is",
")",
";",
"return",
"this",
";",
"}"
] | Adds an entry to this JAR.
@param path the entry's path within the JAR
@param is the entry's content
@return {@code this} | [
"Adds",
"an",
"entry",
"to",
"this",
"JAR",
"."
] | train | https://github.com/puniverse/capsule/blob/291a54e501a32aaf0284707b8c1fbff6a566822b/capsule-util/src/main/java/co/paralleluniverse/capsule/Jar.java#L295-L299 |
hypercube1024/firefly | firefly-common/src/main/java/com/firefly/utils/codec/HexUtils.java | HexUtils.bytesToHex | public static final String bytesToHex(byte[] bs, int off, int length) {
"""
Converts a byte array into a string of lower case hex chars.
@param bs A byte array
@param off The index of the first byte to read
@param length The number of bytes to read.
@return the string of hex chars.
"""
if (bs.length <= off || bs.length < off + length)
throw new IllegalArgumentException();
StringBuilder sb = new StringBuilder(length * 2);
bytesToHexAppend(bs, off, length, sb);
return sb.toString();
} | java | public static final String bytesToHex(byte[] bs, int off, int length) {
if (bs.length <= off || bs.length < off + length)
throw new IllegalArgumentException();
StringBuilder sb = new StringBuilder(length * 2);
bytesToHexAppend(bs, off, length, sb);
return sb.toString();
} | [
"public",
"static",
"final",
"String",
"bytesToHex",
"(",
"byte",
"[",
"]",
"bs",
",",
"int",
"off",
",",
"int",
"length",
")",
"{",
"if",
"(",
"bs",
".",
"length",
"<=",
"off",
"||",
"bs",
".",
"length",
"<",
"off",
"+",
"length",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"length",
"*",
"2",
")",
";",
"bytesToHexAppend",
"(",
"bs",
",",
"off",
",",
"length",
",",
"sb",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] | Converts a byte array into a string of lower case hex chars.
@param bs A byte array
@param off The index of the first byte to read
@param length The number of bytes to read.
@return the string of hex chars. | [
"Converts",
"a",
"byte",
"array",
"into",
"a",
"string",
"of",
"lower",
"case",
"hex",
"chars",
"."
] | train | https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/codec/HexUtils.java#L19-L25 |
riversun/string-grabber | src/main/java/org/riversun/string_grabber/StringGrabber.java | StringGrabber.insertRepeat | public StringGrabber insertRepeat(String str, int repeatCount) {
"""
Append a string to be repeated into head
@see StringGrabber#insertRepeat(String);
@param str
@param repeatCount
@return
"""
for (int i = 0; i < repeatCount; i++) {
insertIntoHead(str);
}
return StringGrabber.this;
} | java | public StringGrabber insertRepeat(String str, int repeatCount) {
for (int i = 0; i < repeatCount; i++) {
insertIntoHead(str);
}
return StringGrabber.this;
} | [
"public",
"StringGrabber",
"insertRepeat",
"(",
"String",
"str",
",",
"int",
"repeatCount",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"repeatCount",
";",
"i",
"++",
")",
"{",
"insertIntoHead",
"(",
"str",
")",
";",
"}",
"return",
"StringGrabber",
".",
"this",
";",
"}"
] | Append a string to be repeated into head
@see StringGrabber#insertRepeat(String);
@param str
@param repeatCount
@return | [
"Append",
"a",
"string",
"to",
"be",
"repeated",
"into",
"head"
] | train | https://github.com/riversun/string-grabber/blob/b5aadc21fe15f50d35392188dec6ab81dcf8d464/src/main/java/org/riversun/string_grabber/StringGrabber.java#L586-L591 |
Dynatrace/OneAgent-SDK-for-Java | samples/webrequest/src/main/java/com/dynatrace/oneagent/sdk/samples/webrequest/FakedWebserver.java | FakedWebserver.serve | private void serve(HttpRequest request, HttpResponse response) {
"""
faked http request handling. shows usage of OneAgent SDK's incoming webrequest API
"""
String url = request.getUri();
System.out.println("[Server] serve " + url);
IncomingWebRequestTracer incomingWebrequestTracer = oneAgentSDK.traceIncomingWebRequest(webAppInfo, url, request.getMethod());
// add request header, parameter and remote address before start:
for (Entry<String, List<String>> headerField : request.getHeaders().entrySet()) {
for (String value : headerField.getValue()) {
incomingWebrequestTracer.addRequestHeader(headerField.getKey(), value);
}
}
for (Entry<String, List<String>> parameter : request.getParameters().entrySet()) {
for (String value : parameter.getValue()) {
incomingWebrequestTracer.addParameter(parameter.getKey(), value);
}
}
incomingWebrequestTracer.setRemoteAddress(request.getRemoteIpAddress());
incomingWebrequestTracer.start();
try {
response.setContent("Hello world!".getBytes());
response.setStatusCode(200);
incomingWebrequestTracer.setStatusCode(200);
} catch (Exception e) {
// we assume, container is sending http 500 in case of exception is thrown while serving an request:
incomingWebrequestTracer.error(e);
e.printStackTrace();
throw new RuntimeException(e);
} finally {
incomingWebrequestTracer.end();
}
} | java | private void serve(HttpRequest request, HttpResponse response) {
String url = request.getUri();
System.out.println("[Server] serve " + url);
IncomingWebRequestTracer incomingWebrequestTracer = oneAgentSDK.traceIncomingWebRequest(webAppInfo, url, request.getMethod());
// add request header, parameter and remote address before start:
for (Entry<String, List<String>> headerField : request.getHeaders().entrySet()) {
for (String value : headerField.getValue()) {
incomingWebrequestTracer.addRequestHeader(headerField.getKey(), value);
}
}
for (Entry<String, List<String>> parameter : request.getParameters().entrySet()) {
for (String value : parameter.getValue()) {
incomingWebrequestTracer.addParameter(parameter.getKey(), value);
}
}
incomingWebrequestTracer.setRemoteAddress(request.getRemoteIpAddress());
incomingWebrequestTracer.start();
try {
response.setContent("Hello world!".getBytes());
response.setStatusCode(200);
incomingWebrequestTracer.setStatusCode(200);
} catch (Exception e) {
// we assume, container is sending http 500 in case of exception is thrown while serving an request:
incomingWebrequestTracer.error(e);
e.printStackTrace();
throw new RuntimeException(e);
} finally {
incomingWebrequestTracer.end();
}
} | [
"private",
"void",
"serve",
"(",
"HttpRequest",
"request",
",",
"HttpResponse",
"response",
")",
"{",
"String",
"url",
"=",
"request",
".",
"getUri",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"[Server] serve \"",
"+",
"url",
")",
";",
"IncomingWebRequestTracer",
"incomingWebrequestTracer",
"=",
"oneAgentSDK",
".",
"traceIncomingWebRequest",
"(",
"webAppInfo",
",",
"url",
",",
"request",
".",
"getMethod",
"(",
")",
")",
";",
"// add request header, parameter and remote address before start:",
"for",
"(",
"Entry",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"headerField",
":",
"request",
".",
"getHeaders",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"for",
"(",
"String",
"value",
":",
"headerField",
".",
"getValue",
"(",
")",
")",
"{",
"incomingWebrequestTracer",
".",
"addRequestHeader",
"(",
"headerField",
".",
"getKey",
"(",
")",
",",
"value",
")",
";",
"}",
"}",
"for",
"(",
"Entry",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"parameter",
":",
"request",
".",
"getParameters",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"for",
"(",
"String",
"value",
":",
"parameter",
".",
"getValue",
"(",
")",
")",
"{",
"incomingWebrequestTracer",
".",
"addParameter",
"(",
"parameter",
".",
"getKey",
"(",
")",
",",
"value",
")",
";",
"}",
"}",
"incomingWebrequestTracer",
".",
"setRemoteAddress",
"(",
"request",
".",
"getRemoteIpAddress",
"(",
")",
")",
";",
"incomingWebrequestTracer",
".",
"start",
"(",
")",
";",
"try",
"{",
"response",
".",
"setContent",
"(",
"\"Hello world!\"",
".",
"getBytes",
"(",
")",
")",
";",
"response",
".",
"setStatusCode",
"(",
"200",
")",
";",
"incomingWebrequestTracer",
".",
"setStatusCode",
"(",
"200",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// we assume, container is sending http 500 in case of exception is thrown while serving an request:",
"incomingWebrequestTracer",
".",
"error",
"(",
"e",
")",
";",
"e",
".",
"printStackTrace",
"(",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"finally",
"{",
"incomingWebrequestTracer",
".",
"end",
"(",
")",
";",
"}",
"}"
] | faked http request handling. shows usage of OneAgent SDK's incoming webrequest API | [
"faked",
"http",
"request",
"handling",
".",
"shows",
"usage",
"of",
"OneAgent",
"SDK",
"s",
"incoming",
"webrequest",
"API"
] | train | https://github.com/Dynatrace/OneAgent-SDK-for-Java/blob/a554cd971179faf8e598dd93df342a603d39e734/samples/webrequest/src/main/java/com/dynatrace/oneagent/sdk/samples/webrequest/FakedWebserver.java#L110-L141 |
Netflix/spectator | spectator-api/src/main/java/com/netflix/spectator/api/Utils.java | Utils.computeIfAbsent | public static <K, V> V computeIfAbsent(ConcurrentMap<K, V> map, K k, Function<K, V> f) {
"""
This method should be used instead of the
{@link ConcurrentMap#computeIfAbsent(Object, Function)} call to minimize
thread contention. This method does not require locking for the common case
where the key exists, but potentially performs additional computation when
absent.
"""
V v = map.get(k);
if (v == null) {
V tmp = f.apply(k);
v = map.putIfAbsent(k, tmp);
if (v == null) {
v = tmp;
}
}
return v;
} | java | public static <K, V> V computeIfAbsent(ConcurrentMap<K, V> map, K k, Function<K, V> f) {
V v = map.get(k);
if (v == null) {
V tmp = f.apply(k);
v = map.putIfAbsent(k, tmp);
if (v == null) {
v = tmp;
}
}
return v;
} | [
"public",
"static",
"<",
"K",
",",
"V",
">",
"V",
"computeIfAbsent",
"(",
"ConcurrentMap",
"<",
"K",
",",
"V",
">",
"map",
",",
"K",
"k",
",",
"Function",
"<",
"K",
",",
"V",
">",
"f",
")",
"{",
"V",
"v",
"=",
"map",
".",
"get",
"(",
"k",
")",
";",
"if",
"(",
"v",
"==",
"null",
")",
"{",
"V",
"tmp",
"=",
"f",
".",
"apply",
"(",
"k",
")",
";",
"v",
"=",
"map",
".",
"putIfAbsent",
"(",
"k",
",",
"tmp",
")",
";",
"if",
"(",
"v",
"==",
"null",
")",
"{",
"v",
"=",
"tmp",
";",
"}",
"}",
"return",
"v",
";",
"}"
] | This method should be used instead of the
{@link ConcurrentMap#computeIfAbsent(Object, Function)} call to minimize
thread contention. This method does not require locking for the common case
where the key exists, but potentially performs additional computation when
absent. | [
"This",
"method",
"should",
"be",
"used",
"instead",
"of",
"the",
"{"
] | train | https://github.com/Netflix/spectator/blob/259318252770de3bad581b85adff187d8f2c6537/spectator-api/src/main/java/com/netflix/spectator/api/Utils.java#L278-L288 |
beangle/beangle3 | commons/model/src/main/java/org/beangle/commons/entity/util/HierarchyEntityUtils.java | HierarchyEntityUtils.sort | public static <T extends HierarchyEntity<T, ?>> Map<T, String> sort(List<T> datas) {
"""
按照上下关系排序
@param datas a {@link java.util.List} object.
@param <T> a T object.
@return a {@link java.util.Map} object.
"""
return sort(datas, null);
} | java | public static <T extends HierarchyEntity<T, ?>> Map<T, String> sort(List<T> datas) {
return sort(datas, null);
} | [
"public",
"static",
"<",
"T",
"extends",
"HierarchyEntity",
"<",
"T",
",",
"?",
">",
">",
"Map",
"<",
"T",
",",
"String",
">",
"sort",
"(",
"List",
"<",
"T",
">",
"datas",
")",
"{",
"return",
"sort",
"(",
"datas",
",",
"null",
")",
";",
"}"
] | 按照上下关系排序
@param datas a {@link java.util.List} object.
@param <T> a T object.
@return a {@link java.util.Map} object. | [
"按照上下关系排序"
] | train | https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/model/src/main/java/org/beangle/commons/entity/util/HierarchyEntityUtils.java#L78-L80 |
jfinal/jfinal | src/main/java/com/jfinal/core/Controller.java | Controller.setAttr | public Controller setAttr(String name, Object value) {
"""
Stores an attribute in this request
@param name a String specifying the name of the attribute
@param value the Object to be stored
"""
request.setAttribute(name, value);
return this;
} | java | public Controller setAttr(String name, Object value) {
request.setAttribute(name, value);
return this;
} | [
"public",
"Controller",
"setAttr",
"(",
"String",
"name",
",",
"Object",
"value",
")",
"{",
"request",
".",
"setAttribute",
"(",
"name",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] | Stores an attribute in this request
@param name a String specifying the name of the attribute
@param value the Object to be stored | [
"Stores",
"an",
"attribute",
"in",
"this",
"request"
] | train | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/core/Controller.java#L132-L135 |
Baidu-AIP/java-sdk | src/main/java/com/baidu/aip/imagesearch/AipImageSearch.java | AipImageSearch.productAddUrl | public JSONObject productAddUrl(String url, HashMap<String, String> options) {
"""
商品检索—入库接口
**该接口实现单张图片入库,入库时需要同步提交图片及可关联至本地图库的摘要信息(具体变量为brief,具体可传入图片在本地标记id、图片url、图片名称等)。同时可提交分类维度信息(具体变量为class_id1、class_id2),方便对图库中的图片进行管理、分类检索。****注:重复添加完全相同的图片会返回错误。**
@param url - 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式,当image字段存在时url字段失效
@param options - 可选参数对象,key: value都为string类型
options - options列表:
brief 检索时原样带回,最长256B。**请注意,检索接口不返回原图,仅反馈当前填写的brief信息,所以调用该入库接口时,brief信息请尽量填写可关联至本地图库的图片id或者图片url、图片名称等信息**
class_id1 商品分类维度1,支持1-60范围内的整数。检索时可圈定该分类维度进行检索
class_id2 商品分类维度1,支持1-60范围内的整数。检索时可圈定该分类维度进行检索
@return JSONObject
"""
AipRequest request = new AipRequest();
preOperation(request);
request.addBody("url", url);
if (options != null) {
request.addBody(options);
}
request.setUri(ImageSearchConsts.PRODUCT_ADD);
postOperation(request);
return requestServer(request);
} | java | public JSONObject productAddUrl(String url, HashMap<String, String> options) {
AipRequest request = new AipRequest();
preOperation(request);
request.addBody("url", url);
if (options != null) {
request.addBody(options);
}
request.setUri(ImageSearchConsts.PRODUCT_ADD);
postOperation(request);
return requestServer(request);
} | [
"public",
"JSONObject",
"productAddUrl",
"(",
"String",
"url",
",",
"HashMap",
"<",
"String",
",",
"String",
">",
"options",
")",
"{",
"AipRequest",
"request",
"=",
"new",
"AipRequest",
"(",
")",
";",
"preOperation",
"(",
"request",
")",
";",
"request",
".",
"addBody",
"(",
"\"url\"",
",",
"url",
")",
";",
"if",
"(",
"options",
"!=",
"null",
")",
"{",
"request",
".",
"addBody",
"(",
"options",
")",
";",
"}",
"request",
".",
"setUri",
"(",
"ImageSearchConsts",
".",
"PRODUCT_ADD",
")",
";",
"postOperation",
"(",
"request",
")",
";",
"return",
"requestServer",
"(",
"request",
")",
";",
"}"
] | 商品检索—入库接口
**该接口实现单张图片入库,入库时需要同步提交图片及可关联至本地图库的摘要信息(具体变量为brief,具体可传入图片在本地标记id、图片url、图片名称等)。同时可提交分类维度信息(具体变量为class_id1、class_id2),方便对图库中的图片进行管理、分类检索。****注:重复添加完全相同的图片会返回错误。**
@param url - 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式,当image字段存在时url字段失效
@param options - 可选参数对象,key: value都为string类型
options - options列表:
brief 检索时原样带回,最长256B。**请注意,检索接口不返回原图,仅反馈当前填写的brief信息,所以调用该入库接口时,brief信息请尽量填写可关联至本地图库的图片id或者图片url、图片名称等信息**
class_id1 商品分类维度1,支持1-60范围内的整数。检索时可圈定该分类维度进行检索
class_id2 商品分类维度1,支持1-60范围内的整数。检索时可圈定该分类维度进行检索
@return JSONObject | [
"商品检索—入库接口",
"**",
"该接口实现单张图片入库,入库时需要同步提交图片及可关联至本地图库的摘要信息(具体变量为brief,具体可传入图片在本地标记id、图片url、图片名称等)。同时可提交分类维度信息(具体变量为class_id1、class_id2),方便对图库中的图片进行管理、分类检索。",
"****",
"注:重复添加完全相同的图片会返回错误。",
"**"
] | train | https://github.com/Baidu-AIP/java-sdk/blob/16bb8b7bb8f9bbcb7c8af62d0a67a1e79eecad90/src/main/java/com/baidu/aip/imagesearch/AipImageSearch.java#L744-L755 |
carewebframework/carewebframework-core | org.carewebframework.api-parent/org.carewebframework.api.core/src/main/java/org/carewebframework/api/spring/BaseXmlParser.java | BaseXmlParser.fromXml | protected Object fromXml(String xml, String tagName) throws Exception {
"""
Parses an xml extension from an xml string.
@param xml XML containing the extension.
@param tagName The top level tag name.
@return Result of the parsed extension.
@throws Exception Unspecified exception.
"""
Document document = XMLUtil.parseXMLFromString(xml);
NodeList nodeList = document.getElementsByTagName(tagName);
if (nodeList == null || nodeList.getLength() != 1) {
throw new DOMException(DOMException.NOT_FOUND_ERR, "Top level tag '" + tagName + "' was not found.");
}
Element element = (Element) nodeList.item(0);
Class<?> beanClass = getBeanClass(element);
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(beanClass);
doParse(element, builder);
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
factory.setParentBeanFactory(SpringUtil.getAppContext());
AbstractBeanDefinition beanDefinition = builder.getBeanDefinition();
factory.registerBeanDefinition(tagName, beanDefinition);
return factory.getBean(tagName);
} | java | protected Object fromXml(String xml, String tagName) throws Exception {
Document document = XMLUtil.parseXMLFromString(xml);
NodeList nodeList = document.getElementsByTagName(tagName);
if (nodeList == null || nodeList.getLength() != 1) {
throw new DOMException(DOMException.NOT_FOUND_ERR, "Top level tag '" + tagName + "' was not found.");
}
Element element = (Element) nodeList.item(0);
Class<?> beanClass = getBeanClass(element);
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(beanClass);
doParse(element, builder);
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
factory.setParentBeanFactory(SpringUtil.getAppContext());
AbstractBeanDefinition beanDefinition = builder.getBeanDefinition();
factory.registerBeanDefinition(tagName, beanDefinition);
return factory.getBean(tagName);
} | [
"protected",
"Object",
"fromXml",
"(",
"String",
"xml",
",",
"String",
"tagName",
")",
"throws",
"Exception",
"{",
"Document",
"document",
"=",
"XMLUtil",
".",
"parseXMLFromString",
"(",
"xml",
")",
";",
"NodeList",
"nodeList",
"=",
"document",
".",
"getElementsByTagName",
"(",
"tagName",
")",
";",
"if",
"(",
"nodeList",
"==",
"null",
"||",
"nodeList",
".",
"getLength",
"(",
")",
"!=",
"1",
")",
"{",
"throw",
"new",
"DOMException",
"(",
"DOMException",
".",
"NOT_FOUND_ERR",
",",
"\"Top level tag '\"",
"+",
"tagName",
"+",
"\"' was not found.\"",
")",
";",
"}",
"Element",
"element",
"=",
"(",
"Element",
")",
"nodeList",
".",
"item",
"(",
"0",
")",
";",
"Class",
"<",
"?",
">",
"beanClass",
"=",
"getBeanClass",
"(",
"element",
")",
";",
"BeanDefinitionBuilder",
"builder",
"=",
"BeanDefinitionBuilder",
".",
"rootBeanDefinition",
"(",
"beanClass",
")",
";",
"doParse",
"(",
"element",
",",
"builder",
")",
";",
"DefaultListableBeanFactory",
"factory",
"=",
"new",
"DefaultListableBeanFactory",
"(",
")",
";",
"factory",
".",
"setParentBeanFactory",
"(",
"SpringUtil",
".",
"getAppContext",
"(",
")",
")",
";",
"AbstractBeanDefinition",
"beanDefinition",
"=",
"builder",
".",
"getBeanDefinition",
"(",
")",
";",
"factory",
".",
"registerBeanDefinition",
"(",
"tagName",
",",
"beanDefinition",
")",
";",
"return",
"factory",
".",
"getBean",
"(",
"tagName",
")",
";",
"}"
] | Parses an xml extension from an xml string.
@param xml XML containing the extension.
@param tagName The top level tag name.
@return Result of the parsed extension.
@throws Exception Unspecified exception. | [
"Parses",
"an",
"xml",
"extension",
"from",
"an",
"xml",
"string",
"."
] | train | https://github.com/carewebframework/carewebframework-core/blob/fa3252d4f7541dbe151b92c3d4f6f91433cd1673/org.carewebframework.api-parent/org.carewebframework.api.core/src/main/java/org/carewebframework/api/spring/BaseXmlParser.java#L124-L141 |
GenesysPureEngage/authentication-client-java | src/main/java/com/genesys/authentication/AuthenticationApi.java | AuthenticationApi.getUserInfoOpenid | public OpenIdUserInfo getUserInfoOpenid(String authorization) throws AuthenticationApiException {
"""
Get OpenID user information by access token
Get information about a user by their OAuth 2 access token.
@param authorization The OAuth 2 bearer access token you received from [/auth/v3/oauth/token](/reference/authentication/Authentication/index.html#retrieveToken). For example: \"Authorization: bearer a4b5da75-a584-4053-9227-0f0ab23ff06e\" (required)
@return OpenIdUserInfo
@throws AuthenticationApiException if the call is unsuccessful.
"""
try {
return authenticationApi.getInfo(authorization);
} catch (ApiException e) {
throw new AuthenticationApiException("Error getting openid userinfo", e);
}
} | java | public OpenIdUserInfo getUserInfoOpenid(String authorization) throws AuthenticationApiException {
try {
return authenticationApi.getInfo(authorization);
} catch (ApiException e) {
throw new AuthenticationApiException("Error getting openid userinfo", e);
}
} | [
"public",
"OpenIdUserInfo",
"getUserInfoOpenid",
"(",
"String",
"authorization",
")",
"throws",
"AuthenticationApiException",
"{",
"try",
"{",
"return",
"authenticationApi",
".",
"getInfo",
"(",
"authorization",
")",
";",
"}",
"catch",
"(",
"ApiException",
"e",
")",
"{",
"throw",
"new",
"AuthenticationApiException",
"(",
"\"Error getting openid userinfo\"",
",",
"e",
")",
";",
"}",
"}"
] | Get OpenID user information by access token
Get information about a user by their OAuth 2 access token.
@param authorization The OAuth 2 bearer access token you received from [/auth/v3/oauth/token](/reference/authentication/Authentication/index.html#retrieveToken). For example: \"Authorization: bearer a4b5da75-a584-4053-9227-0f0ab23ff06e\" (required)
@return OpenIdUserInfo
@throws AuthenticationApiException if the call is unsuccessful. | [
"Get",
"OpenID",
"user",
"information",
"by",
"access",
"token",
"Get",
"information",
"about",
"a",
"user",
"by",
"their",
"OAuth",
"2",
"access",
"token",
"."
] | train | https://github.com/GenesysPureEngage/authentication-client-java/blob/eb0d58343ee42ebd3c037163c1137f611dfcbb3a/src/main/java/com/genesys/authentication/AuthenticationApi.java#L119-L125 |
b3dgs/lionengine | lionengine-network/src/main/java/com/b3dgs/lionengine/network/NetworkModel.java | NetworkModel.decodeMessage | protected void decodeMessage(byte type, byte from, byte dest, DataInputStream buffer) throws IOException {
"""
Decode a message from its type.
@param type The message type.
@param from The client id source.
@param dest The client id destination (-1 if all).
@param buffer The data.
@throws IOException Error on reading.
"""
final NetworkMessage message = decoder.getNetworkMessageFromType(type);
if (message != null)
{
final int skip = 3;
if (buffer.skipBytes(skip) == skip)
{
message.decode(type, from, dest, buffer);
messagesIn.add(message);
}
}
} | java | protected void decodeMessage(byte type, byte from, byte dest, DataInputStream buffer) throws IOException
{
final NetworkMessage message = decoder.getNetworkMessageFromType(type);
if (message != null)
{
final int skip = 3;
if (buffer.skipBytes(skip) == skip)
{
message.decode(type, from, dest, buffer);
messagesIn.add(message);
}
}
} | [
"protected",
"void",
"decodeMessage",
"(",
"byte",
"type",
",",
"byte",
"from",
",",
"byte",
"dest",
",",
"DataInputStream",
"buffer",
")",
"throws",
"IOException",
"{",
"final",
"NetworkMessage",
"message",
"=",
"decoder",
".",
"getNetworkMessageFromType",
"(",
"type",
")",
";",
"if",
"(",
"message",
"!=",
"null",
")",
"{",
"final",
"int",
"skip",
"=",
"3",
";",
"if",
"(",
"buffer",
".",
"skipBytes",
"(",
"skip",
")",
"==",
"skip",
")",
"{",
"message",
".",
"decode",
"(",
"type",
",",
"from",
",",
"dest",
",",
"buffer",
")",
";",
"messagesIn",
".",
"add",
"(",
"message",
")",
";",
"}",
"}",
"}"
] | Decode a message from its type.
@param type The message type.
@param from The client id source.
@param dest The client id destination (-1 if all).
@param buffer The data.
@throws IOException Error on reading. | [
"Decode",
"a",
"message",
"from",
"its",
"type",
"."
] | train | https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-network/src/main/java/com/b3dgs/lionengine/network/NetworkModel.java#L66-L78 |
grpc/grpc-java | netty/src/main/java/io/grpc/netty/NettyChannelBuilder.java | NettyChannelBuilder.withOption | public <T> NettyChannelBuilder withOption(ChannelOption<T> option, T value) {
"""
Specifies a channel option. As the underlying channel as well as network implementation may
ignore this value applications should consider it a hint.
"""
channelOptions.put(option, value);
return this;
} | java | public <T> NettyChannelBuilder withOption(ChannelOption<T> option, T value) {
channelOptions.put(option, value);
return this;
} | [
"public",
"<",
"T",
">",
"NettyChannelBuilder",
"withOption",
"(",
"ChannelOption",
"<",
"T",
">",
"option",
",",
"T",
"value",
")",
"{",
"channelOptions",
".",
"put",
"(",
"option",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] | Specifies a channel option. As the underlying channel as well as network implementation may
ignore this value applications should consider it a hint. | [
"Specifies",
"a",
"channel",
"option",
".",
"As",
"the",
"underlying",
"channel",
"as",
"well",
"as",
"network",
"implementation",
"may",
"ignore",
"this",
"value",
"applications",
"should",
"consider",
"it",
"a",
"hint",
"."
] | train | https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/netty/src/main/java/io/grpc/netty/NettyChannelBuilder.java#L191-L194 |
mozilla/rhino | src/org/mozilla/javascript/Context.java | Context.toObject | public static Scriptable toObject(Object value, Scriptable scope) {
"""
Convert the value to an JavaScript object value.
<p>
Note that a scope must be provided to look up the constructors
for Number, Boolean, and String.
<p>
See ECMA 9.9.
<p>
Additionally, arbitrary Java objects and classes will be
wrapped in a Scriptable object with its Java fields and methods
reflected as JavaScript properties of the object.
@param value any Java object
@param scope global scope containing constructors for Number,
Boolean, and String
@return new JavaScript object
"""
return ScriptRuntime.toObject(scope, value);
} | java | public static Scriptable toObject(Object value, Scriptable scope)
{
return ScriptRuntime.toObject(scope, value);
} | [
"public",
"static",
"Scriptable",
"toObject",
"(",
"Object",
"value",
",",
"Scriptable",
"scope",
")",
"{",
"return",
"ScriptRuntime",
".",
"toObject",
"(",
"scope",
",",
"value",
")",
";",
"}"
] | Convert the value to an JavaScript object value.
<p>
Note that a scope must be provided to look up the constructors
for Number, Boolean, and String.
<p>
See ECMA 9.9.
<p>
Additionally, arbitrary Java objects and classes will be
wrapped in a Scriptable object with its Java fields and methods
reflected as JavaScript properties of the object.
@param value any Java object
@param scope global scope containing constructors for Number,
Boolean, and String
@return new JavaScript object | [
"Convert",
"the",
"value",
"to",
"an",
"JavaScript",
"object",
"value",
".",
"<p",
">",
"Note",
"that",
"a",
"scope",
"must",
"be",
"provided",
"to",
"look",
"up",
"the",
"constructors",
"for",
"Number",
"Boolean",
"and",
"String",
".",
"<p",
">",
"See",
"ECMA",
"9",
".",
"9",
".",
"<p",
">",
"Additionally",
"arbitrary",
"Java",
"objects",
"and",
"classes",
"will",
"be",
"wrapped",
"in",
"a",
"Scriptable",
"object",
"with",
"its",
"Java",
"fields",
"and",
"methods",
"reflected",
"as",
"JavaScript",
"properties",
"of",
"the",
"object",
"."
] | train | https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/Context.java#L1805-L1808 |
mgm-tp/jfunk | jfunk-common/src/main/java/com/mgmtp/jfunk/common/random/MathRandom.java | MathRandom.getLong | public long getLong(final long min, final long max) {
"""
Returns a random integer number in the range of [min, max].
@param min
minimum value for generated number
@param max
maximum value for generated number
"""
return min(min, max) + getLong(abs(max - min));
} | java | public long getLong(final long min, final long max) {
return min(min, max) + getLong(abs(max - min));
} | [
"public",
"long",
"getLong",
"(",
"final",
"long",
"min",
",",
"final",
"long",
"max",
")",
"{",
"return",
"min",
"(",
"min",
",",
"max",
")",
"+",
"getLong",
"(",
"abs",
"(",
"max",
"-",
"min",
")",
")",
";",
"}"
] | Returns a random integer number in the range of [min, max].
@param min
minimum value for generated number
@param max
maximum value for generated number | [
"Returns",
"a",
"random",
"integer",
"number",
"in",
"the",
"range",
"of",
"[",
"min",
"max",
"]",
"."
] | train | https://github.com/mgm-tp/jfunk/blob/5b9fecac5778b988bb458085ded39ea9a4c7c2ae/jfunk-common/src/main/java/com/mgmtp/jfunk/common/random/MathRandom.java#L141-L143 |
Azure/azure-sdk-for-java | common/azure-common/src/main/java/com/azure/common/implementation/serializer/HttpResponseBodyDecoder.java | HttpResponseBodyDecoder.deserializeBody | private static Object deserializeBody(String value, Type resultType, Type wireType, SerializerAdapter serializer, SerializerEncoding encoding) throws IOException {
"""
Deserialize the given string value representing content of a REST API response.
If the {@link ReturnValueWireType} is of type {@link Page}, then the returned object will be an instance of that
{@param wireType}. Otherwise, the returned object is converted back to its {@param resultType}.
@param value the string value to deserialize
@param resultType the return type of the java proxy method
@param wireType value of optional {@link ReturnValueWireType} annotation present in java proxy method indicating
'entity type' (wireType) of REST API wire response body
@param encoding the encoding format of value
@return Deserialized object
@throws IOException When the body cannot be deserialized
"""
if (wireType == null) {
return serializer.deserialize(value, resultType, encoding);
} else if (TypeUtil.isTypeOrSubTypeOf(wireType, Page.class)) {
return deserializePage(value, resultType, wireType, serializer, encoding);
} else {
final Type wireResponseType = constructWireResponseType(resultType, wireType);
final Object wireResponse = serializer.deserialize(value, wireResponseType, encoding);
return convertToResultType(wireResponse, resultType, wireType);
}
} | java | private static Object deserializeBody(String value, Type resultType, Type wireType, SerializerAdapter serializer, SerializerEncoding encoding) throws IOException {
if (wireType == null) {
return serializer.deserialize(value, resultType, encoding);
} else if (TypeUtil.isTypeOrSubTypeOf(wireType, Page.class)) {
return deserializePage(value, resultType, wireType, serializer, encoding);
} else {
final Type wireResponseType = constructWireResponseType(resultType, wireType);
final Object wireResponse = serializer.deserialize(value, wireResponseType, encoding);
return convertToResultType(wireResponse, resultType, wireType);
}
} | [
"private",
"static",
"Object",
"deserializeBody",
"(",
"String",
"value",
",",
"Type",
"resultType",
",",
"Type",
"wireType",
",",
"SerializerAdapter",
"serializer",
",",
"SerializerEncoding",
"encoding",
")",
"throws",
"IOException",
"{",
"if",
"(",
"wireType",
"==",
"null",
")",
"{",
"return",
"serializer",
".",
"deserialize",
"(",
"value",
",",
"resultType",
",",
"encoding",
")",
";",
"}",
"else",
"if",
"(",
"TypeUtil",
".",
"isTypeOrSubTypeOf",
"(",
"wireType",
",",
"Page",
".",
"class",
")",
")",
"{",
"return",
"deserializePage",
"(",
"value",
",",
"resultType",
",",
"wireType",
",",
"serializer",
",",
"encoding",
")",
";",
"}",
"else",
"{",
"final",
"Type",
"wireResponseType",
"=",
"constructWireResponseType",
"(",
"resultType",
",",
"wireType",
")",
";",
"final",
"Object",
"wireResponse",
"=",
"serializer",
".",
"deserialize",
"(",
"value",
",",
"wireResponseType",
",",
"encoding",
")",
";",
"return",
"convertToResultType",
"(",
"wireResponse",
",",
"resultType",
",",
"wireType",
")",
";",
"}",
"}"
] | Deserialize the given string value representing content of a REST API response.
If the {@link ReturnValueWireType} is of type {@link Page}, then the returned object will be an instance of that
{@param wireType}. Otherwise, the returned object is converted back to its {@param resultType}.
@param value the string value to deserialize
@param resultType the return type of the java proxy method
@param wireType value of optional {@link ReturnValueWireType} annotation present in java proxy method indicating
'entity type' (wireType) of REST API wire response body
@param encoding the encoding format of value
@return Deserialized object
@throws IOException When the body cannot be deserialized | [
"Deserialize",
"the",
"given",
"string",
"value",
"representing",
"content",
"of",
"a",
"REST",
"API",
"response",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/common/azure-common/src/main/java/com/azure/common/implementation/serializer/HttpResponseBodyDecoder.java#L161-L172 |
deeplearning4j/deeplearning4j | deeplearning4j/deeplearning4j-graph/src/main/java/org/deeplearning4j/graph/data/GraphLoader.java | GraphLoader.loadUndirectedGraphEdgeListFile | public static Graph<String, String> loadUndirectedGraphEdgeListFile(String path, int numVertices, String delim)
throws IOException {
"""
Simple method for loading an undirected graph, where the graph is represented by a edge list with one edge
per line with a delimiter in between<br>
This method assumes that all lines in the file are of the form {@code i<delim>j} where i and j are integers
in range 0 to numVertices inclusive, and "<delim>" is the user-provided delimiter
<b>Note</b>: this method calls {@link #loadUndirectedGraphEdgeListFile(String, int, String, boolean)} with allowMultipleEdges = true.
@param path Path to the edge list file
@param numVertices number of vertices in the graph
@return graph
@throws IOException if file cannot be read
"""
return loadUndirectedGraphEdgeListFile(path, numVertices, delim, true);
} | java | public static Graph<String, String> loadUndirectedGraphEdgeListFile(String path, int numVertices, String delim)
throws IOException {
return loadUndirectedGraphEdgeListFile(path, numVertices, delim, true);
} | [
"public",
"static",
"Graph",
"<",
"String",
",",
"String",
">",
"loadUndirectedGraphEdgeListFile",
"(",
"String",
"path",
",",
"int",
"numVertices",
",",
"String",
"delim",
")",
"throws",
"IOException",
"{",
"return",
"loadUndirectedGraphEdgeListFile",
"(",
"path",
",",
"numVertices",
",",
"delim",
",",
"true",
")",
";",
"}"
] | Simple method for loading an undirected graph, where the graph is represented by a edge list with one edge
per line with a delimiter in between<br>
This method assumes that all lines in the file are of the form {@code i<delim>j} where i and j are integers
in range 0 to numVertices inclusive, and "<delim>" is the user-provided delimiter
<b>Note</b>: this method calls {@link #loadUndirectedGraphEdgeListFile(String, int, String, boolean)} with allowMultipleEdges = true.
@param path Path to the edge list file
@param numVertices number of vertices in the graph
@return graph
@throws IOException if file cannot be read | [
"Simple",
"method",
"for",
"loading",
"an",
"undirected",
"graph",
"where",
"the",
"graph",
"is",
"represented",
"by",
"a",
"edge",
"list",
"with",
"one",
"edge",
"per",
"line",
"with",
"a",
"delimiter",
"in",
"between<br",
">",
"This",
"method",
"assumes",
"that",
"all",
"lines",
"in",
"the",
"file",
"are",
"of",
"the",
"form",
"{"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-graph/src/main/java/org/deeplearning4j/graph/data/GraphLoader.java#L50-L53 |
kiegroup/droolsjbpm-integration | kie-server-parent/kie-server-common/src/main/java/org/kie/server/common/rest/Base64Util.java | Base64Util.encodeBytes | public static String encodeBytes( byte[] source, int off, int len ) {
"""
Encodes a byte array into Base64 notation.
@param source The data to convert
@param off Offset in array where conversion should begin
@param len Length of data to convert
@return The Base64-encoded data as a String
@throws NullPointerException if source array is null
@throws IllegalArgumentException if source array, offset, or length are invalid
@since 2.0
"""
byte[] encoded = encodeBytesToBytes(source, off, len);
try {
return new String(encoded, PREFERRED_ENCODING);
} catch( UnsupportedEncodingException uee ) {
return new String(encoded);
}
} | java | public static String encodeBytes( byte[] source, int off, int len ) {
byte[] encoded = encodeBytesToBytes(source, off, len);
try {
return new String(encoded, PREFERRED_ENCODING);
} catch( UnsupportedEncodingException uee ) {
return new String(encoded);
}
} | [
"public",
"static",
"String",
"encodeBytes",
"(",
"byte",
"[",
"]",
"source",
",",
"int",
"off",
",",
"int",
"len",
")",
"{",
"byte",
"[",
"]",
"encoded",
"=",
"encodeBytesToBytes",
"(",
"source",
",",
"off",
",",
"len",
")",
";",
"try",
"{",
"return",
"new",
"String",
"(",
"encoded",
",",
"PREFERRED_ENCODING",
")",
";",
"}",
"catch",
"(",
"UnsupportedEncodingException",
"uee",
")",
"{",
"return",
"new",
"String",
"(",
"encoded",
")",
";",
"}",
"}"
] | Encodes a byte array into Base64 notation.
@param source The data to convert
@param off Offset in array where conversion should begin
@param len Length of data to convert
@return The Base64-encoded data as a String
@throws NullPointerException if source array is null
@throws IllegalArgumentException if source array, offset, or length are invalid
@since 2.0 | [
"Encodes",
"a",
"byte",
"array",
"into",
"Base64",
"notation",
"."
] | train | https://github.com/kiegroup/droolsjbpm-integration/blob/6c26200ab03855dbb92b56ca0c6363cdec0eaf2c/kie-server-parent/kie-server-common/src/main/java/org/kie/server/common/rest/Base64Util.java#L149-L156 |
infinispan/infinispan | core/src/main/java/org/infinispan/remoting/transport/AbstractRequest.java | AbstractRequest.setTimeout | public void setTimeout(ScheduledExecutorService timeoutExecutor, long timeout, TimeUnit unit) {
"""
Schedule a timeout task on the given executor, and complete the request with a {@link
org.infinispan.util.concurrent.TimeoutException}
when the task runs.
If a timeout task was already registered with this request, it is cancelled.
"""
cancelTimeoutTask();
ScheduledFuture<Void> timeoutFuture = timeoutExecutor.schedule(this, timeout, unit);
setTimeoutFuture(timeoutFuture);
} | java | public void setTimeout(ScheduledExecutorService timeoutExecutor, long timeout, TimeUnit unit) {
cancelTimeoutTask();
ScheduledFuture<Void> timeoutFuture = timeoutExecutor.schedule(this, timeout, unit);
setTimeoutFuture(timeoutFuture);
} | [
"public",
"void",
"setTimeout",
"(",
"ScheduledExecutorService",
"timeoutExecutor",
",",
"long",
"timeout",
",",
"TimeUnit",
"unit",
")",
"{",
"cancelTimeoutTask",
"(",
")",
";",
"ScheduledFuture",
"<",
"Void",
">",
"timeoutFuture",
"=",
"timeoutExecutor",
".",
"schedule",
"(",
"this",
",",
"timeout",
",",
"unit",
")",
";",
"setTimeoutFuture",
"(",
"timeoutFuture",
")",
";",
"}"
] | Schedule a timeout task on the given executor, and complete the request with a {@link
org.infinispan.util.concurrent.TimeoutException}
when the task runs.
If a timeout task was already registered with this request, it is cancelled. | [
"Schedule",
"a",
"timeout",
"task",
"on",
"the",
"given",
"executor",
"and",
"complete",
"the",
"request",
"with",
"a",
"{",
"@link",
"org",
".",
"infinispan",
".",
"util",
".",
"concurrent",
".",
"TimeoutException",
"}",
"when",
"the",
"task",
"runs",
"."
] | train | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/remoting/transport/AbstractRequest.java#L52-L56 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/vision/customvision/training/src/main/java/com/microsoft/azure/cognitiveservices/vision/customvision/training/implementation/TrainingsImpl.java | TrainingsImpl.updateTag | public Tag updateTag(UUID projectId, UUID tagId, Tag updatedTag) {
"""
Update a tag.
@param projectId The project id
@param tagId The id of the target tag
@param updatedTag The updated tag model
@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 Tag object if successful.
"""
return updateTagWithServiceResponseAsync(projectId, tagId, updatedTag).toBlocking().single().body();
} | java | public Tag updateTag(UUID projectId, UUID tagId, Tag updatedTag) {
return updateTagWithServiceResponseAsync(projectId, tagId, updatedTag).toBlocking().single().body();
} | [
"public",
"Tag",
"updateTag",
"(",
"UUID",
"projectId",
",",
"UUID",
"tagId",
",",
"Tag",
"updatedTag",
")",
"{",
"return",
"updateTagWithServiceResponseAsync",
"(",
"projectId",
",",
"tagId",
",",
"updatedTag",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Update a tag.
@param projectId The project id
@param tagId The id of the target tag
@param updatedTag The updated tag model
@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 Tag object if successful. | [
"Update",
"a",
"tag",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/vision/customvision/training/src/main/java/com/microsoft/azure/cognitiveservices/vision/customvision/training/implementation/TrainingsImpl.java#L603-L605 |
Erudika/para | para-client/src/main/java/com/erudika/para/client/ParaClient.java | ParaClient.readAll | public <P extends ParaObject> List<P> readAll(List<String> keys) {
"""
Retrieves multiple objects from the data store.
@param <P> the type of object
@param keys a list of object ids
@return a list of objects
"""
if (keys == null || keys.isEmpty()) {
return Collections.emptyList();
}
final int size = this.chunkSize;
return IntStream.range(0, getNumChunks(keys, size))
.mapToObj(i -> (List<String>) partitionList(keys, i, size))
.map(chunk -> {
MultivaluedMap<String, String> ids = new MultivaluedHashMap<>();
ids.put("ids", chunk);
return invokeGet("_batch", ids);
})
.map(response -> (List<P>) this.getEntity(response, List.class))
.map(entity -> (List<P>) getItemsFromList(entity))
.flatMap(List::stream)
.collect(Collectors.toList());
} | java | public <P extends ParaObject> List<P> readAll(List<String> keys) {
if (keys == null || keys.isEmpty()) {
return Collections.emptyList();
}
final int size = this.chunkSize;
return IntStream.range(0, getNumChunks(keys, size))
.mapToObj(i -> (List<String>) partitionList(keys, i, size))
.map(chunk -> {
MultivaluedMap<String, String> ids = new MultivaluedHashMap<>();
ids.put("ids", chunk);
return invokeGet("_batch", ids);
})
.map(response -> (List<P>) this.getEntity(response, List.class))
.map(entity -> (List<P>) getItemsFromList(entity))
.flatMap(List::stream)
.collect(Collectors.toList());
} | [
"public",
"<",
"P",
"extends",
"ParaObject",
">",
"List",
"<",
"P",
">",
"readAll",
"(",
"List",
"<",
"String",
">",
"keys",
")",
"{",
"if",
"(",
"keys",
"==",
"null",
"||",
"keys",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"Collections",
".",
"emptyList",
"(",
")",
";",
"}",
"final",
"int",
"size",
"=",
"this",
".",
"chunkSize",
";",
"return",
"IntStream",
".",
"range",
"(",
"0",
",",
"getNumChunks",
"(",
"keys",
",",
"size",
")",
")",
".",
"mapToObj",
"(",
"i",
"->",
"(",
"List",
"<",
"String",
">",
")",
"partitionList",
"(",
"keys",
",",
"i",
",",
"size",
")",
")",
".",
"map",
"(",
"chunk",
"->",
"{",
"MultivaluedMap",
"<",
"String",
",",
"String",
">",
"ids",
"=",
"new",
"MultivaluedHashMap",
"<>",
"(",
")",
";",
"ids",
".",
"put",
"(",
"\"ids\"",
",",
"chunk",
")",
";",
"return",
"invokeGet",
"(",
"\"_batch\"",
",",
"ids",
")",
";",
"}",
")",
".",
"map",
"(",
"response",
"->",
"(",
"List",
"<",
"P",
">",
")",
"this",
".",
"getEntity",
"(",
"response",
",",
"List",
".",
"class",
")",
")",
".",
"map",
"(",
"entity",
"->",
"(",
"List",
"<",
"P",
">",
")",
"getItemsFromList",
"(",
"entity",
")",
")",
".",
"flatMap",
"(",
"List",
"::",
"stream",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"}"
] | Retrieves multiple objects from the data store.
@param <P> the type of object
@param keys a list of object ids
@return a list of objects | [
"Retrieves",
"multiple",
"objects",
"from",
"the",
"data",
"store",
"."
] | train | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-client/src/main/java/com/erudika/para/client/ParaClient.java#L576-L592 |
lucee/Lucee | core/src/main/java/lucee/runtime/db/QoQ.java | QoQ.executeExp | private Object executeExp(PageContext pc, SQL sql, Query qr, Expression exp, int row) throws PageException {
"""
Executes a ZEXp
@param sql
@param qr Query Result
@param exp expression to execute
@param row current row of resultset
@return result
@throws PageException
"""
// print.e("name:"+exp.getClass().getName());
if (exp instanceof Value) return ((Value) exp).getValue();// executeConstant(sql,qr, (Value)exp, row);
if (exp instanceof Column) return executeColumn(sql, qr, (Column) exp, row);
if (exp instanceof Operation) return executeOperation(pc, sql, qr, (Operation) exp, row);
if (exp instanceof BracketExpression) return executeBracked(pc, sql, qr, (BracketExpression) exp, row);
throw new DatabaseException("unsupported sql statement [" + exp + "]", null, sql, null);
} | java | private Object executeExp(PageContext pc, SQL sql, Query qr, Expression exp, int row) throws PageException {
// print.e("name:"+exp.getClass().getName());
if (exp instanceof Value) return ((Value) exp).getValue();// executeConstant(sql,qr, (Value)exp, row);
if (exp instanceof Column) return executeColumn(sql, qr, (Column) exp, row);
if (exp instanceof Operation) return executeOperation(pc, sql, qr, (Operation) exp, row);
if (exp instanceof BracketExpression) return executeBracked(pc, sql, qr, (BracketExpression) exp, row);
throw new DatabaseException("unsupported sql statement [" + exp + "]", null, sql, null);
} | [
"private",
"Object",
"executeExp",
"(",
"PageContext",
"pc",
",",
"SQL",
"sql",
",",
"Query",
"qr",
",",
"Expression",
"exp",
",",
"int",
"row",
")",
"throws",
"PageException",
"{",
"// print.e(\"name:\"+exp.getClass().getName());",
"if",
"(",
"exp",
"instanceof",
"Value",
")",
"return",
"(",
"(",
"Value",
")",
"exp",
")",
".",
"getValue",
"(",
")",
";",
"// executeConstant(sql,qr, (Value)exp, row);",
"if",
"(",
"exp",
"instanceof",
"Column",
")",
"return",
"executeColumn",
"(",
"sql",
",",
"qr",
",",
"(",
"Column",
")",
"exp",
",",
"row",
")",
";",
"if",
"(",
"exp",
"instanceof",
"Operation",
")",
"return",
"executeOperation",
"(",
"pc",
",",
"sql",
",",
"qr",
",",
"(",
"Operation",
")",
"exp",
",",
"row",
")",
";",
"if",
"(",
"exp",
"instanceof",
"BracketExpression",
")",
"return",
"executeBracked",
"(",
"pc",
",",
"sql",
",",
"qr",
",",
"(",
"BracketExpression",
")",
"exp",
",",
"row",
")",
";",
"throw",
"new",
"DatabaseException",
"(",
"\"unsupported sql statement [\"",
"+",
"exp",
"+",
"\"]\"",
",",
"null",
",",
"sql",
",",
"null",
")",
";",
"}"
] | Executes a ZEXp
@param sql
@param qr Query Result
@param exp expression to execute
@param row current row of resultset
@return result
@throws PageException | [
"Executes",
"a",
"ZEXp"
] | train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/runtime/db/QoQ.java#L307-L314 |
mbenson/therian | core/src/main/java/therian/util/Positions.java | Positions.readOnly | public static <T> Position.Readable<T> readOnly(final T value) {
"""
Get a read-only position of value {@code value} (type of {@code value#getClass()}.
@param value not {@code null}
@return Position.Readable
"""
return readOnly(Validate.notNull(value, "value").getClass(), value);
} | java | public static <T> Position.Readable<T> readOnly(final T value) {
return readOnly(Validate.notNull(value, "value").getClass(), value);
} | [
"public",
"static",
"<",
"T",
">",
"Position",
".",
"Readable",
"<",
"T",
">",
"readOnly",
"(",
"final",
"T",
"value",
")",
"{",
"return",
"readOnly",
"(",
"Validate",
".",
"notNull",
"(",
"value",
",",
"\"value\"",
")",
".",
"getClass",
"(",
")",
",",
"value",
")",
";",
"}"
] | Get a read-only position of value {@code value} (type of {@code value#getClass()}.
@param value not {@code null}
@return Position.Readable | [
"Get",
"a",
"read",
"-",
"only",
"position",
"of",
"value",
"{",
"@code",
"value",
"}",
"(",
"type",
"of",
"{",
"@code",
"value#getClass",
"()",
"}",
"."
] | train | https://github.com/mbenson/therian/blob/0653505f73e2a6f5b0abc394ea6d83af03408254/core/src/main/java/therian/util/Positions.java#L167-L169 |
matthewhorridge/owlapi-gwt | owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLSubDataPropertyOfAxiomImpl_CustomFieldSerializer.java | OWLSubDataPropertyOfAxiomImpl_CustomFieldSerializer.serializeInstance | @Override
public void serializeInstance(SerializationStreamWriter streamWriter, OWLSubDataPropertyOfAxiomImpl instance) throws SerializationException {
"""
Serializes the content of the object into the
{@link com.google.gwt.user.client.rpc.SerializationStreamWriter}.
@param streamWriter the {@link com.google.gwt.user.client.rpc.SerializationStreamWriter} to write the
object's content to
@param instance the object instance to serialize
@throws com.google.gwt.user.client.rpc.SerializationException
if the serialization operation is not
successful
"""
serialize(streamWriter, instance);
} | java | @Override
public void serializeInstance(SerializationStreamWriter streamWriter, OWLSubDataPropertyOfAxiomImpl instance) throws SerializationException {
serialize(streamWriter, instance);
} | [
"@",
"Override",
"public",
"void",
"serializeInstance",
"(",
"SerializationStreamWriter",
"streamWriter",
",",
"OWLSubDataPropertyOfAxiomImpl",
"instance",
")",
"throws",
"SerializationException",
"{",
"serialize",
"(",
"streamWriter",
",",
"instance",
")",
";",
"}"
] | Serializes the content of the object into the
{@link com.google.gwt.user.client.rpc.SerializationStreamWriter}.
@param streamWriter the {@link com.google.gwt.user.client.rpc.SerializationStreamWriter} to write the
object's content to
@param instance the object instance to serialize
@throws com.google.gwt.user.client.rpc.SerializationException
if the serialization operation is not
successful | [
"Serializes",
"the",
"content",
"of",
"the",
"object",
"into",
"the",
"{",
"@link",
"com",
".",
"google",
".",
"gwt",
".",
"user",
".",
"client",
".",
"rpc",
".",
"SerializationStreamWriter",
"}",
"."
] | train | https://github.com/matthewhorridge/owlapi-gwt/blob/7ab975fb6cef3c8947099983551672a3b5d4e2fd/owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLSubDataPropertyOfAxiomImpl_CustomFieldSerializer.java#L75-L78 |
SeleniumHQ/selenium | java/server/src/org/openqa/grid/internal/ExternalSessionKey.java | ExternalSessionKey.fromResponseBody | public static ExternalSessionKey fromResponseBody(String responseBody) throws NewSessionException {
"""
extract the external key from the server response for a selenium1 new session request.
@param responseBody the response from the server
@return the ExternalKey if it was present in the server's response.
@throws NewSessionException in case the server didn't send back a success result.
"""
if (responseBody != null && responseBody.startsWith("OK,")) {
return new ExternalSessionKey(responseBody.replace("OK,", ""));
}
throw new NewSessionException("The server returned an error : "+responseBody);
} | java | public static ExternalSessionKey fromResponseBody(String responseBody) throws NewSessionException {
if (responseBody != null && responseBody.startsWith("OK,")) {
return new ExternalSessionKey(responseBody.replace("OK,", ""));
}
throw new NewSessionException("The server returned an error : "+responseBody);
} | [
"public",
"static",
"ExternalSessionKey",
"fromResponseBody",
"(",
"String",
"responseBody",
")",
"throws",
"NewSessionException",
"{",
"if",
"(",
"responseBody",
"!=",
"null",
"&&",
"responseBody",
".",
"startsWith",
"(",
"\"OK,\"",
")",
")",
"{",
"return",
"new",
"ExternalSessionKey",
"(",
"responseBody",
".",
"replace",
"(",
"\"OK,\"",
",",
"\"\"",
")",
")",
";",
"}",
"throw",
"new",
"NewSessionException",
"(",
"\"The server returned an error : \"",
"+",
"responseBody",
")",
";",
"}"
] | extract the external key from the server response for a selenium1 new session request.
@param responseBody the response from the server
@return the ExternalKey if it was present in the server's response.
@throws NewSessionException in case the server didn't send back a success result. | [
"extract",
"the",
"external",
"key",
"from",
"the",
"server",
"response",
"for",
"a",
"selenium1",
"new",
"session",
"request",
"."
] | train | https://github.com/SeleniumHQ/selenium/blob/7af172729f17b20269c8ca4ea6f788db48616535/java/server/src/org/openqa/grid/internal/ExternalSessionKey.java#L130-L135 |
UrielCh/ovh-java-sdk | ovh-java-sdk-ip/src/main/java/net/minidev/ovh/api/ApiOvhIp.java | ApiOvhIp.ip_move_POST | public OvhIpTask ip_move_POST(String ip, String nexthop, String to) throws IOException {
"""
Move this IP to another service
REST: POST /ip/{ip}/move
@param nexthop [required] Nexthop of destination service
@param to [required] Service destination
@param ip [required]
"""
String qPath = "/ip/{ip}/move";
StringBuilder sb = path(qPath, ip);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "nexthop", nexthop);
addBody(o, "to", to);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhIpTask.class);
} | java | public OvhIpTask ip_move_POST(String ip, String nexthop, String to) throws IOException {
String qPath = "/ip/{ip}/move";
StringBuilder sb = path(qPath, ip);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "nexthop", nexthop);
addBody(o, "to", to);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhIpTask.class);
} | [
"public",
"OvhIpTask",
"ip_move_POST",
"(",
"String",
"ip",
",",
"String",
"nexthop",
",",
"String",
"to",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/ip/{ip}/move\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"ip",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"nexthop\"",
",",
"nexthop",
")",
";",
"addBody",
"(",
"o",
",",
"\"to\"",
",",
"to",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhIpTask",
".",
"class",
")",
";",
"}"
] | Move this IP to another service
REST: POST /ip/{ip}/move
@param nexthop [required] Nexthop of destination service
@param to [required] Service destination
@param ip [required] | [
"Move",
"this",
"IP",
"to",
"another",
"service"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-ip/src/main/java/net/minidev/ovh/api/ApiOvhIp.java#L505-L513 |
pryzach/midao | midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/type/TypeHandlerUtils.java | TypeHandlerUtils.convertArray | public static Object convertArray(Connection conn, Object[] array) throws SQLException {
"""
Converts array of Object into sql.Array
@param conn connection for which sql.Array object would be created
@param array array of objects
@return sql.Array from array of Object
@throws SQLException
"""
Object result = null;
result = createArrayOf(conn, convertJavaClassToSqlType(array.getClass().getComponentType().getSimpleName()), array);
return result;
} | java | public static Object convertArray(Connection conn, Object[] array) throws SQLException {
Object result = null;
result = createArrayOf(conn, convertJavaClassToSqlType(array.getClass().getComponentType().getSimpleName()), array);
return result;
} | [
"public",
"static",
"Object",
"convertArray",
"(",
"Connection",
"conn",
",",
"Object",
"[",
"]",
"array",
")",
"throws",
"SQLException",
"{",
"Object",
"result",
"=",
"null",
";",
"result",
"=",
"createArrayOf",
"(",
"conn",
",",
"convertJavaClassToSqlType",
"(",
"array",
".",
"getClass",
"(",
")",
".",
"getComponentType",
"(",
")",
".",
"getSimpleName",
"(",
")",
")",
",",
"array",
")",
";",
"return",
"result",
";",
"}"
] | Converts array of Object into sql.Array
@param conn connection for which sql.Array object would be created
@param array array of objects
@return sql.Array from array of Object
@throws SQLException | [
"Converts",
"array",
"of",
"Object",
"into",
"sql",
".",
"Array"
] | train | https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/type/TypeHandlerUtils.java#L51-L57 |
liyiorg/weixin-popular | src/main/java/weixin/popular/api/WxopenAPI.java | WxopenAPI.templateAdd | public static TemplateAddResult templateAdd(String access_token,String id,List<Integer> keyword_id_list) {
"""
组合模板并添加至帐号下的个人模板库
@since 2.8.18
@param access_token access_token
@param id 模板标题id,可通过接口获取,也可登录小程序后台查看获取
@param keyword_id_list 开发者自行组合好的模板关键词列表,关键词顺序可以自由搭配(例如[3,5,4]或[4,5,3]),最多支持10个关键词组合
@return result
"""
String json = String.format("{\"id\":\"%s\",\"keyword_id_list\":%s}", id,JsonUtil.toJSONString(keyword_id_list));
HttpUriRequest httpUriRequest = RequestBuilder.post()
.setHeader(jsonHeader)
.setUri(BASE_URI+"/cgi-bin/wxopen/template/add")
.addParameter(PARAM_ACCESS_TOKEN, API.accessToken(access_token))
.setEntity(new StringEntity(json,Charset.forName("utf-8")))
.build();
return LocalHttpClient.executeJsonResult(httpUriRequest,TemplateAddResult.class);
} | java | public static TemplateAddResult templateAdd(String access_token,String id,List<Integer> keyword_id_list){
String json = String.format("{\"id\":\"%s\",\"keyword_id_list\":%s}", id,JsonUtil.toJSONString(keyword_id_list));
HttpUriRequest httpUriRequest = RequestBuilder.post()
.setHeader(jsonHeader)
.setUri(BASE_URI+"/cgi-bin/wxopen/template/add")
.addParameter(PARAM_ACCESS_TOKEN, API.accessToken(access_token))
.setEntity(new StringEntity(json,Charset.forName("utf-8")))
.build();
return LocalHttpClient.executeJsonResult(httpUriRequest,TemplateAddResult.class);
} | [
"public",
"static",
"TemplateAddResult",
"templateAdd",
"(",
"String",
"access_token",
",",
"String",
"id",
",",
"List",
"<",
"Integer",
">",
"keyword_id_list",
")",
"{",
"String",
"json",
"=",
"String",
".",
"format",
"(",
"\"{\\\"id\\\":\\\"%s\\\",\\\"keyword_id_list\\\":%s}\"",
",",
"id",
",",
"JsonUtil",
".",
"toJSONString",
"(",
"keyword_id_list",
")",
")",
";",
"HttpUriRequest",
"httpUriRequest",
"=",
"RequestBuilder",
".",
"post",
"(",
")",
".",
"setHeader",
"(",
"jsonHeader",
")",
".",
"setUri",
"(",
"BASE_URI",
"+",
"\"/cgi-bin/wxopen/template/add\"",
")",
".",
"addParameter",
"(",
"PARAM_ACCESS_TOKEN",
",",
"API",
".",
"accessToken",
"(",
"access_token",
")",
")",
".",
"setEntity",
"(",
"new",
"StringEntity",
"(",
"json",
",",
"Charset",
".",
"forName",
"(",
"\"utf-8\"",
")",
")",
")",
".",
"build",
"(",
")",
";",
"return",
"LocalHttpClient",
".",
"executeJsonResult",
"(",
"httpUriRequest",
",",
"TemplateAddResult",
".",
"class",
")",
";",
"}"
] | 组合模板并添加至帐号下的个人模板库
@since 2.8.18
@param access_token access_token
@param id 模板标题id,可通过接口获取,也可登录小程序后台查看获取
@param keyword_id_list 开发者自行组合好的模板关键词列表,关键词顺序可以自由搭配(例如[3,5,4]或[4,5,3]),最多支持10个关键词组合
@return result | [
"组合模板并添加至帐号下的个人模板库"
] | train | https://github.com/liyiorg/weixin-popular/blob/c64255292d41463bdb671938feaabf42a335d82c/src/main/java/weixin/popular/api/WxopenAPI.java#L123-L132 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.