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/ade/containerpage/CmsContainerpageService.java | CmsContainerpageService.isEditSmallElements | private boolean isEditSmallElements(HttpServletRequest request, CmsObject cms) {
"""
Checks if small elements in a container page should be initially editable.<p>
@param request the current request
@param cms the current CMS context
@return true if small elements should be initially editable
"""
CmsUser user = cms.getRequestContext().getCurrentUser();
String editSmallElementsStr = (String)(user.getAdditionalInfo().get(ADDINFO_EDIT_SMALL_ELEMENTS));
if (editSmallElementsStr == null) {
return true;
} else {
return Boolean.valueOf(editSmallElementsStr).booleanValue();
}
} | java | private boolean isEditSmallElements(HttpServletRequest request, CmsObject cms) {
CmsUser user = cms.getRequestContext().getCurrentUser();
String editSmallElementsStr = (String)(user.getAdditionalInfo().get(ADDINFO_EDIT_SMALL_ELEMENTS));
if (editSmallElementsStr == null) {
return true;
} else {
return Boolean.valueOf(editSmallElementsStr).booleanValue();
}
} | [
"private",
"boolean",
"isEditSmallElements",
"(",
"HttpServletRequest",
"request",
",",
"CmsObject",
"cms",
")",
"{",
"CmsUser",
"user",
"=",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"getCurrentUser",
"(",
")",
";",
"String",
"editSmallElementsStr",
"=",
"(",
"String",
")",
"(",
"user",
".",
"getAdditionalInfo",
"(",
")",
".",
"get",
"(",
"ADDINFO_EDIT_SMALL_ELEMENTS",
")",
")",
";",
"if",
"(",
"editSmallElementsStr",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"Boolean",
".",
"valueOf",
"(",
"editSmallElementsStr",
")",
".",
"booleanValue",
"(",
")",
";",
"}",
"}"
] | Checks if small elements in a container page should be initially editable.<p>
@param request the current request
@param cms the current CMS context
@return true if small elements should be initially editable | [
"Checks",
"if",
"small",
"elements",
"in",
"a",
"container",
"page",
"should",
"be",
"initially",
"editable",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ade/containerpage/CmsContainerpageService.java#L2739-L2748 |
ManfredTremmel/gwt-commons-lang3 | src/main/java/org/apache/commons/lang3/time/DateUtils.java | DateUtils.isSameInstant | public static boolean isSameInstant(final Calendar cal1, final Calendar cal2) {
"""
<p>Checks if two calendar objects represent the same instant in time.</p>
<p>This method compares the long millisecond time of the two objects.</p>
@param cal1 the first calendar, not altered, not null
@param cal2 the second calendar, not altered, not null
@return true if they represent the same millisecond instant
@throws IllegalArgumentException if either date is <code>null</code>
@since 2.1
"""
if (cal1 == null || cal2 == null) {
throw new IllegalArgumentException("The date must not be null");
}
return cal1.getTime().getTime() == cal2.getTime().getTime();
} | java | public static boolean isSameInstant(final Calendar cal1, final Calendar cal2) {
if (cal1 == null || cal2 == null) {
throw new IllegalArgumentException("The date must not be null");
}
return cal1.getTime().getTime() == cal2.getTime().getTime();
} | [
"public",
"static",
"boolean",
"isSameInstant",
"(",
"final",
"Calendar",
"cal1",
",",
"final",
"Calendar",
"cal2",
")",
"{",
"if",
"(",
"cal1",
"==",
"null",
"||",
"cal2",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The date must not be null\"",
")",
";",
"}",
"return",
"cal1",
".",
"getTime",
"(",
")",
".",
"getTime",
"(",
")",
"==",
"cal2",
".",
"getTime",
"(",
")",
".",
"getTime",
"(",
")",
";",
"}"
] | <p>Checks if two calendar objects represent the same instant in time.</p>
<p>This method compares the long millisecond time of the two objects.</p>
@param cal1 the first calendar, not altered, not null
@param cal2 the second calendar, not altered, not null
@return true if they represent the same millisecond instant
@throws IllegalArgumentException if either date is <code>null</code>
@since 2.1 | [
"<p",
">",
"Checks",
"if",
"two",
"calendar",
"objects",
"represent",
"the",
"same",
"instant",
"in",
"time",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/time/DateUtils.java#L231-L236 |
Azure/azure-sdk-for-java | common/azure-common/src/main/java/com/azure/common/http/HttpPipelineCallContext.java | HttpPipelineCallContext.setData | public void setData(String key, Object value) {
"""
Stores a key-value data in the context.
@param key the key
@param value the value
"""
this.data = this.data.addData(key, value);
} | java | public void setData(String key, Object value) {
this.data = this.data.addData(key, value);
} | [
"public",
"void",
"setData",
"(",
"String",
"key",
",",
"Object",
"value",
")",
"{",
"this",
".",
"data",
"=",
"this",
".",
"data",
".",
"addData",
"(",
"key",
",",
"value",
")",
";",
"}"
] | Stores a key-value data in the context.
@param key the key
@param value the value | [
"Stores",
"a",
"key",
"-",
"value",
"data",
"in",
"the",
"context",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/common/azure-common/src/main/java/com/azure/common/http/HttpPipelineCallContext.java#L57-L59 |
johnkil/Android-AppMsg | library/src/com/devspark/appmsg/AppMsg.java | AppMsg.makeText | private static AppMsg makeText(Activity context, CharSequence text, Style style, View view, boolean floating) {
"""
Make a {@link AppMsg} with a custom view. It can be used to create non-floating notifications if floating is false.
@param context The context to use. Usually your
{@link android.app.Activity} object.
@param view
View to be used.
@param text The text to show. Can be formatted text.
@param style The style with a background and a duration.
@param floating true if it'll float.
"""
return makeText(context, text, style, view, floating, 0);
} | java | private static AppMsg makeText(Activity context, CharSequence text, Style style, View view, boolean floating) {
return makeText(context, text, style, view, floating, 0);
} | [
"private",
"static",
"AppMsg",
"makeText",
"(",
"Activity",
"context",
",",
"CharSequence",
"text",
",",
"Style",
"style",
",",
"View",
"view",
",",
"boolean",
"floating",
")",
"{",
"return",
"makeText",
"(",
"context",
",",
"text",
",",
"style",
",",
"view",
",",
"floating",
",",
"0",
")",
";",
"}"
] | Make a {@link AppMsg} with a custom view. It can be used to create non-floating notifications if floating is false.
@param context The context to use. Usually your
{@link android.app.Activity} object.
@param view
View to be used.
@param text The text to show. Can be formatted text.
@param style The style with a background and a duration.
@param floating true if it'll float. | [
"Make",
"a",
"{",
"@link",
"AppMsg",
"}",
"with",
"a",
"custom",
"view",
".",
"It",
"can",
"be",
"used",
"to",
"create",
"non",
"-",
"floating",
"notifications",
"if",
"floating",
"is",
"false",
"."
] | train | https://github.com/johnkil/Android-AppMsg/blob/e7fdd7870530a24e6d825278ee0863be0521e8b8/library/src/com/devspark/appmsg/AppMsg.java#L292-L294 |
Jasig/uPortal | uPortal-io/uPortal-io-core/src/main/java/org/apereo/portal/io/xml/JaxbPortalDataHandlerService.java | JaxbPortalDataHandlerService.importDataArchive | private void importDataArchive(
final Resource resource,
final ArchiveInputStream resourceStream,
BatchImportOptions options) {
"""
Extracts the archive resource and then runs the batch-import process on it.
"""
final File tempDir = Files.createTempDir();
try {
ArchiveEntry archiveEntry;
while ((archiveEntry = resourceStream.getNextEntry()) != null) {
final File entryFile = new File(tempDir, archiveEntry.getName());
if (!archiveEntry.isDirectory()) {
entryFile.getParentFile().mkdirs();
IOUtils.copy(
new CloseShieldInputStream(resourceStream),
new FileOutputStream(entryFile));
}
}
importDataDirectory(tempDir, null, options);
} catch (IOException e) {
throw new RuntimeException(
"Failed to extract data from '"
+ resource
+ "' to '"
+ tempDir
+ "' for batch import.",
e);
} finally {
FileUtils.deleteQuietly(tempDir);
}
} | java | private void importDataArchive(
final Resource resource,
final ArchiveInputStream resourceStream,
BatchImportOptions options) {
final File tempDir = Files.createTempDir();
try {
ArchiveEntry archiveEntry;
while ((archiveEntry = resourceStream.getNextEntry()) != null) {
final File entryFile = new File(tempDir, archiveEntry.getName());
if (!archiveEntry.isDirectory()) {
entryFile.getParentFile().mkdirs();
IOUtils.copy(
new CloseShieldInputStream(resourceStream),
new FileOutputStream(entryFile));
}
}
importDataDirectory(tempDir, null, options);
} catch (IOException e) {
throw new RuntimeException(
"Failed to extract data from '"
+ resource
+ "' to '"
+ tempDir
+ "' for batch import.",
e);
} finally {
FileUtils.deleteQuietly(tempDir);
}
} | [
"private",
"void",
"importDataArchive",
"(",
"final",
"Resource",
"resource",
",",
"final",
"ArchiveInputStream",
"resourceStream",
",",
"BatchImportOptions",
"options",
")",
"{",
"final",
"File",
"tempDir",
"=",
"Files",
".",
"createTempDir",
"(",
")",
";",
"try",
"{",
"ArchiveEntry",
"archiveEntry",
";",
"while",
"(",
"(",
"archiveEntry",
"=",
"resourceStream",
".",
"getNextEntry",
"(",
")",
")",
"!=",
"null",
")",
"{",
"final",
"File",
"entryFile",
"=",
"new",
"File",
"(",
"tempDir",
",",
"archiveEntry",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"!",
"archiveEntry",
".",
"isDirectory",
"(",
")",
")",
"{",
"entryFile",
".",
"getParentFile",
"(",
")",
".",
"mkdirs",
"(",
")",
";",
"IOUtils",
".",
"copy",
"(",
"new",
"CloseShieldInputStream",
"(",
"resourceStream",
")",
",",
"new",
"FileOutputStream",
"(",
"entryFile",
")",
")",
";",
"}",
"}",
"importDataDirectory",
"(",
"tempDir",
",",
"null",
",",
"options",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Failed to extract data from '\"",
"+",
"resource",
"+",
"\"' to '\"",
"+",
"tempDir",
"+",
"\"' for batch import.\"",
",",
"e",
")",
";",
"}",
"finally",
"{",
"FileUtils",
".",
"deleteQuietly",
"(",
"tempDir",
")",
";",
"}",
"}"
] | Extracts the archive resource and then runs the batch-import process on it. | [
"Extracts",
"the",
"archive",
"resource",
"and",
"then",
"runs",
"the",
"batch",
"-",
"import",
"process",
"on",
"it",
"."
] | train | https://github.com/Jasig/uPortal/blob/c1986542abb9acd214268f2df21c6305ad2f262b/uPortal-io/uPortal-io-core/src/main/java/org/apereo/portal/io/xml/JaxbPortalDataHandlerService.java#L490-L520 |
google/error-prone-javac | src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstantsSummaryBuilder.java | ConstantsSummaryBuilder.buildClassConstantSummary | public void buildClassConstantSummary(XMLNode node, Content summariesTree)
throws DocletException {
"""
Build the summary for the current class.
@param node the XML element that specifies which components to document
@param summariesTree the tree to which the class constant summary will be added
@throws DocletException if there is a problem while building the documentation
"""
SortedSet<TypeElement> classes = !currentPackage.isUnnamed()
? utils.getAllClasses(currentPackage)
: configuration.typeElementCatalog.allUnnamedClasses();
Content classConstantTree = writer.getClassConstantHeader();
for (TypeElement te : classes) {
if (!typeElementsWithConstFields.contains(te) ||
!utils.isIncluded(te)) {
continue;
}
currentClass = te;
//Build the documentation for the current class.
buildChildren(node, classConstantTree);
}
writer.addClassConstant(summariesTree, classConstantTree);
} | java | public void buildClassConstantSummary(XMLNode node, Content summariesTree)
throws DocletException {
SortedSet<TypeElement> classes = !currentPackage.isUnnamed()
? utils.getAllClasses(currentPackage)
: configuration.typeElementCatalog.allUnnamedClasses();
Content classConstantTree = writer.getClassConstantHeader();
for (TypeElement te : classes) {
if (!typeElementsWithConstFields.contains(te) ||
!utils.isIncluded(te)) {
continue;
}
currentClass = te;
//Build the documentation for the current class.
buildChildren(node, classConstantTree);
}
writer.addClassConstant(summariesTree, classConstantTree);
} | [
"public",
"void",
"buildClassConstantSummary",
"(",
"XMLNode",
"node",
",",
"Content",
"summariesTree",
")",
"throws",
"DocletException",
"{",
"SortedSet",
"<",
"TypeElement",
">",
"classes",
"=",
"!",
"currentPackage",
".",
"isUnnamed",
"(",
")",
"?",
"utils",
".",
"getAllClasses",
"(",
"currentPackage",
")",
":",
"configuration",
".",
"typeElementCatalog",
".",
"allUnnamedClasses",
"(",
")",
";",
"Content",
"classConstantTree",
"=",
"writer",
".",
"getClassConstantHeader",
"(",
")",
";",
"for",
"(",
"TypeElement",
"te",
":",
"classes",
")",
"{",
"if",
"(",
"!",
"typeElementsWithConstFields",
".",
"contains",
"(",
"te",
")",
"||",
"!",
"utils",
".",
"isIncluded",
"(",
"te",
")",
")",
"{",
"continue",
";",
"}",
"currentClass",
"=",
"te",
";",
"//Build the documentation for the current class.",
"buildChildren",
"(",
"node",
",",
"classConstantTree",
")",
";",
"}",
"writer",
".",
"addClassConstant",
"(",
"summariesTree",
",",
"classConstantTree",
")",
";",
"}"
] | Build the summary for the current class.
@param node the XML element that specifies which components to document
@param summariesTree the tree to which the class constant summary will be added
@throws DocletException if there is a problem while building the documentation | [
"Build",
"the",
"summary",
"for",
"the",
"current",
"class",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstantsSummaryBuilder.java#L221-L237 |
mapsforge/mapsforge | mapsforge-poi-writer/src/main/java/org/mapsforge/poi/writer/logging/LoggerWrapper.java | LoggerWrapper.getLogger | public static LoggerWrapper getLogger(String name, ProgressManager pm) {
"""
Returns or creates a logger that forwards messages to a {@link ProgressManager}. If the
logger does not yet have any progress manager assigned, the given one will be used.
@param name The logger's unique name. By default the calling class' name is used.
@param pm The logger's progress manager. This value is only used if a logger object has to
be created or a logger with a given name does not yet have any progress manager
assigned or if the default progress manager is used.
@return A logger that forwards messages to a {@link ProgressManager}.
"""
LoggerWrapper ret = getLogger(name);
if (ret.getProgressManager() == null
|| ret.getProgressManager() == LoggerWrapper.defaultProgressManager) {
ret.setProgressManager(pm);
}
return ret;
} | java | public static LoggerWrapper getLogger(String name, ProgressManager pm) {
LoggerWrapper ret = getLogger(name);
if (ret.getProgressManager() == null
|| ret.getProgressManager() == LoggerWrapper.defaultProgressManager) {
ret.setProgressManager(pm);
}
return ret;
} | [
"public",
"static",
"LoggerWrapper",
"getLogger",
"(",
"String",
"name",
",",
"ProgressManager",
"pm",
")",
"{",
"LoggerWrapper",
"ret",
"=",
"getLogger",
"(",
"name",
")",
";",
"if",
"(",
"ret",
".",
"getProgressManager",
"(",
")",
"==",
"null",
"||",
"ret",
".",
"getProgressManager",
"(",
")",
"==",
"LoggerWrapper",
".",
"defaultProgressManager",
")",
"{",
"ret",
".",
"setProgressManager",
"(",
"pm",
")",
";",
"}",
"return",
"ret",
";",
"}"
] | Returns or creates a logger that forwards messages to a {@link ProgressManager}. If the
logger does not yet have any progress manager assigned, the given one will be used.
@param name The logger's unique name. By default the calling class' name is used.
@param pm The logger's progress manager. This value is only used if a logger object has to
be created or a logger with a given name does not yet have any progress manager
assigned or if the default progress manager is used.
@return A logger that forwards messages to a {@link ProgressManager}. | [
"Returns",
"or",
"creates",
"a",
"logger",
"that",
"forwards",
"messages",
"to",
"a",
"{",
"@link",
"ProgressManager",
"}",
".",
"If",
"the",
"logger",
"does",
"not",
"yet",
"have",
"any",
"progress",
"manager",
"assigned",
"the",
"given",
"one",
"will",
"be",
"used",
"."
] | train | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-poi-writer/src/main/java/org/mapsforge/poi/writer/logging/LoggerWrapper.java#L68-L77 |
tumblr/jumblr | src/main/java/com/tumblr/jumblr/JumblrClient.java | JumblrClient.postReblog | public Post postReblog(String blogName, Long postId, String reblogKey, Map<String, ?> options) {
"""
Reblog a given post
@param blogName the name of the blog to post to
@param postId the id of the post
@param reblogKey the reblog_key of the post
@param options Additional options (or null)
@return The created reblog Post or null
"""
if (options == null) {
options = new HashMap<String, String>();
}
Map<String, Object> soptions = JumblrClient.safeOptionMap(options);
soptions.put("id", postId.toString());
soptions.put("reblog_key", reblogKey);
final Long reblogId = requestBuilder.post(JumblrClient.blogPath(blogName, "/post/reblog"), soptions).getId();
return this.blogPost(blogName, reblogId);
} | java | public Post postReblog(String blogName, Long postId, String reblogKey, Map<String, ?> options) {
if (options == null) {
options = new HashMap<String, String>();
}
Map<String, Object> soptions = JumblrClient.safeOptionMap(options);
soptions.put("id", postId.toString());
soptions.put("reblog_key", reblogKey);
final Long reblogId = requestBuilder.post(JumblrClient.blogPath(blogName, "/post/reblog"), soptions).getId();
return this.blogPost(blogName, reblogId);
} | [
"public",
"Post",
"postReblog",
"(",
"String",
"blogName",
",",
"Long",
"postId",
",",
"String",
"reblogKey",
",",
"Map",
"<",
"String",
",",
"?",
">",
"options",
")",
"{",
"if",
"(",
"options",
"==",
"null",
")",
"{",
"options",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"}",
"Map",
"<",
"String",
",",
"Object",
">",
"soptions",
"=",
"JumblrClient",
".",
"safeOptionMap",
"(",
"options",
")",
";",
"soptions",
".",
"put",
"(",
"\"id\"",
",",
"postId",
".",
"toString",
"(",
")",
")",
";",
"soptions",
".",
"put",
"(",
"\"reblog_key\"",
",",
"reblogKey",
")",
";",
"final",
"Long",
"reblogId",
"=",
"requestBuilder",
".",
"post",
"(",
"JumblrClient",
".",
"blogPath",
"(",
"blogName",
",",
"\"/post/reblog\"",
")",
",",
"soptions",
")",
".",
"getId",
"(",
")",
";",
"return",
"this",
".",
"blogPost",
"(",
"blogName",
",",
"reblogId",
")",
";",
"}"
] | Reblog a given post
@param blogName the name of the blog to post to
@param postId the id of the post
@param reblogKey the reblog_key of the post
@param options Additional options (or null)
@return The created reblog Post or null | [
"Reblog",
"a",
"given",
"post"
] | train | https://github.com/tumblr/jumblr/blob/373629fd545defb016e227ea758f092507fbd624/src/main/java/com/tumblr/jumblr/JumblrClient.java#L342-L351 |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/metadata/JdbcMetadataUtils.java | JdbcMetadataUtils.findPlatformFor | public String findPlatformFor(String jdbcSubProtocol, String jdbcDriver) {
"""
Derives the OJB platform to use for a database that is connected via a url using the specified
subprotocol, and where the specified jdbc driver is used.
@param jdbcSubProtocol The JDBC subprotocol used to connect to the database
@param jdbcDriver The JDBC driver used to connect to the database
@return The platform identifier or <code>null</code> if no platform could be found
"""
String platform = (String)jdbcSubProtocolToPlatform.get(jdbcSubProtocol);
if (platform == null)
{
platform = (String)jdbcDriverToPlatform.get(jdbcDriver);
}
return platform;
} | java | public String findPlatformFor(String jdbcSubProtocol, String jdbcDriver)
{
String platform = (String)jdbcSubProtocolToPlatform.get(jdbcSubProtocol);
if (platform == null)
{
platform = (String)jdbcDriverToPlatform.get(jdbcDriver);
}
return platform;
} | [
"public",
"String",
"findPlatformFor",
"(",
"String",
"jdbcSubProtocol",
",",
"String",
"jdbcDriver",
")",
"{",
"String",
"platform",
"=",
"(",
"String",
")",
"jdbcSubProtocolToPlatform",
".",
"get",
"(",
"jdbcSubProtocol",
")",
";",
"if",
"(",
"platform",
"==",
"null",
")",
"{",
"platform",
"=",
"(",
"String",
")",
"jdbcDriverToPlatform",
".",
"get",
"(",
"jdbcDriver",
")",
";",
"}",
"return",
"platform",
";",
"}"
] | Derives the OJB platform to use for a database that is connected via a url using the specified
subprotocol, and where the specified jdbc driver is used.
@param jdbcSubProtocol The JDBC subprotocol used to connect to the database
@param jdbcDriver The JDBC driver used to connect to the database
@return The platform identifier or <code>null</code> if no platform could be found | [
"Derives",
"the",
"OJB",
"platform",
"to",
"use",
"for",
"a",
"database",
"that",
"is",
"connected",
"via",
"a",
"url",
"using",
"the",
"specified",
"subprotocol",
"and",
"where",
"the",
"specified",
"jdbc",
"driver",
"is",
"used",
"."
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/metadata/JdbcMetadataUtils.java#L391-L400 |
OpenLiberty/open-liberty | dev/com.ibm.ws.security.social/src/com/ibm/ws/security/social/twitter/TwitterEndpointServices.java | TwitterEndpointServices.verifyCredentials | public Map<String, Object> verifyCredentials(SocialLoginConfig config, String accessToken, @Sensitive String accessTokenSecret) {
"""
Invokes the {@value TwitterConstants#TWITTER_ENDPOINT_VERIFY_CREDENTIALS} endpoint in order to obtain a value to use for
the user subject.
@param config
@param accessToken
@param accessTokenSecret
@return
"""
String endpointUrl = config.getUserApi();
try {
SocialUtil.validateEndpointWithQuery(endpointUrl);
} catch (SocialLoginException e) {
return createErrorResponse("TWITTER_BAD_USER_API_URL", new Object[] { endpointUrl, TwitterLoginConfigImpl.KEY_userApi, config.getUniqueId(), e.getLocalizedMessage() });
}
tokenSecret = accessTokenSecret;
requestMethod = "GET";
// Create the Authorization header string necessary to authenticate the request
String authzHeaderString = createAuthzHeaderForVerifyCredentialsEndpoint(endpointUrl, accessToken);
if (tc.isDebugEnabled()) {
Tr.debug(tc, "Authz header string: " + authzHeaderString);
}
return executeRequest(config, requestMethod, authzHeaderString, endpointUrl, TwitterConstants.TWITTER_ENDPOINT_VERIFY_CREDENTIALS, null);
} | java | public Map<String, Object> verifyCredentials(SocialLoginConfig config, String accessToken, @Sensitive String accessTokenSecret) {
String endpointUrl = config.getUserApi();
try {
SocialUtil.validateEndpointWithQuery(endpointUrl);
} catch (SocialLoginException e) {
return createErrorResponse("TWITTER_BAD_USER_API_URL", new Object[] { endpointUrl, TwitterLoginConfigImpl.KEY_userApi, config.getUniqueId(), e.getLocalizedMessage() });
}
tokenSecret = accessTokenSecret;
requestMethod = "GET";
// Create the Authorization header string necessary to authenticate the request
String authzHeaderString = createAuthzHeaderForVerifyCredentialsEndpoint(endpointUrl, accessToken);
if (tc.isDebugEnabled()) {
Tr.debug(tc, "Authz header string: " + authzHeaderString);
}
return executeRequest(config, requestMethod, authzHeaderString, endpointUrl, TwitterConstants.TWITTER_ENDPOINT_VERIFY_CREDENTIALS, null);
} | [
"public",
"Map",
"<",
"String",
",",
"Object",
">",
"verifyCredentials",
"(",
"SocialLoginConfig",
"config",
",",
"String",
"accessToken",
",",
"@",
"Sensitive",
"String",
"accessTokenSecret",
")",
"{",
"String",
"endpointUrl",
"=",
"config",
".",
"getUserApi",
"(",
")",
";",
"try",
"{",
"SocialUtil",
".",
"validateEndpointWithQuery",
"(",
"endpointUrl",
")",
";",
"}",
"catch",
"(",
"SocialLoginException",
"e",
")",
"{",
"return",
"createErrorResponse",
"(",
"\"TWITTER_BAD_USER_API_URL\"",
",",
"new",
"Object",
"[",
"]",
"{",
"endpointUrl",
",",
"TwitterLoginConfigImpl",
".",
"KEY_userApi",
",",
"config",
".",
"getUniqueId",
"(",
")",
",",
"e",
".",
"getLocalizedMessage",
"(",
")",
"}",
")",
";",
"}",
"tokenSecret",
"=",
"accessTokenSecret",
";",
"requestMethod",
"=",
"\"GET\"",
";",
"// Create the Authorization header string necessary to authenticate the request",
"String",
"authzHeaderString",
"=",
"createAuthzHeaderForVerifyCredentialsEndpoint",
"(",
"endpointUrl",
",",
"accessToken",
")",
";",
"if",
"(",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"Authz header string: \"",
"+",
"authzHeaderString",
")",
";",
"}",
"return",
"executeRequest",
"(",
"config",
",",
"requestMethod",
",",
"authzHeaderString",
",",
"endpointUrl",
",",
"TwitterConstants",
".",
"TWITTER_ENDPOINT_VERIFY_CREDENTIALS",
",",
"null",
")",
";",
"}"
] | Invokes the {@value TwitterConstants#TWITTER_ENDPOINT_VERIFY_CREDENTIALS} endpoint in order to obtain a value to use for
the user subject.
@param config
@param accessToken
@param accessTokenSecret
@return | [
"Invokes",
"the",
"{",
"@value",
"TwitterConstants#TWITTER_ENDPOINT_VERIFY_CREDENTIALS",
"}",
"endpoint",
"in",
"order",
"to",
"obtain",
"a",
"value",
"to",
"use",
"for",
"the",
"user",
"subject",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.social/src/com/ibm/ws/security/social/twitter/TwitterEndpointServices.java#L973-L992 |
qiniu/java-sdk | src/main/java/com/qiniu/storage/UploadManager.java | UploadManager.put | public Response put(File file, String key, String token) throws QiniuException {
"""
上传文件
@param file 上传的文件对象
@param key 上传文件保存的文件名
@param token 上传凭证
"""
return put(file, key, token, null, null, false);
} | java | public Response put(File file, String key, String token) throws QiniuException {
return put(file, key, token, null, null, false);
} | [
"public",
"Response",
"put",
"(",
"File",
"file",
",",
"String",
"key",
",",
"String",
"token",
")",
"throws",
"QiniuException",
"{",
"return",
"put",
"(",
"file",
",",
"key",
",",
"token",
",",
"null",
",",
"null",
",",
"false",
")",
";",
"}"
] | 上传文件
@param file 上传的文件对象
@param key 上传文件保存的文件名
@param token 上传凭证 | [
"上传文件"
] | train | https://github.com/qiniu/java-sdk/blob/6c05f3fb718403a496c725b048e9241f80171499/src/main/java/com/qiniu/storage/UploadManager.java#L185-L187 |
Waikato/moa | moa/src/main/java/moa/classifiers/lazy/neighboursearch/KDTree.java | KDTree.clipToInsideHrect | protected boolean clipToInsideHrect(KDTreeNode node, Instance x) {
"""
Finds the closest point in the hyper rectangle to a given point. Change the
given point to this closest point by clipping of at all the dimensions to
be clipped of. If the point is inside the rectangle it stays unchanged. The
return value is true if the point was not changed, so the the return value
is true if the point was inside the rectangle.
@param node The current KDTreeNode in whose hyperrectangle the closest
point is to be found.
@param x a point
@return true if the input point stayed unchanged.
"""
boolean inside = true;
for (int i = 0; i < m_Instances.numAttributes(); i++) {
// TODO treat nominals differently!??
if (x.value(i) < node.m_NodeRanges[i][MIN]) {
x.setValue(i, node.m_NodeRanges[i][MIN]);
inside = false;
} else if (x.value(i) > node.m_NodeRanges[i][MAX]) {
x.setValue(i, node.m_NodeRanges[i][MAX]);
inside = false;
}
}
return inside;
} | java | protected boolean clipToInsideHrect(KDTreeNode node, Instance x) {
boolean inside = true;
for (int i = 0; i < m_Instances.numAttributes(); i++) {
// TODO treat nominals differently!??
if (x.value(i) < node.m_NodeRanges[i][MIN]) {
x.setValue(i, node.m_NodeRanges[i][MIN]);
inside = false;
} else if (x.value(i) > node.m_NodeRanges[i][MAX]) {
x.setValue(i, node.m_NodeRanges[i][MAX]);
inside = false;
}
}
return inside;
} | [
"protected",
"boolean",
"clipToInsideHrect",
"(",
"KDTreeNode",
"node",
",",
"Instance",
"x",
")",
"{",
"boolean",
"inside",
"=",
"true",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"m_Instances",
".",
"numAttributes",
"(",
")",
";",
"i",
"++",
")",
"{",
"// TODO treat nominals differently!??",
"if",
"(",
"x",
".",
"value",
"(",
"i",
")",
"<",
"node",
".",
"m_NodeRanges",
"[",
"i",
"]",
"[",
"MIN",
"]",
")",
"{",
"x",
".",
"setValue",
"(",
"i",
",",
"node",
".",
"m_NodeRanges",
"[",
"i",
"]",
"[",
"MIN",
"]",
")",
";",
"inside",
"=",
"false",
";",
"}",
"else",
"if",
"(",
"x",
".",
"value",
"(",
"i",
")",
">",
"node",
".",
"m_NodeRanges",
"[",
"i",
"]",
"[",
"MAX",
"]",
")",
"{",
"x",
".",
"setValue",
"(",
"i",
",",
"node",
".",
"m_NodeRanges",
"[",
"i",
"]",
"[",
"MAX",
"]",
")",
";",
"inside",
"=",
"false",
";",
"}",
"}",
"return",
"inside",
";",
"}"
] | Finds the closest point in the hyper rectangle to a given point. Change the
given point to this closest point by clipping of at all the dimensions to
be clipped of. If the point is inside the rectangle it stays unchanged. The
return value is true if the point was not changed, so the the return value
is true if the point was inside the rectangle.
@param node The current KDTreeNode in whose hyperrectangle the closest
point is to be found.
@param x a point
@return true if the input point stayed unchanged. | [
"Finds",
"the",
"closest",
"point",
"in",
"the",
"hyper",
"rectangle",
"to",
"a",
"given",
"point",
".",
"Change",
"the",
"given",
"point",
"to",
"this",
"closest",
"point",
"by",
"clipping",
"of",
"at",
"all",
"the",
"dimensions",
"to",
"be",
"clipped",
"of",
".",
"If",
"the",
"point",
"is",
"inside",
"the",
"rectangle",
"it",
"stays",
"unchanged",
".",
"The",
"return",
"value",
"is",
"true",
"if",
"the",
"point",
"was",
"not",
"changed",
"so",
"the",
"the",
"return",
"value",
"is",
"true",
"if",
"the",
"point",
"was",
"inside",
"the",
"rectangle",
"."
] | train | https://github.com/Waikato/moa/blob/395982e5100bfe75a3a4d26115462ce2cc74cbb0/moa/src/main/java/moa/classifiers/lazy/neighboursearch/KDTree.java#L842-L856 |
elki-project/elki | elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/strategies/insert/MinimumEnlargementInsert.java | MinimumEnlargementInsert.choosePath | private IndexTreePath<E> choosePath(AbstractMTree<?, N, E, ?> tree, E object, IndexTreePath<E> subtree) {
"""
Chooses the best path of the specified subtree for insertion of the given
object.
@param tree the tree to insert into
@param object the entry to search
@param subtree the subtree to be tested for insertion
@return the path of the appropriate subtree to insert the given object
"""
N node = tree.getNode(subtree.getEntry());
// leaf
if(node.isLeaf()) {
return subtree;
}
// Initialize from first:
int bestIdx = 0;
E bestEntry = node.getEntry(0);
double bestDistance = tree.distance(object.getRoutingObjectID(), bestEntry.getRoutingObjectID());
// Iterate over remaining
for(int i = 1; i < node.getNumEntries(); i++) {
E entry = node.getEntry(i);
double distance = tree.distance(object.getRoutingObjectID(), entry.getRoutingObjectID());
if(distance < bestDistance) {
bestIdx = i;
bestEntry = entry;
bestDistance = distance;
}
}
return choosePath(tree, object, new IndexTreePath<>(subtree, bestEntry, bestIdx));
} | java | private IndexTreePath<E> choosePath(AbstractMTree<?, N, E, ?> tree, E object, IndexTreePath<E> subtree) {
N node = tree.getNode(subtree.getEntry());
// leaf
if(node.isLeaf()) {
return subtree;
}
// Initialize from first:
int bestIdx = 0;
E bestEntry = node.getEntry(0);
double bestDistance = tree.distance(object.getRoutingObjectID(), bestEntry.getRoutingObjectID());
// Iterate over remaining
for(int i = 1; i < node.getNumEntries(); i++) {
E entry = node.getEntry(i);
double distance = tree.distance(object.getRoutingObjectID(), entry.getRoutingObjectID());
if(distance < bestDistance) {
bestIdx = i;
bestEntry = entry;
bestDistance = distance;
}
}
return choosePath(tree, object, new IndexTreePath<>(subtree, bestEntry, bestIdx));
} | [
"private",
"IndexTreePath",
"<",
"E",
">",
"choosePath",
"(",
"AbstractMTree",
"<",
"?",
",",
"N",
",",
"E",
",",
"?",
">",
"tree",
",",
"E",
"object",
",",
"IndexTreePath",
"<",
"E",
">",
"subtree",
")",
"{",
"N",
"node",
"=",
"tree",
".",
"getNode",
"(",
"subtree",
".",
"getEntry",
"(",
")",
")",
";",
"// leaf",
"if",
"(",
"node",
".",
"isLeaf",
"(",
")",
")",
"{",
"return",
"subtree",
";",
"}",
"// Initialize from first:",
"int",
"bestIdx",
"=",
"0",
";",
"E",
"bestEntry",
"=",
"node",
".",
"getEntry",
"(",
"0",
")",
";",
"double",
"bestDistance",
"=",
"tree",
".",
"distance",
"(",
"object",
".",
"getRoutingObjectID",
"(",
")",
",",
"bestEntry",
".",
"getRoutingObjectID",
"(",
")",
")",
";",
"// Iterate over remaining",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"node",
".",
"getNumEntries",
"(",
")",
";",
"i",
"++",
")",
"{",
"E",
"entry",
"=",
"node",
".",
"getEntry",
"(",
"i",
")",
";",
"double",
"distance",
"=",
"tree",
".",
"distance",
"(",
"object",
".",
"getRoutingObjectID",
"(",
")",
",",
"entry",
".",
"getRoutingObjectID",
"(",
")",
")",
";",
"if",
"(",
"distance",
"<",
"bestDistance",
")",
"{",
"bestIdx",
"=",
"i",
";",
"bestEntry",
"=",
"entry",
";",
"bestDistance",
"=",
"distance",
";",
"}",
"}",
"return",
"choosePath",
"(",
"tree",
",",
"object",
",",
"new",
"IndexTreePath",
"<>",
"(",
"subtree",
",",
"bestEntry",
",",
"bestIdx",
")",
")",
";",
"}"
] | Chooses the best path of the specified subtree for insertion of the given
object.
@param tree the tree to insert into
@param object the entry to search
@param subtree the subtree to be tested for insertion
@return the path of the appropriate subtree to insert the given object | [
"Chooses",
"the",
"best",
"path",
"of",
"the",
"specified",
"subtree",
"for",
"insertion",
"of",
"the",
"given",
"object",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/strategies/insert/MinimumEnlargementInsert.java#L61-L86 |
hankcs/HanLP | src/main/java/com/hankcs/hanlp/dependency/nnparser/Matrix.java | Matrix.constructWithCopy | public static Matrix constructWithCopy(double[][] A) {
"""
Construct a matrix from a copy of a 2-D array.
@param A Two-dimensional array of doubles.
@throws IllegalArgumentException All rows must have the same length
"""
int m = A.length;
int n = A[0].length;
Matrix X = new Matrix(m, n);
double[][] C = X.getArray();
for (int i = 0; i < m; i++)
{
if (A[i].length != n)
{
throw new IllegalArgumentException
("All rows must have the same length.");
}
for (int j = 0; j < n; j++)
{
C[i][j] = A[i][j];
}
}
return X;
} | java | public static Matrix constructWithCopy(double[][] A)
{
int m = A.length;
int n = A[0].length;
Matrix X = new Matrix(m, n);
double[][] C = X.getArray();
for (int i = 0; i < m; i++)
{
if (A[i].length != n)
{
throw new IllegalArgumentException
("All rows must have the same length.");
}
for (int j = 0; j < n; j++)
{
C[i][j] = A[i][j];
}
}
return X;
} | [
"public",
"static",
"Matrix",
"constructWithCopy",
"(",
"double",
"[",
"]",
"[",
"]",
"A",
")",
"{",
"int",
"m",
"=",
"A",
".",
"length",
";",
"int",
"n",
"=",
"A",
"[",
"0",
"]",
".",
"length",
";",
"Matrix",
"X",
"=",
"new",
"Matrix",
"(",
"m",
",",
"n",
")",
";",
"double",
"[",
"]",
"[",
"]",
"C",
"=",
"X",
".",
"getArray",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"m",
";",
"i",
"++",
")",
"{",
"if",
"(",
"A",
"[",
"i",
"]",
".",
"length",
"!=",
"n",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"All rows must have the same length.\"",
")",
";",
"}",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"n",
";",
"j",
"++",
")",
"{",
"C",
"[",
"i",
"]",
"[",
"j",
"]",
"=",
"A",
"[",
"i",
"]",
"[",
"j",
"]",
";",
"}",
"}",
"return",
"X",
";",
"}"
] | Construct a matrix from a copy of a 2-D array.
@param A Two-dimensional array of doubles.
@throws IllegalArgumentException All rows must have the same length | [
"Construct",
"a",
"matrix",
"from",
"a",
"copy",
"of",
"a",
"2",
"-",
"D",
"array",
"."
] | train | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/dependency/nnparser/Matrix.java#L199-L218 |
meltmedia/cadmium | core/src/main/java/com/meltmedia/cadmium/core/git/GitService.java | GitService.initializeConfigDirectory | public static GitService initializeConfigDirectory(String uri, String branch, String root, String warName, HistoryManager historyManager, ConfigManager configManager) throws Exception {
"""
Initializes war configuration directory for a Cadmium war.
@param uri The remote Git repository ssh URI.
@param branch The remote branch to checkout.
@param root The shared root.
@param warName The name of the war file.
@param historyManager The history manager to log the initialization event.
@return A GitService object the points to the freshly cloned Git repository.
@throws RefNotFoundException
@throws Exception
"""
initializeBaseDirectoryStructure(root, warName);
String warDir = FileSystemManager.getChildDirectoryIfExists(root, warName);
Properties configProperties = configManager.getDefaultProperties();
GitLocation gitLocation = new GitLocation(uri, branch, configProperties.getProperty("config.git.ref.sha"));
GitService cloned = initializeRepo(gitLocation, warDir, "git-config-checkout");
try {
String renderedContentDir = initializeSnapshotDirectory(warDir,
configProperties, "com.meltmedia.cadmium.config.lastUpdated", "git-config-checkout", "config");
boolean hasExisting = configProperties.containsKey("com.meltmedia.cadmium.config.lastUpdated") && renderedContentDir != null && renderedContentDir.equals(configProperties.getProperty("com.meltmedia.cadmium.config.lastUpdated"));
if(renderedContentDir != null) {
configProperties.setProperty("com.meltmedia.cadmium.config.lastUpdated", renderedContentDir);
}
configProperties.setProperty("config.branch", cloned.getBranchName());
configProperties.setProperty("config.git.ref.sha", cloned.getCurrentRevision());
configProperties.setProperty("config.repo", cloned.getRemoteRepository());
configManager.persistDefaultProperties();
ExecutorService pool = null;
if(historyManager == null) {
pool = Executors.newSingleThreadExecutor();
historyManager = new HistoryManager(warDir, pool);
}
try{
if(historyManager != null && !hasExisting) {
historyManager.logEvent(EntryType.CONFIG,
// NOTE: We should integrate the git pointer into this class.
new GitLocation(cloned.getRemoteRepository(), cloned.getBranchName(), cloned.getCurrentRevision()),
"AUTO",
renderedContentDir,
"", "Initial config pull.",
true,
true);
}
} finally {
if(pool != null) {
pool.shutdownNow();
}
}
return cloned;
} catch (Throwable e){
cloned.close();
throw new Exception(e);
}
} | java | public static GitService initializeConfigDirectory(String uri, String branch, String root, String warName, HistoryManager historyManager, ConfigManager configManager) throws Exception {
initializeBaseDirectoryStructure(root, warName);
String warDir = FileSystemManager.getChildDirectoryIfExists(root, warName);
Properties configProperties = configManager.getDefaultProperties();
GitLocation gitLocation = new GitLocation(uri, branch, configProperties.getProperty("config.git.ref.sha"));
GitService cloned = initializeRepo(gitLocation, warDir, "git-config-checkout");
try {
String renderedContentDir = initializeSnapshotDirectory(warDir,
configProperties, "com.meltmedia.cadmium.config.lastUpdated", "git-config-checkout", "config");
boolean hasExisting = configProperties.containsKey("com.meltmedia.cadmium.config.lastUpdated") && renderedContentDir != null && renderedContentDir.equals(configProperties.getProperty("com.meltmedia.cadmium.config.lastUpdated"));
if(renderedContentDir != null) {
configProperties.setProperty("com.meltmedia.cadmium.config.lastUpdated", renderedContentDir);
}
configProperties.setProperty("config.branch", cloned.getBranchName());
configProperties.setProperty("config.git.ref.sha", cloned.getCurrentRevision());
configProperties.setProperty("config.repo", cloned.getRemoteRepository());
configManager.persistDefaultProperties();
ExecutorService pool = null;
if(historyManager == null) {
pool = Executors.newSingleThreadExecutor();
historyManager = new HistoryManager(warDir, pool);
}
try{
if(historyManager != null && !hasExisting) {
historyManager.logEvent(EntryType.CONFIG,
// NOTE: We should integrate the git pointer into this class.
new GitLocation(cloned.getRemoteRepository(), cloned.getBranchName(), cloned.getCurrentRevision()),
"AUTO",
renderedContentDir,
"", "Initial config pull.",
true,
true);
}
} finally {
if(pool != null) {
pool.shutdownNow();
}
}
return cloned;
} catch (Throwable e){
cloned.close();
throw new Exception(e);
}
} | [
"public",
"static",
"GitService",
"initializeConfigDirectory",
"(",
"String",
"uri",
",",
"String",
"branch",
",",
"String",
"root",
",",
"String",
"warName",
",",
"HistoryManager",
"historyManager",
",",
"ConfigManager",
"configManager",
")",
"throws",
"Exception",
"{",
"initializeBaseDirectoryStructure",
"(",
"root",
",",
"warName",
")",
";",
"String",
"warDir",
"=",
"FileSystemManager",
".",
"getChildDirectoryIfExists",
"(",
"root",
",",
"warName",
")",
";",
"Properties",
"configProperties",
"=",
"configManager",
".",
"getDefaultProperties",
"(",
")",
";",
"GitLocation",
"gitLocation",
"=",
"new",
"GitLocation",
"(",
"uri",
",",
"branch",
",",
"configProperties",
".",
"getProperty",
"(",
"\"config.git.ref.sha\"",
")",
")",
";",
"GitService",
"cloned",
"=",
"initializeRepo",
"(",
"gitLocation",
",",
"warDir",
",",
"\"git-config-checkout\"",
")",
";",
"try",
"{",
"String",
"renderedContentDir",
"=",
"initializeSnapshotDirectory",
"(",
"warDir",
",",
"configProperties",
",",
"\"com.meltmedia.cadmium.config.lastUpdated\"",
",",
"\"git-config-checkout\"",
",",
"\"config\"",
")",
";",
"boolean",
"hasExisting",
"=",
"configProperties",
".",
"containsKey",
"(",
"\"com.meltmedia.cadmium.config.lastUpdated\"",
")",
"&&",
"renderedContentDir",
"!=",
"null",
"&&",
"renderedContentDir",
".",
"equals",
"(",
"configProperties",
".",
"getProperty",
"(",
"\"com.meltmedia.cadmium.config.lastUpdated\"",
")",
")",
";",
"if",
"(",
"renderedContentDir",
"!=",
"null",
")",
"{",
"configProperties",
".",
"setProperty",
"(",
"\"com.meltmedia.cadmium.config.lastUpdated\"",
",",
"renderedContentDir",
")",
";",
"}",
"configProperties",
".",
"setProperty",
"(",
"\"config.branch\"",
",",
"cloned",
".",
"getBranchName",
"(",
")",
")",
";",
"configProperties",
".",
"setProperty",
"(",
"\"config.git.ref.sha\"",
",",
"cloned",
".",
"getCurrentRevision",
"(",
")",
")",
";",
"configProperties",
".",
"setProperty",
"(",
"\"config.repo\"",
",",
"cloned",
".",
"getRemoteRepository",
"(",
")",
")",
";",
"configManager",
".",
"persistDefaultProperties",
"(",
")",
";",
"ExecutorService",
"pool",
"=",
"null",
";",
"if",
"(",
"historyManager",
"==",
"null",
")",
"{",
"pool",
"=",
"Executors",
".",
"newSingleThreadExecutor",
"(",
")",
";",
"historyManager",
"=",
"new",
"HistoryManager",
"(",
"warDir",
",",
"pool",
")",
";",
"}",
"try",
"{",
"if",
"(",
"historyManager",
"!=",
"null",
"&&",
"!",
"hasExisting",
")",
"{",
"historyManager",
".",
"logEvent",
"(",
"EntryType",
".",
"CONFIG",
",",
"// NOTE: We should integrate the git pointer into this class.",
"new",
"GitLocation",
"(",
"cloned",
".",
"getRemoteRepository",
"(",
")",
",",
"cloned",
".",
"getBranchName",
"(",
")",
",",
"cloned",
".",
"getCurrentRevision",
"(",
")",
")",
",",
"\"AUTO\"",
",",
"renderedContentDir",
",",
"\"\"",
",",
"\"Initial config pull.\"",
",",
"true",
",",
"true",
")",
";",
"}",
"}",
"finally",
"{",
"if",
"(",
"pool",
"!=",
"null",
")",
"{",
"pool",
".",
"shutdownNow",
"(",
")",
";",
"}",
"}",
"return",
"cloned",
";",
"}",
"catch",
"(",
"Throwable",
"e",
")",
"{",
"cloned",
".",
"close",
"(",
")",
";",
"throw",
"new",
"Exception",
"(",
"e",
")",
";",
"}",
"}"
] | Initializes war configuration directory for a Cadmium war.
@param uri The remote Git repository ssh URI.
@param branch The remote branch to checkout.
@param root The shared root.
@param warName The name of the war file.
@param historyManager The history manager to log the initialization event.
@return A GitService object the points to the freshly cloned Git repository.
@throws RefNotFoundException
@throws Exception | [
"Initializes",
"war",
"configuration",
"directory",
"for",
"a",
"Cadmium",
"war",
"."
] | train | https://github.com/meltmedia/cadmium/blob/bca585030e141803a73b58abb128d130157b6ddf/core/src/main/java/com/meltmedia/cadmium/core/git/GitService.java#L175-L225 |
netty/netty | codec-http/src/main/java/io/netty/handler/codec/http/HttpHeaders.java | HttpHeaders.setDateHeader | @Deprecated
public static void setDateHeader(HttpMessage message, String name, Iterable<Date> values) {
"""
@deprecated Use {@link #set(CharSequence, Iterable)} instead.
@see #setDateHeader(HttpMessage, CharSequence, Iterable)
"""
message.headers().set(name, values);
} | java | @Deprecated
public static void setDateHeader(HttpMessage message, String name, Iterable<Date> values) {
message.headers().set(name, values);
} | [
"@",
"Deprecated",
"public",
"static",
"void",
"setDateHeader",
"(",
"HttpMessage",
"message",
",",
"String",
"name",
",",
"Iterable",
"<",
"Date",
">",
"values",
")",
"{",
"message",
".",
"headers",
"(",
")",
".",
"set",
"(",
"name",
",",
"values",
")",
";",
"}"
] | @deprecated Use {@link #set(CharSequence, Iterable)} instead.
@see #setDateHeader(HttpMessage, CharSequence, Iterable) | [
"@deprecated",
"Use",
"{",
"@link",
"#set",
"(",
"CharSequence",
"Iterable",
")",
"}",
"instead",
"."
] | train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec-http/src/main/java/io/netty/handler/codec/http/HttpHeaders.java#L914-L917 |
riversun/d6 | src/main/java/org/riversun/d6/core/D6Crud.java | D6Crud.setObject | private void setObject(int parameterIndex, PreparedStatement preparedStmt, Object value) throws SQLException {
"""
Set object to the preparedStatement
@param parameterIndex
@param preparedStmt
@param value
@throws SQLException
"""
preparedStmt.setObject(parameterIndex, value);
} | java | private void setObject(int parameterIndex, PreparedStatement preparedStmt, Object value) throws SQLException {
preparedStmt.setObject(parameterIndex, value);
} | [
"private",
"void",
"setObject",
"(",
"int",
"parameterIndex",
",",
"PreparedStatement",
"preparedStmt",
",",
"Object",
"value",
")",
"throws",
"SQLException",
"{",
"preparedStmt",
".",
"setObject",
"(",
"parameterIndex",
",",
"value",
")",
";",
"}"
] | Set object to the preparedStatement
@param parameterIndex
@param preparedStmt
@param value
@throws SQLException | [
"Set",
"object",
"to",
"the",
"preparedStatement"
] | train | https://github.com/riversun/d6/blob/2798bd876b9380dbfea8182d11ad306cb1b0e114/src/main/java/org/riversun/d6/core/D6Crud.java#L1004-L1007 |
lonnyj/liquibase-spatial | src/main/java/liquibase/ext/spatial/preconditions/SpatialIndexExistsPrecondition.java | SpatialIndexExistsPrecondition.getExample | public DatabaseObject getExample(final Database database, final String tableName) {
"""
Creates an example of the database object for which to check.
@param database
the database instance.
@param tableName
the table name of the index.
@return the database object example.
"""
final Schema schema = new Schema(getCatalogName(), getSchemaName());
final DatabaseObject example;
// For GeoDB, the index is another table.
if (database instanceof DerbyDatabase || database instanceof H2Database) {
final String correctedTableName = database.correctObjectName(getHatboxTableName(),
Table.class);
example = new Table().setName(correctedTableName).setSchema(schema);
} else {
example = getIndexExample(database, schema, tableName);
}
return example;
} | java | public DatabaseObject getExample(final Database database, final String tableName) {
final Schema schema = new Schema(getCatalogName(), getSchemaName());
final DatabaseObject example;
// For GeoDB, the index is another table.
if (database instanceof DerbyDatabase || database instanceof H2Database) {
final String correctedTableName = database.correctObjectName(getHatboxTableName(),
Table.class);
example = new Table().setName(correctedTableName).setSchema(schema);
} else {
example = getIndexExample(database, schema, tableName);
}
return example;
} | [
"public",
"DatabaseObject",
"getExample",
"(",
"final",
"Database",
"database",
",",
"final",
"String",
"tableName",
")",
"{",
"final",
"Schema",
"schema",
"=",
"new",
"Schema",
"(",
"getCatalogName",
"(",
")",
",",
"getSchemaName",
"(",
")",
")",
";",
"final",
"DatabaseObject",
"example",
";",
"// For GeoDB, the index is another table.",
"if",
"(",
"database",
"instanceof",
"DerbyDatabase",
"||",
"database",
"instanceof",
"H2Database",
")",
"{",
"final",
"String",
"correctedTableName",
"=",
"database",
".",
"correctObjectName",
"(",
"getHatboxTableName",
"(",
")",
",",
"Table",
".",
"class",
")",
";",
"example",
"=",
"new",
"Table",
"(",
")",
".",
"setName",
"(",
"correctedTableName",
")",
".",
"setSchema",
"(",
"schema",
")",
";",
"}",
"else",
"{",
"example",
"=",
"getIndexExample",
"(",
"database",
",",
"schema",
",",
"tableName",
")",
";",
"}",
"return",
"example",
";",
"}"
] | Creates an example of the database object for which to check.
@param database
the database instance.
@param tableName
the table name of the index.
@return the database object example. | [
"Creates",
"an",
"example",
"of",
"the",
"database",
"object",
"for",
"which",
"to",
"check",
"."
] | train | https://github.com/lonnyj/liquibase-spatial/blob/36ae41b0d3d08bb00a22c856e51ffeed08891c0e/src/main/java/liquibase/ext/spatial/preconditions/SpatialIndexExistsPrecondition.java#L161-L174 |
super-csv/super-csv | super-csv/src/main/java/org/supercsv/cellprocessor/HashMapper.java | HashMapper.checkPreconditions | private static void checkPreconditions(final Map<Object, Object> mapping) {
"""
Checks the preconditions for creating a new HashMapper processor.
@param mapping
the Map
@throws NullPointerException
if mapping is null
@throws IllegalArgumentException
if mapping is empty
"""
if( mapping == null ) {
throw new NullPointerException("mapping should not be null");
} else if( mapping.isEmpty() ) {
throw new IllegalArgumentException("mapping should not be empty");
}
} | java | private static void checkPreconditions(final Map<Object, Object> mapping) {
if( mapping == null ) {
throw new NullPointerException("mapping should not be null");
} else if( mapping.isEmpty() ) {
throw new IllegalArgumentException("mapping should not be empty");
}
} | [
"private",
"static",
"void",
"checkPreconditions",
"(",
"final",
"Map",
"<",
"Object",
",",
"Object",
">",
"mapping",
")",
"{",
"if",
"(",
"mapping",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"mapping should not be null\"",
")",
";",
"}",
"else",
"if",
"(",
"mapping",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"mapping should not be empty\"",
")",
";",
"}",
"}"
] | Checks the preconditions for creating a new HashMapper processor.
@param mapping
the Map
@throws NullPointerException
if mapping is null
@throws IllegalArgumentException
if mapping is empty | [
"Checks",
"the",
"preconditions",
"for",
"creating",
"a",
"new",
"HashMapper",
"processor",
"."
] | train | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/cellprocessor/HashMapper.java#L134-L140 |
aws/aws-sdk-java | aws-java-sdk-glue/src/main/java/com/amazonaws/services/glue/model/JobRun.java | JobRun.withArguments | public JobRun withArguments(java.util.Map<String, String> arguments) {
"""
<p>
The job arguments associated with this run. For this job run, they replace the default arguments set in the job
definition itself.
</p>
<p>
You can specify arguments here that your own job-execution script consumes, as well as arguments that AWS Glue
itself consumes.
</p>
<p>
For information about how to specify and consume your own job arguments, see the <a
href="http://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-python-calling.html">Calling AWS Glue APIs
in Python</a> topic in the developer guide.
</p>
<p>
For information about the key-value pairs that AWS Glue consumes to set up your job, see the <a
href="http://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-glue-arguments.html">Special Parameters
Used by AWS Glue</a> topic in the developer guide.
</p>
@param arguments
The job arguments associated with this run. For this job run, they replace the default arguments set in
the job definition itself.</p>
<p>
You can specify arguments here that your own job-execution script consumes, as well as arguments that AWS
Glue itself consumes.
</p>
<p>
For information about how to specify and consume your own job arguments, see the <a
href="http://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-python-calling.html">Calling AWS Glue
APIs in Python</a> topic in the developer guide.
</p>
<p>
For information about the key-value pairs that AWS Glue consumes to set up your job, see the <a
href="http://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-glue-arguments.html">Special
Parameters Used by AWS Glue</a> topic in the developer guide.
@return Returns a reference to this object so that method calls can be chained together.
"""
setArguments(arguments);
return this;
} | java | public JobRun withArguments(java.util.Map<String, String> arguments) {
setArguments(arguments);
return this;
} | [
"public",
"JobRun",
"withArguments",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"arguments",
")",
"{",
"setArguments",
"(",
"arguments",
")",
";",
"return",
"this",
";",
"}"
] | <p>
The job arguments associated with this run. For this job run, they replace the default arguments set in the job
definition itself.
</p>
<p>
You can specify arguments here that your own job-execution script consumes, as well as arguments that AWS Glue
itself consumes.
</p>
<p>
For information about how to specify and consume your own job arguments, see the <a
href="http://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-python-calling.html">Calling AWS Glue APIs
in Python</a> topic in the developer guide.
</p>
<p>
For information about the key-value pairs that AWS Glue consumes to set up your job, see the <a
href="http://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-glue-arguments.html">Special Parameters
Used by AWS Glue</a> topic in the developer guide.
</p>
@param arguments
The job arguments associated with this run. For this job run, they replace the default arguments set in
the job definition itself.</p>
<p>
You can specify arguments here that your own job-execution script consumes, as well as arguments that AWS
Glue itself consumes.
</p>
<p>
For information about how to specify and consume your own job arguments, see the <a
href="http://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-python-calling.html">Calling AWS Glue
APIs in Python</a> topic in the developer guide.
</p>
<p>
For information about the key-value pairs that AWS Glue consumes to set up your job, see the <a
href="http://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-glue-arguments.html">Special
Parameters Used by AWS Glue</a> topic in the developer guide.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"The",
"job",
"arguments",
"associated",
"with",
"this",
"run",
".",
"For",
"this",
"job",
"run",
"they",
"replace",
"the",
"default",
"arguments",
"set",
"in",
"the",
"job",
"definition",
"itself",
".",
"<",
"/",
"p",
">",
"<p",
">",
"You",
"can",
"specify",
"arguments",
"here",
"that",
"your",
"own",
"job",
"-",
"execution",
"script",
"consumes",
"as",
"well",
"as",
"arguments",
"that",
"AWS",
"Glue",
"itself",
"consumes",
".",
"<",
"/",
"p",
">",
"<p",
">",
"For",
"information",
"about",
"how",
"to",
"specify",
"and",
"consume",
"your",
"own",
"job",
"arguments",
"see",
"the",
"<a",
"href",
"=",
"http",
":",
"//",
"docs",
".",
"aws",
".",
"amazon",
".",
"com",
"/",
"glue",
"/",
"latest",
"/",
"dg",
"/",
"aws",
"-",
"glue",
"-",
"programming",
"-",
"python",
"-",
"calling",
".",
"html",
">",
"Calling",
"AWS",
"Glue",
"APIs",
"in",
"Python<",
"/",
"a",
">",
"topic",
"in",
"the",
"developer",
"guide",
".",
"<",
"/",
"p",
">",
"<p",
">",
"For",
"information",
"about",
"the",
"key",
"-",
"value",
"pairs",
"that",
"AWS",
"Glue",
"consumes",
"to",
"set",
"up",
"your",
"job",
"see",
"the",
"<a",
"href",
"=",
"http",
":",
"//",
"docs",
".",
"aws",
".",
"amazon",
".",
"com",
"/",
"glue",
"/",
"latest",
"/",
"dg",
"/",
"aws",
"-",
"glue",
"-",
"programming",
"-",
"etl",
"-",
"glue",
"-",
"arguments",
".",
"html",
">",
"Special",
"Parameters",
"Used",
"by",
"AWS",
"Glue<",
"/",
"a",
">",
"topic",
"in",
"the",
"developer",
"guide",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-glue/src/main/java/com/amazonaws/services/glue/model/JobRun.java#L732-L735 |
mapbox/mapbox-navigation-android | libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/RouteProcessorThreadListener.java | RouteProcessorThreadListener.onCheckFasterRoute | @Override
public void onCheckFasterRoute(Location location, RouteProgress routeProgress, boolean checkFasterRoute) {
"""
RouteListener from the {@link RouteProcessorBackgroundThread} - if fired with checkFasterRoute set
to true, a new {@link DirectionsRoute} should be fetched with {@link RouteFetcher}.
@param location to create a new origin
@param routeProgress for various {@link com.mapbox.api.directions.v5.models.LegStep} data
@param checkFasterRoute true if should check for faster route, false otherwise
"""
if (checkFasterRoute) {
routeFetcher.findRouteFromRouteProgress(location, routeProgress);
}
} | java | @Override
public void onCheckFasterRoute(Location location, RouteProgress routeProgress, boolean checkFasterRoute) {
if (checkFasterRoute) {
routeFetcher.findRouteFromRouteProgress(location, routeProgress);
}
} | [
"@",
"Override",
"public",
"void",
"onCheckFasterRoute",
"(",
"Location",
"location",
",",
"RouteProgress",
"routeProgress",
",",
"boolean",
"checkFasterRoute",
")",
"{",
"if",
"(",
"checkFasterRoute",
")",
"{",
"routeFetcher",
".",
"findRouteFromRouteProgress",
"(",
"location",
",",
"routeProgress",
")",
";",
"}",
"}"
] | RouteListener from the {@link RouteProcessorBackgroundThread} - if fired with checkFasterRoute set
to true, a new {@link DirectionsRoute} should be fetched with {@link RouteFetcher}.
@param location to create a new origin
@param routeProgress for various {@link com.mapbox.api.directions.v5.models.LegStep} data
@param checkFasterRoute true if should check for faster route, false otherwise | [
"RouteListener",
"from",
"the",
"{",
"@link",
"RouteProcessorBackgroundThread",
"}",
"-",
"if",
"fired",
"with",
"checkFasterRoute",
"set",
"to",
"true",
"a",
"new",
"{",
"@link",
"DirectionsRoute",
"}",
"should",
"be",
"fetched",
"with",
"{",
"@link",
"RouteFetcher",
"}",
"."
] | train | https://github.com/mapbox/mapbox-navigation-android/blob/375a89c017d360b9defc2c90d0c03468165162ec/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/RouteProcessorThreadListener.java#L69-L74 |
GenesysPureEngage/provisioning-client-java | src/main/java/com/genesys/provisioning/OperationsApi.java | OperationsApi.getUsedSkillsAsync | public void getUsedSkillsAsync(AsyncCallback callback) throws ProvisioningApiException {
"""
Get used skills.
Get all [CfgSkill](https://docs.genesys.com/Documentation/PSDK/latest/ConfigLayerRef/CfgSkill) that are linked to existing [CfgPerson](https://docs.genesys.com/Documentation/PSDK/latest/ConfigLayerRef/CfgPerson) objects.
@param callback The callback function called when the skills are returned asynchronously. Callback takes one parameter: Map<String, Object< results.
@throws ProvisioningApiException if the call is unsuccessful.
"""
String aioId = UUID.randomUUID().toString();
asyncCallbacks.put(aioId, callback);
try {
ApiAsyncSuccessResponse resp = operationsApi.getUsedSkillsAsync(aioId);
if (!resp.getStatus().getCode().equals(1)) {
throw new ProvisioningApiException("Error getting used skills. Code: " + resp.getStatus().getCode());
}
} catch(ApiException e) {
throw new ProvisioningApiException("Error getting used skills", e);
}
} | java | public void getUsedSkillsAsync(AsyncCallback callback) throws ProvisioningApiException {
String aioId = UUID.randomUUID().toString();
asyncCallbacks.put(aioId, callback);
try {
ApiAsyncSuccessResponse resp = operationsApi.getUsedSkillsAsync(aioId);
if (!resp.getStatus().getCode().equals(1)) {
throw new ProvisioningApiException("Error getting used skills. Code: " + resp.getStatus().getCode());
}
} catch(ApiException e) {
throw new ProvisioningApiException("Error getting used skills", e);
}
} | [
"public",
"void",
"getUsedSkillsAsync",
"(",
"AsyncCallback",
"callback",
")",
"throws",
"ProvisioningApiException",
"{",
"String",
"aioId",
"=",
"UUID",
".",
"randomUUID",
"(",
")",
".",
"toString",
"(",
")",
";",
"asyncCallbacks",
".",
"put",
"(",
"aioId",
",",
"callback",
")",
";",
"try",
"{",
"ApiAsyncSuccessResponse",
"resp",
"=",
"operationsApi",
".",
"getUsedSkillsAsync",
"(",
"aioId",
")",
";",
"if",
"(",
"!",
"resp",
".",
"getStatus",
"(",
")",
".",
"getCode",
"(",
")",
".",
"equals",
"(",
"1",
")",
")",
"{",
"throw",
"new",
"ProvisioningApiException",
"(",
"\"Error getting used skills. Code: \"",
"+",
"resp",
".",
"getStatus",
"(",
")",
".",
"getCode",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"ApiException",
"e",
")",
"{",
"throw",
"new",
"ProvisioningApiException",
"(",
"\"Error getting used skills\"",
",",
"e",
")",
";",
"}",
"}"
] | Get used skills.
Get all [CfgSkill](https://docs.genesys.com/Documentation/PSDK/latest/ConfigLayerRef/CfgSkill) that are linked to existing [CfgPerson](https://docs.genesys.com/Documentation/PSDK/latest/ConfigLayerRef/CfgPerson) objects.
@param callback The callback function called when the skills are returned asynchronously. Callback takes one parameter: Map<String, Object< results.
@throws ProvisioningApiException if the call is unsuccessful. | [
"Get",
"used",
"skills",
".",
"Get",
"all",
"[",
"CfgSkill",
"]",
"(",
"https",
":",
"//",
"docs",
".",
"genesys",
".",
"com",
"/",
"Documentation",
"/",
"PSDK",
"/",
"latest",
"/",
"ConfigLayerRef",
"/",
"CfgSkill",
")",
"that",
"are",
"linked",
"to",
"existing",
"[",
"CfgPerson",
"]",
"(",
"https",
":",
"//",
"docs",
".",
"genesys",
".",
"com",
"/",
"Documentation",
"/",
"PSDK",
"/",
"latest",
"/",
"ConfigLayerRef",
"/",
"CfgPerson",
")",
"objects",
"."
] | train | https://github.com/GenesysPureEngage/provisioning-client-java/blob/1ad594c3767cec83052168e350994f922a26f75e/src/main/java/com/genesys/provisioning/OperationsApi.java#L31-L44 |
qos-ch/slf4j | slf4j-simple/src/main/java/org/slf4j/simple/SimpleLogger.java | SimpleLogger.formatAndLog | private void formatAndLog(int level, String format, Object arg1, Object arg2) {
"""
For formatted messages, first substitute arguments and then log.
@param level
@param format
@param arg1
@param arg2
"""
if (!isLevelEnabled(level)) {
return;
}
FormattingTuple tp = MessageFormatter.format(format, arg1, arg2);
log(level, tp.getMessage(), tp.getThrowable());
} | java | private void formatAndLog(int level, String format, Object arg1, Object arg2) {
if (!isLevelEnabled(level)) {
return;
}
FormattingTuple tp = MessageFormatter.format(format, arg1, arg2);
log(level, tp.getMessage(), tp.getThrowable());
} | [
"private",
"void",
"formatAndLog",
"(",
"int",
"level",
",",
"String",
"format",
",",
"Object",
"arg1",
",",
"Object",
"arg2",
")",
"{",
"if",
"(",
"!",
"isLevelEnabled",
"(",
"level",
")",
")",
"{",
"return",
";",
"}",
"FormattingTuple",
"tp",
"=",
"MessageFormatter",
".",
"format",
"(",
"format",
",",
"arg1",
",",
"arg2",
")",
";",
"log",
"(",
"level",
",",
"tp",
".",
"getMessage",
"(",
")",
",",
"tp",
".",
"getThrowable",
"(",
")",
")",
";",
"}"
] | For formatted messages, first substitute arguments and then log.
@param level
@param format
@param arg1
@param arg2 | [
"For",
"formatted",
"messages",
"first",
"substitute",
"arguments",
"and",
"then",
"log",
"."
] | train | https://github.com/qos-ch/slf4j/blob/905443f39fadd88a8dd2c467e44affd8cb072a4d/slf4j-simple/src/main/java/org/slf4j/simple/SimpleLogger.java#L350-L356 |
calrissian/mango | mango-core/src/main/java/org/calrissian/mango/collect/CloseableIterators.java | CloseableIterators.groupBy | public static <T> CloseableIterator<List<T>> groupBy(final CloseableIterator<? extends T> iterator, final Function<? super T, ?> groupingFunction) {
"""
Divides a closeableiterator into unmodifiable sublists of equivalent elements. The iterator groups elements
in consecutive order, forming a new partition when the value from the provided function changes. For example,
grouping the iterator {@code [1, 3, 2, 4, 5]} with a function grouping even and odd numbers
yields {@code [[1, 3], [2, 4], [5]} all in the original order.
<p/>
<p>The returned lists implement {@link java.util.RandomAccess}.
"""
return wrap(Iterators2.groupBy(iterator, groupingFunction), iterator);
} | java | public static <T> CloseableIterator<List<T>> groupBy(final CloseableIterator<? extends T> iterator, final Function<? super T, ?> groupingFunction) {
return wrap(Iterators2.groupBy(iterator, groupingFunction), iterator);
} | [
"public",
"static",
"<",
"T",
">",
"CloseableIterator",
"<",
"List",
"<",
"T",
">",
">",
"groupBy",
"(",
"final",
"CloseableIterator",
"<",
"?",
"extends",
"T",
">",
"iterator",
",",
"final",
"Function",
"<",
"?",
"super",
"T",
",",
"?",
">",
"groupingFunction",
")",
"{",
"return",
"wrap",
"(",
"Iterators2",
".",
"groupBy",
"(",
"iterator",
",",
"groupingFunction",
")",
",",
"iterator",
")",
";",
"}"
] | Divides a closeableiterator into unmodifiable sublists of equivalent elements. The iterator groups elements
in consecutive order, forming a new partition when the value from the provided function changes. For example,
grouping the iterator {@code [1, 3, 2, 4, 5]} with a function grouping even and odd numbers
yields {@code [[1, 3], [2, 4], [5]} all in the original order.
<p/>
<p>The returned lists implement {@link java.util.RandomAccess}. | [
"Divides",
"a",
"closeableiterator",
"into",
"unmodifiable",
"sublists",
"of",
"equivalent",
"elements",
".",
"The",
"iterator",
"groups",
"elements",
"in",
"consecutive",
"order",
"forming",
"a",
"new",
"partition",
"when",
"the",
"value",
"from",
"the",
"provided",
"function",
"changes",
".",
"For",
"example",
"grouping",
"the",
"iterator",
"{",
"@code",
"[",
"1",
"3",
"2",
"4",
"5",
"]",
"}",
"with",
"a",
"function",
"grouping",
"even",
"and",
"odd",
"numbers",
"yields",
"{",
"@code",
"[[",
"1",
"3",
"]",
"[",
"2",
"4",
"]",
"[",
"5",
"]",
"}",
"all",
"in",
"the",
"original",
"order",
"."
] | train | https://github.com/calrissian/mango/blob/a95aa5e77af9aa0e629787228d80806560023452/mango-core/src/main/java/org/calrissian/mango/collect/CloseableIterators.java#L104-L106 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/text/SimpleDateFormat.java | SimpleDateFormat.matchString | private int matchString(String text, int start, int field, String[] data, CalendarBuilder calb) {
"""
Private code-size reduction function used by subParse.
@param text the time text being parsed.
@param start where to start parsing.
@param field the date field being parsed.
@param data the string array to parsed.
@return the new start position if matching succeeded; a negative number
indicating matching failure, otherwise.
"""
int i = 0;
int count = data.length;
if (field == Calendar.DAY_OF_WEEK) i = 1;
// There may be multiple strings in the data[] array which begin with
// the same prefix (e.g., Cerven and Cervenec (June and July) in Czech).
// We keep track of the longest match, and return that. Note that this
// unfortunately requires us to test all array elements.
int bestMatchLength = 0, bestMatch = -1;
for (; i<count; ++i)
{
int length = data[i].length();
// Always compare if we have no match yet; otherwise only compare
// against potentially better matches (longer strings).
if (length > bestMatchLength &&
text.regionMatches(true, start, data[i], 0, length))
{
bestMatch = i;
bestMatchLength = length;
}
// When the input option ends with a period (usually an abbreviated form), attempt
// to match all chars up to that period.
if ((data[i].charAt(length - 1) == '.') &&
((length - 1) > bestMatchLength) &&
text.regionMatches(true, start, data[i], 0, length - 1)) {
bestMatch = i;
bestMatchLength = (length - 1);
}
}
if (bestMatch >= 0)
{
calb.set(field, bestMatch);
return start + bestMatchLength;
}
return -start;
} | java | private int matchString(String text, int start, int field, String[] data, CalendarBuilder calb)
{
int i = 0;
int count = data.length;
if (field == Calendar.DAY_OF_WEEK) i = 1;
// There may be multiple strings in the data[] array which begin with
// the same prefix (e.g., Cerven and Cervenec (June and July) in Czech).
// We keep track of the longest match, and return that. Note that this
// unfortunately requires us to test all array elements.
int bestMatchLength = 0, bestMatch = -1;
for (; i<count; ++i)
{
int length = data[i].length();
// Always compare if we have no match yet; otherwise only compare
// against potentially better matches (longer strings).
if (length > bestMatchLength &&
text.regionMatches(true, start, data[i], 0, length))
{
bestMatch = i;
bestMatchLength = length;
}
// When the input option ends with a period (usually an abbreviated form), attempt
// to match all chars up to that period.
if ((data[i].charAt(length - 1) == '.') &&
((length - 1) > bestMatchLength) &&
text.regionMatches(true, start, data[i], 0, length - 1)) {
bestMatch = i;
bestMatchLength = (length - 1);
}
}
if (bestMatch >= 0)
{
calb.set(field, bestMatch);
return start + bestMatchLength;
}
return -start;
} | [
"private",
"int",
"matchString",
"(",
"String",
"text",
",",
"int",
"start",
",",
"int",
"field",
",",
"String",
"[",
"]",
"data",
",",
"CalendarBuilder",
"calb",
")",
"{",
"int",
"i",
"=",
"0",
";",
"int",
"count",
"=",
"data",
".",
"length",
";",
"if",
"(",
"field",
"==",
"Calendar",
".",
"DAY_OF_WEEK",
")",
"i",
"=",
"1",
";",
"// There may be multiple strings in the data[] array which begin with",
"// the same prefix (e.g., Cerven and Cervenec (June and July) in Czech).",
"// We keep track of the longest match, and return that. Note that this",
"// unfortunately requires us to test all array elements.",
"int",
"bestMatchLength",
"=",
"0",
",",
"bestMatch",
"=",
"-",
"1",
";",
"for",
"(",
";",
"i",
"<",
"count",
";",
"++",
"i",
")",
"{",
"int",
"length",
"=",
"data",
"[",
"i",
"]",
".",
"length",
"(",
")",
";",
"// Always compare if we have no match yet; otherwise only compare",
"// against potentially better matches (longer strings).",
"if",
"(",
"length",
">",
"bestMatchLength",
"&&",
"text",
".",
"regionMatches",
"(",
"true",
",",
"start",
",",
"data",
"[",
"i",
"]",
",",
"0",
",",
"length",
")",
")",
"{",
"bestMatch",
"=",
"i",
";",
"bestMatchLength",
"=",
"length",
";",
"}",
"// When the input option ends with a period (usually an abbreviated form), attempt",
"// to match all chars up to that period.",
"if",
"(",
"(",
"data",
"[",
"i",
"]",
".",
"charAt",
"(",
"length",
"-",
"1",
")",
"==",
"'",
"'",
")",
"&&",
"(",
"(",
"length",
"-",
"1",
")",
">",
"bestMatchLength",
")",
"&&",
"text",
".",
"regionMatches",
"(",
"true",
",",
"start",
",",
"data",
"[",
"i",
"]",
",",
"0",
",",
"length",
"-",
"1",
")",
")",
"{",
"bestMatch",
"=",
"i",
";",
"bestMatchLength",
"=",
"(",
"length",
"-",
"1",
")",
";",
"}",
"}",
"if",
"(",
"bestMatch",
">=",
"0",
")",
"{",
"calb",
".",
"set",
"(",
"field",
",",
"bestMatch",
")",
";",
"return",
"start",
"+",
"bestMatchLength",
";",
"}",
"return",
"-",
"start",
";",
"}"
] | Private code-size reduction function used by subParse.
@param text the time text being parsed.
@param start where to start parsing.
@param field the date field being parsed.
@param data the string array to parsed.
@return the new start position if matching succeeded; a negative number
indicating matching failure, otherwise. | [
"Private",
"code",
"-",
"size",
"reduction",
"function",
"used",
"by",
"subParse",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/text/SimpleDateFormat.java#L1581-L1620 |
dropbox/dropbox-sdk-java | src/main/java/com/dropbox/core/v1/DbxClientV1.java | DbxClientV1.getDeltaC | public <C> DbxDeltaC<C> getDeltaC(Collector<DbxDeltaC.Entry<DbxEntry>, C> collector, /*@Nullable*/String cursor)
throws DbxException {
"""
Same as {@link #getDeltaC(Collector, String, boolean)} with {@code includeMediaInfo} set to {@code false}.
"""
return getDeltaC(collector, cursor, false);
} | java | public <C> DbxDeltaC<C> getDeltaC(Collector<DbxDeltaC.Entry<DbxEntry>, C> collector, /*@Nullable*/String cursor)
throws DbxException
{
return getDeltaC(collector, cursor, false);
} | [
"public",
"<",
"C",
">",
"DbxDeltaC",
"<",
"C",
">",
"getDeltaC",
"(",
"Collector",
"<",
"DbxDeltaC",
".",
"Entry",
"<",
"DbxEntry",
">",
",",
"C",
">",
"collector",
",",
"/*@Nullable*/",
"String",
"cursor",
")",
"throws",
"DbxException",
"{",
"return",
"getDeltaC",
"(",
"collector",
",",
"cursor",
",",
"false",
")",
";",
"}"
] | Same as {@link #getDeltaC(Collector, String, boolean)} with {@code includeMediaInfo} set to {@code false}. | [
"Same",
"as",
"{"
] | train | https://github.com/dropbox/dropbox-sdk-java/blob/d86157005fad6233c18b4b0f10f00b8d9d56ae92/src/main/java/com/dropbox/core/v1/DbxClientV1.java#L1508-L1512 |
OpenLiberty/open-liberty | dev/com.ibm.ws.concurrent.persistent/src/com/ibm/ws/concurrent/persistent/internal/PersistentExecutorImpl.java | PersistentExecutorImpl.notificationCreated | @Override
public void notificationCreated(RuntimeUpdateManager updateManager, RuntimeUpdateNotification notification) {
"""
This method is driven for various RuntimeUpdateNotification's. When we receive a
notification we will bump our count of active configuration updates in progress. A non-zero count value
signifies configuration update(s) are in progress.
We monitor the completion of the Futures related to the notifications. When we
are driven for their completion we decrement our configuration update in progress count.
@see com.ibm.ws.runtime.update.RuntimeUpdateListener#notificationCreated(com.ibm.ws.runtime.update.RuntimeUpdateManager, com.ibm.ws.runtime.update.RuntimeUpdateNotification)
"""
class MyCompletionListener implements CompletionListener<Boolean> {
String notificationName;
public MyCompletionListener(String name) {
notificationName = name;
}
@Override
public void successfulCompletion(Future<Boolean> future, Boolean result) {
// The configuration update for which we were monitoring is now complete.
// Update our awareness to the update and perform any deferred actions.
configUpdateCompleted(notificationName);
}
@Override
public void failedCompletion(Future<Boolean> future, Throwable t) {
// The configuration update failed, but we still want to resume functions.
// Update our awareness to the update and perform any deferred actions.
configUpdateCompleted(notificationName);
}
}
if (deactivated)
return;
int prevCnt = configUpdateInProgress();
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(PersistentExecutorImpl.this, tc, "Notified of \"" + notification.getName() + "\" previous configUpdatesInProgress: " + prevCnt);
FutureMonitor futureMonitor = _futureMonitor;
if (futureMonitor != null) {
MyCompletionListener newListener = new MyCompletionListener(notification.getName());
futureMonitor.onCompletion(notification.getFuture(), newListener);
}
} | java | @Override
public void notificationCreated(RuntimeUpdateManager updateManager, RuntimeUpdateNotification notification) {
class MyCompletionListener implements CompletionListener<Boolean> {
String notificationName;
public MyCompletionListener(String name) {
notificationName = name;
}
@Override
public void successfulCompletion(Future<Boolean> future, Boolean result) {
// The configuration update for which we were monitoring is now complete.
// Update our awareness to the update and perform any deferred actions.
configUpdateCompleted(notificationName);
}
@Override
public void failedCompletion(Future<Boolean> future, Throwable t) {
// The configuration update failed, but we still want to resume functions.
// Update our awareness to the update and perform any deferred actions.
configUpdateCompleted(notificationName);
}
}
if (deactivated)
return;
int prevCnt = configUpdateInProgress();
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(PersistentExecutorImpl.this, tc, "Notified of \"" + notification.getName() + "\" previous configUpdatesInProgress: " + prevCnt);
FutureMonitor futureMonitor = _futureMonitor;
if (futureMonitor != null) {
MyCompletionListener newListener = new MyCompletionListener(notification.getName());
futureMonitor.onCompletion(notification.getFuture(), newListener);
}
} | [
"@",
"Override",
"public",
"void",
"notificationCreated",
"(",
"RuntimeUpdateManager",
"updateManager",
",",
"RuntimeUpdateNotification",
"notification",
")",
"{",
"class",
"MyCompletionListener",
"implements",
"CompletionListener",
"<",
"Boolean",
">",
"{",
"String",
"notificationName",
";",
"public",
"MyCompletionListener",
"(",
"String",
"name",
")",
"{",
"notificationName",
"=",
"name",
";",
"}",
"@",
"Override",
"public",
"void",
"successfulCompletion",
"(",
"Future",
"<",
"Boolean",
">",
"future",
",",
"Boolean",
"result",
")",
"{",
"// The configuration update for which we were monitoring is now complete.",
"// Update our awareness to the update and perform any deferred actions.",
"configUpdateCompleted",
"(",
"notificationName",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"failedCompletion",
"(",
"Future",
"<",
"Boolean",
">",
"future",
",",
"Throwable",
"t",
")",
"{",
"// The configuration update failed, but we still want to resume functions.",
"// Update our awareness to the update and perform any deferred actions.",
"configUpdateCompleted",
"(",
"notificationName",
")",
";",
"}",
"}",
"if",
"(",
"deactivated",
")",
"return",
";",
"int",
"prevCnt",
"=",
"configUpdateInProgress",
"(",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"Tr",
".",
"debug",
"(",
"PersistentExecutorImpl",
".",
"this",
",",
"tc",
",",
"\"Notified of \\\"\"",
"+",
"notification",
".",
"getName",
"(",
")",
"+",
"\"\\\" previous configUpdatesInProgress: \"",
"+",
"prevCnt",
")",
";",
"FutureMonitor",
"futureMonitor",
"=",
"_futureMonitor",
";",
"if",
"(",
"futureMonitor",
"!=",
"null",
")",
"{",
"MyCompletionListener",
"newListener",
"=",
"new",
"MyCompletionListener",
"(",
"notification",
".",
"getName",
"(",
")",
")",
";",
"futureMonitor",
".",
"onCompletion",
"(",
"notification",
".",
"getFuture",
"(",
")",
",",
"newListener",
")",
";",
"}",
"}"
] | This method is driven for various RuntimeUpdateNotification's. When we receive a
notification we will bump our count of active configuration updates in progress. A non-zero count value
signifies configuration update(s) are in progress.
We monitor the completion of the Futures related to the notifications. When we
are driven for their completion we decrement our configuration update in progress count.
@see com.ibm.ws.runtime.update.RuntimeUpdateListener#notificationCreated(com.ibm.ws.runtime.update.RuntimeUpdateManager, com.ibm.ws.runtime.update.RuntimeUpdateNotification) | [
"This",
"method",
"is",
"driven",
"for",
"various",
"RuntimeUpdateNotification",
"s",
".",
"When",
"we",
"receive",
"a",
"notification",
"we",
"will",
"bump",
"our",
"count",
"of",
"active",
"configuration",
"updates",
"in",
"progress",
".",
"A",
"non",
"-",
"zero",
"count",
"value",
"signifies",
"configuration",
"update",
"(",
"s",
")",
"are",
"in",
"progress",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.concurrent.persistent/src/com/ibm/ws/concurrent/persistent/internal/PersistentExecutorImpl.java#L1975-L2014 |
wisdom-framework/wisdom | framework/thymeleaf-template-engine/src/main/java/org/wisdom/template/thymeleaf/ThymeleafTemplateCollector.java | ThymeleafTemplateCollector.addTemplate | public ThymeLeafTemplateImplementation addTemplate(Bundle bundle, URL templateURL) {
"""
Adds a template form the given url.
@param bundle the bundle containing the template, use system bundle for external templates.
@param templateURL the url
@return the added template. IF the given url is already used by another template, return this other template.
"""
ThymeLeafTemplateImplementation template = getTemplateByURL(templateURL);
if (template != null) {
// Already existing.
return template;
}
synchronized (this) {
// need to be synchronized because of the access to engine.
template = new ThymeLeafTemplateImplementation(engine, templateURL,
router, assets, bundle);
}
ServiceRegistration<Template> reg = context.registerService(Template.class, template,
template.getServiceProperties());
registrations.put(template, reg);
LOGGER.debug("Thymeleaf template added for {}", templateURL.toExternalForm());
return template;
} | java | public ThymeLeafTemplateImplementation addTemplate(Bundle bundle, URL templateURL) {
ThymeLeafTemplateImplementation template = getTemplateByURL(templateURL);
if (template != null) {
// Already existing.
return template;
}
synchronized (this) {
// need to be synchronized because of the access to engine.
template = new ThymeLeafTemplateImplementation(engine, templateURL,
router, assets, bundle);
}
ServiceRegistration<Template> reg = context.registerService(Template.class, template,
template.getServiceProperties());
registrations.put(template, reg);
LOGGER.debug("Thymeleaf template added for {}", templateURL.toExternalForm());
return template;
} | [
"public",
"ThymeLeafTemplateImplementation",
"addTemplate",
"(",
"Bundle",
"bundle",
",",
"URL",
"templateURL",
")",
"{",
"ThymeLeafTemplateImplementation",
"template",
"=",
"getTemplateByURL",
"(",
"templateURL",
")",
";",
"if",
"(",
"template",
"!=",
"null",
")",
"{",
"// Already existing.",
"return",
"template",
";",
"}",
"synchronized",
"(",
"this",
")",
"{",
"// need to be synchronized because of the access to engine.",
"template",
"=",
"new",
"ThymeLeafTemplateImplementation",
"(",
"engine",
",",
"templateURL",
",",
"router",
",",
"assets",
",",
"bundle",
")",
";",
"}",
"ServiceRegistration",
"<",
"Template",
">",
"reg",
"=",
"context",
".",
"registerService",
"(",
"Template",
".",
"class",
",",
"template",
",",
"template",
".",
"getServiceProperties",
"(",
")",
")",
";",
"registrations",
".",
"put",
"(",
"template",
",",
"reg",
")",
";",
"LOGGER",
".",
"debug",
"(",
"\"Thymeleaf template added for {}\"",
",",
"templateURL",
".",
"toExternalForm",
"(",
")",
")",
";",
"return",
"template",
";",
"}"
] | Adds a template form the given url.
@param bundle the bundle containing the template, use system bundle for external templates.
@param templateURL the url
@return the added template. IF the given url is already used by another template, return this other template. | [
"Adds",
"a",
"template",
"form",
"the",
"given",
"url",
"."
] | train | https://github.com/wisdom-framework/wisdom/blob/a35b6431200fec56b178c0ff60837ed73fd7874d/framework/thymeleaf-template-engine/src/main/java/org/wisdom/template/thymeleaf/ThymeleafTemplateCollector.java#L189-L205 |
samskivert/pythagoras | src/main/java/pythagoras/d/Transforms.java | Transforms.multiply | public static <T extends Transform> T multiply (
AffineTransform a, double m00, double m01, double m10, double m11, double tx, double ty, T into) {
"""
Multiplies the supplied two affine transforms, storing the result in {@code into}. {@code
into} may refer to the same instance as {@code a}.
@return {@code into} for chaining.
"""
return multiply(a.m00, a.m01, a.m10, a.m11, a.tx, a.ty, m00, m01, m10, m11, tx, ty, into);
} | java | public static <T extends Transform> T multiply (
AffineTransform a, double m00, double m01, double m10, double m11, double tx, double ty, T into) {
return multiply(a.m00, a.m01, a.m10, a.m11, a.tx, a.ty, m00, m01, m10, m11, tx, ty, into);
} | [
"public",
"static",
"<",
"T",
"extends",
"Transform",
">",
"T",
"multiply",
"(",
"AffineTransform",
"a",
",",
"double",
"m00",
",",
"double",
"m01",
",",
"double",
"m10",
",",
"double",
"m11",
",",
"double",
"tx",
",",
"double",
"ty",
",",
"T",
"into",
")",
"{",
"return",
"multiply",
"(",
"a",
".",
"m00",
",",
"a",
".",
"m01",
",",
"a",
".",
"m10",
",",
"a",
".",
"m11",
",",
"a",
".",
"tx",
",",
"a",
".",
"ty",
",",
"m00",
",",
"m01",
",",
"m10",
",",
"m11",
",",
"tx",
",",
"ty",
",",
"into",
")",
";",
"}"
] | Multiplies the supplied two affine transforms, storing the result in {@code into}. {@code
into} may refer to the same instance as {@code a}.
@return {@code into} for chaining. | [
"Multiplies",
"the",
"supplied",
"two",
"affine",
"transforms",
"storing",
"the",
"result",
"in",
"{"
] | train | https://github.com/samskivert/pythagoras/blob/b8fea743ee8a7d742ad9c06ee4f11f50571fbd32/src/main/java/pythagoras/d/Transforms.java#L44-L47 |
Azure/azure-sdk-for-java | servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/management/ManagementClientAsync.java | ManagementClientAsync.createSubscriptionAsync | public CompletableFuture<SubscriptionDescription> createSubscriptionAsync(String topicPath, String subscriptionName) {
"""
Creates a new subscription for a given topic in the service namespace with the given name.
See {@link SubscriptionDescription} for default values of subscription properties.
@param topicPath - The name of the topic relative to the service namespace base address.
@param subscriptionName - The name of the subscription.
@return {@link SubscriptionDescription} of the newly created subscription.
@throws IllegalArgumentException - Entity name is null, empty, too long or uses illegal characters.
"""
return this.createSubscriptionAsync(new SubscriptionDescription(topicPath, subscriptionName));
} | java | public CompletableFuture<SubscriptionDescription> createSubscriptionAsync(String topicPath, String subscriptionName) {
return this.createSubscriptionAsync(new SubscriptionDescription(topicPath, subscriptionName));
} | [
"public",
"CompletableFuture",
"<",
"SubscriptionDescription",
">",
"createSubscriptionAsync",
"(",
"String",
"topicPath",
",",
"String",
"subscriptionName",
")",
"{",
"return",
"this",
".",
"createSubscriptionAsync",
"(",
"new",
"SubscriptionDescription",
"(",
"topicPath",
",",
"subscriptionName",
")",
")",
";",
"}"
] | Creates a new subscription for a given topic in the service namespace with the given name.
See {@link SubscriptionDescription} for default values of subscription properties.
@param topicPath - The name of the topic relative to the service namespace base address.
@param subscriptionName - The name of the subscription.
@return {@link SubscriptionDescription} of the newly created subscription.
@throws IllegalArgumentException - Entity name is null, empty, too long or uses illegal characters. | [
"Creates",
"a",
"new",
"subscription",
"for",
"a",
"given",
"topic",
"in",
"the",
"service",
"namespace",
"with",
"the",
"given",
"name",
".",
"See",
"{"
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/management/ManagementClientAsync.java#L629-L631 |
PSDev/LicensesDialog | licensesdialog/src/main/java/de/psdev/licensesdialog/LicenseResolver.java | LicenseResolver.read | public static License read(final String license) {
"""
Get a license by name
@param license license name
@return License
@throws java.lang.IllegalStateException when unknown license is requested
"""
final String trimmedLicense = license.trim();
if (sLicenses.containsKey(trimmedLicense)) {
return sLicenses.get(trimmedLicense);
} else {
throw new IllegalStateException(String.format("no such license available: %s, did you forget to register it?", trimmedLicense));
}
} | java | public static License read(final String license) {
final String trimmedLicense = license.trim();
if (sLicenses.containsKey(trimmedLicense)) {
return sLicenses.get(trimmedLicense);
} else {
throw new IllegalStateException(String.format("no such license available: %s, did you forget to register it?", trimmedLicense));
}
} | [
"public",
"static",
"License",
"read",
"(",
"final",
"String",
"license",
")",
"{",
"final",
"String",
"trimmedLicense",
"=",
"license",
".",
"trim",
"(",
")",
";",
"if",
"(",
"sLicenses",
".",
"containsKey",
"(",
"trimmedLicense",
")",
")",
"{",
"return",
"sLicenses",
".",
"get",
"(",
"trimmedLicense",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"String",
".",
"format",
"(",
"\"no such license available: %s, did you forget to register it?\"",
",",
"trimmedLicense",
")",
")",
";",
"}",
"}"
] | Get a license by name
@param license license name
@return License
@throws java.lang.IllegalStateException when unknown license is requested | [
"Get",
"a",
"license",
"by",
"name"
] | train | https://github.com/PSDev/LicensesDialog/blob/c09b669cbf8f70bf5509da4b0b57910a1f5dcba8/licensesdialog/src/main/java/de/psdev/licensesdialog/LicenseResolver.java#L83-L90 |
xwiki/xwiki-rendering | xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/impl/WikiScannerUtil.java | WikiScannerUtil.extractSubstring | public static String extractSubstring(
String str,
String open,
String close,
char escape) {
"""
Extracts and returns a substring of the given string starting from the
given open sequence and finishing by the specified close sequence. This
method unescapes all symbols prefixed by the given escape symbol.
@param str from this string the substring framed by the specified open
and close sequence will be returned
@param open the start substring sequence
@param close the closing substring sequence
@param escape the escape symbol
@return a substring of the given string starting from the given open
sequence and finishing by the specified close sequence
"""
return extractSubstring(str, open, close, escape, true);
} | java | public static String extractSubstring(
String str,
String open,
String close,
char escape)
{
return extractSubstring(str, open, close, escape, true);
} | [
"public",
"static",
"String",
"extractSubstring",
"(",
"String",
"str",
",",
"String",
"open",
",",
"String",
"close",
",",
"char",
"escape",
")",
"{",
"return",
"extractSubstring",
"(",
"str",
",",
"open",
",",
"close",
",",
"escape",
",",
"true",
")",
";",
"}"
] | Extracts and returns a substring of the given string starting from the
given open sequence and finishing by the specified close sequence. This
method unescapes all symbols prefixed by the given escape symbol.
@param str from this string the substring framed by the specified open
and close sequence will be returned
@param open the start substring sequence
@param close the closing substring sequence
@param escape the escape symbol
@return a substring of the given string starting from the given open
sequence and finishing by the specified close sequence | [
"Extracts",
"and",
"returns",
"a",
"substring",
"of",
"the",
"given",
"string",
"starting",
"from",
"the",
"given",
"open",
"sequence",
"and",
"finishing",
"by",
"the",
"specified",
"close",
"sequence",
".",
"This",
"method",
"unescapes",
"all",
"symbols",
"prefixed",
"by",
"the",
"given",
"escape",
"symbol",
"."
] | train | https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/impl/WikiScannerUtil.java#L69-L76 |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/common/Similarity.java | Similarity.kendallsTau | public static double kendallsTau(double[] a, double[] b) {
"""
Computes <a href="http://en.wikipedia.org/wiki/Kendall%27s_tau">Kendall's
tau</a> of the values in the two arrays. This method uses tau-b, which
is suitable for arrays with duplicate values.
@throws IllegalArgumentException when the length of the two arrays are
not the same.
"""
return kendallsTau(Vectors.asVector(a), Vectors.asVector(b));
} | java | public static double kendallsTau(double[] a, double[] b) {
return kendallsTau(Vectors.asVector(a), Vectors.asVector(b));
} | [
"public",
"static",
"double",
"kendallsTau",
"(",
"double",
"[",
"]",
"a",
",",
"double",
"[",
"]",
"b",
")",
"{",
"return",
"kendallsTau",
"(",
"Vectors",
".",
"asVector",
"(",
"a",
")",
",",
"Vectors",
".",
"asVector",
"(",
"b",
")",
")",
";",
"}"
] | Computes <a href="http://en.wikipedia.org/wiki/Kendall%27s_tau">Kendall's
tau</a> of the values in the two arrays. This method uses tau-b, which
is suitable for arrays with duplicate values.
@throws IllegalArgumentException when the length of the two arrays are
not the same. | [
"Computes",
"<a",
"href",
"=",
"http",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"Kendall%27s_tau",
">",
"Kendall",
"s",
"tau<",
"/",
"a",
">",
"of",
"the",
"values",
"in",
"the",
"two",
"arrays",
".",
"This",
"method",
"uses",
"tau",
"-",
"b",
"which",
"is",
"suitable",
"for",
"arrays",
"with",
"duplicate",
"values",
"."
] | train | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/common/Similarity.java#L2031-L2033 |
Omertron/api-themoviedb | src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java | TheMovieDbApi.getSeasonExternalID | public ExternalID getSeasonExternalID(int tvID, int seasonNumber, String language) throws MovieDbException {
"""
Get the external ids that we have stored for a TV season by season
number.
@param tvID tvID
@param seasonNumber seasonNumber
@param language language
@return
@throws MovieDbException exception
"""
return tmdbSeasons.getSeasonExternalID(tvID, seasonNumber, language);
} | java | public ExternalID getSeasonExternalID(int tvID, int seasonNumber, String language) throws MovieDbException {
return tmdbSeasons.getSeasonExternalID(tvID, seasonNumber, language);
} | [
"public",
"ExternalID",
"getSeasonExternalID",
"(",
"int",
"tvID",
",",
"int",
"seasonNumber",
",",
"String",
"language",
")",
"throws",
"MovieDbException",
"{",
"return",
"tmdbSeasons",
".",
"getSeasonExternalID",
"(",
"tvID",
",",
"seasonNumber",
",",
"language",
")",
";",
"}"
] | Get the external ids that we have stored for a TV season by season
number.
@param tvID tvID
@param seasonNumber seasonNumber
@param language language
@return
@throws MovieDbException exception | [
"Get",
"the",
"external",
"ids",
"that",
"we",
"have",
"stored",
"for",
"a",
"TV",
"season",
"by",
"season",
"number",
"."
] | train | https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java#L1726-L1728 |
VoltDB/voltdb | src/frontend/org/voltdb/importer/AbstractImporter.java | AbstractImporter.callProcedure | public boolean callProcedure(Invocation invocation, ProcedureCallback callback) {
"""
This should be used importer implementations to execute a stored procedure.
@param invocation Invocation object with procedure name and parameter information
@param callback the callback that will receive procedure invocation status
@return returns true if the procedure execution went through successfully; false otherwise
"""
try {
boolean result = m_importServerAdapter.callProcedure(this,
m_backPressurePredicate,
callback, invocation.getProcedure(), invocation.getParams());
reportStat(result, invocation.getProcedure());
return result;
} catch (Exception ex) {
rateLimitedLog(Level.ERROR, ex, "%s: Error trying to import", getName());
reportFailureStat(invocation.getProcedure());
return false;
}
} | java | public boolean callProcedure(Invocation invocation, ProcedureCallback callback)
{
try {
boolean result = m_importServerAdapter.callProcedure(this,
m_backPressurePredicate,
callback, invocation.getProcedure(), invocation.getParams());
reportStat(result, invocation.getProcedure());
return result;
} catch (Exception ex) {
rateLimitedLog(Level.ERROR, ex, "%s: Error trying to import", getName());
reportFailureStat(invocation.getProcedure());
return false;
}
} | [
"public",
"boolean",
"callProcedure",
"(",
"Invocation",
"invocation",
",",
"ProcedureCallback",
"callback",
")",
"{",
"try",
"{",
"boolean",
"result",
"=",
"m_importServerAdapter",
".",
"callProcedure",
"(",
"this",
",",
"m_backPressurePredicate",
",",
"callback",
",",
"invocation",
".",
"getProcedure",
"(",
")",
",",
"invocation",
".",
"getParams",
"(",
")",
")",
";",
"reportStat",
"(",
"result",
",",
"invocation",
".",
"getProcedure",
"(",
")",
")",
";",
"return",
"result",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"rateLimitedLog",
"(",
"Level",
".",
"ERROR",
",",
"ex",
",",
"\"%s: Error trying to import\"",
",",
"getName",
"(",
")",
")",
";",
"reportFailureStat",
"(",
"invocation",
".",
"getProcedure",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"}"
] | This should be used importer implementations to execute a stored procedure.
@param invocation Invocation object with procedure name and parameter information
@param callback the callback that will receive procedure invocation status
@return returns true if the procedure execution went through successfully; false otherwise | [
"This",
"should",
"be",
"used",
"importer",
"implementations",
"to",
"execute",
"a",
"stored",
"procedure",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/importer/AbstractImporter.java#L108-L121 |
astrapi69/mystic-crypt | crypt-data/src/main/java/de/alpharogroup/crypto/key/PublicKeyExtensions.java | PublicKeyExtensions.toPemFile | public static void toPemFile(final @NonNull PublicKey publicKey, final @NonNull File file)
throws IOException {
"""
Write the given {@link PublicKey} into the given {@link File}.
@param publicKey
the public key
@param file
the file to write in
@throws IOException
Signals that an I/O exception has occurred.
"""
PublicKeyWriter.writeInPemFormat(publicKey, file);
} | java | public static void toPemFile(final @NonNull PublicKey publicKey, final @NonNull File file)
throws IOException {
PublicKeyWriter.writeInPemFormat(publicKey, file);
} | [
"public",
"static",
"void",
"toPemFile",
"(",
"final",
"@",
"NonNull",
"PublicKey",
"publicKey",
",",
"final",
"@",
"NonNull",
"File",
"file",
")",
"throws",
"IOException",
"{",
"PublicKeyWriter",
".",
"writeInPemFormat",
"(",
"publicKey",
",",
"file",
")",
";",
"}"
] | Write the given {@link PublicKey} into the given {@link File}.
@param publicKey
the public key
@param file
the file to write in
@throws IOException
Signals that an I/O exception has occurred. | [
"Write",
"the",
"given",
"{",
"@link",
"PublicKey",
"}",
"into",
"the",
"given",
"{",
"@link",
"File",
"}",
"."
] | train | https://github.com/astrapi69/mystic-crypt/blob/7f51ef5e4457e24de7ff391f10bfc5609e6f1a34/crypt-data/src/main/java/de/alpharogroup/crypto/key/PublicKeyExtensions.java#L153-L156 |
ngageoint/geopackage-android-map | geopackage-map/src/main/java/mil/nga/geopackage/map/MapUtils.java | MapUtils.isPointNearMultiLatLng | public static boolean isPointNearMultiLatLng(LatLng point, MultiLatLng multiLatLng, double tolerance) {
"""
Is the point near any points in the multi lat lng
@param point point
@param multiLatLng multi lat lng
@param tolerance distance tolerance
@return true if near
"""
boolean near = false;
for (LatLng multiPoint : multiLatLng.getLatLngs()) {
near = isPointNearPoint(point, multiPoint, tolerance);
if (near) {
break;
}
}
return near;
} | java | public static boolean isPointNearMultiLatLng(LatLng point, MultiLatLng multiLatLng, double tolerance) {
boolean near = false;
for (LatLng multiPoint : multiLatLng.getLatLngs()) {
near = isPointNearPoint(point, multiPoint, tolerance);
if (near) {
break;
}
}
return near;
} | [
"public",
"static",
"boolean",
"isPointNearMultiLatLng",
"(",
"LatLng",
"point",
",",
"MultiLatLng",
"multiLatLng",
",",
"double",
"tolerance",
")",
"{",
"boolean",
"near",
"=",
"false",
";",
"for",
"(",
"LatLng",
"multiPoint",
":",
"multiLatLng",
".",
"getLatLngs",
"(",
")",
")",
"{",
"near",
"=",
"isPointNearPoint",
"(",
"point",
",",
"multiPoint",
",",
"tolerance",
")",
";",
"if",
"(",
"near",
")",
"{",
"break",
";",
"}",
"}",
"return",
"near",
";",
"}"
] | Is the point near any points in the multi lat lng
@param point point
@param multiLatLng multi lat lng
@param tolerance distance tolerance
@return true if near | [
"Is",
"the",
"point",
"near",
"any",
"points",
"in",
"the",
"multi",
"lat",
"lng"
] | train | https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/MapUtils.java#L305-L314 |
google/closure-templates | java/src/com/google/template/soy/jbcsrc/restricted/AnnotationRef.java | AnnotationRef.annotationArrayFieldWriter | private static <T extends Annotation> FieldWriter annotationArrayFieldWriter(
final String name, final AnnotationRef<T> ref) {
"""
Writes an annotation array valued field to the annotation visitor.
"""
return new FieldWriter() {
@Override
public void write(AnnotationVisitor visitor, Object value) {
int len = Array.getLength(value);
AnnotationVisitor arrayVisitor = visitor.visitArray(name);
for (int i = 0; i < len; i++) {
ref.doWrite(
ref.annType.cast(Array.get(value, i)),
arrayVisitor.visitAnnotation(null, ref.typeDescriptor));
}
arrayVisitor.visitEnd();
}
};
} | java | private static <T extends Annotation> FieldWriter annotationArrayFieldWriter(
final String name, final AnnotationRef<T> ref) {
return new FieldWriter() {
@Override
public void write(AnnotationVisitor visitor, Object value) {
int len = Array.getLength(value);
AnnotationVisitor arrayVisitor = visitor.visitArray(name);
for (int i = 0; i < len; i++) {
ref.doWrite(
ref.annType.cast(Array.get(value, i)),
arrayVisitor.visitAnnotation(null, ref.typeDescriptor));
}
arrayVisitor.visitEnd();
}
};
} | [
"private",
"static",
"<",
"T",
"extends",
"Annotation",
">",
"FieldWriter",
"annotationArrayFieldWriter",
"(",
"final",
"String",
"name",
",",
"final",
"AnnotationRef",
"<",
"T",
">",
"ref",
")",
"{",
"return",
"new",
"FieldWriter",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"write",
"(",
"AnnotationVisitor",
"visitor",
",",
"Object",
"value",
")",
"{",
"int",
"len",
"=",
"Array",
".",
"getLength",
"(",
"value",
")",
";",
"AnnotationVisitor",
"arrayVisitor",
"=",
"visitor",
".",
"visitArray",
"(",
"name",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"ref",
".",
"doWrite",
"(",
"ref",
".",
"annType",
".",
"cast",
"(",
"Array",
".",
"get",
"(",
"value",
",",
"i",
")",
")",
",",
"arrayVisitor",
".",
"visitAnnotation",
"(",
"null",
",",
"ref",
".",
"typeDescriptor",
")",
")",
";",
"}",
"arrayVisitor",
".",
"visitEnd",
"(",
")",
";",
"}",
"}",
";",
"}"
] | Writes an annotation array valued field to the annotation visitor. | [
"Writes",
"an",
"annotation",
"array",
"valued",
"field",
"to",
"the",
"annotation",
"visitor",
"."
] | train | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/jbcsrc/restricted/AnnotationRef.java#L170-L185 |
Azure/azure-sdk-for-java | authorization/resource-manager/v2018_09_01_preview/src/main/java/com/microsoft/azure/management/authorization/v2018_09_01_preview/implementation/RoleDefinitionsInner.java | RoleDefinitionsInner.deleteAsync | public Observable<RoleDefinitionInner> deleteAsync(String scope, String roleDefinitionId) {
"""
Deletes a role definition.
@param scope The scope of the role definition.
@param roleDefinitionId The ID of the role definition to delete.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the RoleDefinitionInner object
"""
return deleteWithServiceResponseAsync(scope, roleDefinitionId).map(new Func1<ServiceResponse<RoleDefinitionInner>, RoleDefinitionInner>() {
@Override
public RoleDefinitionInner call(ServiceResponse<RoleDefinitionInner> response) {
return response.body();
}
});
} | java | public Observable<RoleDefinitionInner> deleteAsync(String scope, String roleDefinitionId) {
return deleteWithServiceResponseAsync(scope, roleDefinitionId).map(new Func1<ServiceResponse<RoleDefinitionInner>, RoleDefinitionInner>() {
@Override
public RoleDefinitionInner call(ServiceResponse<RoleDefinitionInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"RoleDefinitionInner",
">",
"deleteAsync",
"(",
"String",
"scope",
",",
"String",
"roleDefinitionId",
")",
"{",
"return",
"deleteWithServiceResponseAsync",
"(",
"scope",
",",
"roleDefinitionId",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"RoleDefinitionInner",
">",
",",
"RoleDefinitionInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"RoleDefinitionInner",
"call",
"(",
"ServiceResponse",
"<",
"RoleDefinitionInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Deletes a role definition.
@param scope The scope of the role definition.
@param roleDefinitionId The ID of the role definition to delete.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the RoleDefinitionInner object | [
"Deletes",
"a",
"role",
"definition",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/authorization/resource-manager/v2018_09_01_preview/src/main/java/com/microsoft/azure/management/authorization/v2018_09_01_preview/implementation/RoleDefinitionsInner.java#L126-L133 |
dkpro/dkpro-jwpl | de.tudarmstadt.ukp.wikipedia.api/src/main/java/de/tudarmstadt/ukp/wikipedia/api/Page.java | Page.getCompiledPage | private EngProcessedPage getCompiledPage() throws WikiApiException {
"""
Returns CompiledPage produced by the SWEBLE parser using the SimpleWikiConfiguration.
@return the parsed page
@throws WikiApiException Thrown if errors occurred.
"""
EngProcessedPage cp;
try{
WtEngineImpl engine = new WtEngineImpl(this.wiki.getWikConfig());
PageTitle pageTitle = PageTitle.make(this.wiki.getWikConfig(), this.getTitle().toString());
PageId pageId = new PageId(pageTitle, -1);
// Compile the retrieved page
cp = engine.postprocess(pageId, this.getText(), null);
} catch(Exception e){
throw new WikiApiException(e);
}
return cp;
} | java | private EngProcessedPage getCompiledPage() throws WikiApiException
{
EngProcessedPage cp;
try{
WtEngineImpl engine = new WtEngineImpl(this.wiki.getWikConfig());
PageTitle pageTitle = PageTitle.make(this.wiki.getWikConfig(), this.getTitle().toString());
PageId pageId = new PageId(pageTitle, -1);
// Compile the retrieved page
cp = engine.postprocess(pageId, this.getText(), null);
} catch(Exception e){
throw new WikiApiException(e);
}
return cp;
} | [
"private",
"EngProcessedPage",
"getCompiledPage",
"(",
")",
"throws",
"WikiApiException",
"{",
"EngProcessedPage",
"cp",
";",
"try",
"{",
"WtEngineImpl",
"engine",
"=",
"new",
"WtEngineImpl",
"(",
"this",
".",
"wiki",
".",
"getWikConfig",
"(",
")",
")",
";",
"PageTitle",
"pageTitle",
"=",
"PageTitle",
".",
"make",
"(",
"this",
".",
"wiki",
".",
"getWikConfig",
"(",
")",
",",
"this",
".",
"getTitle",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"PageId",
"pageId",
"=",
"new",
"PageId",
"(",
"pageTitle",
",",
"-",
"1",
")",
";",
"// Compile the retrieved page",
"cp",
"=",
"engine",
".",
"postprocess",
"(",
"pageId",
",",
"this",
".",
"getText",
"(",
")",
",",
"null",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"WikiApiException",
"(",
"e",
")",
";",
"}",
"return",
"cp",
";",
"}"
] | Returns CompiledPage produced by the SWEBLE parser using the SimpleWikiConfiguration.
@return the parsed page
@throws WikiApiException Thrown if errors occurred. | [
"Returns",
"CompiledPage",
"produced",
"by",
"the",
"SWEBLE",
"parser",
"using",
"the",
"SimpleWikiConfiguration",
"."
] | train | https://github.com/dkpro/dkpro-jwpl/blob/0a0304b6a0aa13acc18838957994e06dd4613a58/de.tudarmstadt.ukp.wikipedia.api/src/main/java/de/tudarmstadt/ukp/wikipedia/api/Page.java#L608-L623 |
xqbase/util | util/src/main/java/com/xqbase/util/Bytes.java | Bytes.setShort | public static void setShort(int n, byte[] b, int off, boolean littleEndian) {
"""
Store a <b>short</b> number into a byte array in a given byte order
"""
if (littleEndian) {
b[off] = (byte) n;
b[off + 1] = (byte) (n >>> 8);
} else {
b[off] = (byte) (n >>> 8);
b[off + 1] = (byte) n;
}
} | java | public static void setShort(int n, byte[] b, int off, boolean littleEndian) {
if (littleEndian) {
b[off] = (byte) n;
b[off + 1] = (byte) (n >>> 8);
} else {
b[off] = (byte) (n >>> 8);
b[off + 1] = (byte) n;
}
} | [
"public",
"static",
"void",
"setShort",
"(",
"int",
"n",
",",
"byte",
"[",
"]",
"b",
",",
"int",
"off",
",",
"boolean",
"littleEndian",
")",
"{",
"if",
"(",
"littleEndian",
")",
"{",
"b",
"[",
"off",
"]",
"=",
"(",
"byte",
")",
"n",
";",
"b",
"[",
"off",
"+",
"1",
"]",
"=",
"(",
"byte",
")",
"(",
"n",
">>>",
"8",
")",
";",
"}",
"else",
"{",
"b",
"[",
"off",
"]",
"=",
"(",
"byte",
")",
"(",
"n",
">>>",
"8",
")",
";",
"b",
"[",
"off",
"+",
"1",
"]",
"=",
"(",
"byte",
")",
"n",
";",
"}",
"}"
] | Store a <b>short</b> number into a byte array in a given byte order | [
"Store",
"a",
"<b",
">",
"short<",
"/",
"b",
">",
"number",
"into",
"a",
"byte",
"array",
"in",
"a",
"given",
"byte",
"order"
] | train | https://github.com/xqbase/util/blob/e7b9167b6c701b9eec988a9d1e68446cef5ef420/util/src/main/java/com/xqbase/util/Bytes.java#L108-L116 |
hawkular/hawkular-commons | hawkular-bus/hawkular-bus-common/src/main/java/org/hawkular/bus/common/ConnectionContextFactory.java | ConnectionContextFactory.createConsumerConnectionContext | public ConsumerConnectionContext createConsumerConnectionContext(Endpoint endpoint, String messageSelector)
throws JMSException {
"""
Creates a new consumer connection context, reusing any existing connection that might have
already been created. The destination of the connection's session will be that of the given endpoint.
The consumer will filter messages based on the given message selector expression (which may be
null in which case the consumer will consume all messages).
@param endpoint where the consumer will listen for messages
@param messageSelector message consumer's message selector expression.
@return the new consumer connection context fully populated
@throws JMSException any error
"""
ConsumerConnectionContext context = new ConsumerConnectionContext();
createOrReuseConnection(context, true);
createSession(context);
createDestination(context, endpoint);
createConsumer(context, messageSelector);
return context;
} | java | public ConsumerConnectionContext createConsumerConnectionContext(Endpoint endpoint, String messageSelector)
throws JMSException {
ConsumerConnectionContext context = new ConsumerConnectionContext();
createOrReuseConnection(context, true);
createSession(context);
createDestination(context, endpoint);
createConsumer(context, messageSelector);
return context;
} | [
"public",
"ConsumerConnectionContext",
"createConsumerConnectionContext",
"(",
"Endpoint",
"endpoint",
",",
"String",
"messageSelector",
")",
"throws",
"JMSException",
"{",
"ConsumerConnectionContext",
"context",
"=",
"new",
"ConsumerConnectionContext",
"(",
")",
";",
"createOrReuseConnection",
"(",
"context",
",",
"true",
")",
";",
"createSession",
"(",
"context",
")",
";",
"createDestination",
"(",
"context",
",",
"endpoint",
")",
";",
"createConsumer",
"(",
"context",
",",
"messageSelector",
")",
";",
"return",
"context",
";",
"}"
] | Creates a new consumer connection context, reusing any existing connection that might have
already been created. The destination of the connection's session will be that of the given endpoint.
The consumer will filter messages based on the given message selector expression (which may be
null in which case the consumer will consume all messages).
@param endpoint where the consumer will listen for messages
@param messageSelector message consumer's message selector expression.
@return the new consumer connection context fully populated
@throws JMSException any error | [
"Creates",
"a",
"new",
"consumer",
"connection",
"context",
"reusing",
"any",
"existing",
"connection",
"that",
"might",
"have",
"already",
"been",
"created",
".",
"The",
"destination",
"of",
"the",
"connection",
"s",
"session",
"will",
"be",
"that",
"of",
"the",
"given",
"endpoint",
".",
"The",
"consumer",
"will",
"filter",
"messages",
"based",
"on",
"the",
"given",
"message",
"selector",
"expression",
"(",
"which",
"may",
"be",
"null",
"in",
"which",
"case",
"the",
"consumer",
"will",
"consume",
"all",
"messages",
")",
"."
] | train | https://github.com/hawkular/hawkular-commons/blob/e4a832862b3446d7f4d629bb05790f2df578e035/hawkular-bus/hawkular-bus-common/src/main/java/org/hawkular/bus/common/ConnectionContextFactory.java#L124-L132 |
couchbase/couchbase-lite-java | src/main/java/com/couchbase/lite/Parameters.java | Parameters.setDate | @NonNull
public Parameters setDate(@NonNull String name, Date value) {
"""
Set a date value to the query parameter referenced by the given name. A query parameter
is defined by using the Expression's parameter(String name) function.
@param name The parameter name.
@param value The date value.
@return The self object.
"""
return setValue(name, value);
} | java | @NonNull
public Parameters setDate(@NonNull String name, Date value) {
return setValue(name, value);
} | [
"@",
"NonNull",
"public",
"Parameters",
"setDate",
"(",
"@",
"NonNull",
"String",
"name",
",",
"Date",
"value",
")",
"{",
"return",
"setValue",
"(",
"name",
",",
"value",
")",
";",
"}"
] | Set a date value to the query parameter referenced by the given name. A query parameter
is defined by using the Expression's parameter(String name) function.
@param name The parameter name.
@param value The date value.
@return The self object. | [
"Set",
"a",
"date",
"value",
"to",
"the",
"query",
"parameter",
"referenced",
"by",
"the",
"given",
"name",
".",
"A",
"query",
"parameter",
"is",
"defined",
"by",
"using",
"the",
"Expression",
"s",
"parameter",
"(",
"String",
"name",
")",
"function",
"."
] | train | https://github.com/couchbase/couchbase-lite-java/blob/cb72c44186456e6191a9ad0a7feb310011d0b081/src/main/java/com/couchbase/lite/Parameters.java#L170-L173 |
deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/factory/BaseNDArrayFactory.java | BaseNDArrayFactory.valueArrayOf | @Override
public INDArray valueArrayOf(int[] shape, double value) {
"""
Creates an ndarray with the specified value
as the only value in the ndarray
@param shape the shape of the ndarray
@param value the value to assign
@return the created ndarray
"""
INDArray ret = Nd4j.createUninitialized(shape, Nd4j.order());
ret.assign(value);
return ret;
} | java | @Override
public INDArray valueArrayOf(int[] shape, double value) {
INDArray ret = Nd4j.createUninitialized(shape, Nd4j.order());
ret.assign(value);
return ret;
} | [
"@",
"Override",
"public",
"INDArray",
"valueArrayOf",
"(",
"int",
"[",
"]",
"shape",
",",
"double",
"value",
")",
"{",
"INDArray",
"ret",
"=",
"Nd4j",
".",
"createUninitialized",
"(",
"shape",
",",
"Nd4j",
".",
"order",
"(",
")",
")",
";",
"ret",
".",
"assign",
"(",
"value",
")",
";",
"return",
"ret",
";",
"}"
] | Creates an ndarray with the specified value
as the only value in the ndarray
@param shape the shape of the ndarray
@param value the value to assign
@return the created ndarray | [
"Creates",
"an",
"ndarray",
"with",
"the",
"specified",
"value",
"as",
"the",
"only",
"value",
"in",
"the",
"ndarray"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/factory/BaseNDArrayFactory.java#L796-L801 |
Impetus/Kundera | src/kundera-cassandra/cassandra-core/src/main/java/com/impetus/client/cassandra/thrift/CQLTranslator.java | CQLTranslator.appendMap | private boolean appendMap(StringBuilder builder, Object value) {
"""
Appends a object of type {@link java.util.List}
@param builder
the builder
@param value
the value
@return true, if successful
"""
boolean isPresent = false;
if (value instanceof Map)
{
Map map = ((Map) value);
isPresent = true;
builder.append(Constants.OPEN_CURLY_BRACKET);
for (Object mapKey : map.keySet())
{
Object mapValue = map.get(mapKey);
// Allowing null keys.
appendValue(builder, mapKey != null ? mapKey.getClass() : null, mapKey, false);
builder.append(Constants.COLON);
// Allowing null values.
appendValue(builder, mapValue != null ? mapValue.getClass() : null, mapValue, false);
builder.append(Constants.COMMA);
}
if (!map.isEmpty())
{
builder.deleteCharAt(builder.length() - 1);
}
builder.append(Constants.CLOSE_CURLY_BRACKET);
}
else
{
appendValue(builder, value.getClass(), value, false);
}
return isPresent;
} | java | private boolean appendMap(StringBuilder builder, Object value)
{
boolean isPresent = false;
if (value instanceof Map)
{
Map map = ((Map) value);
isPresent = true;
builder.append(Constants.OPEN_CURLY_BRACKET);
for (Object mapKey : map.keySet())
{
Object mapValue = map.get(mapKey);
// Allowing null keys.
appendValue(builder, mapKey != null ? mapKey.getClass() : null, mapKey, false);
builder.append(Constants.COLON);
// Allowing null values.
appendValue(builder, mapValue != null ? mapValue.getClass() : null, mapValue, false);
builder.append(Constants.COMMA);
}
if (!map.isEmpty())
{
builder.deleteCharAt(builder.length() - 1);
}
builder.append(Constants.CLOSE_CURLY_BRACKET);
}
else
{
appendValue(builder, value.getClass(), value, false);
}
return isPresent;
} | [
"private",
"boolean",
"appendMap",
"(",
"StringBuilder",
"builder",
",",
"Object",
"value",
")",
"{",
"boolean",
"isPresent",
"=",
"false",
";",
"if",
"(",
"value",
"instanceof",
"Map",
")",
"{",
"Map",
"map",
"=",
"(",
"(",
"Map",
")",
"value",
")",
";",
"isPresent",
"=",
"true",
";",
"builder",
".",
"append",
"(",
"Constants",
".",
"OPEN_CURLY_BRACKET",
")",
";",
"for",
"(",
"Object",
"mapKey",
":",
"map",
".",
"keySet",
"(",
")",
")",
"{",
"Object",
"mapValue",
"=",
"map",
".",
"get",
"(",
"mapKey",
")",
";",
"// Allowing null keys.",
"appendValue",
"(",
"builder",
",",
"mapKey",
"!=",
"null",
"?",
"mapKey",
".",
"getClass",
"(",
")",
":",
"null",
",",
"mapKey",
",",
"false",
")",
";",
"builder",
".",
"append",
"(",
"Constants",
".",
"COLON",
")",
";",
"// Allowing null values.",
"appendValue",
"(",
"builder",
",",
"mapValue",
"!=",
"null",
"?",
"mapValue",
".",
"getClass",
"(",
")",
":",
"null",
",",
"mapValue",
",",
"false",
")",
";",
"builder",
".",
"append",
"(",
"Constants",
".",
"COMMA",
")",
";",
"}",
"if",
"(",
"!",
"map",
".",
"isEmpty",
"(",
")",
")",
"{",
"builder",
".",
"deleteCharAt",
"(",
"builder",
".",
"length",
"(",
")",
"-",
"1",
")",
";",
"}",
"builder",
".",
"append",
"(",
"Constants",
".",
"CLOSE_CURLY_BRACKET",
")",
";",
"}",
"else",
"{",
"appendValue",
"(",
"builder",
",",
"value",
".",
"getClass",
"(",
")",
",",
"value",
",",
"false",
")",
";",
"}",
"return",
"isPresent",
";",
"}"
] | Appends a object of type {@link java.util.List}
@param builder
the builder
@param value
the value
@return true, if successful | [
"Appends",
"a",
"object",
"of",
"type",
"{",
"@link",
"java",
".",
"util",
".",
"List",
"}"
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-cassandra/cassandra-core/src/main/java/com/impetus/client/cassandra/thrift/CQLTranslator.java#L1210-L1240 |
apache/groovy | subprojects/groovy-datetime/src/main/java/org/apache/groovy/datetime/extensions/DateTimeExtensions.java | DateTimeExtensions.rightShift | public static Period rightShift(YearMonth self, YearMonth other) {
"""
Returns a {@link java.time.Period} of time between the first day of this year/month (inclusive) and the
given {@link java.time.YearMonth} (exclusive).
@param self a YearMonth
@param other another YearMonth
@return a Period
@since 2.5.0
"""
return Period.between(self.atDay(1), other.atDay(1));
} | java | public static Period rightShift(YearMonth self, YearMonth other) {
return Period.between(self.atDay(1), other.atDay(1));
} | [
"public",
"static",
"Period",
"rightShift",
"(",
"YearMonth",
"self",
",",
"YearMonth",
"other",
")",
"{",
"return",
"Period",
".",
"between",
"(",
"self",
".",
"atDay",
"(",
"1",
")",
",",
"other",
".",
"atDay",
"(",
"1",
")",
")",
";",
"}"
] | Returns a {@link java.time.Period} of time between the first day of this year/month (inclusive) and the
given {@link java.time.YearMonth} (exclusive).
@param self a YearMonth
@param other another YearMonth
@return a Period
@since 2.5.0 | [
"Returns",
"a",
"{",
"@link",
"java",
".",
"time",
".",
"Period",
"}",
"of",
"time",
"between",
"the",
"first",
"day",
"of",
"this",
"year",
"/",
"month",
"(",
"inclusive",
")",
"and",
"the",
"given",
"{",
"@link",
"java",
".",
"time",
".",
"YearMonth",
"}",
"(",
"exclusive",
")",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-datetime/src/main/java/org/apache/groovy/datetime/extensions/DateTimeExtensions.java#L1603-L1605 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/text/DateFormat.java | DateFormat.getDateTimeInstance | public final static DateFormat getDateTimeInstance() {
"""
Gets the date/time formatter with the default formatting style
for the default locale.
@return a date/time formatter.
"""
return get(DEFAULT, DEFAULT, 3, Locale.getDefault(Locale.Category.FORMAT));
} | java | public final static DateFormat getDateTimeInstance()
{
return get(DEFAULT, DEFAULT, 3, Locale.getDefault(Locale.Category.FORMAT));
} | [
"public",
"final",
"static",
"DateFormat",
"getDateTimeInstance",
"(",
")",
"{",
"return",
"get",
"(",
"DEFAULT",
",",
"DEFAULT",
",",
"3",
",",
"Locale",
".",
"getDefault",
"(",
"Locale",
".",
"Category",
".",
"FORMAT",
")",
")",
";",
"}"
] | Gets the date/time formatter with the default formatting style
for the default locale.
@return a date/time formatter. | [
"Gets",
"the",
"date",
"/",
"time",
"formatter",
"with",
"the",
"default",
"formatting",
"style",
"for",
"the",
"default",
"locale",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/text/DateFormat.java#L518-L521 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/lang/Math.java | Math.multiplyExact | public static long multiplyExact(long x, long y) {
"""
Returns the product of the arguments,
throwing an exception if the result overflows a {@code long}.
@param x the first value
@param y the second value
@return the result
@throws ArithmeticException if the result overflows a long
@since 1.8
"""
long r = x * y;
long ax = Math.abs(x);
long ay = Math.abs(y);
if (((ax | ay) >>> 31 != 0)) {
// Some bits greater than 2^31 that might cause overflow
// Check the result using the divide operator
// and check for the special case of Long.MIN_VALUE * -1
if (((y != 0) && (r / y != x)) ||
(x == Long.MIN_VALUE && y == -1)) {
throw new ArithmeticException("long overflow");
}
}
return r;
} | java | public static long multiplyExact(long x, long y) {
long r = x * y;
long ax = Math.abs(x);
long ay = Math.abs(y);
if (((ax | ay) >>> 31 != 0)) {
// Some bits greater than 2^31 that might cause overflow
// Check the result using the divide operator
// and check for the special case of Long.MIN_VALUE * -1
if (((y != 0) && (r / y != x)) ||
(x == Long.MIN_VALUE && y == -1)) {
throw new ArithmeticException("long overflow");
}
}
return r;
} | [
"public",
"static",
"long",
"multiplyExact",
"(",
"long",
"x",
",",
"long",
"y",
")",
"{",
"long",
"r",
"=",
"x",
"*",
"y",
";",
"long",
"ax",
"=",
"Math",
".",
"abs",
"(",
"x",
")",
";",
"long",
"ay",
"=",
"Math",
".",
"abs",
"(",
"y",
")",
";",
"if",
"(",
"(",
"(",
"ax",
"|",
"ay",
")",
">>>",
"31",
"!=",
"0",
")",
")",
"{",
"// Some bits greater than 2^31 that might cause overflow",
"// Check the result using the divide operator",
"// and check for the special case of Long.MIN_VALUE * -1",
"if",
"(",
"(",
"(",
"y",
"!=",
"0",
")",
"&&",
"(",
"r",
"/",
"y",
"!=",
"x",
")",
")",
"||",
"(",
"x",
"==",
"Long",
".",
"MIN_VALUE",
"&&",
"y",
"==",
"-",
"1",
")",
")",
"{",
"throw",
"new",
"ArithmeticException",
"(",
"\"long overflow\"",
")",
";",
"}",
"}",
"return",
"r",
";",
"}"
] | Returns the product of the arguments,
throwing an exception if the result overflows a {@code long}.
@param x the first value
@param y the second value
@return the result
@throws ArithmeticException if the result overflows a long
@since 1.8 | [
"Returns",
"the",
"product",
"of",
"the",
"arguments",
"throwing",
"an",
"exception",
"if",
"the",
"result",
"overflows",
"a",
"{",
"@code",
"long",
"}",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/lang/Math.java#L887-L901 |
sbt-compiler-maven-plugin/sbt-compiler-maven-plugin | sbt-compiler-maven-plugin/src/main/java/com/google/code/sbt/compiler/plugin/SBTAddScalaSourcesMojo.java | SBTAddScalaSourcesMojo.execute | @Override
public void execute() {
"""
Adds default Scala sources locations to Maven project.
<ul>
<li>{@code src/main/scala} is added to project's compile source roots</li>
<li>{@code src/test/scala} is added to project's test compile source roots</li>
</ul>
"""
if ( "pom".equals( project.getPackaging() ) )
{
return;
}
File baseDir = project.getBasedir();
File mainScalaPath = new File( baseDir, "src/main/scala" );
if ( mainScalaPath.isDirectory() )
{
String mainScalaPathStr = mainScalaPath.getAbsolutePath();
if ( !project.getCompileSourceRoots().contains( mainScalaPathStr ) )
{
project.addCompileSourceRoot( mainScalaPathStr );
getLog().debug( "Added source directory: " + mainScalaPathStr );
}
}
File testScalaPath = new File( baseDir, "src/test/scala" );
if ( testScalaPath.isDirectory() )
{
String testScalaPathStr = testScalaPath.getAbsolutePath();
if ( !project.getTestCompileSourceRoots().contains( testScalaPathStr ) )
{
project.addTestCompileSourceRoot( testScalaPathStr );
getLog().debug( "Added test source directory: " + testScalaPathStr );
}
}
} | java | @Override
public void execute()
{
if ( "pom".equals( project.getPackaging() ) )
{
return;
}
File baseDir = project.getBasedir();
File mainScalaPath = new File( baseDir, "src/main/scala" );
if ( mainScalaPath.isDirectory() )
{
String mainScalaPathStr = mainScalaPath.getAbsolutePath();
if ( !project.getCompileSourceRoots().contains( mainScalaPathStr ) )
{
project.addCompileSourceRoot( mainScalaPathStr );
getLog().debug( "Added source directory: " + mainScalaPathStr );
}
}
File testScalaPath = new File( baseDir, "src/test/scala" );
if ( testScalaPath.isDirectory() )
{
String testScalaPathStr = testScalaPath.getAbsolutePath();
if ( !project.getTestCompileSourceRoots().contains( testScalaPathStr ) )
{
project.addTestCompileSourceRoot( testScalaPathStr );
getLog().debug( "Added test source directory: " + testScalaPathStr );
}
}
} | [
"@",
"Override",
"public",
"void",
"execute",
"(",
")",
"{",
"if",
"(",
"\"pom\"",
".",
"equals",
"(",
"project",
".",
"getPackaging",
"(",
")",
")",
")",
"{",
"return",
";",
"}",
"File",
"baseDir",
"=",
"project",
".",
"getBasedir",
"(",
")",
";",
"File",
"mainScalaPath",
"=",
"new",
"File",
"(",
"baseDir",
",",
"\"src/main/scala\"",
")",
";",
"if",
"(",
"mainScalaPath",
".",
"isDirectory",
"(",
")",
")",
"{",
"String",
"mainScalaPathStr",
"=",
"mainScalaPath",
".",
"getAbsolutePath",
"(",
")",
";",
"if",
"(",
"!",
"project",
".",
"getCompileSourceRoots",
"(",
")",
".",
"contains",
"(",
"mainScalaPathStr",
")",
")",
"{",
"project",
".",
"addCompileSourceRoot",
"(",
"mainScalaPathStr",
")",
";",
"getLog",
"(",
")",
".",
"debug",
"(",
"\"Added source directory: \"",
"+",
"mainScalaPathStr",
")",
";",
"}",
"}",
"File",
"testScalaPath",
"=",
"new",
"File",
"(",
"baseDir",
",",
"\"src/test/scala\"",
")",
";",
"if",
"(",
"testScalaPath",
".",
"isDirectory",
"(",
")",
")",
"{",
"String",
"testScalaPathStr",
"=",
"testScalaPath",
".",
"getAbsolutePath",
"(",
")",
";",
"if",
"(",
"!",
"project",
".",
"getTestCompileSourceRoots",
"(",
")",
".",
"contains",
"(",
"testScalaPathStr",
")",
")",
"{",
"project",
".",
"addTestCompileSourceRoot",
"(",
"testScalaPathStr",
")",
";",
"getLog",
"(",
")",
".",
"debug",
"(",
"\"Added test source directory: \"",
"+",
"testScalaPathStr",
")",
";",
"}",
"}",
"}"
] | Adds default Scala sources locations to Maven project.
<ul>
<li>{@code src/main/scala} is added to project's compile source roots</li>
<li>{@code src/test/scala} is added to project's test compile source roots</li>
</ul> | [
"Adds",
"default",
"Scala",
"sources",
"locations",
"to",
"Maven",
"project",
"."
] | train | https://github.com/sbt-compiler-maven-plugin/sbt-compiler-maven-plugin/blob/cf8b8766956841c13f388eb311d214644dba9137/sbt-compiler-maven-plugin/src/main/java/com/google/code/sbt/compiler/plugin/SBTAddScalaSourcesMojo.java#L59-L90 |
Azure/azure-sdk-for-java | labservices/resource-manager/v2018_10_15/src/main/java/com/microsoft/azure/management/labservices/v2018_10_15/implementation/LabAccountsInner.java | LabAccountsInner.update | public LabAccountInner update(String resourceGroupName, String labAccountName, LabAccountFragment labAccount) {
"""
Modify properties of lab accounts.
@param resourceGroupName The name of the resource group.
@param labAccountName The name of the lab Account.
@param labAccount Represents a lab account.
@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 LabAccountInner object if successful.
"""
return updateWithServiceResponseAsync(resourceGroupName, labAccountName, labAccount).toBlocking().single().body();
} | java | public LabAccountInner update(String resourceGroupName, String labAccountName, LabAccountFragment labAccount) {
return updateWithServiceResponseAsync(resourceGroupName, labAccountName, labAccount).toBlocking().single().body();
} | [
"public",
"LabAccountInner",
"update",
"(",
"String",
"resourceGroupName",
",",
"String",
"labAccountName",
",",
"LabAccountFragment",
"labAccount",
")",
"{",
"return",
"updateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"labAccountName",
",",
"labAccount",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Modify properties of lab accounts.
@param resourceGroupName The name of the resource group.
@param labAccountName The name of the lab Account.
@param labAccount Represents a lab account.
@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 LabAccountInner object if successful. | [
"Modify",
"properties",
"of",
"lab",
"accounts",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/labservices/resource-manager/v2018_10_15/src/main/java/com/microsoft/azure/management/labservices/v2018_10_15/implementation/LabAccountsInner.java#L1025-L1027 |
oehf/ipf-oht-atna | auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/AuditorFactory.java | AuditorFactory.getAuditor | public static IHEAuditor getAuditor(String className, boolean useGlobalConfig, boolean useGlobalContext) {
"""
Get an auditor instance for the specified auditor class name. Auditor
will use a standalone configuration or context if a non-global
configuration / context is requested. If a standalone configuration
is requested, the existing global configuration is cloned and used as the
base configuration.
@param className Class name of the auditor class to instantiate
@param useGlobalConfig Whether to use the global (true) or standalone (false) config
@param useGlobalContext Whether to use the global (true) or standalone (false) context
@return Instance of an IHE Auditor
"""
Class<? extends IHEAuditor> clazz = AuditorFactory.getAuditorClassForClassName(className);
return getAuditor(clazz,useGlobalConfig, useGlobalContext);
} | java | public static IHEAuditor getAuditor(String className, boolean useGlobalConfig, boolean useGlobalContext)
{
Class<? extends IHEAuditor> clazz = AuditorFactory.getAuditorClassForClassName(className);
return getAuditor(clazz,useGlobalConfig, useGlobalContext);
} | [
"public",
"static",
"IHEAuditor",
"getAuditor",
"(",
"String",
"className",
",",
"boolean",
"useGlobalConfig",
",",
"boolean",
"useGlobalContext",
")",
"{",
"Class",
"<",
"?",
"extends",
"IHEAuditor",
">",
"clazz",
"=",
"AuditorFactory",
".",
"getAuditorClassForClassName",
"(",
"className",
")",
";",
"return",
"getAuditor",
"(",
"clazz",
",",
"useGlobalConfig",
",",
"useGlobalContext",
")",
";",
"}"
] | Get an auditor instance for the specified auditor class name. Auditor
will use a standalone configuration or context if a non-global
configuration / context is requested. If a standalone configuration
is requested, the existing global configuration is cloned and used as the
base configuration.
@param className Class name of the auditor class to instantiate
@param useGlobalConfig Whether to use the global (true) or standalone (false) config
@param useGlobalContext Whether to use the global (true) or standalone (false) context
@return Instance of an IHE Auditor | [
"Get",
"an",
"auditor",
"instance",
"for",
"the",
"specified",
"auditor",
"class",
"name",
".",
"Auditor",
"will",
"use",
"a",
"standalone",
"configuration",
"or",
"context",
"if",
"a",
"non",
"-",
"global",
"configuration",
"/",
"context",
"is",
"requested",
".",
"If",
"a",
"standalone",
"configuration",
"is",
"requested",
"the",
"existing",
"global",
"configuration",
"is",
"cloned",
"and",
"used",
"as",
"the",
"base",
"configuration",
"."
] | train | https://github.com/oehf/ipf-oht-atna/blob/25ed1e926825169c94923a2c89a4618f60478ae8/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/AuditorFactory.java#L139-L143 |
tzaeschke/zoodb | src/org/zoodb/internal/server/index/FreeSpaceManager.java | FreeSpaceManager.initBackingIndexLoad | public void initBackingIndexLoad(IOResourceProvider file, int pageId, int pageCount) {
"""
Constructor for creating new index.
@param file The file
@param pageId The page ID of the root page
@param pageCount Current number of pages
"""
if (idx != null) {
throw new IllegalStateException();
}
//8 byte page, 1 byte flag
idx = new PagedUniqueLongLong(PAGE_TYPE.FREE_INDEX, file, pageId, 4, 8);
lastPage.set(pageCount-1);
iter = idx.iterator(1, Long.MAX_VALUE);//pageCount);
} | java | public void initBackingIndexLoad(IOResourceProvider file, int pageId, int pageCount) {
if (idx != null) {
throw new IllegalStateException();
}
//8 byte page, 1 byte flag
idx = new PagedUniqueLongLong(PAGE_TYPE.FREE_INDEX, file, pageId, 4, 8);
lastPage.set(pageCount-1);
iter = idx.iterator(1, Long.MAX_VALUE);//pageCount);
} | [
"public",
"void",
"initBackingIndexLoad",
"(",
"IOResourceProvider",
"file",
",",
"int",
"pageId",
",",
"int",
"pageCount",
")",
"{",
"if",
"(",
"idx",
"!=",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
")",
";",
"}",
"//8 byte page, 1 byte flag ",
"idx",
"=",
"new",
"PagedUniqueLongLong",
"(",
"PAGE_TYPE",
".",
"FREE_INDEX",
",",
"file",
",",
"pageId",
",",
"4",
",",
"8",
")",
";",
"lastPage",
".",
"set",
"(",
"pageCount",
"-",
"1",
")",
";",
"iter",
"=",
"idx",
".",
"iterator",
"(",
"1",
",",
"Long",
".",
"MAX_VALUE",
")",
";",
"//pageCount);",
"}"
] | Constructor for creating new index.
@param file The file
@param pageId The page ID of the root page
@param pageCount Current number of pages | [
"Constructor",
"for",
"creating",
"new",
"index",
"."
] | train | https://github.com/tzaeschke/zoodb/blob/058d0ff161a8ee9d53244c433aca97ee9c654410/src/org/zoodb/internal/server/index/FreeSpaceManager.java#L103-L111 |
RestComm/media-core | rtp/src/main/java/org/restcomm/media/core/rtp/crypto/SRTCPCryptoContext.java | SRTCPCryptoContext.processPacketAESCM | public void processPacketAESCM(RawPacket pkt, int index) {
"""
Perform Counter Mode AES encryption / decryption
@param pkt the RTP packet to be encrypted / decrypted
"""
long ssrc = pkt.getRTCPSSRC();
/* Compute the CM IV (refer to chapter 4.1.1 in RFC 3711):
*
* k_s XX XX XX XX XX XX XX XX XX XX XX XX XX XX
* SSRC XX XX XX XX
* index XX XX XX XX
* ------------------------------------------------------XOR
* IV XX XX XX XX XX XX XX XX XX XX XX XX XX XX 00 00
* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
*/
ivStore[0] = saltKey[0];
ivStore[1] = saltKey[1];
ivStore[2] = saltKey[2];
ivStore[3] = saltKey[3];
// The shifts transform the ssrc and index into network order
ivStore[4] = (byte) (((ssrc >> 24) & 0xff) ^ this.saltKey[4]);
ivStore[5] = (byte) (((ssrc >> 16) & 0xff) ^ this.saltKey[5]);
ivStore[6] = (byte) (((ssrc >> 8) & 0xff) ^ this.saltKey[6]);
ivStore[7] = (byte) ((ssrc & 0xff) ^ this.saltKey[7]);
ivStore[8] = saltKey[8];
ivStore[9] = saltKey[9];
ivStore[10] = (byte) (((index >> 24) & 0xff) ^ this.saltKey[10]);
ivStore[11] = (byte) (((index >> 16) & 0xff) ^ this.saltKey[11]);
ivStore[12] = (byte) (((index >> 8) & 0xff) ^ this.saltKey[12]);
ivStore[13] = (byte) ((index & 0xff) ^ this.saltKey[13]);
ivStore[14] = ivStore[15] = 0;
// Encrypted part excludes fixed header (8 bytes)
final int payloadOffset = 8;
final int payloadLength = pkt.getLength() - payloadOffset;
cipherCtr.process(cipher, pkt.getBuffer(), payloadOffset, payloadLength, ivStore);
} | java | public void processPacketAESCM(RawPacket pkt, int index) {
long ssrc = pkt.getRTCPSSRC();
/* Compute the CM IV (refer to chapter 4.1.1 in RFC 3711):
*
* k_s XX XX XX XX XX XX XX XX XX XX XX XX XX XX
* SSRC XX XX XX XX
* index XX XX XX XX
* ------------------------------------------------------XOR
* IV XX XX XX XX XX XX XX XX XX XX XX XX XX XX 00 00
* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
*/
ivStore[0] = saltKey[0];
ivStore[1] = saltKey[1];
ivStore[2] = saltKey[2];
ivStore[3] = saltKey[3];
// The shifts transform the ssrc and index into network order
ivStore[4] = (byte) (((ssrc >> 24) & 0xff) ^ this.saltKey[4]);
ivStore[5] = (byte) (((ssrc >> 16) & 0xff) ^ this.saltKey[5]);
ivStore[6] = (byte) (((ssrc >> 8) & 0xff) ^ this.saltKey[6]);
ivStore[7] = (byte) ((ssrc & 0xff) ^ this.saltKey[7]);
ivStore[8] = saltKey[8];
ivStore[9] = saltKey[9];
ivStore[10] = (byte) (((index >> 24) & 0xff) ^ this.saltKey[10]);
ivStore[11] = (byte) (((index >> 16) & 0xff) ^ this.saltKey[11]);
ivStore[12] = (byte) (((index >> 8) & 0xff) ^ this.saltKey[12]);
ivStore[13] = (byte) ((index & 0xff) ^ this.saltKey[13]);
ivStore[14] = ivStore[15] = 0;
// Encrypted part excludes fixed header (8 bytes)
final int payloadOffset = 8;
final int payloadLength = pkt.getLength() - payloadOffset;
cipherCtr.process(cipher, pkt.getBuffer(), payloadOffset, payloadLength, ivStore);
} | [
"public",
"void",
"processPacketAESCM",
"(",
"RawPacket",
"pkt",
",",
"int",
"index",
")",
"{",
"long",
"ssrc",
"=",
"pkt",
".",
"getRTCPSSRC",
"(",
")",
";",
"/* Compute the CM IV (refer to chapter 4.1.1 in RFC 3711):\r\n *\r\n * k_s XX XX XX XX XX XX XX XX XX XX XX XX XX XX\r\n * SSRC XX XX XX XX\r\n * index XX XX XX XX\r\n * ------------------------------------------------------XOR\r\n * IV XX XX XX XX XX XX XX XX XX XX XX XX XX XX 00 00\r\n * 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\r\n */",
"ivStore",
"[",
"0",
"]",
"=",
"saltKey",
"[",
"0",
"]",
";",
"ivStore",
"[",
"1",
"]",
"=",
"saltKey",
"[",
"1",
"]",
";",
"ivStore",
"[",
"2",
"]",
"=",
"saltKey",
"[",
"2",
"]",
";",
"ivStore",
"[",
"3",
"]",
"=",
"saltKey",
"[",
"3",
"]",
";",
"// The shifts transform the ssrc and index into network order\r",
"ivStore",
"[",
"4",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"(",
"ssrc",
">>",
"24",
")",
"&",
"0xff",
")",
"^",
"this",
".",
"saltKey",
"[",
"4",
"]",
")",
";",
"ivStore",
"[",
"5",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"(",
"ssrc",
">>",
"16",
")",
"&",
"0xff",
")",
"^",
"this",
".",
"saltKey",
"[",
"5",
"]",
")",
";",
"ivStore",
"[",
"6",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"(",
"ssrc",
">>",
"8",
")",
"&",
"0xff",
")",
"^",
"this",
".",
"saltKey",
"[",
"6",
"]",
")",
";",
"ivStore",
"[",
"7",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"ssrc",
"&",
"0xff",
")",
"^",
"this",
".",
"saltKey",
"[",
"7",
"]",
")",
";",
"ivStore",
"[",
"8",
"]",
"=",
"saltKey",
"[",
"8",
"]",
";",
"ivStore",
"[",
"9",
"]",
"=",
"saltKey",
"[",
"9",
"]",
";",
"ivStore",
"[",
"10",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"(",
"index",
">>",
"24",
")",
"&",
"0xff",
")",
"^",
"this",
".",
"saltKey",
"[",
"10",
"]",
")",
";",
"ivStore",
"[",
"11",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"(",
"index",
">>",
"16",
")",
"&",
"0xff",
")",
"^",
"this",
".",
"saltKey",
"[",
"11",
"]",
")",
";",
"ivStore",
"[",
"12",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"(",
"index",
">>",
"8",
")",
"&",
"0xff",
")",
"^",
"this",
".",
"saltKey",
"[",
"12",
"]",
")",
";",
"ivStore",
"[",
"13",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"index",
"&",
"0xff",
")",
"^",
"this",
".",
"saltKey",
"[",
"13",
"]",
")",
";",
"ivStore",
"[",
"14",
"]",
"=",
"ivStore",
"[",
"15",
"]",
"=",
"0",
";",
"// Encrypted part excludes fixed header (8 bytes) \r",
"final",
"int",
"payloadOffset",
"=",
"8",
";",
"final",
"int",
"payloadLength",
"=",
"pkt",
".",
"getLength",
"(",
")",
"-",
"payloadOffset",
";",
"cipherCtr",
".",
"process",
"(",
"cipher",
",",
"pkt",
".",
"getBuffer",
"(",
")",
",",
"payloadOffset",
",",
"payloadLength",
",",
"ivStore",
")",
";",
"}"
] | Perform Counter Mode AES encryption / decryption
@param pkt the RTP packet to be encrypted / decrypted | [
"Perform",
"Counter",
"Mode",
"AES",
"encryption",
"/",
"decryption"
] | train | https://github.com/RestComm/media-core/blob/07b8703343708599f60af66bae62aded77ee81b5/rtp/src/main/java/org/restcomm/media/core/rtp/crypto/SRTCPCryptoContext.java#L372-L409 |
shinesolutions/swagger-aem | java/generated/src/main/java/com/shinesolutions/swaggeraem4j/api/SlingApi.java | SlingApi.postConfigApacheFelixJettyBasedHttpServiceAsync | public com.squareup.okhttp.Call postConfigApacheFelixJettyBasedHttpServiceAsync(String runmode, Boolean orgApacheFelixHttpsNio, String orgApacheFelixHttpsNioTypeHint, String orgApacheFelixHttpsKeystore, String orgApacheFelixHttpsKeystoreTypeHint, String orgApacheFelixHttpsKeystorePassword, String orgApacheFelixHttpsKeystorePasswordTypeHint, String orgApacheFelixHttpsKeystoreKey, String orgApacheFelixHttpsKeystoreKeyTypeHint, String orgApacheFelixHttpsKeystoreKeyPassword, String orgApacheFelixHttpsKeystoreKeyPasswordTypeHint, String orgApacheFelixHttpsTruststore, String orgApacheFelixHttpsTruststoreTypeHint, String orgApacheFelixHttpsTruststorePassword, String orgApacheFelixHttpsTruststorePasswordTypeHint, String orgApacheFelixHttpsClientcertificate, String orgApacheFelixHttpsClientcertificateTypeHint, Boolean orgApacheFelixHttpsEnable, String orgApacheFelixHttpsEnableTypeHint, String orgOsgiServiceHttpPortSecure, String orgOsgiServiceHttpPortSecureTypeHint, final ApiCallback<Void> callback) throws ApiException {
"""
(asynchronously)
@param runmode (required)
@param orgApacheFelixHttpsNio (optional)
@param orgApacheFelixHttpsNioTypeHint (optional)
@param orgApacheFelixHttpsKeystore (optional)
@param orgApacheFelixHttpsKeystoreTypeHint (optional)
@param orgApacheFelixHttpsKeystorePassword (optional)
@param orgApacheFelixHttpsKeystorePasswordTypeHint (optional)
@param orgApacheFelixHttpsKeystoreKey (optional)
@param orgApacheFelixHttpsKeystoreKeyTypeHint (optional)
@param orgApacheFelixHttpsKeystoreKeyPassword (optional)
@param orgApacheFelixHttpsKeystoreKeyPasswordTypeHint (optional)
@param orgApacheFelixHttpsTruststore (optional)
@param orgApacheFelixHttpsTruststoreTypeHint (optional)
@param orgApacheFelixHttpsTruststorePassword (optional)
@param orgApacheFelixHttpsTruststorePasswordTypeHint (optional)
@param orgApacheFelixHttpsClientcertificate (optional)
@param orgApacheFelixHttpsClientcertificateTypeHint (optional)
@param orgApacheFelixHttpsEnable (optional)
@param orgApacheFelixHttpsEnableTypeHint (optional)
@param orgOsgiServiceHttpPortSecure (optional)
@param orgOsgiServiceHttpPortSecureTypeHint (optional)
@param callback The callback to be executed when the API call finishes
@return The request call
@throws ApiException If fail to process the API call, e.g. serializing the request body object
"""
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
callback.onDownloadProgress(bytesRead, contentLength, done);
}
};
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
@Override
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
callback.onUploadProgress(bytesWritten, contentLength, done);
}
};
}
com.squareup.okhttp.Call call = postConfigApacheFelixJettyBasedHttpServiceValidateBeforeCall(runmode, orgApacheFelixHttpsNio, orgApacheFelixHttpsNioTypeHint, orgApacheFelixHttpsKeystore, orgApacheFelixHttpsKeystoreTypeHint, orgApacheFelixHttpsKeystorePassword, orgApacheFelixHttpsKeystorePasswordTypeHint, orgApacheFelixHttpsKeystoreKey, orgApacheFelixHttpsKeystoreKeyTypeHint, orgApacheFelixHttpsKeystoreKeyPassword, orgApacheFelixHttpsKeystoreKeyPasswordTypeHint, orgApacheFelixHttpsTruststore, orgApacheFelixHttpsTruststoreTypeHint, orgApacheFelixHttpsTruststorePassword, orgApacheFelixHttpsTruststorePasswordTypeHint, orgApacheFelixHttpsClientcertificate, orgApacheFelixHttpsClientcertificateTypeHint, orgApacheFelixHttpsEnable, orgApacheFelixHttpsEnableTypeHint, orgOsgiServiceHttpPortSecure, orgOsgiServiceHttpPortSecureTypeHint, progressListener, progressRequestListener);
apiClient.executeAsync(call, callback);
return call;
} | java | public com.squareup.okhttp.Call postConfigApacheFelixJettyBasedHttpServiceAsync(String runmode, Boolean orgApacheFelixHttpsNio, String orgApacheFelixHttpsNioTypeHint, String orgApacheFelixHttpsKeystore, String orgApacheFelixHttpsKeystoreTypeHint, String orgApacheFelixHttpsKeystorePassword, String orgApacheFelixHttpsKeystorePasswordTypeHint, String orgApacheFelixHttpsKeystoreKey, String orgApacheFelixHttpsKeystoreKeyTypeHint, String orgApacheFelixHttpsKeystoreKeyPassword, String orgApacheFelixHttpsKeystoreKeyPasswordTypeHint, String orgApacheFelixHttpsTruststore, String orgApacheFelixHttpsTruststoreTypeHint, String orgApacheFelixHttpsTruststorePassword, String orgApacheFelixHttpsTruststorePasswordTypeHint, String orgApacheFelixHttpsClientcertificate, String orgApacheFelixHttpsClientcertificateTypeHint, Boolean orgApacheFelixHttpsEnable, String orgApacheFelixHttpsEnableTypeHint, String orgOsgiServiceHttpPortSecure, String orgOsgiServiceHttpPortSecureTypeHint, final ApiCallback<Void> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
callback.onDownloadProgress(bytesRead, contentLength, done);
}
};
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
@Override
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
callback.onUploadProgress(bytesWritten, contentLength, done);
}
};
}
com.squareup.okhttp.Call call = postConfigApacheFelixJettyBasedHttpServiceValidateBeforeCall(runmode, orgApacheFelixHttpsNio, orgApacheFelixHttpsNioTypeHint, orgApacheFelixHttpsKeystore, orgApacheFelixHttpsKeystoreTypeHint, orgApacheFelixHttpsKeystorePassword, orgApacheFelixHttpsKeystorePasswordTypeHint, orgApacheFelixHttpsKeystoreKey, orgApacheFelixHttpsKeystoreKeyTypeHint, orgApacheFelixHttpsKeystoreKeyPassword, orgApacheFelixHttpsKeystoreKeyPasswordTypeHint, orgApacheFelixHttpsTruststore, orgApacheFelixHttpsTruststoreTypeHint, orgApacheFelixHttpsTruststorePassword, orgApacheFelixHttpsTruststorePasswordTypeHint, orgApacheFelixHttpsClientcertificate, orgApacheFelixHttpsClientcertificateTypeHint, orgApacheFelixHttpsEnable, orgApacheFelixHttpsEnableTypeHint, orgOsgiServiceHttpPortSecure, orgOsgiServiceHttpPortSecureTypeHint, progressListener, progressRequestListener);
apiClient.executeAsync(call, callback);
return call;
} | [
"public",
"com",
".",
"squareup",
".",
"okhttp",
".",
"Call",
"postConfigApacheFelixJettyBasedHttpServiceAsync",
"(",
"String",
"runmode",
",",
"Boolean",
"orgApacheFelixHttpsNio",
",",
"String",
"orgApacheFelixHttpsNioTypeHint",
",",
"String",
"orgApacheFelixHttpsKeystore",
",",
"String",
"orgApacheFelixHttpsKeystoreTypeHint",
",",
"String",
"orgApacheFelixHttpsKeystorePassword",
",",
"String",
"orgApacheFelixHttpsKeystorePasswordTypeHint",
",",
"String",
"orgApacheFelixHttpsKeystoreKey",
",",
"String",
"orgApacheFelixHttpsKeystoreKeyTypeHint",
",",
"String",
"orgApacheFelixHttpsKeystoreKeyPassword",
",",
"String",
"orgApacheFelixHttpsKeystoreKeyPasswordTypeHint",
",",
"String",
"orgApacheFelixHttpsTruststore",
",",
"String",
"orgApacheFelixHttpsTruststoreTypeHint",
",",
"String",
"orgApacheFelixHttpsTruststorePassword",
",",
"String",
"orgApacheFelixHttpsTruststorePasswordTypeHint",
",",
"String",
"orgApacheFelixHttpsClientcertificate",
",",
"String",
"orgApacheFelixHttpsClientcertificateTypeHint",
",",
"Boolean",
"orgApacheFelixHttpsEnable",
",",
"String",
"orgApacheFelixHttpsEnableTypeHint",
",",
"String",
"orgOsgiServiceHttpPortSecure",
",",
"String",
"orgOsgiServiceHttpPortSecureTypeHint",
",",
"final",
"ApiCallback",
"<",
"Void",
">",
"callback",
")",
"throws",
"ApiException",
"{",
"ProgressResponseBody",
".",
"ProgressListener",
"progressListener",
"=",
"null",
";",
"ProgressRequestBody",
".",
"ProgressRequestListener",
"progressRequestListener",
"=",
"null",
";",
"if",
"(",
"callback",
"!=",
"null",
")",
"{",
"progressListener",
"=",
"new",
"ProgressResponseBody",
".",
"ProgressListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"update",
"(",
"long",
"bytesRead",
",",
"long",
"contentLength",
",",
"boolean",
"done",
")",
"{",
"callback",
".",
"onDownloadProgress",
"(",
"bytesRead",
",",
"contentLength",
",",
"done",
")",
";",
"}",
"}",
";",
"progressRequestListener",
"=",
"new",
"ProgressRequestBody",
".",
"ProgressRequestListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onRequestProgress",
"(",
"long",
"bytesWritten",
",",
"long",
"contentLength",
",",
"boolean",
"done",
")",
"{",
"callback",
".",
"onUploadProgress",
"(",
"bytesWritten",
",",
"contentLength",
",",
"done",
")",
";",
"}",
"}",
";",
"}",
"com",
".",
"squareup",
".",
"okhttp",
".",
"Call",
"call",
"=",
"postConfigApacheFelixJettyBasedHttpServiceValidateBeforeCall",
"(",
"runmode",
",",
"orgApacheFelixHttpsNio",
",",
"orgApacheFelixHttpsNioTypeHint",
",",
"orgApacheFelixHttpsKeystore",
",",
"orgApacheFelixHttpsKeystoreTypeHint",
",",
"orgApacheFelixHttpsKeystorePassword",
",",
"orgApacheFelixHttpsKeystorePasswordTypeHint",
",",
"orgApacheFelixHttpsKeystoreKey",
",",
"orgApacheFelixHttpsKeystoreKeyTypeHint",
",",
"orgApacheFelixHttpsKeystoreKeyPassword",
",",
"orgApacheFelixHttpsKeystoreKeyPasswordTypeHint",
",",
"orgApacheFelixHttpsTruststore",
",",
"orgApacheFelixHttpsTruststoreTypeHint",
",",
"orgApacheFelixHttpsTruststorePassword",
",",
"orgApacheFelixHttpsTruststorePasswordTypeHint",
",",
"orgApacheFelixHttpsClientcertificate",
",",
"orgApacheFelixHttpsClientcertificateTypeHint",
",",
"orgApacheFelixHttpsEnable",
",",
"orgApacheFelixHttpsEnableTypeHint",
",",
"orgOsgiServiceHttpPortSecure",
",",
"orgOsgiServiceHttpPortSecureTypeHint",
",",
"progressListener",
",",
"progressRequestListener",
")",
";",
"apiClient",
".",
"executeAsync",
"(",
"call",
",",
"callback",
")",
";",
"return",
"call",
";",
"}"
] | (asynchronously)
@param runmode (required)
@param orgApacheFelixHttpsNio (optional)
@param orgApacheFelixHttpsNioTypeHint (optional)
@param orgApacheFelixHttpsKeystore (optional)
@param orgApacheFelixHttpsKeystoreTypeHint (optional)
@param orgApacheFelixHttpsKeystorePassword (optional)
@param orgApacheFelixHttpsKeystorePasswordTypeHint (optional)
@param orgApacheFelixHttpsKeystoreKey (optional)
@param orgApacheFelixHttpsKeystoreKeyTypeHint (optional)
@param orgApacheFelixHttpsKeystoreKeyPassword (optional)
@param orgApacheFelixHttpsKeystoreKeyPasswordTypeHint (optional)
@param orgApacheFelixHttpsTruststore (optional)
@param orgApacheFelixHttpsTruststoreTypeHint (optional)
@param orgApacheFelixHttpsTruststorePassword (optional)
@param orgApacheFelixHttpsTruststorePasswordTypeHint (optional)
@param orgApacheFelixHttpsClientcertificate (optional)
@param orgApacheFelixHttpsClientcertificateTypeHint (optional)
@param orgApacheFelixHttpsEnable (optional)
@param orgApacheFelixHttpsEnableTypeHint (optional)
@param orgOsgiServiceHttpPortSecure (optional)
@param orgOsgiServiceHttpPortSecureTypeHint (optional)
@param callback The callback to be executed when the API call finishes
@return The request call
@throws ApiException If fail to process the API call, e.g. serializing the request body object | [
"(",
"asynchronously",
")"
] | train | https://github.com/shinesolutions/swagger-aem/blob/ae7da4df93e817dc2bad843779b2069d9c4e7c6b/java/generated/src/main/java/com/shinesolutions/swaggeraem4j/api/SlingApi.java#L3112-L3136 |
jbundle/jbundle | thin/base/remote/src/main/java/org/jbundle/thin/base/remote/proxy/transport/BaseTransport.java | BaseTransport.addParam | public void addParam(String strParam, boolean bValue) {
"""
Add this method param to the param list.
@param strParam The param name.
@param strValue The param value.
"""
this.addParam(strParam, bValue ? Constants.TRUE : Constants.FALSE);
} | java | public void addParam(String strParam, boolean bValue)
{
this.addParam(strParam, bValue ? Constants.TRUE : Constants.FALSE);
} | [
"public",
"void",
"addParam",
"(",
"String",
"strParam",
",",
"boolean",
"bValue",
")",
"{",
"this",
".",
"addParam",
"(",
"strParam",
",",
"bValue",
"?",
"Constants",
".",
"TRUE",
":",
"Constants",
".",
"FALSE",
")",
";",
"}"
] | Add this method param to the param list.
@param strParam The param name.
@param strValue The param value. | [
"Add",
"this",
"method",
"param",
"to",
"the",
"param",
"list",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/remote/src/main/java/org/jbundle/thin/base/remote/proxy/transport/BaseTransport.java#L101-L104 |
exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LocalNameRangeQuery.java | LocalNameRangeQuery.getUpperTerm | private static Term getUpperTerm(String upperName) {
"""
Creates a {@link Term} for the upper bound local name.
@param upperName the upper bound local name.
@return a {@link Term} for the upper bound local name.
"""
String text;
if (upperName == null) {
text = "\uFFFF";
} else {
text = upperName;
}
return new Term(FieldNames.LOCAL_NAME, text);
} | java | private static Term getUpperTerm(String upperName) {
String text;
if (upperName == null) {
text = "\uFFFF";
} else {
text = upperName;
}
return new Term(FieldNames.LOCAL_NAME, text);
} | [
"private",
"static",
"Term",
"getUpperTerm",
"(",
"String",
"upperName",
")",
"{",
"String",
"text",
";",
"if",
"(",
"upperName",
"==",
"null",
")",
"{",
"text",
"=",
"\"\\uFFFF\"",
";",
"}",
"else",
"{",
"text",
"=",
"upperName",
";",
"}",
"return",
"new",
"Term",
"(",
"FieldNames",
".",
"LOCAL_NAME",
",",
"text",
")",
";",
"}"
] | Creates a {@link Term} for the upper bound local name.
@param upperName the upper bound local name.
@return a {@link Term} for the upper bound local name. | [
"Creates",
"a",
"{",
"@link",
"Term",
"}",
"for",
"the",
"upper",
"bound",
"local",
"name",
"."
] | train | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LocalNameRangeQuery.java#L68-L76 |
GoogleCloudPlatform/appengine-mapreduce | java/src/main/java/com/google/appengine/tools/mapreduce/bigqueryjobs/BigQueryLoadFileSetJob.java | BigQueryLoadFileSetJob.triggerBigQueryLoadJob | private BigQueryLoadJobReference triggerBigQueryLoadJob() {
"""
Triggers a bigquery load {@link Job} request and returns the job Id for the same.
"""
Job job = createJob();
// Set up Bigquery Insert
try {
Insert insert =
BigQueryLoadGoogleCloudStorageFilesJob.getBigquery().jobs().insert(projectId, job);
Job executedJob = insert.execute();
log.info("Triggered the bigQuery load job for files " + fileSet + " . Job Id = "
+ executedJob.getId());
return new BigQueryLoadJobReference(projectId, executedJob.getJobReference());
} catch (IOException e) {
throw new RuntimeException("Error in triggering BigQuery load job for files " + fileSet, e);
}
} | java | private BigQueryLoadJobReference triggerBigQueryLoadJob() {
Job job = createJob();
// Set up Bigquery Insert
try {
Insert insert =
BigQueryLoadGoogleCloudStorageFilesJob.getBigquery().jobs().insert(projectId, job);
Job executedJob = insert.execute();
log.info("Triggered the bigQuery load job for files " + fileSet + " . Job Id = "
+ executedJob.getId());
return new BigQueryLoadJobReference(projectId, executedJob.getJobReference());
} catch (IOException e) {
throw new RuntimeException("Error in triggering BigQuery load job for files " + fileSet, e);
}
} | [
"private",
"BigQueryLoadJobReference",
"triggerBigQueryLoadJob",
"(",
")",
"{",
"Job",
"job",
"=",
"createJob",
"(",
")",
";",
"// Set up Bigquery Insert",
"try",
"{",
"Insert",
"insert",
"=",
"BigQueryLoadGoogleCloudStorageFilesJob",
".",
"getBigquery",
"(",
")",
".",
"jobs",
"(",
")",
".",
"insert",
"(",
"projectId",
",",
"job",
")",
";",
"Job",
"executedJob",
"=",
"insert",
".",
"execute",
"(",
")",
";",
"log",
".",
"info",
"(",
"\"Triggered the bigQuery load job for files \"",
"+",
"fileSet",
"+",
"\" . Job Id = \"",
"+",
"executedJob",
".",
"getId",
"(",
")",
")",
";",
"return",
"new",
"BigQueryLoadJobReference",
"(",
"projectId",
",",
"executedJob",
".",
"getJobReference",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Error in triggering BigQuery load job for files \"",
"+",
"fileSet",
",",
"e",
")",
";",
"}",
"}"
] | Triggers a bigquery load {@link Job} request and returns the job Id for the same. | [
"Triggers",
"a",
"bigquery",
"load",
"{"
] | train | https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/java/src/main/java/com/google/appengine/tools/mapreduce/bigqueryjobs/BigQueryLoadFileSetJob.java#L54-L67 |
google/closure-templates | java/src/com/google/template/soy/sharedpasses/render/RenderVisitor.java | RenderVisitor.createHelperInstance | protected RenderVisitor createHelperInstance(Appendable outputBuf, SoyRecord data) {
"""
Creates a helper instance for rendering a subtemplate.
@param outputBuf The Appendable to append the output to.
@param data The template data.
@return The newly created RenderVisitor instance.
"""
return new RenderVisitor(
evalVisitorFactory,
outputBuf,
basicTemplates,
deltemplates,
data,
ijData,
activeDelPackageSelector,
msgBundle,
xidRenamingMap,
cssRenamingMap,
debugSoyTemplateInfo,
pluginInstances);
} | java | protected RenderVisitor createHelperInstance(Appendable outputBuf, SoyRecord data) {
return new RenderVisitor(
evalVisitorFactory,
outputBuf,
basicTemplates,
deltemplates,
data,
ijData,
activeDelPackageSelector,
msgBundle,
xidRenamingMap,
cssRenamingMap,
debugSoyTemplateInfo,
pluginInstances);
} | [
"protected",
"RenderVisitor",
"createHelperInstance",
"(",
"Appendable",
"outputBuf",
",",
"SoyRecord",
"data",
")",
"{",
"return",
"new",
"RenderVisitor",
"(",
"evalVisitorFactory",
",",
"outputBuf",
",",
"basicTemplates",
",",
"deltemplates",
",",
"data",
",",
"ijData",
",",
"activeDelPackageSelector",
",",
"msgBundle",
",",
"xidRenamingMap",
",",
"cssRenamingMap",
",",
"debugSoyTemplateInfo",
",",
"pluginInstances",
")",
";",
"}"
] | Creates a helper instance for rendering a subtemplate.
@param outputBuf The Appendable to append the output to.
@param data The template data.
@return The newly created RenderVisitor instance. | [
"Creates",
"a",
"helper",
"instance",
"for",
"rendering",
"a",
"subtemplate",
"."
] | train | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/sharedpasses/render/RenderVisitor.java#L239-L253 |
moparisthebest/beehive | beehive-netui-tags/src/main/java/org/apache/beehive/netui/databinding/datagrid/runtime/config/DefaultSortStrategy.java | DefaultSortStrategy.nextDirection | public SortDirection nextDirection(SortDirection direction) {
"""
<p>
Given a sort direction, get the next sort direction. This implements a simple sort machine
that cycles through the sort directions in the following order:
<pre>
SortDirection.NONE > SortDirection.ASCENDING > SortDirection.DESCENDING > repeat
</pre>
</p>
@param direction the current {@link SortDirection}
@return the next {@link SortDirection}
"""
if(direction == SortDirection.NONE)
return SortDirection.ASCENDING;
else if(direction == SortDirection.ASCENDING)
return SortDirection.DESCENDING;
else if(direction == SortDirection.DESCENDING)
return SortDirection.NONE;
else throw new IllegalStateException(Bundle.getErrorString("SortStrategy_InvalidSortDirection", new Object[]{direction}));
} | java | public SortDirection nextDirection(SortDirection direction) {
if(direction == SortDirection.NONE)
return SortDirection.ASCENDING;
else if(direction == SortDirection.ASCENDING)
return SortDirection.DESCENDING;
else if(direction == SortDirection.DESCENDING)
return SortDirection.NONE;
else throw new IllegalStateException(Bundle.getErrorString("SortStrategy_InvalidSortDirection", new Object[]{direction}));
} | [
"public",
"SortDirection",
"nextDirection",
"(",
"SortDirection",
"direction",
")",
"{",
"if",
"(",
"direction",
"==",
"SortDirection",
".",
"NONE",
")",
"return",
"SortDirection",
".",
"ASCENDING",
";",
"else",
"if",
"(",
"direction",
"==",
"SortDirection",
".",
"ASCENDING",
")",
"return",
"SortDirection",
".",
"DESCENDING",
";",
"else",
"if",
"(",
"direction",
"==",
"SortDirection",
".",
"DESCENDING",
")",
"return",
"SortDirection",
".",
"NONE",
";",
"else",
"throw",
"new",
"IllegalStateException",
"(",
"Bundle",
".",
"getErrorString",
"(",
"\"SortStrategy_InvalidSortDirection\"",
",",
"new",
"Object",
"[",
"]",
"{",
"direction",
"}",
")",
")",
";",
"}"
] | <p>
Given a sort direction, get the next sort direction. This implements a simple sort machine
that cycles through the sort directions in the following order:
<pre>
SortDirection.NONE > SortDirection.ASCENDING > SortDirection.DESCENDING > repeat
</pre>
</p>
@param direction the current {@link SortDirection}
@return the next {@link SortDirection} | [
"<p",
">",
"Given",
"a",
"sort",
"direction",
"get",
"the",
"next",
"sort",
"direction",
".",
"This",
"implements",
"a",
"simple",
"sort",
"machine",
"that",
"cycles",
"through",
"the",
"sort",
"directions",
"in",
"the",
"following",
"order",
":",
"<pre",
">",
"SortDirection",
".",
"NONE",
">",
"SortDirection",
".",
"ASCENDING",
">",
"SortDirection",
".",
"DESCENDING",
">",
"repeat",
"<",
"/",
"pre",
">",
"<",
"/",
"p",
">"
] | train | https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-netui-tags/src/main/java/org/apache/beehive/netui/databinding/datagrid/runtime/config/DefaultSortStrategy.java#L60-L68 |
googleapis/google-cloud-java | google-cloud-clients/google-cloud-logging/src/main/java/com/google/cloud/logging/Structs.java | Structs.newStruct | static Struct newStruct(Map<String, ?> map) {
"""
Creates a new {@link Struct} object given the content of the provided {@code map} parameter.
<p>Notice that all numbers (int, long, float and double) are serialized as double values. Enums
are serialized as strings.
"""
Map<String, Value> valueMap = Maps.transformValues(checkNotNull(map), OBJECT_TO_VALUE);
return Struct.newBuilder().putAllFields(valueMap).build();
} | java | static Struct newStruct(Map<String, ?> map) {
Map<String, Value> valueMap = Maps.transformValues(checkNotNull(map), OBJECT_TO_VALUE);
return Struct.newBuilder().putAllFields(valueMap).build();
} | [
"static",
"Struct",
"newStruct",
"(",
"Map",
"<",
"String",
",",
"?",
">",
"map",
")",
"{",
"Map",
"<",
"String",
",",
"Value",
">",
"valueMap",
"=",
"Maps",
".",
"transformValues",
"(",
"checkNotNull",
"(",
"map",
")",
",",
"OBJECT_TO_VALUE",
")",
";",
"return",
"Struct",
".",
"newBuilder",
"(",
")",
".",
"putAllFields",
"(",
"valueMap",
")",
".",
"build",
"(",
")",
";",
"}"
] | Creates a new {@link Struct} object given the content of the provided {@code map} parameter.
<p>Notice that all numbers (int, long, float and double) are serialized as double values. Enums
are serialized as strings. | [
"Creates",
"a",
"new",
"{",
"@link",
"Struct",
"}",
"object",
"given",
"the",
"content",
"of",
"the",
"provided",
"{",
"@code",
"map",
"}",
"parameter",
"."
] | train | https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-logging/src/main/java/com/google/cloud/logging/Structs.java#L118-L121 |
playn/playn | core/src/playn/core/Surface.java | Surface.drawLine | public Surface drawLine (XY a, XY b, float width) {
"""
Fills a line between the specified coordinates, of the specified display unit width.
"""
return drawLine(a.x(), a.y(), b.x(), b.y(), width);
} | java | public Surface drawLine (XY a, XY b, float width) {
return drawLine(a.x(), a.y(), b.x(), b.y(), width);
} | [
"public",
"Surface",
"drawLine",
"(",
"XY",
"a",
",",
"XY",
"b",
",",
"float",
"width",
")",
"{",
"return",
"drawLine",
"(",
"a",
".",
"x",
"(",
")",
",",
"a",
".",
"y",
"(",
")",
",",
"b",
".",
"x",
"(",
")",
",",
"b",
".",
"y",
"(",
")",
",",
"width",
")",
";",
"}"
] | Fills a line between the specified coordinates, of the specified display unit width. | [
"Fills",
"a",
"line",
"between",
"the",
"specified",
"coordinates",
"of",
"the",
"specified",
"display",
"unit",
"width",
"."
] | train | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/core/src/playn/core/Surface.java#L346-L348 |
aws/aws-sdk-java | aws-java-sdk-resourcegroups/src/main/java/com/amazonaws/services/resourcegroups/model/CreateGroupResult.java | CreateGroupResult.withTags | public CreateGroupResult withTags(java.util.Map<String, String> tags) {
"""
<p>
The tags associated with the group.
</p>
@param tags
The tags associated with the group.
@return Returns a reference to this object so that method calls can be chained together.
"""
setTags(tags);
return this;
} | java | public CreateGroupResult withTags(java.util.Map<String, String> tags) {
setTags(tags);
return this;
} | [
"public",
"CreateGroupResult",
"withTags",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"tags",
")",
"{",
"setTags",
"(",
"tags",
")",
";",
"return",
"this",
";",
"}"
] | <p>
The tags associated with the group.
</p>
@param tags
The tags associated with the group.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"The",
"tags",
"associated",
"with",
"the",
"group",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-resourcegroups/src/main/java/com/amazonaws/services/resourcegroups/model/CreateGroupResult.java#L160-L163 |
google/error-prone-javac | src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java | Main.processOldJdk | boolean processOldJdk(String jdkHome, Collection<String> classNames) throws IOException {
"""
Processes named class files from rt.jar of a JDK version 7 or 8.
If classNames is empty, processes all classes.
@param jdkHome the path to the "home" of the JDK to process
@param classNames the names of classes to process
@return true for success, false for failure
@throws IOException if an I/O error occurs
"""
String RTJAR = jdkHome + "/jre/lib/rt.jar";
String CSJAR = jdkHome + "/jre/lib/charsets.jar";
bootClassPath.add(0, new File(RTJAR));
bootClassPath.add(1, new File(CSJAR));
options.add("-source");
options.add("8");
if (classNames.isEmpty()) {
return doJarFile(RTJAR);
} else {
return doClassNames(classNames);
}
} | java | boolean processOldJdk(String jdkHome, Collection<String> classNames) throws IOException {
String RTJAR = jdkHome + "/jre/lib/rt.jar";
String CSJAR = jdkHome + "/jre/lib/charsets.jar";
bootClassPath.add(0, new File(RTJAR));
bootClassPath.add(1, new File(CSJAR));
options.add("-source");
options.add("8");
if (classNames.isEmpty()) {
return doJarFile(RTJAR);
} else {
return doClassNames(classNames);
}
} | [
"boolean",
"processOldJdk",
"(",
"String",
"jdkHome",
",",
"Collection",
"<",
"String",
">",
"classNames",
")",
"throws",
"IOException",
"{",
"String",
"RTJAR",
"=",
"jdkHome",
"+",
"\"/jre/lib/rt.jar\"",
";",
"String",
"CSJAR",
"=",
"jdkHome",
"+",
"\"/jre/lib/charsets.jar\"",
";",
"bootClassPath",
".",
"add",
"(",
"0",
",",
"new",
"File",
"(",
"RTJAR",
")",
")",
";",
"bootClassPath",
".",
"add",
"(",
"1",
",",
"new",
"File",
"(",
"CSJAR",
")",
")",
";",
"options",
".",
"add",
"(",
"\"-source\"",
")",
";",
"options",
".",
"add",
"(",
"\"8\"",
")",
";",
"if",
"(",
"classNames",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"doJarFile",
"(",
"RTJAR",
")",
";",
"}",
"else",
"{",
"return",
"doClassNames",
"(",
"classNames",
")",
";",
"}",
"}"
] | Processes named class files from rt.jar of a JDK version 7 or 8.
If classNames is empty, processes all classes.
@param jdkHome the path to the "home" of the JDK to process
@param classNames the names of classes to process
@return true for success, false for failure
@throws IOException if an I/O error occurs | [
"Processes",
"named",
"class",
"files",
"from",
"rt",
".",
"jar",
"of",
"a",
"JDK",
"version",
"7",
"or",
"8",
".",
"If",
"classNames",
"is",
"empty",
"processes",
"all",
"classes",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java#L300-L314 |
jparsec/jparsec | jparsec-examples/src/main/java/org/jparsec/examples/common/Strings.java | Strings.prependEach | public static String prependEach(String delim, Iterable<?> objects) {
"""
Prepends {@code delim} before each object of {@code objects}.
"""
StringBuilder builder = new StringBuilder();
for (Object obj : objects) {
builder.append(delim);
builder.append(obj);
}
return builder.toString();
} | java | public static String prependEach(String delim, Iterable<?> objects) {
StringBuilder builder = new StringBuilder();
for (Object obj : objects) {
builder.append(delim);
builder.append(obj);
}
return builder.toString();
} | [
"public",
"static",
"String",
"prependEach",
"(",
"String",
"delim",
",",
"Iterable",
"<",
"?",
">",
"objects",
")",
"{",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"Object",
"obj",
":",
"objects",
")",
"{",
"builder",
".",
"append",
"(",
"delim",
")",
";",
"builder",
".",
"append",
"(",
"obj",
")",
";",
"}",
"return",
"builder",
".",
"toString",
"(",
")",
";",
"}"
] | Prepends {@code delim} before each object of {@code objects}. | [
"Prepends",
"{"
] | train | https://github.com/jparsec/jparsec/blob/df1280259f5da9eb5ffc537437569dddba66cb94/jparsec-examples/src/main/java/org/jparsec/examples/common/Strings.java#L28-L35 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/regex/RegExHelper.java | RegExHelper.getAsIdentifier | @Nullable
public static String getAsIdentifier (@Nullable final String s, final char cReplacement) {
"""
Convert an identifier to a programming language identifier by replacing all
non-word characters with an underscore.
@param s
The string to convert. May be <code>null</code> or empty.
@param cReplacement
The replacement character to be used for all non-identifier
characters
@return The converted string or <code>null</code> if the input string is
<code>null</code>.
"""
if (StringHelper.hasNoText (s))
return s;
String sReplacement;
if (cReplacement == '$' || cReplacement == '\\')
{
// These 2 chars must be quoted, otherwise an
// StringIndexOutOfBoundsException occurs!
sReplacement = "\\" + cReplacement;
}
else
sReplacement = Character.toString (cReplacement);
// replace all non-word characters with the replacement character
// Important: quote the replacement in case it is a backslash or another
// special regex character
final String ret = stringReplacePattern ("\\W", s, sReplacement);
if (!Character.isJavaIdentifierStart (ret.charAt (0)))
return sReplacement + ret;
return ret;
} | java | @Nullable
public static String getAsIdentifier (@Nullable final String s, final char cReplacement)
{
if (StringHelper.hasNoText (s))
return s;
String sReplacement;
if (cReplacement == '$' || cReplacement == '\\')
{
// These 2 chars must be quoted, otherwise an
// StringIndexOutOfBoundsException occurs!
sReplacement = "\\" + cReplacement;
}
else
sReplacement = Character.toString (cReplacement);
// replace all non-word characters with the replacement character
// Important: quote the replacement in case it is a backslash or another
// special regex character
final String ret = stringReplacePattern ("\\W", s, sReplacement);
if (!Character.isJavaIdentifierStart (ret.charAt (0)))
return sReplacement + ret;
return ret;
} | [
"@",
"Nullable",
"public",
"static",
"String",
"getAsIdentifier",
"(",
"@",
"Nullable",
"final",
"String",
"s",
",",
"final",
"char",
"cReplacement",
")",
"{",
"if",
"(",
"StringHelper",
".",
"hasNoText",
"(",
"s",
")",
")",
"return",
"s",
";",
"String",
"sReplacement",
";",
"if",
"(",
"cReplacement",
"==",
"'",
"'",
"||",
"cReplacement",
"==",
"'",
"'",
")",
"{",
"// These 2 chars must be quoted, otherwise an",
"// StringIndexOutOfBoundsException occurs!",
"sReplacement",
"=",
"\"\\\\\"",
"+",
"cReplacement",
";",
"}",
"else",
"sReplacement",
"=",
"Character",
".",
"toString",
"(",
"cReplacement",
")",
";",
"// replace all non-word characters with the replacement character",
"// Important: quote the replacement in case it is a backslash or another",
"// special regex character",
"final",
"String",
"ret",
"=",
"stringReplacePattern",
"(",
"\"\\\\W\"",
",",
"s",
",",
"sReplacement",
")",
";",
"if",
"(",
"!",
"Character",
".",
"isJavaIdentifierStart",
"(",
"ret",
".",
"charAt",
"(",
"0",
")",
")",
")",
"return",
"sReplacement",
"+",
"ret",
";",
"return",
"ret",
";",
"}"
] | Convert an identifier to a programming language identifier by replacing all
non-word characters with an underscore.
@param s
The string to convert. May be <code>null</code> or empty.
@param cReplacement
The replacement character to be used for all non-identifier
characters
@return The converted string or <code>null</code> if the input string is
<code>null</code>. | [
"Convert",
"an",
"identifier",
"to",
"a",
"programming",
"language",
"identifier",
"by",
"replacing",
"all",
"non",
"-",
"word",
"characters",
"with",
"an",
"underscore",
"."
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/regex/RegExHelper.java#L279-L302 |
gallandarakhneorg/afc | core/maths/mathgraph/src/main/java/org/arakhne/afc/math/graph/GraphPath.java | GraphPath.removeUntilLast | public boolean removeUntilLast(ST obj, PT pt) {
"""
Remove the path's elements before the
specified one which is starting
at the specified point. The specified element will
be removed.
<p>This function removes until the <i>last occurence</i>
of the given object.
@param obj is the segment to remove
@param pt is the point on which the segment was connected
as its first point.
@return <code>true</code> on success, otherwise <code>false</code>
"""
return removeUntil(lastIndexOf(obj, pt), true);
} | java | public boolean removeUntilLast(ST obj, PT pt) {
return removeUntil(lastIndexOf(obj, pt), true);
} | [
"public",
"boolean",
"removeUntilLast",
"(",
"ST",
"obj",
",",
"PT",
"pt",
")",
"{",
"return",
"removeUntil",
"(",
"lastIndexOf",
"(",
"obj",
",",
"pt",
")",
",",
"true",
")",
";",
"}"
] | Remove the path's elements before the
specified one which is starting
at the specified point. The specified element will
be removed.
<p>This function removes until the <i>last occurence</i>
of the given object.
@param obj is the segment to remove
@param pt is the point on which the segment was connected
as its first point.
@return <code>true</code> on success, otherwise <code>false</code> | [
"Remove",
"the",
"path",
"s",
"elements",
"before",
"the",
"specified",
"one",
"which",
"is",
"starting",
"at",
"the",
"specified",
"point",
".",
"The",
"specified",
"element",
"will",
"be",
"removed",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgraph/src/main/java/org/arakhne/afc/math/graph/GraphPath.java#L709-L711 |
prestodb/presto | presto-main/src/main/java/com/facebook/presto/metadata/StaticFunctionNamespace.java | StaticFunctionNamespace.isMoreSpecificThan | private boolean isMoreSpecificThan(ApplicableFunction left, ApplicableFunction right) {
"""
One method is more specific than another if invocation handled by the first method could be passed on to the other one
"""
List<TypeSignatureProvider> resolvedTypes = fromTypeSignatures(left.getBoundSignature().getArgumentTypes());
Optional<BoundVariables> boundVariables = new SignatureBinder(typeManager, right.getDeclaredSignature(), true)
.bindVariables(resolvedTypes);
return boundVariables.isPresent();
} | java | private boolean isMoreSpecificThan(ApplicableFunction left, ApplicableFunction right)
{
List<TypeSignatureProvider> resolvedTypes = fromTypeSignatures(left.getBoundSignature().getArgumentTypes());
Optional<BoundVariables> boundVariables = new SignatureBinder(typeManager, right.getDeclaredSignature(), true)
.bindVariables(resolvedTypes);
return boundVariables.isPresent();
} | [
"private",
"boolean",
"isMoreSpecificThan",
"(",
"ApplicableFunction",
"left",
",",
"ApplicableFunction",
"right",
")",
"{",
"List",
"<",
"TypeSignatureProvider",
">",
"resolvedTypes",
"=",
"fromTypeSignatures",
"(",
"left",
".",
"getBoundSignature",
"(",
")",
".",
"getArgumentTypes",
"(",
")",
")",
";",
"Optional",
"<",
"BoundVariables",
">",
"boundVariables",
"=",
"new",
"SignatureBinder",
"(",
"typeManager",
",",
"right",
".",
"getDeclaredSignature",
"(",
")",
",",
"true",
")",
".",
"bindVariables",
"(",
"resolvedTypes",
")",
";",
"return",
"boundVariables",
".",
"isPresent",
"(",
")",
";",
"}"
] | One method is more specific than another if invocation handled by the first method could be passed on to the other one | [
"One",
"method",
"is",
"more",
"specific",
"than",
"another",
"if",
"invocation",
"handled",
"by",
"the",
"first",
"method",
"could",
"be",
"passed",
"on",
"to",
"the",
"other",
"one"
] | train | https://github.com/prestodb/presto/blob/89de5e379d8f85e139d292b0add8c537a2a01a88/presto-main/src/main/java/com/facebook/presto/metadata/StaticFunctionNamespace.java#L1178-L1184 |
lievendoclo/Valkyrie-RCP | valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/CommandGroup.java | CommandGroup.createButtonStack | public JComponent createButtonStack(final ColumnSpec columnSpec, final RowSpec rowSpec) {
"""
Create a button stack with buttons for all the commands.
@param columnSpec Custom columnSpec for the stack, can be
<code>null</code>.
@param rowSpec Custom rowspec for each row containing a button can be
<code>null</code>.
@return never null
"""
return createButtonStack(columnSpec, rowSpec, null);
} | java | public JComponent createButtonStack(final ColumnSpec columnSpec, final RowSpec rowSpec) {
return createButtonStack(columnSpec, rowSpec, null);
} | [
"public",
"JComponent",
"createButtonStack",
"(",
"final",
"ColumnSpec",
"columnSpec",
",",
"final",
"RowSpec",
"rowSpec",
")",
"{",
"return",
"createButtonStack",
"(",
"columnSpec",
",",
"rowSpec",
",",
"null",
")",
";",
"}"
] | Create a button stack with buttons for all the commands.
@param columnSpec Custom columnSpec for the stack, can be
<code>null</code>.
@param rowSpec Custom rowspec for each row containing a button can be
<code>null</code>.
@return never null | [
"Create",
"a",
"button",
"stack",
"with",
"buttons",
"for",
"all",
"the",
"commands",
"."
] | train | https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/command/support/CommandGroup.java#L521-L523 |
google/closure-compiler | src/com/google/javascript/jscomp/Es6RewriteModules.java | Es6RewriteModules.maybeAddAliasToSymbolTable | private void maybeAddAliasToSymbolTable(Node n, String module) {
"""
Add alias nodes to the symbol table as they going to be removed by rewriter. Example aliases:
<pre>
import * as foo from './foo';
import {doBar} from './bar';
console.log(doBar);
</pre>
@param n Alias node. In the example above alias nodes are foo, doBar, and doBar.
@param module Name of the module currently being processed.
"""
if (preprocessorSymbolTable == null) {
return;
}
n.putBooleanProp(Node.MODULE_ALIAS, true);
// Alias can be used in js types. Types have node type STRING and not NAME so we have to
// use their name as string.
String nodeName =
n.isString() || n.isImportStar()
? n.getString()
: preprocessorSymbolTable.getQualifiedName(n);
// We need to include module as part of the name because aliases are local to current module.
// Aliases with the same name from different module should be completely different entities.
String name = "alias_" + module + "_" + nodeName;
preprocessorSymbolTable.addReference(n, name);
} | java | private void maybeAddAliasToSymbolTable(Node n, String module) {
if (preprocessorSymbolTable == null) {
return;
}
n.putBooleanProp(Node.MODULE_ALIAS, true);
// Alias can be used in js types. Types have node type STRING and not NAME so we have to
// use their name as string.
String nodeName =
n.isString() || n.isImportStar()
? n.getString()
: preprocessorSymbolTable.getQualifiedName(n);
// We need to include module as part of the name because aliases are local to current module.
// Aliases with the same name from different module should be completely different entities.
String name = "alias_" + module + "_" + nodeName;
preprocessorSymbolTable.addReference(n, name);
} | [
"private",
"void",
"maybeAddAliasToSymbolTable",
"(",
"Node",
"n",
",",
"String",
"module",
")",
"{",
"if",
"(",
"preprocessorSymbolTable",
"==",
"null",
")",
"{",
"return",
";",
"}",
"n",
".",
"putBooleanProp",
"(",
"Node",
".",
"MODULE_ALIAS",
",",
"true",
")",
";",
"// Alias can be used in js types. Types have node type STRING and not NAME so we have to",
"// use their name as string.",
"String",
"nodeName",
"=",
"n",
".",
"isString",
"(",
")",
"||",
"n",
".",
"isImportStar",
"(",
")",
"?",
"n",
".",
"getString",
"(",
")",
":",
"preprocessorSymbolTable",
".",
"getQualifiedName",
"(",
"n",
")",
";",
"// We need to include module as part of the name because aliases are local to current module.",
"// Aliases with the same name from different module should be completely different entities.",
"String",
"name",
"=",
"\"alias_\"",
"+",
"module",
"+",
"\"_\"",
"+",
"nodeName",
";",
"preprocessorSymbolTable",
".",
"addReference",
"(",
"n",
",",
"name",
")",
";",
"}"
] | Add alias nodes to the symbol table as they going to be removed by rewriter. Example aliases:
<pre>
import * as foo from './foo';
import {doBar} from './bar';
console.log(doBar);
</pre>
@param n Alias node. In the example above alias nodes are foo, doBar, and doBar.
@param module Name of the module currently being processed. | [
"Add",
"alias",
"nodes",
"to",
"the",
"symbol",
"table",
"as",
"they",
"going",
"to",
"be",
"removed",
"by",
"rewriter",
".",
"Example",
"aliases",
":"
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/Es6RewriteModules.java#L953-L968 |
deeplearning4j/deeplearning4j | deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/util/Convolution1DUtils.java | Convolution1DUtils.validateCnn1DKernelStridePadding | public static void validateCnn1DKernelStridePadding(int kernel, int stride, int padding) {
"""
Perform validation on the CNN layer kernel/stride/padding. Expect int, with values > 0 for kernel size and
stride, and values >= 0 for padding.
@param kernel Kernel size to check
@param stride Stride to check
@param padding Padding to check
"""
if (kernel <= 0) {
throw new IllegalStateException("Invalid kernel size: value must be positive (> 0). Got: " + kernel);
}
if (stride <= 0) {
throw new IllegalStateException("Invalid kernel size: value must be positive (> 0). Got: " + stride);
}
if (padding < 0) {
throw new IllegalStateException("Invalid kernel size: value must be positive (> 0). Got: " + padding);
}
} | java | public static void validateCnn1DKernelStridePadding(int kernel, int stride, int padding) {
if (kernel <= 0) {
throw new IllegalStateException("Invalid kernel size: value must be positive (> 0). Got: " + kernel);
}
if (stride <= 0) {
throw new IllegalStateException("Invalid kernel size: value must be positive (> 0). Got: " + stride);
}
if (padding < 0) {
throw new IllegalStateException("Invalid kernel size: value must be positive (> 0). Got: " + padding);
}
} | [
"public",
"static",
"void",
"validateCnn1DKernelStridePadding",
"(",
"int",
"kernel",
",",
"int",
"stride",
",",
"int",
"padding",
")",
"{",
"if",
"(",
"kernel",
"<=",
"0",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Invalid kernel size: value must be positive (> 0). Got: \"",
"+",
"kernel",
")",
";",
"}",
"if",
"(",
"stride",
"<=",
"0",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Invalid kernel size: value must be positive (> 0). Got: \"",
"+",
"stride",
")",
";",
"}",
"if",
"(",
"padding",
"<",
"0",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Invalid kernel size: value must be positive (> 0). Got: \"",
"+",
"padding",
")",
";",
"}",
"}"
] | Perform validation on the CNN layer kernel/stride/padding. Expect int, with values > 0 for kernel size and
stride, and values >= 0 for padding.
@param kernel Kernel size to check
@param stride Stride to check
@param padding Padding to check | [
"Perform",
"validation",
"on",
"the",
"CNN",
"layer",
"kernel",
"/",
"stride",
"/",
"padding",
".",
"Expect",
"int",
"with",
"values",
">",
"0",
"for",
"kernel",
"size",
"and",
"stride",
"and",
"values",
">",
"=",
"0",
"for",
"padding",
"."
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/util/Convolution1DUtils.java#L230-L242 |
xcesco/kripton | kripton/src/main/java/com/abubusoft/kripton/xml/XMLSerializer.java | XMLSerializer.writeAttribute | public void writeAttribute(String namespaceURI, String localName, String value) throws Exception {
"""
Write attribute.
@param namespaceURI the namespace URI
@param localName the local name
@param value the value
@throws Exception the exception
"""
this.attribute(namespaceURI, localName, value.toString());
} | java | public void writeAttribute(String namespaceURI, String localName, String value) throws Exception {
this.attribute(namespaceURI, localName, value.toString());
} | [
"public",
"void",
"writeAttribute",
"(",
"String",
"namespaceURI",
",",
"String",
"localName",
",",
"String",
"value",
")",
"throws",
"Exception",
"{",
"this",
".",
"attribute",
"(",
"namespaceURI",
",",
"localName",
",",
"value",
".",
"toString",
"(",
")",
")",
";",
"}"
] | Write attribute.
@param namespaceURI the namespace URI
@param localName the local name
@param value the value
@throws Exception the exception | [
"Write",
"attribute",
"."
] | train | https://github.com/xcesco/kripton/blob/90de2c0523d39b99e81b8d38aa996898762f594a/kripton/src/main/java/com/abubusoft/kripton/xml/XMLSerializer.java#L1694-L1696 |
rimerosolutions/ant-git-tasks | src/main/java/com/rimerosolutions/ant/git/GitTaskUtils.java | GitTaskUtils.validateRemoteRefUpdates | public static void validateRemoteRefUpdates(String errorPrefix, Collection<RemoteRefUpdate> refUpdates) {
"""
Check references updates for any errors
@param errorPrefix The error prefix for any error message
@param refUpdates A collection of remote references updates
"""
for (RemoteRefUpdate refUpdate : refUpdates) {
RemoteRefUpdate.Status status = refUpdate.getStatus();
if (status == RemoteRefUpdate.Status.REJECTED_NODELETE ||
status == RemoteRefUpdate.Status.NON_EXISTING ||
status == RemoteRefUpdate.Status.NOT_ATTEMPTED ||
status == RemoteRefUpdate.Status.REJECTED_NONFASTFORWARD ||
status == RemoteRefUpdate.Status.REJECTED_OTHER_REASON ||
status == RemoteRefUpdate.Status.REJECTED_REMOTE_CHANGED) {
throw new BuildException(String.format("%s - Status '%s'", errorPrefix, status.name()));
}
}
} | java | public static void validateRemoteRefUpdates(String errorPrefix, Collection<RemoteRefUpdate> refUpdates) {
for (RemoteRefUpdate refUpdate : refUpdates) {
RemoteRefUpdate.Status status = refUpdate.getStatus();
if (status == RemoteRefUpdate.Status.REJECTED_NODELETE ||
status == RemoteRefUpdate.Status.NON_EXISTING ||
status == RemoteRefUpdate.Status.NOT_ATTEMPTED ||
status == RemoteRefUpdate.Status.REJECTED_NONFASTFORWARD ||
status == RemoteRefUpdate.Status.REJECTED_OTHER_REASON ||
status == RemoteRefUpdate.Status.REJECTED_REMOTE_CHANGED) {
throw new BuildException(String.format("%s - Status '%s'", errorPrefix, status.name()));
}
}
} | [
"public",
"static",
"void",
"validateRemoteRefUpdates",
"(",
"String",
"errorPrefix",
",",
"Collection",
"<",
"RemoteRefUpdate",
">",
"refUpdates",
")",
"{",
"for",
"(",
"RemoteRefUpdate",
"refUpdate",
":",
"refUpdates",
")",
"{",
"RemoteRefUpdate",
".",
"Status",
"status",
"=",
"refUpdate",
".",
"getStatus",
"(",
")",
";",
"if",
"(",
"status",
"==",
"RemoteRefUpdate",
".",
"Status",
".",
"REJECTED_NODELETE",
"||",
"status",
"==",
"RemoteRefUpdate",
".",
"Status",
".",
"NON_EXISTING",
"||",
"status",
"==",
"RemoteRefUpdate",
".",
"Status",
".",
"NOT_ATTEMPTED",
"||",
"status",
"==",
"RemoteRefUpdate",
".",
"Status",
".",
"REJECTED_NONFASTFORWARD",
"||",
"status",
"==",
"RemoteRefUpdate",
".",
"Status",
".",
"REJECTED_OTHER_REASON",
"||",
"status",
"==",
"RemoteRefUpdate",
".",
"Status",
".",
"REJECTED_REMOTE_CHANGED",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"String",
".",
"format",
"(",
"\"%s - Status '%s'\"",
",",
"errorPrefix",
",",
"status",
".",
"name",
"(",
")",
")",
")",
";",
"}",
"}",
"}"
] | Check references updates for any errors
@param errorPrefix The error prefix for any error message
@param refUpdates A collection of remote references updates | [
"Check",
"references",
"updates",
"for",
"any",
"errors"
] | train | https://github.com/rimerosolutions/ant-git-tasks/blob/bfb32fe68afe6b9dcfd0a5194497d748ef3e8a6f/src/main/java/com/rimerosolutions/ant/git/GitTaskUtils.java#L111-L124 |
tzaeschke/zoodb | src/org/zoodb/internal/query/TypeConverterTools.java | TypeConverterTools.checkAssignability | public static void checkAssignability(Class<?> c1, Class<?> c2) {
"""
This assumes that comparability implies assignability or convertability...
@param c1 type #1
@param c2 type #2
"""
COMPARISON_TYPE ct1 = COMPARISON_TYPE.fromClass(c1);
COMPARISON_TYPE ct2 = COMPARISON_TYPE.fromClass(c2);
try {
COMPARISON_TYPE.fromOperands(ct1, ct2);
} catch (Exception e) {
throw DBLogger.newUser("Cannot assign " + c2 + " to " + c1, e);
}
} | java | public static void checkAssignability(Class<?> c1, Class<?> c2) {
COMPARISON_TYPE ct1 = COMPARISON_TYPE.fromClass(c1);
COMPARISON_TYPE ct2 = COMPARISON_TYPE.fromClass(c2);
try {
COMPARISON_TYPE.fromOperands(ct1, ct2);
} catch (Exception e) {
throw DBLogger.newUser("Cannot assign " + c2 + " to " + c1, e);
}
} | [
"public",
"static",
"void",
"checkAssignability",
"(",
"Class",
"<",
"?",
">",
"c1",
",",
"Class",
"<",
"?",
">",
"c2",
")",
"{",
"COMPARISON_TYPE",
"ct1",
"=",
"COMPARISON_TYPE",
".",
"fromClass",
"(",
"c1",
")",
";",
"COMPARISON_TYPE",
"ct2",
"=",
"COMPARISON_TYPE",
".",
"fromClass",
"(",
"c2",
")",
";",
"try",
"{",
"COMPARISON_TYPE",
".",
"fromOperands",
"(",
"ct1",
",",
"ct2",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"DBLogger",
".",
"newUser",
"(",
"\"Cannot assign \"",
"+",
"c2",
"+",
"\" to \"",
"+",
"c1",
",",
"e",
")",
";",
"}",
"}"
] | This assumes that comparability implies assignability or convertability...
@param c1 type #1
@param c2 type #2 | [
"This",
"assumes",
"that",
"comparability",
"implies",
"assignability",
"or",
"convertability",
"..."
] | train | https://github.com/tzaeschke/zoodb/blob/058d0ff161a8ee9d53244c433aca97ee9c654410/src/org/zoodb/internal/query/TypeConverterTools.java#L183-L191 |
alkacon/opencms-core | src/org/opencms/jsp/util/CmsJspContentAccessValueWrapper.java | CmsJspContentAccessValueWrapper.createWrapper | public static CmsJspContentAccessValueWrapper createWrapper(
CmsObject cms,
I_CmsXmlContentValue value,
I_CmsXmlDocument content,
String valueName,
Locale locale) {
"""
Factory method to create a new XML content value wrapper.<p>
In case either parameter is <code>null</code>, the {@link #NULL_VALUE_WRAPPER} is returned.<p>
@param cms the current users OpenCms context
@param value the value to warp
@param content the content document, required to set the null value info
@param valueName the value path name
@param locale the selected locale
@return a new content value wrapper instance, or <code>null</code> if any parameter is <code>null</code>
"""
if ((value != null) && (cms != null)) {
return new CmsJspContentAccessValueWrapper(cms, value);
}
if ((content != null) && (valueName != null) && (locale != null) && (cms != null)) {
CmsJspContentAccessValueWrapper wrapper = new CmsJspContentAccessValueWrapper();
wrapper.m_nullValueInfo = new NullValueInfo(content, valueName, locale);
wrapper.m_cms = cms;
return wrapper;
}
// if no value is available,
return NULL_VALUE_WRAPPER;
} | java | public static CmsJspContentAccessValueWrapper createWrapper(
CmsObject cms,
I_CmsXmlContentValue value,
I_CmsXmlDocument content,
String valueName,
Locale locale) {
if ((value != null) && (cms != null)) {
return new CmsJspContentAccessValueWrapper(cms, value);
}
if ((content != null) && (valueName != null) && (locale != null) && (cms != null)) {
CmsJspContentAccessValueWrapper wrapper = new CmsJspContentAccessValueWrapper();
wrapper.m_nullValueInfo = new NullValueInfo(content, valueName, locale);
wrapper.m_cms = cms;
return wrapper;
}
// if no value is available,
return NULL_VALUE_WRAPPER;
} | [
"public",
"static",
"CmsJspContentAccessValueWrapper",
"createWrapper",
"(",
"CmsObject",
"cms",
",",
"I_CmsXmlContentValue",
"value",
",",
"I_CmsXmlDocument",
"content",
",",
"String",
"valueName",
",",
"Locale",
"locale",
")",
"{",
"if",
"(",
"(",
"value",
"!=",
"null",
")",
"&&",
"(",
"cms",
"!=",
"null",
")",
")",
"{",
"return",
"new",
"CmsJspContentAccessValueWrapper",
"(",
"cms",
",",
"value",
")",
";",
"}",
"if",
"(",
"(",
"content",
"!=",
"null",
")",
"&&",
"(",
"valueName",
"!=",
"null",
")",
"&&",
"(",
"locale",
"!=",
"null",
")",
"&&",
"(",
"cms",
"!=",
"null",
")",
")",
"{",
"CmsJspContentAccessValueWrapper",
"wrapper",
"=",
"new",
"CmsJspContentAccessValueWrapper",
"(",
")",
";",
"wrapper",
".",
"m_nullValueInfo",
"=",
"new",
"NullValueInfo",
"(",
"content",
",",
"valueName",
",",
"locale",
")",
";",
"wrapper",
".",
"m_cms",
"=",
"cms",
";",
"return",
"wrapper",
";",
"}",
"// if no value is available,",
"return",
"NULL_VALUE_WRAPPER",
";",
"}"
] | Factory method to create a new XML content value wrapper.<p>
In case either parameter is <code>null</code>, the {@link #NULL_VALUE_WRAPPER} is returned.<p>
@param cms the current users OpenCms context
@param value the value to warp
@param content the content document, required to set the null value info
@param valueName the value path name
@param locale the selected locale
@return a new content value wrapper instance, or <code>null</code> if any parameter is <code>null</code> | [
"Factory",
"method",
"to",
"create",
"a",
"new",
"XML",
"content",
"value",
"wrapper",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/util/CmsJspContentAccessValueWrapper.java#L419-L437 |
riversun/d6 | src/main/java/org/riversun/d6/core/D6Crud.java | D6Crud.execSelectTable | public <T extends D6Model> T[] execSelectTable(String preparedSql, Object[] searchKeys, Class<T> modelClazz) {
"""
Execute select statement for the single table. <br>
<br>
-About SQL<br>
You can use prepared SQL.<br>
<br>
In addition,you can also use non-wildcard ('?') SQL (=raw SQL).In this
case searchKeys must be null or empty array(size 0 array).<br>
When you use a wildcard('?'), you must not include the "'"(=>single
quotes) to preparedSQL.<br>
<br>
-About processing<br>
Used when you execute the SQL that is JOIN multiple tables.<br>
In this method, you can specify more than one model class.<br>
When the column name specified in the annotation of the model classes is
included in the resultSet,<br>
a value corresponding to the column name is set to the corresponding
field of model objects.<br>
In other words, if multiple model class has the same column name, values
in the resultSet is set in the same manner for each mode class.<br>
<br>
@param preparedSql
@param searchKeys
@param modelClazz
@return
"""
@SuppressWarnings("unchecked")
final Map<Class<?>, List<Object>> result = execSelectTableWithJoin(preparedSql, searchKeys, modelClazz);
final List<Object> rowList = result.get(modelClazz);
return toArray(rowList, modelClazz);
} | java | public <T extends D6Model> T[] execSelectTable(String preparedSql, Object[] searchKeys, Class<T> modelClazz) {
@SuppressWarnings("unchecked")
final Map<Class<?>, List<Object>> result = execSelectTableWithJoin(preparedSql, searchKeys, modelClazz);
final List<Object> rowList = result.get(modelClazz);
return toArray(rowList, modelClazz);
} | [
"public",
"<",
"T",
"extends",
"D6Model",
">",
"T",
"[",
"]",
"execSelectTable",
"(",
"String",
"preparedSql",
",",
"Object",
"[",
"]",
"searchKeys",
",",
"Class",
"<",
"T",
">",
"modelClazz",
")",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"final",
"Map",
"<",
"Class",
"<",
"?",
">",
",",
"List",
"<",
"Object",
">",
">",
"result",
"=",
"execSelectTableWithJoin",
"(",
"preparedSql",
",",
"searchKeys",
",",
"modelClazz",
")",
";",
"final",
"List",
"<",
"Object",
">",
"rowList",
"=",
"result",
".",
"get",
"(",
"modelClazz",
")",
";",
"return",
"toArray",
"(",
"rowList",
",",
"modelClazz",
")",
";",
"}"
] | Execute select statement for the single table. <br>
<br>
-About SQL<br>
You can use prepared SQL.<br>
<br>
In addition,you can also use non-wildcard ('?') SQL (=raw SQL).In this
case searchKeys must be null or empty array(size 0 array).<br>
When you use a wildcard('?'), you must not include the "'"(=>single
quotes) to preparedSQL.<br>
<br>
-About processing<br>
Used when you execute the SQL that is JOIN multiple tables.<br>
In this method, you can specify more than one model class.<br>
When the column name specified in the annotation of the model classes is
included in the resultSet,<br>
a value corresponding to the column name is set to the corresponding
field of model objects.<br>
In other words, if multiple model class has the same column name, values
in the resultSet is set in the same manner for each mode class.<br>
<br>
@param preparedSql
@param searchKeys
@param modelClazz
@return | [
"Execute",
"select",
"statement",
"for",
"the",
"single",
"table",
".",
"<br",
">",
"<br",
">",
"-",
"About",
"SQL<br",
">",
"You",
"can",
"use",
"prepared",
"SQL",
".",
"<br",
">",
"<br",
">",
"In",
"addition",
"you",
"can",
"also",
"use",
"non",
"-",
"wildcard",
"(",
"?",
")",
"SQL",
"(",
"=",
"raw",
"SQL",
")",
".",
"In",
"this",
"case",
"searchKeys",
"must",
"be",
"null",
"or",
"empty",
"array",
"(",
"size",
"0",
"array",
")",
".",
"<br",
">",
"When",
"you",
"use",
"a",
"wildcard",
"(",
"?",
")",
"you",
"must",
"not",
"include",
"the",
"(",
"=",
">",
"single",
"quotes",
")",
"to",
"preparedSQL",
".",
"<br",
">"
] | train | https://github.com/riversun/d6/blob/2798bd876b9380dbfea8182d11ad306cb1b0e114/src/main/java/org/riversun/d6/core/D6Crud.java#L806-L814 |
deeplearning4j/deeplearning4j | deeplearning4j/deeplearning4j-scaleout/spark/dl4j-spark/src/main/java/org/deeplearning4j/spark/impl/graph/SparkComputationGraph.java | SparkComputationGraph.scoreExamplesMultiDataSet | public <K> JavaPairRDD<K, Double> scoreExamplesMultiDataSet(JavaPairRDD<K, MultiDataSet> data,
boolean includeRegularizationTerms) {
"""
Score the examples individually, using the default batch size {@link #DEFAULT_EVAL_SCORE_BATCH_SIZE}. Unlike {@link #calculateScore(JavaRDD, boolean)},
this method returns a score for each example separately<br>
Note: The provided JavaPairRDD has a key that is associated with each example and returned score.<br>
<b>Note:</b> The DataSet objects passed in must have exactly one example in them (otherwise: can't have a 1:1 association
between keys and data sets to score)
@param data Data to score
@param includeRegularizationTerms If true: include the l1/l2 regularization terms with the score (if any)
@param <K> Key type
@return A {@code JavaPairRDD<K,Double>} containing the scores of each example
@see MultiLayerNetwork#scoreExamples(DataSet, boolean)
"""
return scoreExamplesMultiDataSet(data, includeRegularizationTerms, DEFAULT_EVAL_SCORE_BATCH_SIZE);
} | java | public <K> JavaPairRDD<K, Double> scoreExamplesMultiDataSet(JavaPairRDD<K, MultiDataSet> data,
boolean includeRegularizationTerms) {
return scoreExamplesMultiDataSet(data, includeRegularizationTerms, DEFAULT_EVAL_SCORE_BATCH_SIZE);
} | [
"public",
"<",
"K",
">",
"JavaPairRDD",
"<",
"K",
",",
"Double",
">",
"scoreExamplesMultiDataSet",
"(",
"JavaPairRDD",
"<",
"K",
",",
"MultiDataSet",
">",
"data",
",",
"boolean",
"includeRegularizationTerms",
")",
"{",
"return",
"scoreExamplesMultiDataSet",
"(",
"data",
",",
"includeRegularizationTerms",
",",
"DEFAULT_EVAL_SCORE_BATCH_SIZE",
")",
";",
"}"
] | Score the examples individually, using the default batch size {@link #DEFAULT_EVAL_SCORE_BATCH_SIZE}. Unlike {@link #calculateScore(JavaRDD, boolean)},
this method returns a score for each example separately<br>
Note: The provided JavaPairRDD has a key that is associated with each example and returned score.<br>
<b>Note:</b> The DataSet objects passed in must have exactly one example in them (otherwise: can't have a 1:1 association
between keys and data sets to score)
@param data Data to score
@param includeRegularizationTerms If true: include the l1/l2 regularization terms with the score (if any)
@param <K> Key type
@return A {@code JavaPairRDD<K,Double>} containing the scores of each example
@see MultiLayerNetwork#scoreExamples(DataSet, boolean) | [
"Score",
"the",
"examples",
"individually",
"using",
"the",
"default",
"batch",
"size",
"{",
"@link",
"#DEFAULT_EVAL_SCORE_BATCH_SIZE",
"}",
".",
"Unlike",
"{",
"@link",
"#calculateScore",
"(",
"JavaRDD",
"boolean",
")",
"}",
"this",
"method",
"returns",
"a",
"score",
"for",
"each",
"example",
"separately<br",
">",
"Note",
":",
"The",
"provided",
"JavaPairRDD",
"has",
"a",
"key",
"that",
"is",
"associated",
"with",
"each",
"example",
"and",
"returned",
"score",
".",
"<br",
">",
"<b",
">",
"Note",
":",
"<",
"/",
"b",
">",
"The",
"DataSet",
"objects",
"passed",
"in",
"must",
"have",
"exactly",
"one",
"example",
"in",
"them",
"(",
"otherwise",
":",
"can",
"t",
"have",
"a",
"1",
":",
"1",
"association",
"between",
"keys",
"and",
"data",
"sets",
"to",
"score",
")"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-scaleout/spark/dl4j-spark/src/main/java/org/deeplearning4j/spark/impl/graph/SparkComputationGraph.java#L501-L504 |
openbase/jul | extension/protobuf/src/main/java/org/openbase/jul/extension/protobuf/IdentifiableMessage.java | IdentifiableMessage.setMessage | public IdentifiableMessage<KEY, M, MB> setMessage(final M message) throws CouldNotPerformException {
"""
Updates the message of this instance.
@param message the new message.
@return the updated message is returned.
@throws CouldNotPerformException in thrown in case something went wrong during message processing.
@deprecated since v2.0 and will be removed in v3.0. Please please use setMessage(final M message, final Object source) instead.
"""
return setMessage(message, this);
} | java | public IdentifiableMessage<KEY, M, MB> setMessage(final M message) throws CouldNotPerformException {
return setMessage(message, this);
} | [
"public",
"IdentifiableMessage",
"<",
"KEY",
",",
"M",
",",
"MB",
">",
"setMessage",
"(",
"final",
"M",
"message",
")",
"throws",
"CouldNotPerformException",
"{",
"return",
"setMessage",
"(",
"message",
",",
"this",
")",
";",
"}"
] | Updates the message of this instance.
@param message the new message.
@return the updated message is returned.
@throws CouldNotPerformException in thrown in case something went wrong during message processing.
@deprecated since v2.0 and will be removed in v3.0. Please please use setMessage(final M message, final Object source) instead. | [
"Updates",
"the",
"message",
"of",
"this",
"instance",
"."
] | train | https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/extension/protobuf/src/main/java/org/openbase/jul/extension/protobuf/IdentifiableMessage.java#L271-L273 |
bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/protocols/payments/PaymentSession.java | PaymentSession.getPayment | @Nullable
public Protos.Payment getPayment(List<Transaction> txns, @Nullable Address refundAddr, @Nullable String memo)
throws IOException, PaymentProtocolException.InvalidNetwork {
"""
Generates a Payment message based on the information in the PaymentRequest.
Provide transactions built by the wallet.
If the PaymentRequest did not specify a payment_url, returns null.
@param txns list of transactions to be included with the Payment message.
@param refundAddr will be used by the merchant to send money back if there was a problem.
@param memo is a message to include in the payment message sent to the merchant.
"""
if (paymentDetails.hasPaymentUrl()) {
for (Transaction tx : txns)
if (!tx.getParams().equals(params))
throw new PaymentProtocolException.InvalidNetwork(params.getPaymentProtocolId());
return PaymentProtocol.createPaymentMessage(txns, totalValue, refundAddr, memo, getMerchantData());
} else {
return null;
}
} | java | @Nullable
public Protos.Payment getPayment(List<Transaction> txns, @Nullable Address refundAddr, @Nullable String memo)
throws IOException, PaymentProtocolException.InvalidNetwork {
if (paymentDetails.hasPaymentUrl()) {
for (Transaction tx : txns)
if (!tx.getParams().equals(params))
throw new PaymentProtocolException.InvalidNetwork(params.getPaymentProtocolId());
return PaymentProtocol.createPaymentMessage(txns, totalValue, refundAddr, memo, getMerchantData());
} else {
return null;
}
} | [
"@",
"Nullable",
"public",
"Protos",
".",
"Payment",
"getPayment",
"(",
"List",
"<",
"Transaction",
">",
"txns",
",",
"@",
"Nullable",
"Address",
"refundAddr",
",",
"@",
"Nullable",
"String",
"memo",
")",
"throws",
"IOException",
",",
"PaymentProtocolException",
".",
"InvalidNetwork",
"{",
"if",
"(",
"paymentDetails",
".",
"hasPaymentUrl",
"(",
")",
")",
"{",
"for",
"(",
"Transaction",
"tx",
":",
"txns",
")",
"if",
"(",
"!",
"tx",
".",
"getParams",
"(",
")",
".",
"equals",
"(",
"params",
")",
")",
"throw",
"new",
"PaymentProtocolException",
".",
"InvalidNetwork",
"(",
"params",
".",
"getPaymentProtocolId",
"(",
")",
")",
";",
"return",
"PaymentProtocol",
".",
"createPaymentMessage",
"(",
"txns",
",",
"totalValue",
",",
"refundAddr",
",",
"memo",
",",
"getMerchantData",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | Generates a Payment message based on the information in the PaymentRequest.
Provide transactions built by the wallet.
If the PaymentRequest did not specify a payment_url, returns null.
@param txns list of transactions to be included with the Payment message.
@param refundAddr will be used by the merchant to send money back if there was a problem.
@param memo is a message to include in the payment message sent to the merchant. | [
"Generates",
"a",
"Payment",
"message",
"based",
"on",
"the",
"information",
"in",
"the",
"PaymentRequest",
".",
"Provide",
"transactions",
"built",
"by",
"the",
"wallet",
".",
"If",
"the",
"PaymentRequest",
"did",
"not",
"specify",
"a",
"payment_url",
"returns",
"null",
"."
] | train | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/protocols/payments/PaymentSession.java#L343-L354 |
jOOQ/jOOL | jOOL-java-8/src/main/java/org/jooq/lambda/Unchecked.java | Unchecked.biConsumer | public static <T, U> BiConsumer<T, U> biConsumer(CheckedBiConsumer<T, U> consumer, Consumer<Throwable> handler) {
"""
Wrap a {@link CheckedBiConsumer} in a {@link BiConsumer} with a custom handler for checked exceptions.
<p>
Example:
<code><pre>
map.forEach(Unchecked.biConsumer(
(k, v) -> {
if (k == null || v == null)
throw new Exception("No nulls allowed in map");
},
e -> {
throw new IllegalStateException(e);
}
));
</pre></code>
"""
return (t, u) -> {
try {
consumer.accept(t, u);
}
catch (Throwable e) {
handler.accept(e);
throw new IllegalStateException("Exception handler must throw a RuntimeException", e);
}
};
} | java | public static <T, U> BiConsumer<T, U> biConsumer(CheckedBiConsumer<T, U> consumer, Consumer<Throwable> handler) {
return (t, u) -> {
try {
consumer.accept(t, u);
}
catch (Throwable e) {
handler.accept(e);
throw new IllegalStateException("Exception handler must throw a RuntimeException", e);
}
};
} | [
"public",
"static",
"<",
"T",
",",
"U",
">",
"BiConsumer",
"<",
"T",
",",
"U",
">",
"biConsumer",
"(",
"CheckedBiConsumer",
"<",
"T",
",",
"U",
">",
"consumer",
",",
"Consumer",
"<",
"Throwable",
">",
"handler",
")",
"{",
"return",
"(",
"t",
",",
"u",
")",
"->",
"{",
"try",
"{",
"consumer",
".",
"accept",
"(",
"t",
",",
"u",
")",
";",
"}",
"catch",
"(",
"Throwable",
"e",
")",
"{",
"handler",
".",
"accept",
"(",
"e",
")",
";",
"throw",
"new",
"IllegalStateException",
"(",
"\"Exception handler must throw a RuntimeException\"",
",",
"e",
")",
";",
"}",
"}",
";",
"}"
] | Wrap a {@link CheckedBiConsumer} in a {@link BiConsumer} with a custom handler for checked exceptions.
<p>
Example:
<code><pre>
map.forEach(Unchecked.biConsumer(
(k, v) -> {
if (k == null || v == null)
throw new Exception("No nulls allowed in map");
},
e -> {
throw new IllegalStateException(e);
}
));
</pre></code> | [
"Wrap",
"a",
"{"
] | train | https://github.com/jOOQ/jOOL/blob/889d87c85ca57bafd4eddd78e0f7ae2804d2ee86/jOOL-java-8/src/main/java/org/jooq/lambda/Unchecked.java#L230-L241 |
xvik/guice-persist-orient | src/main/java/ru/vyarus/guice/persist/orient/repository/core/MethodExecutionException.java | MethodExecutionException.checkExec | public static void checkExec(final boolean condition, final String message, final Object... args) {
"""
Shortcut to check and throw execution exception.
@param condition condition to validate
@param message fail message
@param args fail message arguments
"""
if (!condition) {
throw new MethodExecutionException(String.format(message, args));
}
} | java | public static void checkExec(final boolean condition, final String message, final Object... args) {
if (!condition) {
throw new MethodExecutionException(String.format(message, args));
}
} | [
"public",
"static",
"void",
"checkExec",
"(",
"final",
"boolean",
"condition",
",",
"final",
"String",
"message",
",",
"final",
"Object",
"...",
"args",
")",
"{",
"if",
"(",
"!",
"condition",
")",
"{",
"throw",
"new",
"MethodExecutionException",
"(",
"String",
".",
"format",
"(",
"message",
",",
"args",
")",
")",
";",
"}",
"}"
] | Shortcut to check and throw execution exception.
@param condition condition to validate
@param message fail message
@param args fail message arguments | [
"Shortcut",
"to",
"check",
"and",
"throw",
"execution",
"exception",
"."
] | train | https://github.com/xvik/guice-persist-orient/blob/5ef06fb4f734360512e9824a3b875c4906c56b5b/src/main/java/ru/vyarus/guice/persist/orient/repository/core/MethodExecutionException.java#L28-L32 |
threerings/nenya | core/src/main/java/com/threerings/media/animation/AnimationSequencer.java | AnimationSequencer.startAnimation | protected void startAnimation (Animation anim, long tickStamp) {
"""
Called when the time comes to start an animation. Derived classes may override this method
and pass the animation on to their animation manager and do whatever else they need to do
with operating animations. The default implementation simply adds them to the media panel
supplied when we were constructed.
@param anim the animation to be displayed.
@param tickStamp the timestamp at which this animation was fired.
"""
// account for any view scrolling that happened before this animation
// was actually added to the view
if (_vdx != 0 || _vdy != 0) {
anim.viewLocationDidChange(_vdx, _vdy);
}
_animmgr.registerAnimation(anim);
} | java | protected void startAnimation (Animation anim, long tickStamp)
{
// account for any view scrolling that happened before this animation
// was actually added to the view
if (_vdx != 0 || _vdy != 0) {
anim.viewLocationDidChange(_vdx, _vdy);
}
_animmgr.registerAnimation(anim);
} | [
"protected",
"void",
"startAnimation",
"(",
"Animation",
"anim",
",",
"long",
"tickStamp",
")",
"{",
"// account for any view scrolling that happened before this animation",
"// was actually added to the view",
"if",
"(",
"_vdx",
"!=",
"0",
"||",
"_vdy",
"!=",
"0",
")",
"{",
"anim",
".",
"viewLocationDidChange",
"(",
"_vdx",
",",
"_vdy",
")",
";",
"}",
"_animmgr",
".",
"registerAnimation",
"(",
"anim",
")",
";",
"}"
] | Called when the time comes to start an animation. Derived classes may override this method
and pass the animation on to their animation manager and do whatever else they need to do
with operating animations. The default implementation simply adds them to the media panel
supplied when we were constructed.
@param anim the animation to be displayed.
@param tickStamp the timestamp at which this animation was fired. | [
"Called",
"when",
"the",
"time",
"comes",
"to",
"start",
"an",
"animation",
".",
"Derived",
"classes",
"may",
"override",
"this",
"method",
"and",
"pass",
"the",
"animation",
"on",
"to",
"their",
"animation",
"manager",
"and",
"do",
"whatever",
"else",
"they",
"need",
"to",
"do",
"with",
"operating",
"animations",
".",
"The",
"default",
"implementation",
"simply",
"adds",
"them",
"to",
"the",
"media",
"panel",
"supplied",
"when",
"we",
"were",
"constructed",
"."
] | train | https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/animation/AnimationSequencer.java#L189-L198 |
jglobus/JGlobus | gridftp/src/main/java/org/globus/ftp/FTPClient.java | FTPClient.allocate | public void allocate(long size) throws IOException, ServerException {
"""
Reserve sufficient storage to accommodate the new file to be
transferred.
@param size the amount of space to reserve
@exception ServerException if an error occured.
"""
Command cmd = new Command("ALLO", String.valueOf(size));
Reply reply = null;
try {
reply = controlChannel.execute(cmd);
} catch (UnexpectedReplyCodeException urce) {
throw ServerException.embedUnexpectedReplyCodeException(urce);
} catch (FTPReplyParseException rpe) {
throw ServerException.embedFTPReplyParseException(rpe);
}
} | java | public void allocate(long size) throws IOException, ServerException {
Command cmd = new Command("ALLO", String.valueOf(size));
Reply reply = null;
try {
reply = controlChannel.execute(cmd);
} catch (UnexpectedReplyCodeException urce) {
throw ServerException.embedUnexpectedReplyCodeException(urce);
} catch (FTPReplyParseException rpe) {
throw ServerException.embedFTPReplyParseException(rpe);
}
} | [
"public",
"void",
"allocate",
"(",
"long",
"size",
")",
"throws",
"IOException",
",",
"ServerException",
"{",
"Command",
"cmd",
"=",
"new",
"Command",
"(",
"\"ALLO\"",
",",
"String",
".",
"valueOf",
"(",
"size",
")",
")",
";",
"Reply",
"reply",
"=",
"null",
";",
"try",
"{",
"reply",
"=",
"controlChannel",
".",
"execute",
"(",
"cmd",
")",
";",
"}",
"catch",
"(",
"UnexpectedReplyCodeException",
"urce",
")",
"{",
"throw",
"ServerException",
".",
"embedUnexpectedReplyCodeException",
"(",
"urce",
")",
";",
"}",
"catch",
"(",
"FTPReplyParseException",
"rpe",
")",
"{",
"throw",
"ServerException",
".",
"embedFTPReplyParseException",
"(",
"rpe",
")",
";",
"}",
"}"
] | Reserve sufficient storage to accommodate the new file to be
transferred.
@param size the amount of space to reserve
@exception ServerException if an error occured. | [
"Reserve",
"sufficient",
"storage",
"to",
"accommodate",
"the",
"new",
"file",
"to",
"be",
"transferred",
"."
] | train | https://github.com/jglobus/JGlobus/blob/e14f6f6636544fd84298f9cec749d626ea971930/gridftp/src/main/java/org/globus/ftp/FTPClient.java#L1544-L1554 |
alkacon/opencms-core | src/org/opencms/importexport/CmsImportExportManager.java | CmsImportExportManager.exportData | public void exportData(CmsObject cms, I_CmsImportExportHandler handler, I_CmsReport report)
throws CmsConfigurationException, CmsImportExportException, CmsRoleViolationException {
"""
Checks if the current user has permissions to export Cms data of a specified export handler,
and if so, triggers the handler to write the export.<p>
@param cms the cms context
@param handler handler containing the export data
@param report the output report
@throws CmsRoleViolationException if the current user is not a allowed to export the OpenCms database
@throws CmsImportExportException if operation was not successful
@throws CmsConfigurationException if something goes wrong
@see I_CmsImportExportHandler
"""
OpenCms.getRoleManager().checkRole(cms, CmsRole.DATABASE_MANAGER);
handler.exportData(cms, report);
} | java | public void exportData(CmsObject cms, I_CmsImportExportHandler handler, I_CmsReport report)
throws CmsConfigurationException, CmsImportExportException, CmsRoleViolationException {
OpenCms.getRoleManager().checkRole(cms, CmsRole.DATABASE_MANAGER);
handler.exportData(cms, report);
} | [
"public",
"void",
"exportData",
"(",
"CmsObject",
"cms",
",",
"I_CmsImportExportHandler",
"handler",
",",
"I_CmsReport",
"report",
")",
"throws",
"CmsConfigurationException",
",",
"CmsImportExportException",
",",
"CmsRoleViolationException",
"{",
"OpenCms",
".",
"getRoleManager",
"(",
")",
".",
"checkRole",
"(",
"cms",
",",
"CmsRole",
".",
"DATABASE_MANAGER",
")",
";",
"handler",
".",
"exportData",
"(",
"cms",
",",
"report",
")",
";",
"}"
] | Checks if the current user has permissions to export Cms data of a specified export handler,
and if so, triggers the handler to write the export.<p>
@param cms the cms context
@param handler handler containing the export data
@param report the output report
@throws CmsRoleViolationException if the current user is not a allowed to export the OpenCms database
@throws CmsImportExportException if operation was not successful
@throws CmsConfigurationException if something goes wrong
@see I_CmsImportExportHandler | [
"Checks",
"if",
"the",
"current",
"user",
"has",
"permissions",
"to",
"export",
"Cms",
"data",
"of",
"a",
"specified",
"export",
"handler",
"and",
"if",
"so",
"triggers",
"the",
"handler",
"to",
"write",
"the",
"export",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/importexport/CmsImportExportManager.java#L660-L665 |
ManfredTremmel/gwt-bean-validators | gwt-bean-validators/src/main/super/de/knightsoftnet/validators/supersource/org/hibernate/validator/internal/util/Contracts.java | Contracts.assertNotEmpty | public static void assertNotEmpty(final String pstring, final String pmessage) {
"""
check if a string is not empty.
@param pstring string to check
@param pmessage error message to throw if test fails
"""
if (pstring == null || pstring.length() == 0) {
throw new IllegalArgumentException(pmessage);
}
} | java | public static void assertNotEmpty(final String pstring, final String pmessage) {
if (pstring == null || pstring.length() == 0) {
throw new IllegalArgumentException(pmessage);
}
} | [
"public",
"static",
"void",
"assertNotEmpty",
"(",
"final",
"String",
"pstring",
",",
"final",
"String",
"pmessage",
")",
"{",
"if",
"(",
"pstring",
"==",
"null",
"||",
"pstring",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"pmessage",
")",
";",
"}",
"}"
] | check if a string is not empty.
@param pstring string to check
@param pmessage error message to throw if test fails | [
"check",
"if",
"a",
"string",
"is",
"not",
"empty",
"."
] | train | https://github.com/ManfredTremmel/gwt-bean-validators/blob/cff7a2c3d68c2d17bf9d3cc57c79cc16fa8b4d5c/gwt-bean-validators/src/main/super/de/knightsoftnet/validators/supersource/org/hibernate/validator/internal/util/Contracts.java#L77-L81 |
pravega/pravega | segmentstore/server/host/src/main/java/io/pravega/segmentstore/server/host/stat/SegmentStatsRecorderImpl.java | SegmentStatsRecorderImpl.recordAppend | @Override
public void recordAppend(String streamSegmentName, long dataLength, int numOfEvents, Duration elapsed) {
"""
Updates segment specific aggregates.
Then if two minutes have elapsed between last report
of aggregates for this segment, send a new update to the monitor.
This update to the monitor is processed by monitor asynchronously.
@param streamSegmentName stream segment name
@param dataLength length of data that was written
@param numOfEvents number of events that were written
@param elapsed elapsed time for the append
"""
getWriteStreamSegment().reportSuccessEvent(elapsed);
DynamicLogger dl = getDynamicLogger();
dl.incCounterValue(globalMetricName(SEGMENT_WRITE_BYTES), dataLength);
dl.incCounterValue(globalMetricName(SEGMENT_WRITE_EVENTS), numOfEvents);
if (!StreamSegmentNameUtils.isTransactionSegment(streamSegmentName)) {
//Don't report segment specific metrics if segment is a transaction
//The parent segment metrics will be updated once the transaction is merged
dl.incCounterValue(SEGMENT_WRITE_BYTES, dataLength, segmentTags(streamSegmentName));
dl.incCounterValue(SEGMENT_WRITE_EVENTS, numOfEvents, segmentTags(streamSegmentName));
try {
SegmentAggregates aggregates = getSegmentAggregate(streamSegmentName);
// Note: we could get stats for a transaction segment. We will simply ignore this as we
// do not maintain intermittent txn segment stats. Txn stats will be accounted for
// only upon txn commit. This is done via merge method. So here we can get a txn which
// we do not know about and hence we can get null and ignore.
if (aggregates != null && aggregates.update(dataLength, numOfEvents)) {
report(streamSegmentName, aggregates);
}
} catch (Exception e) {
log.warn("Record statistic for {} for data: {} and events:{} threw exception", streamSegmentName, dataLength, numOfEvents, e);
}
}
} | java | @Override
public void recordAppend(String streamSegmentName, long dataLength, int numOfEvents, Duration elapsed) {
getWriteStreamSegment().reportSuccessEvent(elapsed);
DynamicLogger dl = getDynamicLogger();
dl.incCounterValue(globalMetricName(SEGMENT_WRITE_BYTES), dataLength);
dl.incCounterValue(globalMetricName(SEGMENT_WRITE_EVENTS), numOfEvents);
if (!StreamSegmentNameUtils.isTransactionSegment(streamSegmentName)) {
//Don't report segment specific metrics if segment is a transaction
//The parent segment metrics will be updated once the transaction is merged
dl.incCounterValue(SEGMENT_WRITE_BYTES, dataLength, segmentTags(streamSegmentName));
dl.incCounterValue(SEGMENT_WRITE_EVENTS, numOfEvents, segmentTags(streamSegmentName));
try {
SegmentAggregates aggregates = getSegmentAggregate(streamSegmentName);
// Note: we could get stats for a transaction segment. We will simply ignore this as we
// do not maintain intermittent txn segment stats. Txn stats will be accounted for
// only upon txn commit. This is done via merge method. So here we can get a txn which
// we do not know about and hence we can get null and ignore.
if (aggregates != null && aggregates.update(dataLength, numOfEvents)) {
report(streamSegmentName, aggregates);
}
} catch (Exception e) {
log.warn("Record statistic for {} for data: {} and events:{} threw exception", streamSegmentName, dataLength, numOfEvents, e);
}
}
} | [
"@",
"Override",
"public",
"void",
"recordAppend",
"(",
"String",
"streamSegmentName",
",",
"long",
"dataLength",
",",
"int",
"numOfEvents",
",",
"Duration",
"elapsed",
")",
"{",
"getWriteStreamSegment",
"(",
")",
".",
"reportSuccessEvent",
"(",
"elapsed",
")",
";",
"DynamicLogger",
"dl",
"=",
"getDynamicLogger",
"(",
")",
";",
"dl",
".",
"incCounterValue",
"(",
"globalMetricName",
"(",
"SEGMENT_WRITE_BYTES",
")",
",",
"dataLength",
")",
";",
"dl",
".",
"incCounterValue",
"(",
"globalMetricName",
"(",
"SEGMENT_WRITE_EVENTS",
")",
",",
"numOfEvents",
")",
";",
"if",
"(",
"!",
"StreamSegmentNameUtils",
".",
"isTransactionSegment",
"(",
"streamSegmentName",
")",
")",
"{",
"//Don't report segment specific metrics if segment is a transaction",
"//The parent segment metrics will be updated once the transaction is merged",
"dl",
".",
"incCounterValue",
"(",
"SEGMENT_WRITE_BYTES",
",",
"dataLength",
",",
"segmentTags",
"(",
"streamSegmentName",
")",
")",
";",
"dl",
".",
"incCounterValue",
"(",
"SEGMENT_WRITE_EVENTS",
",",
"numOfEvents",
",",
"segmentTags",
"(",
"streamSegmentName",
")",
")",
";",
"try",
"{",
"SegmentAggregates",
"aggregates",
"=",
"getSegmentAggregate",
"(",
"streamSegmentName",
")",
";",
"// Note: we could get stats for a transaction segment. We will simply ignore this as we",
"// do not maintain intermittent txn segment stats. Txn stats will be accounted for",
"// only upon txn commit. This is done via merge method. So here we can get a txn which",
"// we do not know about and hence we can get null and ignore.",
"if",
"(",
"aggregates",
"!=",
"null",
"&&",
"aggregates",
".",
"update",
"(",
"dataLength",
",",
"numOfEvents",
")",
")",
"{",
"report",
"(",
"streamSegmentName",
",",
"aggregates",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"log",
".",
"warn",
"(",
"\"Record statistic for {} for data: {} and events:{} threw exception\"",
",",
"streamSegmentName",
",",
"dataLength",
",",
"numOfEvents",
",",
"e",
")",
";",
"}",
"}",
"}"
] | Updates segment specific aggregates.
Then if two minutes have elapsed between last report
of aggregates for this segment, send a new update to the monitor.
This update to the monitor is processed by monitor asynchronously.
@param streamSegmentName stream segment name
@param dataLength length of data that was written
@param numOfEvents number of events that were written
@param elapsed elapsed time for the append | [
"Updates",
"segment",
"specific",
"aggregates",
".",
"Then",
"if",
"two",
"minutes",
"have",
"elapsed",
"between",
"last",
"report",
"of",
"aggregates",
"for",
"this",
"segment",
"send",
"a",
"new",
"update",
"to",
"the",
"monitor",
".",
"This",
"update",
"to",
"the",
"monitor",
"is",
"processed",
"by",
"monitor",
"asynchronously",
"."
] | train | https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/segmentstore/server/host/src/main/java/io/pravega/segmentstore/server/host/stat/SegmentStatsRecorderImpl.java#L191-L215 |
alkacon/opencms-core | src/org/opencms/xml/containerpage/CmsDynamicFunctionBean.java | CmsDynamicFunctionBean.getFormatForContainer | public Format getFormatForContainer(CmsObject cms, String type, int width) {
"""
Finds the correct format for a given container type and width.<p>
@param cms the current CMS context
@param type the container type
@param width the container width
@return the format for the given container type and width
"""
IdentityHashMap<CmsFormatterBean, Format> formatsByFormatter = new IdentityHashMap<CmsFormatterBean, Format>();
// relate formatters to formats so we can pick the corresponding format after a formatter has been selected
CmsFormatterBean mainFormatter = createFormatterBean(m_mainFormat, true);
formatsByFormatter.put(mainFormatter, m_mainFormat);
List<I_CmsFormatterBean> formatters = new ArrayList<I_CmsFormatterBean>();
for (Format format : m_otherFormats) {
CmsFormatterBean formatter = createFormatterBean(format, false);
formatsByFormatter.put(formatter, format);
formatters.add(formatter);
}
formatters.add(0, mainFormatter);
CmsFormatterConfiguration formatterConfiguration = CmsFormatterConfiguration.create(cms, formatters);
I_CmsFormatterBean matchingFormatter = formatterConfiguration.getDefaultFormatter(type, width);
if (matchingFormatter == null) {
return null;
}
return formatsByFormatter.get(matchingFormatter);
} | java | public Format getFormatForContainer(CmsObject cms, String type, int width) {
IdentityHashMap<CmsFormatterBean, Format> formatsByFormatter = new IdentityHashMap<CmsFormatterBean, Format>();
// relate formatters to formats so we can pick the corresponding format after a formatter has been selected
CmsFormatterBean mainFormatter = createFormatterBean(m_mainFormat, true);
formatsByFormatter.put(mainFormatter, m_mainFormat);
List<I_CmsFormatterBean> formatters = new ArrayList<I_CmsFormatterBean>();
for (Format format : m_otherFormats) {
CmsFormatterBean formatter = createFormatterBean(format, false);
formatsByFormatter.put(formatter, format);
formatters.add(formatter);
}
formatters.add(0, mainFormatter);
CmsFormatterConfiguration formatterConfiguration = CmsFormatterConfiguration.create(cms, formatters);
I_CmsFormatterBean matchingFormatter = formatterConfiguration.getDefaultFormatter(type, width);
if (matchingFormatter == null) {
return null;
}
return formatsByFormatter.get(matchingFormatter);
} | [
"public",
"Format",
"getFormatForContainer",
"(",
"CmsObject",
"cms",
",",
"String",
"type",
",",
"int",
"width",
")",
"{",
"IdentityHashMap",
"<",
"CmsFormatterBean",
",",
"Format",
">",
"formatsByFormatter",
"=",
"new",
"IdentityHashMap",
"<",
"CmsFormatterBean",
",",
"Format",
">",
"(",
")",
";",
"// relate formatters to formats so we can pick the corresponding format after a formatter has been selected\r",
"CmsFormatterBean",
"mainFormatter",
"=",
"createFormatterBean",
"(",
"m_mainFormat",
",",
"true",
")",
";",
"formatsByFormatter",
".",
"put",
"(",
"mainFormatter",
",",
"m_mainFormat",
")",
";",
"List",
"<",
"I_CmsFormatterBean",
">",
"formatters",
"=",
"new",
"ArrayList",
"<",
"I_CmsFormatterBean",
">",
"(",
")",
";",
"for",
"(",
"Format",
"format",
":",
"m_otherFormats",
")",
"{",
"CmsFormatterBean",
"formatter",
"=",
"createFormatterBean",
"(",
"format",
",",
"false",
")",
";",
"formatsByFormatter",
".",
"put",
"(",
"formatter",
",",
"format",
")",
";",
"formatters",
".",
"add",
"(",
"formatter",
")",
";",
"}",
"formatters",
".",
"add",
"(",
"0",
",",
"mainFormatter",
")",
";",
"CmsFormatterConfiguration",
"formatterConfiguration",
"=",
"CmsFormatterConfiguration",
".",
"create",
"(",
"cms",
",",
"formatters",
")",
";",
"I_CmsFormatterBean",
"matchingFormatter",
"=",
"formatterConfiguration",
".",
"getDefaultFormatter",
"(",
"type",
",",
"width",
")",
";",
"if",
"(",
"matchingFormatter",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"formatsByFormatter",
".",
"get",
"(",
"matchingFormatter",
")",
";",
"}"
] | Finds the correct format for a given container type and width.<p>
@param cms the current CMS context
@param type the container type
@param width the container width
@return the format for the given container type and width | [
"Finds",
"the",
"correct",
"format",
"for",
"a",
"given",
"container",
"type",
"and",
"width",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/xml/containerpage/CmsDynamicFunctionBean.java#L228-L247 |
Azure/azure-sdk-for-java | appservice/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/appservice/v2016_09_01/implementation/AppServicePlansInner.java | AppServicePlansInner.restartWebApps | public void restartWebApps(String resourceGroupName, String name) {
"""
Restart all apps in an App Service plan.
Restart all apps in an App Service plan.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param name Name of the App Service plan.
@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
"""
restartWebAppsWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().body();
} | java | public void restartWebApps(String resourceGroupName, String name) {
restartWebAppsWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().body();
} | [
"public",
"void",
"restartWebApps",
"(",
"String",
"resourceGroupName",
",",
"String",
"name",
")",
"{",
"restartWebAppsWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"name",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Restart all apps in an App Service plan.
Restart all apps in an App Service plan.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param name Name of the App Service plan.
@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 | [
"Restart",
"all",
"apps",
"in",
"an",
"App",
"Service",
"plan",
".",
"Restart",
"all",
"apps",
"in",
"an",
"App",
"Service",
"plan",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/appservice/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/appservice/v2016_09_01/implementation/AppServicePlansInner.java#L2195-L2197 |
NoraUi/NoraUi | src/main/java/com/github/noraui/browser/DriverFactory.java | DriverFactory.setChromeOptions | private void setChromeOptions(final DesiredCapabilities capabilities, ChromeOptions chromeOptions) {
"""
Sets the target browser binary path in chromeOptions if it exists in configuration.
@param capabilities
The global DesiredCapabilities
"""
// Set custom downloaded file path. When you check content of downloaded file by robot.
final HashMap<String, Object> chromePrefs = new HashMap<>();
chromePrefs.put("download.default_directory", System.getProperty(USER_DIR) + File.separator + DOWNLOADED_FILES_FOLDER);
chromeOptions.setExperimentalOption("prefs", chromePrefs);
// Set custom chromium (if you not use default chromium on your target device)
final String targetBrowserBinaryPath = Context.getWebdriversProperties("targetBrowserBinaryPath");
if (targetBrowserBinaryPath != null && !"".equals(targetBrowserBinaryPath)) {
chromeOptions.setBinary(targetBrowserBinaryPath);
}
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
} | java | private void setChromeOptions(final DesiredCapabilities capabilities, ChromeOptions chromeOptions) {
// Set custom downloaded file path. When you check content of downloaded file by robot.
final HashMap<String, Object> chromePrefs = new HashMap<>();
chromePrefs.put("download.default_directory", System.getProperty(USER_DIR) + File.separator + DOWNLOADED_FILES_FOLDER);
chromeOptions.setExperimentalOption("prefs", chromePrefs);
// Set custom chromium (if you not use default chromium on your target device)
final String targetBrowserBinaryPath = Context.getWebdriversProperties("targetBrowserBinaryPath");
if (targetBrowserBinaryPath != null && !"".equals(targetBrowserBinaryPath)) {
chromeOptions.setBinary(targetBrowserBinaryPath);
}
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
} | [
"private",
"void",
"setChromeOptions",
"(",
"final",
"DesiredCapabilities",
"capabilities",
",",
"ChromeOptions",
"chromeOptions",
")",
"{",
"// Set custom downloaded file path. When you check content of downloaded file by robot.\r",
"final",
"HashMap",
"<",
"String",
",",
"Object",
">",
"chromePrefs",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"chromePrefs",
".",
"put",
"(",
"\"download.default_directory\"",
",",
"System",
".",
"getProperty",
"(",
"USER_DIR",
")",
"+",
"File",
".",
"separator",
"+",
"DOWNLOADED_FILES_FOLDER",
")",
";",
"chromeOptions",
".",
"setExperimentalOption",
"(",
"\"prefs\"",
",",
"chromePrefs",
")",
";",
"// Set custom chromium (if you not use default chromium on your target device)\r",
"final",
"String",
"targetBrowserBinaryPath",
"=",
"Context",
".",
"getWebdriversProperties",
"(",
"\"targetBrowserBinaryPath\"",
")",
";",
"if",
"(",
"targetBrowserBinaryPath",
"!=",
"null",
"&&",
"!",
"\"\"",
".",
"equals",
"(",
"targetBrowserBinaryPath",
")",
")",
"{",
"chromeOptions",
".",
"setBinary",
"(",
"targetBrowserBinaryPath",
")",
";",
"}",
"capabilities",
".",
"setCapability",
"(",
"ChromeOptions",
".",
"CAPABILITY",
",",
"chromeOptions",
")",
";",
"}"
] | Sets the target browser binary path in chromeOptions if it exists in configuration.
@param capabilities
The global DesiredCapabilities | [
"Sets",
"the",
"target",
"browser",
"binary",
"path",
"in",
"chromeOptions",
"if",
"it",
"exists",
"in",
"configuration",
"."
] | train | https://github.com/NoraUi/NoraUi/blob/5f491a3339c7d3c20d7207760bdaf2acdb8f260c/src/main/java/com/github/noraui/browser/DriverFactory.java#L184-L198 |
sirthias/parboiled | parboiled-core/src/main/java/org/parboiled/errors/ErrorUtils.java | ErrorUtils.printErrorMessage | public static String printErrorMessage(String format, String errorMessage, int errorIndex,
InputBuffer inputBuffer) {
"""
Prints an error message showing a location in the given InputBuffer.
@param format the format string, must include three placeholders for a string
(the error message) and two integers (the error line / column respectively)
@param errorMessage the error message
@param errorIndex the error location as an index into the inputBuffer
@param inputBuffer the underlying InputBuffer
@return the error message including the relevant line from the underlying input plus location indicator
"""
checkArgNotNull(inputBuffer, "inputBuffer");
return printErrorMessage(format, errorMessage, errorIndex, errorIndex + 1, inputBuffer);
} | java | public static String printErrorMessage(String format, String errorMessage, int errorIndex,
InputBuffer inputBuffer) {
checkArgNotNull(inputBuffer, "inputBuffer");
return printErrorMessage(format, errorMessage, errorIndex, errorIndex + 1, inputBuffer);
} | [
"public",
"static",
"String",
"printErrorMessage",
"(",
"String",
"format",
",",
"String",
"errorMessage",
",",
"int",
"errorIndex",
",",
"InputBuffer",
"inputBuffer",
")",
"{",
"checkArgNotNull",
"(",
"inputBuffer",
",",
"\"inputBuffer\"",
")",
";",
"return",
"printErrorMessage",
"(",
"format",
",",
"errorMessage",
",",
"errorIndex",
",",
"errorIndex",
"+",
"1",
",",
"inputBuffer",
")",
";",
"}"
] | Prints an error message showing a location in the given InputBuffer.
@param format the format string, must include three placeholders for a string
(the error message) and two integers (the error line / column respectively)
@param errorMessage the error message
@param errorIndex the error location as an index into the inputBuffer
@param inputBuffer the underlying InputBuffer
@return the error message including the relevant line from the underlying input plus location indicator | [
"Prints",
"an",
"error",
"message",
"showing",
"a",
"location",
"in",
"the",
"given",
"InputBuffer",
"."
] | train | https://github.com/sirthias/parboiled/blob/84f3ed43e3e171b4c6ab5e6ca6297d264a9d686a/parboiled-core/src/main/java/org/parboiled/errors/ErrorUtils.java#L132-L136 |
joniles/mpxj | src/main/java/net/sf/mpxj/mspdi/MSPDIReader.java | MSPDIReader.readTaskBaselines | private void readTaskBaselines(Project.Tasks.Task xmlTask, Task mpxjTask, TimeUnit durationFormat) {
"""
Reads baseline values for the current task.
@param xmlTask MSPDI task instance
@param mpxjTask MPXJ task instance
@param durationFormat duration format to use
"""
for (Project.Tasks.Task.Baseline baseline : xmlTask.getBaseline())
{
int number = NumberHelper.getInt(baseline.getNumber());
Double cost = DatatypeConverter.parseCurrency(baseline.getCost());
Duration duration = DatatypeConverter.parseDuration(m_projectFile, durationFormat, baseline.getDuration());
Date finish = baseline.getFinish();
Date start = baseline.getStart();
Duration work = DatatypeConverter.parseDuration(m_projectFile, TimeUnit.HOURS, baseline.getWork());
if (number == 0)
{
mpxjTask.setBaselineCost(cost);
mpxjTask.setBaselineDuration(duration);
mpxjTask.setBaselineFinish(finish);
mpxjTask.setBaselineStart(start);
mpxjTask.setBaselineWork(work);
}
else
{
mpxjTask.setBaselineCost(number, cost);
mpxjTask.setBaselineDuration(number, duration);
mpxjTask.setBaselineFinish(number, finish);
mpxjTask.setBaselineStart(number, start);
mpxjTask.setBaselineWork(number, work);
}
}
} | java | private void readTaskBaselines(Project.Tasks.Task xmlTask, Task mpxjTask, TimeUnit durationFormat)
{
for (Project.Tasks.Task.Baseline baseline : xmlTask.getBaseline())
{
int number = NumberHelper.getInt(baseline.getNumber());
Double cost = DatatypeConverter.parseCurrency(baseline.getCost());
Duration duration = DatatypeConverter.parseDuration(m_projectFile, durationFormat, baseline.getDuration());
Date finish = baseline.getFinish();
Date start = baseline.getStart();
Duration work = DatatypeConverter.parseDuration(m_projectFile, TimeUnit.HOURS, baseline.getWork());
if (number == 0)
{
mpxjTask.setBaselineCost(cost);
mpxjTask.setBaselineDuration(duration);
mpxjTask.setBaselineFinish(finish);
mpxjTask.setBaselineStart(start);
mpxjTask.setBaselineWork(work);
}
else
{
mpxjTask.setBaselineCost(number, cost);
mpxjTask.setBaselineDuration(number, duration);
mpxjTask.setBaselineFinish(number, finish);
mpxjTask.setBaselineStart(number, start);
mpxjTask.setBaselineWork(number, work);
}
}
} | [
"private",
"void",
"readTaskBaselines",
"(",
"Project",
".",
"Tasks",
".",
"Task",
"xmlTask",
",",
"Task",
"mpxjTask",
",",
"TimeUnit",
"durationFormat",
")",
"{",
"for",
"(",
"Project",
".",
"Tasks",
".",
"Task",
".",
"Baseline",
"baseline",
":",
"xmlTask",
".",
"getBaseline",
"(",
")",
")",
"{",
"int",
"number",
"=",
"NumberHelper",
".",
"getInt",
"(",
"baseline",
".",
"getNumber",
"(",
")",
")",
";",
"Double",
"cost",
"=",
"DatatypeConverter",
".",
"parseCurrency",
"(",
"baseline",
".",
"getCost",
"(",
")",
")",
";",
"Duration",
"duration",
"=",
"DatatypeConverter",
".",
"parseDuration",
"(",
"m_projectFile",
",",
"durationFormat",
",",
"baseline",
".",
"getDuration",
"(",
")",
")",
";",
"Date",
"finish",
"=",
"baseline",
".",
"getFinish",
"(",
")",
";",
"Date",
"start",
"=",
"baseline",
".",
"getStart",
"(",
")",
";",
"Duration",
"work",
"=",
"DatatypeConverter",
".",
"parseDuration",
"(",
"m_projectFile",
",",
"TimeUnit",
".",
"HOURS",
",",
"baseline",
".",
"getWork",
"(",
")",
")",
";",
"if",
"(",
"number",
"==",
"0",
")",
"{",
"mpxjTask",
".",
"setBaselineCost",
"(",
"cost",
")",
";",
"mpxjTask",
".",
"setBaselineDuration",
"(",
"duration",
")",
";",
"mpxjTask",
".",
"setBaselineFinish",
"(",
"finish",
")",
";",
"mpxjTask",
".",
"setBaselineStart",
"(",
"start",
")",
";",
"mpxjTask",
".",
"setBaselineWork",
"(",
"work",
")",
";",
"}",
"else",
"{",
"mpxjTask",
".",
"setBaselineCost",
"(",
"number",
",",
"cost",
")",
";",
"mpxjTask",
".",
"setBaselineDuration",
"(",
"number",
",",
"duration",
")",
";",
"mpxjTask",
".",
"setBaselineFinish",
"(",
"number",
",",
"finish",
")",
";",
"mpxjTask",
".",
"setBaselineStart",
"(",
"number",
",",
"start",
")",
";",
"mpxjTask",
".",
"setBaselineWork",
"(",
"number",
",",
"work",
")",
";",
"}",
"}",
"}"
] | Reads baseline values for the current task.
@param xmlTask MSPDI task instance
@param mpxjTask MPXJ task instance
@param durationFormat duration format to use | [
"Reads",
"baseline",
"values",
"for",
"the",
"current",
"task",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mspdi/MSPDIReader.java#L1407-L1436 |
xmlunit/xmlunit | xmlunit-legacy/src/main/java/org/custommonkey/xmlunit/jaxp13/Jaxp13XpathEngine.java | Jaxp13XpathEngine.getMatchingNodes | public NodeList getMatchingNodes(String select, Document document)
throws XpathException {
"""
Execute the specified xpath syntax <code>select</code> expression
on the specified document and return the list of nodes (could have
length zero) that match
@param select
@param document
@return list of matching nodes
"""
try {
return new NodeListForIterable(engine
.selectNodes(select,
new DOMSource(document))
);
} catch (XMLUnitException ex) {
throw new XpathException(ex.getCause());
}
} | java | public NodeList getMatchingNodes(String select, Document document)
throws XpathException {
try {
return new NodeListForIterable(engine
.selectNodes(select,
new DOMSource(document))
);
} catch (XMLUnitException ex) {
throw new XpathException(ex.getCause());
}
} | [
"public",
"NodeList",
"getMatchingNodes",
"(",
"String",
"select",
",",
"Document",
"document",
")",
"throws",
"XpathException",
"{",
"try",
"{",
"return",
"new",
"NodeListForIterable",
"(",
"engine",
".",
"selectNodes",
"(",
"select",
",",
"new",
"DOMSource",
"(",
"document",
")",
")",
")",
";",
"}",
"catch",
"(",
"XMLUnitException",
"ex",
")",
"{",
"throw",
"new",
"XpathException",
"(",
"ex",
".",
"getCause",
"(",
")",
")",
";",
"}",
"}"
] | Execute the specified xpath syntax <code>select</code> expression
on the specified document and return the list of nodes (could have
length zero) that match
@param select
@param document
@return list of matching nodes | [
"Execute",
"the",
"specified",
"xpath",
"syntax",
"<code",
">",
"select<",
"/",
"code",
">",
"expression",
"on",
"the",
"specified",
"document",
"and",
"return",
"the",
"list",
"of",
"nodes",
"(",
"could",
"have",
"length",
"zero",
")",
"that",
"match"
] | train | https://github.com/xmlunit/xmlunit/blob/fe3d701d43f57ee83dcba336e4c1555619d3084b/xmlunit-legacy/src/main/java/org/custommonkey/xmlunit/jaxp13/Jaxp13XpathEngine.java#L91-L101 |
mgormley/optimize | src/main/java/edu/jhu/hlt/util/stats/Multinomials.java | Multinomials.assertLogNormalized | public static void assertLogNormalized(double[] logProps, double delta) {
"""
Asserts that the parameters are log-normalized within some delta.
"""
double logPropSum = Vectors.logSum(logProps);
assert(Utilities.equals(0.0, logPropSum, delta));
} | java | public static void assertLogNormalized(double[] logProps, double delta) {
double logPropSum = Vectors.logSum(logProps);
assert(Utilities.equals(0.0, logPropSum, delta));
} | [
"public",
"static",
"void",
"assertLogNormalized",
"(",
"double",
"[",
"]",
"logProps",
",",
"double",
"delta",
")",
"{",
"double",
"logPropSum",
"=",
"Vectors",
".",
"logSum",
"(",
"logProps",
")",
";",
"assert",
"(",
"Utilities",
".",
"equals",
"(",
"0.0",
",",
"logPropSum",
",",
"delta",
")",
")",
";",
"}"
] | Asserts that the parameters are log-normalized within some delta. | [
"Asserts",
"that",
"the",
"parameters",
"are",
"log",
"-",
"normalized",
"within",
"some",
"delta",
"."
] | train | https://github.com/mgormley/optimize/blob/3d1b93260b99febb8a5ecd9e8543c223e151a8d3/src/main/java/edu/jhu/hlt/util/stats/Multinomials.java#L59-L62 |
pravega/pravega | common/src/main/java/io/pravega/common/LoggerHelpers.java | LoggerHelpers.traceEnterWithContext | public static long traceEnterWithContext(Logger log, String context, String method, Object... args) {
"""
Traces the fact that a method entry has occurred.
@param log The Logger to log to.
@param context Identifying context for the operation. For example, this can be used to differentiate between
different instances of the same object.
@param method The name of the method.
@param args The arguments to the method.
@return A generated identifier that can be used to correlate this traceEnter with its corresponding traceLeave.
This is usually generated from the current System time, and when used with traceLeave it can be used to log
elapsed call times.
"""
if (!log.isTraceEnabled()) {
return 0;
}
long time = CURRENT_TIME.get();
log.trace("ENTER {}::{}@{} {}.", context, method, time, args);
return time;
} | java | public static long traceEnterWithContext(Logger log, String context, String method, Object... args) {
if (!log.isTraceEnabled()) {
return 0;
}
long time = CURRENT_TIME.get();
log.trace("ENTER {}::{}@{} {}.", context, method, time, args);
return time;
} | [
"public",
"static",
"long",
"traceEnterWithContext",
"(",
"Logger",
"log",
",",
"String",
"context",
",",
"String",
"method",
",",
"Object",
"...",
"args",
")",
"{",
"if",
"(",
"!",
"log",
".",
"isTraceEnabled",
"(",
")",
")",
"{",
"return",
"0",
";",
"}",
"long",
"time",
"=",
"CURRENT_TIME",
".",
"get",
"(",
")",
";",
"log",
".",
"trace",
"(",
"\"ENTER {}::{}@{} {}.\"",
",",
"context",
",",
"method",
",",
"time",
",",
"args",
")",
";",
"return",
"time",
";",
"}"
] | Traces the fact that a method entry has occurred.
@param log The Logger to log to.
@param context Identifying context for the operation. For example, this can be used to differentiate between
different instances of the same object.
@param method The name of the method.
@param args The arguments to the method.
@return A generated identifier that can be used to correlate this traceEnter with its corresponding traceLeave.
This is usually generated from the current System time, and when used with traceLeave it can be used to log
elapsed call times. | [
"Traces",
"the",
"fact",
"that",
"a",
"method",
"entry",
"has",
"occurred",
"."
] | train | https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/common/src/main/java/io/pravega/common/LoggerHelpers.java#L62-L70 |
HadoopGenomics/Hadoop-BAM | src/main/java/org/seqdoop/hadoop_bam/BAMInputFormat.java | BAMInputFormat.addProbabilisticSplits | private int addProbabilisticSplits(
List<InputSplit> splits, int i, List<InputSplit> newSplits,
Configuration cfg)
throws IOException {
"""
file repeatedly and checking addIndexedSplits for an index repeatedly.
"""
final Path path = ((FileSplit)splits.get(i)).getPath();
try (final SeekableStream sin = WrapSeekable.openPath(path.getFileSystem(cfg), path)) {
final BAMSplitGuesser guesser = new BAMSplitGuesser(sin, cfg);
FileVirtualSplit previousSplit = null;
for (; i < splits.size(); ++i) {
FileSplit fspl = (FileSplit)splits.get(i);
if (!fspl.getPath().equals(path))
break;
long beg = fspl.getStart();
long end = beg + fspl.getLength();
long alignedBeg = guesser.guessNextBAMRecordStart(beg, end);
// As the guesser goes to the next BGZF block before looking for BAM
// records, the ending BGZF blocks have to always be traversed fully.
// Hence force the length to be 0xffff, the maximum possible.
long alignedEnd = end << 16 | 0xffff;
if (alignedBeg == end) {
// No records detected in this split: merge it to the previous one.
// This could legitimately happen e.g. if we have a split that is
// so small that it only contains the middle part of a BGZF block.
//
// Of course, if it's the first split, then this is simply not a
// valid BAM file.
//
// FIXME: In theory, any number of splits could only contain parts
// of the BAM header before we start to see splits that contain BAM
// records. For now, we require that the split size is at least as
// big as the header and don't handle that case.
if (previousSplit == null)
throw new IOException("'" + path + "': "+
"no reads in first split: bad BAM file or tiny split size?");
previousSplit.setEndVirtualOffset(alignedEnd);
} else {
previousSplit = new FileVirtualSplit(
path, alignedBeg, alignedEnd, fspl.getLocations());
if (logger.isDebugEnabled()) {
final long byteOffset = alignedBeg >>> 16;
final long recordOffset = alignedBeg & 0xffff;
logger.debug(
"Split {}: byte offset: {} record offset: {}, virtual offset: {}",
i, byteOffset, recordOffset, alignedBeg);
}
newSplits.add(previousSplit);
}
}
}
return i;
} | java | private int addProbabilisticSplits(
List<InputSplit> splits, int i, List<InputSplit> newSplits,
Configuration cfg)
throws IOException
{
final Path path = ((FileSplit)splits.get(i)).getPath();
try (final SeekableStream sin = WrapSeekable.openPath(path.getFileSystem(cfg), path)) {
final BAMSplitGuesser guesser = new BAMSplitGuesser(sin, cfg);
FileVirtualSplit previousSplit = null;
for (; i < splits.size(); ++i) {
FileSplit fspl = (FileSplit)splits.get(i);
if (!fspl.getPath().equals(path))
break;
long beg = fspl.getStart();
long end = beg + fspl.getLength();
long alignedBeg = guesser.guessNextBAMRecordStart(beg, end);
// As the guesser goes to the next BGZF block before looking for BAM
// records, the ending BGZF blocks have to always be traversed fully.
// Hence force the length to be 0xffff, the maximum possible.
long alignedEnd = end << 16 | 0xffff;
if (alignedBeg == end) {
// No records detected in this split: merge it to the previous one.
// This could legitimately happen e.g. if we have a split that is
// so small that it only contains the middle part of a BGZF block.
//
// Of course, if it's the first split, then this is simply not a
// valid BAM file.
//
// FIXME: In theory, any number of splits could only contain parts
// of the BAM header before we start to see splits that contain BAM
// records. For now, we require that the split size is at least as
// big as the header and don't handle that case.
if (previousSplit == null)
throw new IOException("'" + path + "': "+
"no reads in first split: bad BAM file or tiny split size?");
previousSplit.setEndVirtualOffset(alignedEnd);
} else {
previousSplit = new FileVirtualSplit(
path, alignedBeg, alignedEnd, fspl.getLocations());
if (logger.isDebugEnabled()) {
final long byteOffset = alignedBeg >>> 16;
final long recordOffset = alignedBeg & 0xffff;
logger.debug(
"Split {}: byte offset: {} record offset: {}, virtual offset: {}",
i, byteOffset, recordOffset, alignedBeg);
}
newSplits.add(previousSplit);
}
}
}
return i;
} | [
"private",
"int",
"addProbabilisticSplits",
"(",
"List",
"<",
"InputSplit",
">",
"splits",
",",
"int",
"i",
",",
"List",
"<",
"InputSplit",
">",
"newSplits",
",",
"Configuration",
"cfg",
")",
"throws",
"IOException",
"{",
"final",
"Path",
"path",
"=",
"(",
"(",
"FileSplit",
")",
"splits",
".",
"get",
"(",
"i",
")",
")",
".",
"getPath",
"(",
")",
";",
"try",
"(",
"final",
"SeekableStream",
"sin",
"=",
"WrapSeekable",
".",
"openPath",
"(",
"path",
".",
"getFileSystem",
"(",
"cfg",
")",
",",
"path",
")",
")",
"{",
"final",
"BAMSplitGuesser",
"guesser",
"=",
"new",
"BAMSplitGuesser",
"(",
"sin",
",",
"cfg",
")",
";",
"FileVirtualSplit",
"previousSplit",
"=",
"null",
";",
"for",
"(",
";",
"i",
"<",
"splits",
".",
"size",
"(",
")",
";",
"++",
"i",
")",
"{",
"FileSplit",
"fspl",
"=",
"(",
"FileSplit",
")",
"splits",
".",
"get",
"(",
"i",
")",
";",
"if",
"(",
"!",
"fspl",
".",
"getPath",
"(",
")",
".",
"equals",
"(",
"path",
")",
")",
"break",
";",
"long",
"beg",
"=",
"fspl",
".",
"getStart",
"(",
")",
";",
"long",
"end",
"=",
"beg",
"+",
"fspl",
".",
"getLength",
"(",
")",
";",
"long",
"alignedBeg",
"=",
"guesser",
".",
"guessNextBAMRecordStart",
"(",
"beg",
",",
"end",
")",
";",
"// As the guesser goes to the next BGZF block before looking for BAM",
"// records, the ending BGZF blocks have to always be traversed fully.",
"// Hence force the length to be 0xffff, the maximum possible.",
"long",
"alignedEnd",
"=",
"end",
"<<",
"16",
"|",
"0xffff",
";",
"if",
"(",
"alignedBeg",
"==",
"end",
")",
"{",
"// No records detected in this split: merge it to the previous one.",
"// This could legitimately happen e.g. if we have a split that is",
"// so small that it only contains the middle part of a BGZF block.",
"//",
"// Of course, if it's the first split, then this is simply not a",
"// valid BAM file.",
"//",
"// FIXME: In theory, any number of splits could only contain parts",
"// of the BAM header before we start to see splits that contain BAM",
"// records. For now, we require that the split size is at least as",
"// big as the header and don't handle that case.",
"if",
"(",
"previousSplit",
"==",
"null",
")",
"throw",
"new",
"IOException",
"(",
"\"'\"",
"+",
"path",
"+",
"\"': \"",
"+",
"\"no reads in first split: bad BAM file or tiny split size?\"",
")",
";",
"previousSplit",
".",
"setEndVirtualOffset",
"(",
"alignedEnd",
")",
";",
"}",
"else",
"{",
"previousSplit",
"=",
"new",
"FileVirtualSplit",
"(",
"path",
",",
"alignedBeg",
",",
"alignedEnd",
",",
"fspl",
".",
"getLocations",
"(",
")",
")",
";",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"final",
"long",
"byteOffset",
"=",
"alignedBeg",
">>>",
"16",
";",
"final",
"long",
"recordOffset",
"=",
"alignedBeg",
"&",
"0xffff",
";",
"logger",
".",
"debug",
"(",
"\"Split {}: byte offset: {} record offset: {}, virtual offset: {}\"",
",",
"i",
",",
"byteOffset",
",",
"recordOffset",
",",
"alignedBeg",
")",
";",
"}",
"newSplits",
".",
"add",
"(",
"previousSplit",
")",
";",
"}",
"}",
"}",
"return",
"i",
";",
"}"
] | file repeatedly and checking addIndexedSplits for an index repeatedly. | [
"file",
"repeatedly",
"and",
"checking",
"addIndexedSplits",
"for",
"an",
"index",
"repeatedly",
"."
] | train | https://github.com/HadoopGenomics/Hadoop-BAM/blob/9f974cf635a8d72f69604021cc3d5f3469d38d2f/src/main/java/org/seqdoop/hadoop_bam/BAMInputFormat.java#L481-L540 |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/interfaces/LoopbackAddressInterfaceCriteria.java | LoopbackAddressInterfaceCriteria.isAcceptable | @Override
protected InetAddress isAcceptable(NetworkInterface networkInterface, InetAddress address) throws SocketException {
"""
{@inheritDoc}
@return <code>{@link #getAddress()}()</code> if {@link NetworkInterface#isLoopback()} is true, null otherwise.
"""
try {
if( networkInterface.isLoopback() ) {
return getAddress();
}
} catch (UnknownHostException e) {
// One time only log a warning
if (!unknownHostLogged) {
MGMT_OP_LOGGER.cannotResolveAddress(this.address);
unknownHostLogged = true;
}
}
return null;
} | java | @Override
protected InetAddress isAcceptable(NetworkInterface networkInterface, InetAddress address) throws SocketException {
try {
if( networkInterface.isLoopback() ) {
return getAddress();
}
} catch (UnknownHostException e) {
// One time only log a warning
if (!unknownHostLogged) {
MGMT_OP_LOGGER.cannotResolveAddress(this.address);
unknownHostLogged = true;
}
}
return null;
} | [
"@",
"Override",
"protected",
"InetAddress",
"isAcceptable",
"(",
"NetworkInterface",
"networkInterface",
",",
"InetAddress",
"address",
")",
"throws",
"SocketException",
"{",
"try",
"{",
"if",
"(",
"networkInterface",
".",
"isLoopback",
"(",
")",
")",
"{",
"return",
"getAddress",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"UnknownHostException",
"e",
")",
"{",
"// One time only log a warning",
"if",
"(",
"!",
"unknownHostLogged",
")",
"{",
"MGMT_OP_LOGGER",
".",
"cannotResolveAddress",
"(",
"this",
".",
"address",
")",
";",
"unknownHostLogged",
"=",
"true",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | {@inheritDoc}
@return <code>{@link #getAddress()}()</code> if {@link NetworkInterface#isLoopback()} is true, null otherwise. | [
"{",
"@inheritDoc",
"}"
] | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/interfaces/LoopbackAddressInterfaceCriteria.java#L83-L98 |
ulisesbocchio/spring-boot-security-saml | spring-boot-security-saml/src/main/java/com/github/ulisesbocchio/spring/boot/security/saml/resource/KeystoreFactory.java | KeystoreFactory.addKeyToKeystore | @SneakyThrows
public void addKeyToKeystore(KeyStore keyStore, X509Certificate cert, RSAPrivateKey privateKey, String alias, String password) {
"""
Based on a public certificate, private key, alias and password, this method will load the certificate and
private key as an entry into the keystore, and it will set the provided alias and password to the keystore entry.
@param keyStore
@param cert
@param privateKey
@param alias
@param password
"""
KeyStore.PasswordProtection pass = new KeyStore.PasswordProtection(password.toCharArray());
Certificate[] certificateChain = {cert};
keyStore.setEntry(alias, new KeyStore.PrivateKeyEntry(privateKey, certificateChain), pass);
} | java | @SneakyThrows
public void addKeyToKeystore(KeyStore keyStore, X509Certificate cert, RSAPrivateKey privateKey, String alias, String password) {
KeyStore.PasswordProtection pass = new KeyStore.PasswordProtection(password.toCharArray());
Certificate[] certificateChain = {cert};
keyStore.setEntry(alias, new KeyStore.PrivateKeyEntry(privateKey, certificateChain), pass);
} | [
"@",
"SneakyThrows",
"public",
"void",
"addKeyToKeystore",
"(",
"KeyStore",
"keyStore",
",",
"X509Certificate",
"cert",
",",
"RSAPrivateKey",
"privateKey",
",",
"String",
"alias",
",",
"String",
"password",
")",
"{",
"KeyStore",
".",
"PasswordProtection",
"pass",
"=",
"new",
"KeyStore",
".",
"PasswordProtection",
"(",
"password",
".",
"toCharArray",
"(",
")",
")",
";",
"Certificate",
"[",
"]",
"certificateChain",
"=",
"{",
"cert",
"}",
";",
"keyStore",
".",
"setEntry",
"(",
"alias",
",",
"new",
"KeyStore",
".",
"PrivateKeyEntry",
"(",
"privateKey",
",",
"certificateChain",
")",
",",
"pass",
")",
";",
"}"
] | Based on a public certificate, private key, alias and password, this method will load the certificate and
private key as an entry into the keystore, and it will set the provided alias and password to the keystore entry.
@param keyStore
@param cert
@param privateKey
@param alias
@param password | [
"Based",
"on",
"a",
"public",
"certificate",
"private",
"key",
"alias",
"and",
"password",
"this",
"method",
"will",
"load",
"the",
"certificate",
"and",
"private",
"key",
"as",
"an",
"entry",
"into",
"the",
"keystore",
"and",
"it",
"will",
"set",
"the",
"provided",
"alias",
"and",
"password",
"to",
"the",
"keystore",
"entry",
"."
] | train | https://github.com/ulisesbocchio/spring-boot-security-saml/blob/63596fe9b4b5504053392b9ee9a925b9a77644d4/spring-boot-security-saml/src/main/java/com/github/ulisesbocchio/spring/boot/security/saml/resource/KeystoreFactory.java#L65-L70 |
stephenc/java-iso-tools | loop-fs-spi/src/main/java/com/github/stephenc/javaisotools/loopfs/spi/AbstractBlockFileSystem.java | AbstractBlockFileSystem.readData | protected final synchronized int readData(final long startPos, final byte[] buffer, final int offset,
final int len)
throws IOException {
"""
Read file data, starting at the specified position.
@return the number of bytes read into the buffer
"""
seek(startPos);
return read(buffer, offset, len);
} | java | protected final synchronized int readData(final long startPos, final byte[] buffer, final int offset,
final int len)
throws IOException {
seek(startPos);
return read(buffer, offset, len);
} | [
"protected",
"final",
"synchronized",
"int",
"readData",
"(",
"final",
"long",
"startPos",
",",
"final",
"byte",
"[",
"]",
"buffer",
",",
"final",
"int",
"offset",
",",
"final",
"int",
"len",
")",
"throws",
"IOException",
"{",
"seek",
"(",
"startPos",
")",
";",
"return",
"read",
"(",
"buffer",
",",
"offset",
",",
"len",
")",
";",
"}"
] | Read file data, starting at the specified position.
@return the number of bytes read into the buffer | [
"Read",
"file",
"data",
"starting",
"at",
"the",
"specified",
"position",
"."
] | train | https://github.com/stephenc/java-iso-tools/blob/828c50b02eb311a14dde0dab43462a0d0c9dfb06/loop-fs-spi/src/main/java/com/github/stephenc/javaisotools/loopfs/spi/AbstractBlockFileSystem.java#L108-L113 |
alkacon/opencms-core | src/org/opencms/ui/editors/messagebundle/CmsMessageBundleEditorOptions.java | CmsMessageBundleEditorOptions.initAddKeyInput | private void initAddKeyInput() {
"""
Initializes the input field for new keys {@link #m_addKeyInput}.
"""
//the input field for the key
m_addKeyInput = new TextField();
m_addKeyInput.setWidth("100%");
m_addKeyInput.setInputPrompt(m_messages.key(Messages.GUI_INPUT_PROMPT_ADD_KEY_0));
final ShortcutListener shortCutListener = new ShortcutListener("Add key via ENTER", KeyCode.ENTER, null) {
private static final long serialVersionUID = 1L;
@Override
public void handleAction(Object sender, Object target) {
handleAddKey();
}
};
m_addKeyInput.addFocusListener(new FocusListener() {
private static final long serialVersionUID = 1L;
public void focus(FocusEvent event) {
m_addKeyInput.addShortcutListener(shortCutListener);
}
});
m_addKeyInput.addBlurListener(new BlurListener() {
private static final long serialVersionUID = 1L;
public void blur(BlurEvent event) {
m_addKeyInput.removeShortcutListener(shortCutListener);
}
});
} | java | private void initAddKeyInput() {
//the input field for the key
m_addKeyInput = new TextField();
m_addKeyInput.setWidth("100%");
m_addKeyInput.setInputPrompt(m_messages.key(Messages.GUI_INPUT_PROMPT_ADD_KEY_0));
final ShortcutListener shortCutListener = new ShortcutListener("Add key via ENTER", KeyCode.ENTER, null) {
private static final long serialVersionUID = 1L;
@Override
public void handleAction(Object sender, Object target) {
handleAddKey();
}
};
m_addKeyInput.addFocusListener(new FocusListener() {
private static final long serialVersionUID = 1L;
public void focus(FocusEvent event) {
m_addKeyInput.addShortcutListener(shortCutListener);
}
});
m_addKeyInput.addBlurListener(new BlurListener() {
private static final long serialVersionUID = 1L;
public void blur(BlurEvent event) {
m_addKeyInput.removeShortcutListener(shortCutListener);
}
});
} | [
"private",
"void",
"initAddKeyInput",
"(",
")",
"{",
"//the input field for the key",
"m_addKeyInput",
"=",
"new",
"TextField",
"(",
")",
";",
"m_addKeyInput",
".",
"setWidth",
"(",
"\"100%\"",
")",
";",
"m_addKeyInput",
".",
"setInputPrompt",
"(",
"m_messages",
".",
"key",
"(",
"Messages",
".",
"GUI_INPUT_PROMPT_ADD_KEY_0",
")",
")",
";",
"final",
"ShortcutListener",
"shortCutListener",
"=",
"new",
"ShortcutListener",
"(",
"\"Add key via ENTER\"",
",",
"KeyCode",
".",
"ENTER",
",",
"null",
")",
"{",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"@",
"Override",
"public",
"void",
"handleAction",
"(",
"Object",
"sender",
",",
"Object",
"target",
")",
"{",
"handleAddKey",
"(",
")",
";",
"}",
"}",
";",
"m_addKeyInput",
".",
"addFocusListener",
"(",
"new",
"FocusListener",
"(",
")",
"{",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"public",
"void",
"focus",
"(",
"FocusEvent",
"event",
")",
"{",
"m_addKeyInput",
".",
"addShortcutListener",
"(",
"shortCutListener",
")",
";",
"}",
"}",
")",
";",
"m_addKeyInput",
".",
"addBlurListener",
"(",
"new",
"BlurListener",
"(",
")",
"{",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"public",
"void",
"blur",
"(",
"BlurEvent",
"event",
")",
"{",
"m_addKeyInput",
".",
"removeShortcutListener",
"(",
"shortCutListener",
")",
";",
"}",
"}",
")",
";",
"}"
] | Initializes the input field for new keys {@link #m_addKeyInput}. | [
"Initializes",
"the",
"input",
"field",
"for",
"new",
"keys",
"{"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/editors/messagebundle/CmsMessageBundleEditorOptions.java#L292-L331 |
aggregateknowledge/java-hll | src/main/java/net/agkn/hll/HLL.java | HLL.initializeStorage | private void initializeStorage(final HLLType type) {
"""
Initializes storage for the specified {@link HLLType} and changes the
instance's {@link #type}.
@param type the {@link HLLType} to initialize storage for. This cannot be
<code>null</code> and must be an instantiable type. (For instance,
it cannot be {@link HLLType#UNDEFINED}.)
"""
this.type = type;
switch(type) {
case EMPTY:
// nothing to be done
break;
case EXPLICIT:
this.explicitStorage = new LongOpenHashSet();
break;
case SPARSE:
this.sparseProbabilisticStorage = new Int2ByteOpenHashMap();
break;
case FULL:
this.probabilisticStorage = new BitVector(regwidth, m);
break;
default:
throw new RuntimeException("Unsupported HLL type " + type);
}
} | java | private void initializeStorage(final HLLType type) {
this.type = type;
switch(type) {
case EMPTY:
// nothing to be done
break;
case EXPLICIT:
this.explicitStorage = new LongOpenHashSet();
break;
case SPARSE:
this.sparseProbabilisticStorage = new Int2ByteOpenHashMap();
break;
case FULL:
this.probabilisticStorage = new BitVector(regwidth, m);
break;
default:
throw new RuntimeException("Unsupported HLL type " + type);
}
} | [
"private",
"void",
"initializeStorage",
"(",
"final",
"HLLType",
"type",
")",
"{",
"this",
".",
"type",
"=",
"type",
";",
"switch",
"(",
"type",
")",
"{",
"case",
"EMPTY",
":",
"// nothing to be done",
"break",
";",
"case",
"EXPLICIT",
":",
"this",
".",
"explicitStorage",
"=",
"new",
"LongOpenHashSet",
"(",
")",
";",
"break",
";",
"case",
"SPARSE",
":",
"this",
".",
"sparseProbabilisticStorage",
"=",
"new",
"Int2ByteOpenHashMap",
"(",
")",
";",
"break",
";",
"case",
"FULL",
":",
"this",
".",
"probabilisticStorage",
"=",
"new",
"BitVector",
"(",
"regwidth",
",",
"m",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"RuntimeException",
"(",
"\"Unsupported HLL type \"",
"+",
"type",
")",
";",
"}",
"}"
] | Initializes storage for the specified {@link HLLType} and changes the
instance's {@link #type}.
@param type the {@link HLLType} to initialize storage for. This cannot be
<code>null</code> and must be an instantiable type. (For instance,
it cannot be {@link HLLType#UNDEFINED}.) | [
"Initializes",
"storage",
"for",
"the",
"specified",
"{",
"@link",
"HLLType",
"}",
"and",
"changes",
"the",
"instance",
"s",
"{",
"@link",
"#type",
"}",
"."
] | train | https://github.com/aggregateknowledge/java-hll/blob/1f4126e79a85b79581460c75bf1c1634b8a7402d/src/main/java/net/agkn/hll/HLL.java#L484-L502 |
mijecu25/dsa | src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java | LinearSearch.searchLast | public static int searchLast(byte[] byteArray, byte value, int occurrence) {
"""
Search for the value in the byte array and return the index of the first occurrence from the
end of the array.
@param byteArray array that we are searching in.
@param value value that is being searched in the array.
@param occurrence number of times we have seen the value before returning the index.
@return the index where the value is found in the array, else -1.
"""
if(occurrence <= 0 || occurrence > byteArray.length) {
throw new IllegalArgumentException("Occurrence must be greater or equal to 1 and less than "
+ "the array length: " + occurrence);
}
int valuesSeen = 0;
for(int i = byteArray.length-1; i >=0; i--) {
if(byteArray[i] == value) {
valuesSeen++;
if(valuesSeen == occurrence) {
return i;
}
}
}
return -1;
} | java | public static int searchLast(byte[] byteArray, byte value, int occurrence) {
if(occurrence <= 0 || occurrence > byteArray.length) {
throw new IllegalArgumentException("Occurrence must be greater or equal to 1 and less than "
+ "the array length: " + occurrence);
}
int valuesSeen = 0;
for(int i = byteArray.length-1; i >=0; i--) {
if(byteArray[i] == value) {
valuesSeen++;
if(valuesSeen == occurrence) {
return i;
}
}
}
return -1;
} | [
"public",
"static",
"int",
"searchLast",
"(",
"byte",
"[",
"]",
"byteArray",
",",
"byte",
"value",
",",
"int",
"occurrence",
")",
"{",
"if",
"(",
"occurrence",
"<=",
"0",
"||",
"occurrence",
">",
"byteArray",
".",
"length",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Occurrence must be greater or equal to 1 and less than \"",
"+",
"\"the array length: \"",
"+",
"occurrence",
")",
";",
"}",
"int",
"valuesSeen",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"byteArray",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"if",
"(",
"byteArray",
"[",
"i",
"]",
"==",
"value",
")",
"{",
"valuesSeen",
"++",
";",
"if",
"(",
"valuesSeen",
"==",
"occurrence",
")",
"{",
"return",
"i",
";",
"}",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] | Search for the value in the byte array and return the index of the first occurrence from the
end of the array.
@param byteArray array that we are searching in.
@param value value that is being searched in the array.
@param occurrence number of times we have seen the value before returning the index.
@return the index where the value is found in the array, else -1. | [
"Search",
"for",
"the",
"value",
"in",
"the",
"byte",
"array",
"and",
"return",
"the",
"index",
"of",
"the",
"first",
"occurrence",
"from",
"the",
"end",
"of",
"the",
"array",
"."
] | train | https://github.com/mijecu25/dsa/blob/a22971b746833e78a3939ae4de65e8f6bf2e3fd4/src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java#L1590-L1609 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.