repository_name stringlengths 7 58 | func_path_in_repository stringlengths 18 194 | func_name stringlengths 6 111 | whole_func_string stringlengths 80 3.8k | language stringclasses 1
value | func_code_string stringlengths 80 3.8k | func_code_tokens listlengths 20 697 | func_documentation_string stringlengths 61 2k | func_documentation_tokens listlengths 1 434 | split_name stringclasses 1
value | func_code_url stringlengths 111 308 |
|---|---|---|---|---|---|---|---|---|---|---|
alkacon/opencms-core | src/org/opencms/db/CmsSecurityManager.java | CmsSecurityManager.readUser | public CmsUser readUser(CmsRequestContext context, CmsUUID id) throws CmsException {
CmsDbContext dbc = m_dbContextFactory.getDbContext(context);
CmsUser result = null;
try {
result = m_driverManager.readUser(dbc, id);
} catch (Exception e) {
dbc.report(null, Messages.get().container(Messages.ERR_READ_USER_FOR_ID_1, id.toString()), e);
} finally {
dbc.clear();
}
return result;
} | java | public CmsUser readUser(CmsRequestContext context, CmsUUID id) throws CmsException {
CmsDbContext dbc = m_dbContextFactory.getDbContext(context);
CmsUser result = null;
try {
result = m_driverManager.readUser(dbc, id);
} catch (Exception e) {
dbc.report(null, Messages.get().container(Messages.ERR_READ_USER_FOR_ID_1, id.toString()), e);
} finally {
dbc.clear();
}
return result;
} | [
"public",
"CmsUser",
"readUser",
"(",
"CmsRequestContext",
"context",
",",
"CmsUUID",
"id",
")",
"throws",
"CmsException",
"{",
"CmsDbContext",
"dbc",
"=",
"m_dbContextFactory",
".",
"getDbContext",
"(",
"context",
")",
";",
"CmsUser",
"result",
"=",
"null",
";"... | Returns a user object based on the id of a user.<p>
@param context the current request context
@param id the id of the user to read
@return the user read
@throws CmsException if something goes wrong | [
"Returns",
"a",
"user",
"object",
"based",
"on",
"the",
"id",
"of",
"a",
"user",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/db/CmsSecurityManager.java#L5472-L5484 |
Azure/azure-sdk-for-java | recoveryservices.backup/resource-manager/v2017_07_01/src/main/java/com/microsoft/azure/management/recoveryservices/backup/v2017_07_01/implementation/JobDetailsInner.java | JobDetailsInner.getAsync | public Observable<JobResourceInner> getAsync(String vaultName, String resourceGroupName, String jobName) {
return getWithServiceResponseAsync(vaultName, resourceGroupName, jobName).map(new Func1<ServiceResponse<JobResourceInner>, JobResourceInner>() {
@Override
public JobResourceInner call(ServiceResponse<JobResourceInner> response) {
return response.body();
}
});
} | java | public Observable<JobResourceInner> getAsync(String vaultName, String resourceGroupName, String jobName) {
return getWithServiceResponseAsync(vaultName, resourceGroupName, jobName).map(new Func1<ServiceResponse<JobResourceInner>, JobResourceInner>() {
@Override
public JobResourceInner call(ServiceResponse<JobResourceInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"JobResourceInner",
">",
"getAsync",
"(",
"String",
"vaultName",
",",
"String",
"resourceGroupName",
",",
"String",
"jobName",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"vaultName",
",",
"resourceGroupName",
",",
"jobName",
... | Gets exteded information associated with the job.
@param vaultName The name of the recovery services vault.
@param resourceGroupName The name of the resource group where the recovery services vault is present.
@param jobName Name of the job whose details are to be fetched.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the JobResourceInner object | [
"Gets",
"exteded",
"information",
"associated",
"with",
"the",
"job",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/recoveryservices.backup/resource-manager/v2017_07_01/src/main/java/com/microsoft/azure/management/recoveryservices/backup/v2017_07_01/implementation/JobDetailsInner.java#L98-L105 |
javagl/CommonUI | src/main/java/de/javagl/common/ui/GuiUtils.java | GuiUtils.wrapCollapsible | public static CollapsiblePanel wrapCollapsible(
String title, JComponent component)
{
CollapsiblePanel collapsiblePanel =
new CollapsiblePanel(new GridLayout(1,1), title);
collapsiblePanel.add(component);
return collapsiblePanel;
} | java | public static CollapsiblePanel wrapCollapsible(
String title, JComponent component)
{
CollapsiblePanel collapsiblePanel =
new CollapsiblePanel(new GridLayout(1,1), title);
collapsiblePanel.add(component);
return collapsiblePanel;
} | [
"public",
"static",
"CollapsiblePanel",
"wrapCollapsible",
"(",
"String",
"title",
",",
"JComponent",
"component",
")",
"{",
"CollapsiblePanel",
"collapsiblePanel",
"=",
"new",
"CollapsiblePanel",
"(",
"new",
"GridLayout",
"(",
"1",
",",
"1",
")",
",",
"title",
... | Wrap the given component into a {@link CollapsiblePanel} with
the given title
@param title The title
@param component The component
@return The panel | [
"Wrap",
"the",
"given",
"component",
"into",
"a",
"{",
"@link",
"CollapsiblePanel",
"}",
"with",
"the",
"given",
"title"
] | train | https://github.com/javagl/CommonUI/blob/b2c7a7637d4e288271392ba148dc17e4c9780255/src/main/java/de/javagl/common/ui/GuiUtils.java#L54-L61 |
UrielCh/ovh-java-sdk | ovh-java-sdk-dedicatedserver/src/main/java/net/minidev/ovh/api/ApiOvhDedicatedserver.java | ApiOvhDedicatedserver.serviceName_virtualMac_macAddress_virtualAddress_POST | public OvhTask serviceName_virtualMac_macAddress_virtualAddress_POST(String serviceName, String macAddress, String ipAddress, String virtualMachineName) throws IOException {
String qPath = "/dedicated/server/{serviceName}/virtualMac/{macAddress}/virtualAddress";
StringBuilder sb = path(qPath, serviceName, macAddress);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "ipAddress", ipAddress);
addBody(o, "virtualMachineName", virtualMachineName);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhTask.class);
} | java | public OvhTask serviceName_virtualMac_macAddress_virtualAddress_POST(String serviceName, String macAddress, String ipAddress, String virtualMachineName) throws IOException {
String qPath = "/dedicated/server/{serviceName}/virtualMac/{macAddress}/virtualAddress";
StringBuilder sb = path(qPath, serviceName, macAddress);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "ipAddress", ipAddress);
addBody(o, "virtualMachineName", virtualMachineName);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhTask.class);
} | [
"public",
"OvhTask",
"serviceName_virtualMac_macAddress_virtualAddress_POST",
"(",
"String",
"serviceName",
",",
"String",
"macAddress",
",",
"String",
"ipAddress",
",",
"String",
"virtualMachineName",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/dedicat... | Add an IP to this Virtual MAC
REST: POST /dedicated/server/{serviceName}/virtualMac/{macAddress}/virtualAddress
@param virtualMachineName [required] Friendly name of your Virtual Machine behind this IP/MAC
@param ipAddress [required] IP address to link to this virtual MAC
@param serviceName [required] The internal name of your dedicated server
@param macAddress [required] Virtual MAC address in 00:00:00:00:00:00 format | [
"Add",
"an",
"IP",
"to",
"this",
"Virtual",
"MAC"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-dedicatedserver/src/main/java/net/minidev/ovh/api/ApiOvhDedicatedserver.java#L619-L627 |
diirt/util | src/main/java/org/epics/util/text/CsvParser.java | CsvParser.csvLines | static List<String> csvLines(Reader reader) {
// This needs to handle quoted text that spans multiple lines,
// so we divide the full text into chunks that correspond to
// a single csv line
try {
BufferedReader br = new BufferedReader(reader);
List<String> lines = new ArrayList<>();
// The current line read from the Reader
String line;
// The full csv line that may span multiple lines
String longLine = null;
while ((line = br.readLine()) != null) {
// If we have a line from the previous iteration,
// we concatenate it
if (longLine == null) {
longLine = line;
} else {
longLine = longLine.concat("\n").concat(line);
}
// Count the number of quotes: if it's even, the csv line
// must end here. If not, it will continue to the next
if (isEvenQuotes(longLine)) {
lines.add(longLine);
longLine = null;
}
}
// If there is text leftover, the line was not closed propertly.
// XXX: we need to figure out how to handle errors like this
if (longLine != null) {
lines.add(longLine);
}
return lines;
} catch(IOException ex) {
throw new RuntimeException("Couldn't process data", ex);
}
} | java | static List<String> csvLines(Reader reader) {
// This needs to handle quoted text that spans multiple lines,
// so we divide the full text into chunks that correspond to
// a single csv line
try {
BufferedReader br = new BufferedReader(reader);
List<String> lines = new ArrayList<>();
// The current line read from the Reader
String line;
// The full csv line that may span multiple lines
String longLine = null;
while ((line = br.readLine()) != null) {
// If we have a line from the previous iteration,
// we concatenate it
if (longLine == null) {
longLine = line;
} else {
longLine = longLine.concat("\n").concat(line);
}
// Count the number of quotes: if it's even, the csv line
// must end here. If not, it will continue to the next
if (isEvenQuotes(longLine)) {
lines.add(longLine);
longLine = null;
}
}
// If there is text leftover, the line was not closed propertly.
// XXX: we need to figure out how to handle errors like this
if (longLine != null) {
lines.add(longLine);
}
return lines;
} catch(IOException ex) {
throw new RuntimeException("Couldn't process data", ex);
}
} | [
"static",
"List",
"<",
"String",
">",
"csvLines",
"(",
"Reader",
"reader",
")",
"{",
"// This needs to handle quoted text that spans multiple lines,\r",
"// so we divide the full text into chunks that correspond to\r",
"// a single csv line\r",
"try",
"{",
"BufferedReader",
"br",
... | Divides the whole text into lines.
@param reader the source of text
@return the lines | [
"Divides",
"the",
"whole",
"text",
"into",
"lines",
"."
] | train | https://github.com/diirt/util/blob/24aca0a173a635aaf0b78d213a3fee8d4f91c077/src/main/java/org/epics/util/text/CsvParser.java#L296-L331 |
cesarferreira/AndroidQuickUtils | library/src/main/java/quickutils/core/categories/web.java | web.downloadToSDCard | public static boolean downloadToSDCard(String downloadURL, String sdcardPath) {
try {
URL url = new URL(downloadURL);
URLConnection connection = url.openConnection();
connection.connect();
// download the file
InputStream input = new BufferedInputStream(url.openStream());
OutputStream output = new FileOutputStream(sdcardPath);
byte data[] = new byte[1024];
long total = 0;
int count;
while ((count = input.read(data)) != -1) {
total += count;
output.write(data, 0, count);
}
output.flush();
output.close();
input.close();
} catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
} | java | public static boolean downloadToSDCard(String downloadURL, String sdcardPath) {
try {
URL url = new URL(downloadURL);
URLConnection connection = url.openConnection();
connection.connect();
// download the file
InputStream input = new BufferedInputStream(url.openStream());
OutputStream output = new FileOutputStream(sdcardPath);
byte data[] = new byte[1024];
long total = 0;
int count;
while ((count = input.read(data)) != -1) {
total += count;
output.write(data, 0, count);
}
output.flush();
output.close();
input.close();
} catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
} | [
"public",
"static",
"boolean",
"downloadToSDCard",
"(",
"String",
"downloadURL",
",",
"String",
"sdcardPath",
")",
"{",
"try",
"{",
"URL",
"url",
"=",
"new",
"URL",
"(",
"downloadURL",
")",
";",
"URLConnection",
"connection",
"=",
"url",
".",
"openConnection",... | Download a file to the sdcard<br/>
Please remember to <br/>
<li>give your application the permission to access the Internet and to
write to external storage</li> <li>Create the Folder (eg.
<code>File wallpaperDirectory = new File("/sdcard/Wallpaper/");
// have the object build the directory structure, if needed.
wallpaperDirectory.mkdirs();</code>
@param downloadURL from where you want to download
@param sdcardPath path to download the asset
@return | [
"Download",
"a",
"file",
"to",
"the",
"sdcard<br",
"/",
">",
"Please",
"remember",
"to",
"<br",
"/",
">",
"<li",
">",
"give",
"your",
"application",
"the",
"permission",
"to",
"access",
"the",
"Internet",
"and",
"to",
"write",
"to",
"external",
"storage<",... | train | https://github.com/cesarferreira/AndroidQuickUtils/blob/73a91daedbb9f7be7986ea786fbc441c9e5a881c/library/src/main/java/quickutils/core/categories/web.java#L67-L95 |
orbisgis/h2gis | h2gis-functions/src/main/java/org/h2gis/functions/io/osm/OSMTablesFactory.java | OSMTablesFactory.createTagTable | public static PreparedStatement createTagTable(Connection connection, String tagTableName) throws SQLException {
// PostgreSQL and H2 will automatically create an index on TAG_KEY,TAG_VALUE when UNIQUE constraint is set
try (Statement stmt = connection.createStatement()) {
// PostgreSQL and H2 will automatically create an index on TAG_KEY,TAG_VALUE when UNIQUE constraint is set
stmt.execute("CREATE TABLE " + tagTableName + "(ID_TAG SERIAL PRIMARY KEY, TAG_KEY VARCHAR UNIQUE);");
}
//We return the prepared statement of the tag table
return connection.prepareStatement("INSERT INTO " + tagTableName + " (TAG_KEY) VALUES (?)");
} | java | public static PreparedStatement createTagTable(Connection connection, String tagTableName) throws SQLException {
// PostgreSQL and H2 will automatically create an index on TAG_KEY,TAG_VALUE when UNIQUE constraint is set
try (Statement stmt = connection.createStatement()) {
// PostgreSQL and H2 will automatically create an index on TAG_KEY,TAG_VALUE when UNIQUE constraint is set
stmt.execute("CREATE TABLE " + tagTableName + "(ID_TAG SERIAL PRIMARY KEY, TAG_KEY VARCHAR UNIQUE);");
}
//We return the prepared statement of the tag table
return connection.prepareStatement("INSERT INTO " + tagTableName + " (TAG_KEY) VALUES (?)");
} | [
"public",
"static",
"PreparedStatement",
"createTagTable",
"(",
"Connection",
"connection",
",",
"String",
"tagTableName",
")",
"throws",
"SQLException",
"{",
"// PostgreSQL and H2 will automatically create an index on TAG_KEY,TAG_VALUE when UNIQUE constraint is set",
"try",
"(",
"... | Create the tag table to store all key and value
@param connection
@param tagTableName
@return
@throws SQLException | [
"Create",
"the",
"tag",
"table",
"to",
"store",
"all",
"key",
"and",
"value"
] | train | https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/io/osm/OSMTablesFactory.java#L79-L87 |
vdmeer/asciitable | src/main/java/de/vandermeer/asciitable/AT_Context.java | AT_Context.setFrameLeftRightChar | public AT_Context setFrameLeftRightChar(Character frameLeft, Character frameRight){
if(frameLeft!=null && frameRight!=null){
this.frameLeftChar = frameLeft;
this.frameRightChar = frameRight;
}
return this;
} | java | public AT_Context setFrameLeftRightChar(Character frameLeft, Character frameRight){
if(frameLeft!=null && frameRight!=null){
this.frameLeftChar = frameLeft;
this.frameRightChar = frameRight;
}
return this;
} | [
"public",
"AT_Context",
"setFrameLeftRightChar",
"(",
"Character",
"frameLeft",
",",
"Character",
"frameRight",
")",
"{",
"if",
"(",
"frameLeft",
"!=",
"null",
"&&",
"frameRight",
"!=",
"null",
")",
"{",
"this",
".",
"frameLeftChar",
"=",
"frameLeft",
";",
"th... | Sets the left and right frame margin character.
@param frameLeft character
@param frameRight character
@return this to allow chaining | [
"Sets",
"the",
"left",
"and",
"right",
"frame",
"margin",
"character",
"."
] | train | https://github.com/vdmeer/asciitable/blob/b6a73710271c89f9c749603be856ba84a969ed5f/src/main/java/de/vandermeer/asciitable/AT_Context.java#L216-L222 |
ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/WidgetsUtils.java | WidgetsUtils.matchesTags | public static boolean matchesTags(Element e, String... tagNames) {
assert e != null : "Element cannot be null";
StringBuilder regExp = new StringBuilder("^(");
int tagNameLenght = tagNames != null ? tagNames.length : 0;
for (int i = 0; i < tagNameLenght; i++) {
regExp.append(tagNames[i].toUpperCase());
if (i < tagNameLenght - 1) {
regExp.append("|");
}
}
regExp.append(")$");
return e.getTagName().toUpperCase().matches(regExp.toString());
} | java | public static boolean matchesTags(Element e, String... tagNames) {
assert e != null : "Element cannot be null";
StringBuilder regExp = new StringBuilder("^(");
int tagNameLenght = tagNames != null ? tagNames.length : 0;
for (int i = 0; i < tagNameLenght; i++) {
regExp.append(tagNames[i].toUpperCase());
if (i < tagNameLenght - 1) {
regExp.append("|");
}
}
regExp.append(")$");
return e.getTagName().toUpperCase().matches(regExp.toString());
} | [
"public",
"static",
"boolean",
"matchesTags",
"(",
"Element",
"e",
",",
"String",
"...",
"tagNames",
")",
"{",
"assert",
"e",
"!=",
"null",
":",
"\"Element cannot be null\"",
";",
"StringBuilder",
"regExp",
"=",
"new",
"StringBuilder",
"(",
"\"^(\"",
")",
";",... | Test if the tag name of the element is one of tag names given in parameter.
@param tagNames
@return | [
"Test",
"if",
"the",
"tag",
"name",
"of",
"the",
"element",
"is",
"one",
"of",
"tag",
"names",
"given",
"in",
"parameter",
"."
] | train | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/WidgetsUtils.java#L67-L82 |
shrinkwrap/resolver | maven/impl-maven-archive/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/plugins/ConfigurationUtils.java | ConfigurationUtils.valueAsBoolean | static boolean valueAsBoolean(Map<String, Object> map, Key key, boolean defaultValue) {
return Boolean.parseBoolean(valueAsString(map, key, String.valueOf(defaultValue)));
} | java | static boolean valueAsBoolean(Map<String, Object> map, Key key, boolean defaultValue) {
return Boolean.parseBoolean(valueAsString(map, key, String.valueOf(defaultValue)));
} | [
"static",
"boolean",
"valueAsBoolean",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"map",
",",
"Key",
"key",
",",
"boolean",
"defaultValue",
")",
"{",
"return",
"Boolean",
".",
"parseBoolean",
"(",
"valueAsString",
"(",
"map",
",",
"key",
",",
"String",... | Fetches a value specified by key
@param map XPP3 map equivalent
@param key navigation key
@param defaultValue Default value if no such key exists
@return Boolean representation of the value | [
"Fetches",
"a",
"value",
"specified",
"by",
"key"
] | train | https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/maven/impl-maven-archive/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/plugins/ConfigurationUtils.java#L61-L63 |
pushtorefresh/storio | storio-content-resolver/src/main/java/com/pushtorefresh/storio3/contentresolver/operations/delete/DeleteResult.java | DeleteResult.newInstance | @NonNull
public static DeleteResult newInstance(int numberOfRowsDeleted, @NonNull Set<Uri> affectedUris) {
checkNotNull(affectedUris, "Please specify affected Uris");
return new DeleteResult(numberOfRowsDeleted, affectedUris);
} | java | @NonNull
public static DeleteResult newInstance(int numberOfRowsDeleted, @NonNull Set<Uri> affectedUris) {
checkNotNull(affectedUris, "Please specify affected Uris");
return new DeleteResult(numberOfRowsDeleted, affectedUris);
} | [
"@",
"NonNull",
"public",
"static",
"DeleteResult",
"newInstance",
"(",
"int",
"numberOfRowsDeleted",
",",
"@",
"NonNull",
"Set",
"<",
"Uri",
">",
"affectedUris",
")",
"{",
"checkNotNull",
"(",
"affectedUris",
",",
"\"Please specify affected Uris\"",
")",
";",
"re... | Creates new instance of immutable container for results of Delete Operation.
@param numberOfRowsDeleted number of rows that were deleted.
@param affectedUris non-null set of Uris that wer affected.
@return new instance of immutable container for results of Delete Operation. | [
"Creates",
"new",
"instance",
"of",
"immutable",
"container",
"for",
"results",
"of",
"Delete",
"Operation",
"."
] | train | https://github.com/pushtorefresh/storio/blob/58f53d81bcc7b069c8bb271c46a90e37775abe8d/storio-content-resolver/src/main/java/com/pushtorefresh/storio3/contentresolver/operations/delete/DeleteResult.java#L35-L39 |
bbottema/simple-java-mail | modules/simple-java-mail/src/main/java/org/simplejavamail/mailer/MailerBuilder.java | MailerBuilder.withSMTPServer | @SuppressWarnings("deprecation")
public static MailerRegularBuilderImpl withSMTPServer(@Nullable final String host, @Nullable final Integer port, @Nullable final String username, @Nullable final String password) {
return new MailerRegularBuilderImpl().withSMTPServer(host, port, username, password);
} | java | @SuppressWarnings("deprecation")
public static MailerRegularBuilderImpl withSMTPServer(@Nullable final String host, @Nullable final Integer port, @Nullable final String username, @Nullable final String password) {
return new MailerRegularBuilderImpl().withSMTPServer(host, port, username, password);
} | [
"@",
"SuppressWarnings",
"(",
"\"deprecation\"",
")",
"public",
"static",
"MailerRegularBuilderImpl",
"withSMTPServer",
"(",
"@",
"Nullable",
"final",
"String",
"host",
",",
"@",
"Nullable",
"final",
"Integer",
"port",
",",
"@",
"Nullable",
"final",
"String",
"use... | Delegates to {@link MailerRegularBuilder#withSMTPServer(String, Integer, String, String)}. | [
"Delegates",
"to",
"{"
] | train | https://github.com/bbottema/simple-java-mail/blob/b03635328aeecd525e35eddfef8f5b9a184559d8/modules/simple-java-mail/src/main/java/org/simplejavamail/mailer/MailerBuilder.java#L48-L51 |
pravega/pravega | segmentstore/server/src/main/java/io/pravega/segmentstore/server/tables/TableCompactor.java | TableCompactor.calculateTruncationOffset | long calculateTruncationOffset(SegmentProperties info, long highestCopiedOffset) {
long truncateOffset = -1;
if (highestCopiedOffset > 0) {
// Due to the nature of compaction (all entries are copied in order of their original versions), if we encounter
// any copied Table Entries then the highest explicit version defined on any of them is where we can truncate.
truncateOffset = highestCopiedOffset;
} else if (this.indexReader.getLastIndexedOffset(info) >= info.getLength()) {
// Did not encounter any copied entries. If we were able to index the whole segment, then we should be safe
// to truncate at wherever the compaction last finished.
truncateOffset = this.indexReader.getCompactionOffset(info);
}
if (truncateOffset <= info.getStartOffset()) {
// The segment is already truncated at the compaction offset; no need for more.
truncateOffset = -1;
}
return truncateOffset;
} | java | long calculateTruncationOffset(SegmentProperties info, long highestCopiedOffset) {
long truncateOffset = -1;
if (highestCopiedOffset > 0) {
// Due to the nature of compaction (all entries are copied in order of their original versions), if we encounter
// any copied Table Entries then the highest explicit version defined on any of them is where we can truncate.
truncateOffset = highestCopiedOffset;
} else if (this.indexReader.getLastIndexedOffset(info) >= info.getLength()) {
// Did not encounter any copied entries. If we were able to index the whole segment, then we should be safe
// to truncate at wherever the compaction last finished.
truncateOffset = this.indexReader.getCompactionOffset(info);
}
if (truncateOffset <= info.getStartOffset()) {
// The segment is already truncated at the compaction offset; no need for more.
truncateOffset = -1;
}
return truncateOffset;
} | [
"long",
"calculateTruncationOffset",
"(",
"SegmentProperties",
"info",
",",
"long",
"highestCopiedOffset",
")",
"{",
"long",
"truncateOffset",
"=",
"-",
"1",
";",
"if",
"(",
"highestCopiedOffset",
">",
"0",
")",
"{",
"// Due to the nature of compaction (all entries are ... | Calculates the offset in the Segment where it is safe to truncate based on the current state of the Segment and
the highest copied offset encountered during an index update.
This method is invoked from the {@link WriterTableProcessor} after indexing. Since compaction is loosely coupled
with indexing, the {@link WriterTableProcessor} does not have too many insights into what has been compacted or not;
it can only decide based on the current state of the Table Segment and what it has just indexed. As such:
- If recently indexed Table Entries indicate they were copied as part of a compaction, then it is safe to truncate
at the highest copied offset encountered (since they are copied in order, by offset). Everything prior to this
offset is guaranteed not to exist in the index anymore.
- If no recently indexed Table Entry indicates it was copied as a result of compaction, then it may not be safe to
truncate at {@link TableAttributes#COMPACTION_OFFSET}, because there may exist unindexed Table Entries that the
indexer hasn't gotten to yet. As such, it is only safe to truncate at {@link TableAttributes#COMPACTION_OFFSET}
if the indexer has indexed all the entries in the Table Segment.
@param info The {@link SegmentProperties} associated with the Table Segment to inquire about.
@param highestCopiedOffset The highest offset that was copied from a lower offset during a compaction. If the copied
entry has already been index then it is guaranteed that every entry prior to this
offset is no longer part of the index and can be safely truncated away.
@return The calculated truncation offset or a negative number if no truncation is required or possible given the
arguments provided. | [
"Calculates",
"the",
"offset",
"in",
"the",
"Segment",
"where",
"it",
"is",
"safe",
"to",
"truncate",
"based",
"on",
"the",
"current",
"state",
"of",
"the",
"Segment",
"and",
"the",
"highest",
"copied",
"offset",
"encountered",
"during",
"an",
"index",
"upda... | train | https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/segmentstore/server/src/main/java/io/pravega/segmentstore/server/tables/TableCompactor.java#L125-L143 |
BotMill/fb-botmill | src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/AirlineItineraryTemplateBuilder.java | AirlineItineraryTemplateBuilder.addPriceInfo | public AirlineItineraryTemplateBuilder addPriceInfo(String title,
BigDecimal amount) {
PriceInfo priceInfo = new PriceInfo(title, amount);
this.payload.addPriceInfo(priceInfo);
return this;
} | java | public AirlineItineraryTemplateBuilder addPriceInfo(String title,
BigDecimal amount) {
PriceInfo priceInfo = new PriceInfo(title, amount);
this.payload.addPriceInfo(priceInfo);
return this;
} | [
"public",
"AirlineItineraryTemplateBuilder",
"addPriceInfo",
"(",
"String",
"title",
",",
"BigDecimal",
"amount",
")",
"{",
"PriceInfo",
"priceInfo",
"=",
"new",
"PriceInfo",
"(",
"title",
",",
"amount",
")",
";",
"this",
".",
"payload",
".",
"addPriceInfo",
"("... | Adds a {@link PriceInfo} object to this template. This field is optional.
There can be at most 4 price info objects per template.
@param title
the price info title. It can't be empty.
@param amount
the price amount.
@return this builder. | [
"Adds",
"a",
"{",
"@link",
"PriceInfo",
"}",
"object",
"to",
"this",
"template",
".",
"This",
"field",
"is",
"optional",
".",
"There",
"can",
"be",
"at",
"most",
"4",
"price",
"info",
"objects",
"per",
"template",
"."
] | train | https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/AirlineItineraryTemplateBuilder.java#L216-L221 |
MariaDB/mariadb-connector-j | src/main/java/org/mariadb/jdbc/BasePrepareStatement.java | BasePrepareStatement.setDate | public void setDate(final int parameterIndex, final Date date, final Calendar cal)
throws SQLException {
if (date == null) {
setNull(parameterIndex, Types.DATE);
return;
}
setParameter(parameterIndex,
new DateParameter(date, cal != null ? cal.getTimeZone() : TimeZone.getDefault(),
protocol.getOptions()));
} | java | public void setDate(final int parameterIndex, final Date date, final Calendar cal)
throws SQLException {
if (date == null) {
setNull(parameterIndex, Types.DATE);
return;
}
setParameter(parameterIndex,
new DateParameter(date, cal != null ? cal.getTimeZone() : TimeZone.getDefault(),
protocol.getOptions()));
} | [
"public",
"void",
"setDate",
"(",
"final",
"int",
"parameterIndex",
",",
"final",
"Date",
"date",
",",
"final",
"Calendar",
"cal",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"date",
"==",
"null",
")",
"{",
"setNull",
"(",
"parameterIndex",
",",
"Types"... | Sets the designated parameter to the given <code>java.sql.Date</code> value, using the given
<code>Calendar</code> object. The driver uses the <code>Calendar</code> object to construct
an SQL
<code>DATE</code> value, which the driver then sends to the database. With a
<code>Calendar</code> object, the
driver can calculate the date taking into account a custom timezone. If no
<code>Calendar</code> object is specified, the driver uses the default timezone, which is that
of the virtual machine running the application.
@param parameterIndex the first parameter is 1, the second is 2, ...
@param date the parameter value
@param cal the <code>Calendar</code> object the driver will use to construct the
date
@throws SQLException if parameterIndex does not correspond to a parameter marker in the SQL
statement; if a database access error occurs or this method is called on a
closed
<code>PreparedStatement</code> | [
"Sets",
"the",
"designated",
"parameter",
"to",
"the",
"given",
"<code",
">",
"java",
".",
"sql",
".",
"Date<",
"/",
"code",
">",
"value",
"using",
"the",
"given",
"<code",
">",
"Calendar<",
"/",
"code",
">",
"object",
".",
"The",
"driver",
"uses",
"th... | train | https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/BasePrepareStatement.java#L490-L499 |
lessthanoptimal/ejml | main/ejml-core/src/org/ejml/ops/ConvertDMatrixStruct.java | ConvertDMatrixStruct.convert | public static void convert(DMatrix input , DMatrix output ) {
if( output instanceof ReshapeMatrix ) {
((ReshapeMatrix)output).reshape(input.getNumRows(),input.getNumCols());
} else {
if (input.getNumRows() != output.getNumRows())
throw new IllegalArgumentException("Number of rows do not match");
if (input.getNumCols() != output.getNumCols())
throw new IllegalArgumentException("Number of columns do not match");
}
for( int i = 0; i < input.getNumRows(); i++ ) {
for( int j = 0; j < input.getNumCols(); j++ ) {
output.unsafe_set(i,j,input.unsafe_get(i,j));
}
}
} | java | public static void convert(DMatrix input , DMatrix output ) {
if( output instanceof ReshapeMatrix ) {
((ReshapeMatrix)output).reshape(input.getNumRows(),input.getNumCols());
} else {
if (input.getNumRows() != output.getNumRows())
throw new IllegalArgumentException("Number of rows do not match");
if (input.getNumCols() != output.getNumCols())
throw new IllegalArgumentException("Number of columns do not match");
}
for( int i = 0; i < input.getNumRows(); i++ ) {
for( int j = 0; j < input.getNumCols(); j++ ) {
output.unsafe_set(i,j,input.unsafe_get(i,j));
}
}
} | [
"public",
"static",
"void",
"convert",
"(",
"DMatrix",
"input",
",",
"DMatrix",
"output",
")",
"{",
"if",
"(",
"output",
"instanceof",
"ReshapeMatrix",
")",
"{",
"(",
"(",
"ReshapeMatrix",
")",
"output",
")",
".",
"reshape",
"(",
"input",
".",
"getNumRows"... | Generic, but slow, conversion function.
@param input Input matrix.
@param output Output matrix. | [
"Generic",
"but",
"slow",
"conversion",
"function",
"."
] | train | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-core/src/org/ejml/ops/ConvertDMatrixStruct.java#L39-L54 |
drallgood/jpasskit | jpasskit/src/main/java/de/brendamour/jpasskit/signing/PKSigningInformationUtil.java | PKSigningInformationUtil.loadPKCS12File | @Deprecated
public KeyStore loadPKCS12File(String pathToP12, String password) throws CertificateException, IOException {
try (InputStream keystoreInputStream = CertUtils.toInputStream(pathToP12)) {
return loadPKCS12File(keystoreInputStream, password);
}
} | java | @Deprecated
public KeyStore loadPKCS12File(String pathToP12, String password) throws CertificateException, IOException {
try (InputStream keystoreInputStream = CertUtils.toInputStream(pathToP12)) {
return loadPKCS12File(keystoreInputStream, password);
}
} | [
"@",
"Deprecated",
"public",
"KeyStore",
"loadPKCS12File",
"(",
"String",
"pathToP12",
",",
"String",
"password",
")",
"throws",
"CertificateException",
",",
"IOException",
"{",
"try",
"(",
"InputStream",
"keystoreInputStream",
"=",
"CertUtils",
".",
"toInputStream",
... | Load PKCS12 keystore file from file (will try to load it from the classpath)
@param pathToP12
path to PKCS 12 file (on the filesystem or classpath)
@param password
password to access the key store
@return Key store loaded from the provided files
@throws IOException
@throws CertificateException
@throws IllegalArgumentException
@deprecated | [
"Load",
"PKCS12",
"keystore",
"file",
"from",
"file",
"(",
"will",
"try",
"to",
"load",
"it",
"from",
"the",
"classpath",
")"
] | train | https://github.com/drallgood/jpasskit/blob/63bfa8abbdb85c2d7596c60eed41ed8e374cbd01/jpasskit/src/main/java/de/brendamour/jpasskit/signing/PKSigningInformationUtil.java#L124-L129 |
Tristan971/EasyFXML | easyfxml/src/main/java/moe/tristan/easyfxml/util/Clipping.java | Clipping.getSquareClip | public static Rectangle getSquareClip(final double side, final double roundedRadius) {
final Rectangle rectangle = new Rectangle();
rectangle.setHeight(side);
rectangle.setWidth(side);
rectangle.setArcWidth(roundedRadius);
rectangle.setArcHeight(roundedRadius);
return rectangle;
} | java | public static Rectangle getSquareClip(final double side, final double roundedRadius) {
final Rectangle rectangle = new Rectangle();
rectangle.setHeight(side);
rectangle.setWidth(side);
rectangle.setArcWidth(roundedRadius);
rectangle.setArcHeight(roundedRadius);
return rectangle;
} | [
"public",
"static",
"Rectangle",
"getSquareClip",
"(",
"final",
"double",
"side",
",",
"final",
"double",
"roundedRadius",
")",
"{",
"final",
"Rectangle",
"rectangle",
"=",
"new",
"Rectangle",
"(",
")",
";",
"rectangle",
".",
"setHeight",
"(",
"side",
")",
"... | Builds a clip-ready rounded corners {@link Rectangle} that is square.
@param side The size of the size of this square
@param roundedRadius The radius of this square's corners rounding
@return A square with the given side size and rounded corners with the given radius | [
"Builds",
"a",
"clip",
"-",
"ready",
"rounded",
"corners",
"{",
"@link",
"Rectangle",
"}",
"that",
"is",
"square",
"."
] | train | https://github.com/Tristan971/EasyFXML/blob/f82cad1d54e62903ca5e4a250279ad315b028aef/easyfxml/src/main/java/moe/tristan/easyfxml/util/Clipping.java#L40-L47 |
apache/incubator-gobblin | gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/metastore/HiveMetaStoreBasedRegister.java | HiveMetaStoreBasedRegister.ensureHiveDbExistence | private boolean ensureHiveDbExistence(String hiveDbName, IMetaStoreClient client) throws IOException{
try (AutoCloseableLock lock = this.locks.getDbLock(hiveDbName)) {
Database db = new Database();
db.setName(hiveDbName);
try {
try (Timer.Context context = this.metricContext.timer(GET_HIVE_DATABASE).time()) {
client.getDatabase(db.getName());
}
return false;
} catch (NoSuchObjectException nsoe) {
// proceed with create
} catch (TException te) {
throw new IOException(te);
}
Preconditions.checkState(this.hiveDbRootDir.isPresent(),
"Missing required property " + HiveRegProps.HIVE_DB_ROOT_DIR);
db.setLocationUri(new Path(this.hiveDbRootDir.get(), hiveDbName + HIVE_DB_EXTENSION).toString());
try {
try (Timer.Context context = this.metricContext.timer(CREATE_HIVE_DATABASE).time()) {
client.createDatabase(db);
}
log.info("Created database " + hiveDbName);
HiveMetaStoreEventHelper.submitSuccessfulDBCreation(this.eventSubmitter, hiveDbName);
return true;
} catch (AlreadyExistsException e) {
return false;
} catch (TException e) {
HiveMetaStoreEventHelper.submitFailedDBCreation(this.eventSubmitter, hiveDbName, e);
throw new IOException("Unable to create Hive database " + hiveDbName, e);
}
}
} | java | private boolean ensureHiveDbExistence(String hiveDbName, IMetaStoreClient client) throws IOException{
try (AutoCloseableLock lock = this.locks.getDbLock(hiveDbName)) {
Database db = new Database();
db.setName(hiveDbName);
try {
try (Timer.Context context = this.metricContext.timer(GET_HIVE_DATABASE).time()) {
client.getDatabase(db.getName());
}
return false;
} catch (NoSuchObjectException nsoe) {
// proceed with create
} catch (TException te) {
throw new IOException(te);
}
Preconditions.checkState(this.hiveDbRootDir.isPresent(),
"Missing required property " + HiveRegProps.HIVE_DB_ROOT_DIR);
db.setLocationUri(new Path(this.hiveDbRootDir.get(), hiveDbName + HIVE_DB_EXTENSION).toString());
try {
try (Timer.Context context = this.metricContext.timer(CREATE_HIVE_DATABASE).time()) {
client.createDatabase(db);
}
log.info("Created database " + hiveDbName);
HiveMetaStoreEventHelper.submitSuccessfulDBCreation(this.eventSubmitter, hiveDbName);
return true;
} catch (AlreadyExistsException e) {
return false;
} catch (TException e) {
HiveMetaStoreEventHelper.submitFailedDBCreation(this.eventSubmitter, hiveDbName, e);
throw new IOException("Unable to create Hive database " + hiveDbName, e);
}
}
} | [
"private",
"boolean",
"ensureHiveDbExistence",
"(",
"String",
"hiveDbName",
",",
"IMetaStoreClient",
"client",
")",
"throws",
"IOException",
"{",
"try",
"(",
"AutoCloseableLock",
"lock",
"=",
"this",
".",
"locks",
".",
"getDbLock",
"(",
"hiveDbName",
")",
")",
"... | If databse existed on Hive side will return false;
Or will create the table thru. RPC and return retVal from remote MetaStore.
@param hiveDbName is the hive databases to be checked for existence | [
"If",
"databse",
"existed",
"on",
"Hive",
"side",
"will",
"return",
"false",
";",
"Or",
"will",
"create",
"the",
"table",
"thru",
".",
"RPC",
"and",
"return",
"retVal",
"from",
"remote",
"MetaStore",
"."
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/metastore/HiveMetaStoreBasedRegister.java#L217-L251 |
pip-services3-java/pip-services3-commons-java | src/org/pipservices3/commons/errors/ApplicationException.java | ApplicationException.wrapException | public static ApplicationException wrapException(ApplicationException error, Throwable cause) {
if (cause instanceof ApplicationException)
return (ApplicationException) cause;
error.withCause(cause);
return error;
} | java | public static ApplicationException wrapException(ApplicationException error, Throwable cause) {
if (cause instanceof ApplicationException)
return (ApplicationException) cause;
error.withCause(cause);
return error;
} | [
"public",
"static",
"ApplicationException",
"wrapException",
"(",
"ApplicationException",
"error",
",",
"Throwable",
"cause",
")",
"{",
"if",
"(",
"cause",
"instanceof",
"ApplicationException",
")",
"return",
"(",
"ApplicationException",
")",
"cause",
";",
"error",
... | Wraps another exception into specified application exception object.
If original exception is of ApplicationException type it is returned without
changes. Otherwise the original error is set as a cause to specified
ApplicationException object.
@param error an ApplicationException object to wrap the cause
@param cause an original error object
@return an original or newly created ApplicationException | [
"Wraps",
"another",
"exception",
"into",
"specified",
"application",
"exception",
"object",
"."
] | train | https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/errors/ApplicationException.java#L320-L327 |
VoltDB/voltdb | src/frontend/org/voltdb/jdbc/JDBC4CallableStatement.java | JDBC4CallableStatement.getObject | @Override
public Object getObject(String parameterName, Map<String,Class<?>> map) throws SQLException
{
checkClosed();
throw SQLError.noSupport();
} | java | @Override
public Object getObject(String parameterName, Map<String,Class<?>> map) throws SQLException
{
checkClosed();
throw SQLError.noSupport();
} | [
"@",
"Override",
"public",
"Object",
"getObject",
"(",
"String",
"parameterName",
",",
"Map",
"<",
"String",
",",
"Class",
"<",
"?",
">",
">",
"map",
")",
"throws",
"SQLException",
"{",
"checkClosed",
"(",
")",
";",
"throw",
"SQLError",
".",
"noSupport",
... | Returns an object representing the value of OUT parameter parameterName and uses map for the custom mapping of the parameter value. | [
"Returns",
"an",
"object",
"representing",
"the",
"value",
"of",
"OUT",
"parameter",
"parameterName",
"and",
"uses",
"map",
"for",
"the",
"custom",
"mapping",
"of",
"the",
"parameter",
"value",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/jdbc/JDBC4CallableStatement.java#L351-L356 |
apache/incubator-druid | core/src/main/java/org/apache/druid/collections/CombiningIterable.java | CombiningIterable.createSplatted | @SuppressWarnings("unchecked")
public static <InType> CombiningIterable<InType> createSplatted(
Iterable<? extends Iterable<InType>> in,
Comparator<InType> comparator
)
{
return create(
new MergeIterable<InType>(comparator, (Iterable<Iterable<InType>>) in),
comparator,
new BinaryFn<InType, InType, InType>()
{
@Override
public InType apply(InType arg1, InType arg2)
{
if (arg1 == null) {
return arg2;
}
return arg1;
}
}
);
} | java | @SuppressWarnings("unchecked")
public static <InType> CombiningIterable<InType> createSplatted(
Iterable<? extends Iterable<InType>> in,
Comparator<InType> comparator
)
{
return create(
new MergeIterable<InType>(comparator, (Iterable<Iterable<InType>>) in),
comparator,
new BinaryFn<InType, InType, InType>()
{
@Override
public InType apply(InType arg1, InType arg2)
{
if (arg1 == null) {
return arg2;
}
return arg1;
}
}
);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"InType",
">",
"CombiningIterable",
"<",
"InType",
">",
"createSplatted",
"(",
"Iterable",
"<",
"?",
"extends",
"Iterable",
"<",
"InType",
">",
">",
"in",
",",
"Comparator",
"<",
"I... | Creates a CombiningIterable around a MergeIterable such that equivalent elements are thrown away
If there are multiple Iterables in parameter "in" with equivalent objects, there are no guarantees
around which object will win. You will get *some* object from one of the Iterables, but which Iterable is
unknown.
@param in An Iterable of Iterables to be merged
@param comparator the Comparator to determine sort and equality
@param <InType> Type of object
@return An Iterable that is the merge of all Iterables from in such that there is only one instance of
equivalent objects. | [
"Creates",
"a",
"CombiningIterable",
"around",
"a",
"MergeIterable",
"such",
"that",
"equivalent",
"elements",
"are",
"thrown",
"away"
] | train | https://github.com/apache/incubator-druid/blob/f776b9408962b9006cfcfe4d6c1794751972cc8e/core/src/main/java/org/apache/druid/collections/CombiningIterable.java#L45-L66 |
alkacon/opencms-core | src-gwt/org/opencms/ade/sitemap/client/ui/CmsCreateGalleryDialog.java | CmsCreateGalleryDialog.addInputRow | private void addInputRow(String label, Widget inputWidget) {
FlowPanel row = new FlowPanel();
row.setStyleName(I_CmsLayoutBundle.INSTANCE.generalCss().simpleFormRow());
CmsLabel labelWidget = new CmsLabel(label);
labelWidget.setStyleName(I_CmsLayoutBundle.INSTANCE.generalCss().simpleFormLabel());
row.add(labelWidget);
inputWidget.addStyleName(I_CmsLayoutBundle.INSTANCE.generalCss().simpleFormInputBox());
row.add(inputWidget);
m_dialogContent.getFieldSet().add(row);
} | java | private void addInputRow(String label, Widget inputWidget) {
FlowPanel row = new FlowPanel();
row.setStyleName(I_CmsLayoutBundle.INSTANCE.generalCss().simpleFormRow());
CmsLabel labelWidget = new CmsLabel(label);
labelWidget.setStyleName(I_CmsLayoutBundle.INSTANCE.generalCss().simpleFormLabel());
row.add(labelWidget);
inputWidget.addStyleName(I_CmsLayoutBundle.INSTANCE.generalCss().simpleFormInputBox());
row.add(inputWidget);
m_dialogContent.getFieldSet().add(row);
} | [
"private",
"void",
"addInputRow",
"(",
"String",
"label",
",",
"Widget",
"inputWidget",
")",
"{",
"FlowPanel",
"row",
"=",
"new",
"FlowPanel",
"(",
")",
";",
"row",
".",
"setStyleName",
"(",
"I_CmsLayoutBundle",
".",
"INSTANCE",
".",
"generalCss",
"(",
")",
... | Adds a row to the form.<p>
@param label the label
@param inputWidget the input widget | [
"Adds",
"a",
"row",
"to",
"the",
"form",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/ade/sitemap/client/ui/CmsCreateGalleryDialog.java#L181-L191 |
xiancloud/xian | xian-oauth20/xian-apifestOauth20/src/main/java/com/apifest/oauth20/bean/AuthCode.java | AuthCode.loadFromMap | public static AuthCode loadFromMap(Map<String, Object> map) {
AuthCode authCode = new AuthCode();
authCode.code = (String) map.get("code");
authCode.clientId = (String) map.get("LOCAL_NODE_ID");
authCode.redirectUri = (String) map.get("redirectUri");
authCode.state = (String) map.get("state");
authCode.scope = (String) map.get("scope");
authCode.type = (String) map.get("type");
authCode.valid = (Boolean) map.get("valid");
authCode.userId = (String) map.get("userId");
authCode.created = (Long) map.get("created");
authCode.id = map.get("_id").toString();
return authCode;
} | java | public static AuthCode loadFromMap(Map<String, Object> map) {
AuthCode authCode = new AuthCode();
authCode.code = (String) map.get("code");
authCode.clientId = (String) map.get("LOCAL_NODE_ID");
authCode.redirectUri = (String) map.get("redirectUri");
authCode.state = (String) map.get("state");
authCode.scope = (String) map.get("scope");
authCode.type = (String) map.get("type");
authCode.valid = (Boolean) map.get("valid");
authCode.userId = (String) map.get("userId");
authCode.created = (Long) map.get("created");
authCode.id = map.get("_id").toString();
return authCode;
} | [
"public",
"static",
"AuthCode",
"loadFromMap",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"map",
")",
"{",
"AuthCode",
"authCode",
"=",
"new",
"AuthCode",
"(",
")",
";",
"authCode",
".",
"code",
"=",
"(",
"String",
")",
"map",
".",
"get",
"(",
"\... | Used to create an instance when a record from DB is loaded.
@param map Map that contains the record info
@return instance of AuthCode | [
"Used",
"to",
"create",
"an",
"instance",
"when",
"a",
"record",
"from",
"DB",
"is",
"loaded",
"."
] | train | https://github.com/xiancloud/xian/blob/1948e088545553d2745b2c86d8b5a64988bb850e/xian-oauth20/xian-apifestOauth20/src/main/java/com/apifest/oauth20/bean/AuthCode.java#L166-L179 |
apache/flink | flink-optimizer/src/main/java/org/apache/flink/optimizer/dag/BulkIterationNode.java | BulkIterationNode.setNextPartialSolution | public void setNextPartialSolution(OptimizerNode nextPartialSolution, OptimizerNode terminationCriterion) {
// check if the root of the step function has the same parallelism as the iteration
// or if the step function has any operator at all
if (nextPartialSolution.getParallelism() != getParallelism() ||
nextPartialSolution == partialSolution || nextPartialSolution instanceof BinaryUnionNode)
{
// add a no-op to the root to express the re-partitioning
NoOpNode noop = new NoOpNode();
noop.setParallelism(getParallelism());
DagConnection noOpConn = new DagConnection(nextPartialSolution, noop, ExecutionMode.PIPELINED);
noop.setIncomingConnection(noOpConn);
nextPartialSolution.addOutgoingConnection(noOpConn);
nextPartialSolution = noop;
}
this.nextPartialSolution = nextPartialSolution;
this.terminationCriterion = terminationCriterion;
if (terminationCriterion == null) {
this.singleRoot = nextPartialSolution;
this.rootConnection = new DagConnection(nextPartialSolution, ExecutionMode.PIPELINED);
}
else {
// we have a termination criterion
SingleRootJoiner singleRootJoiner = new SingleRootJoiner();
this.rootConnection = new DagConnection(nextPartialSolution, singleRootJoiner, ExecutionMode.PIPELINED);
this.terminationCriterionRootConnection = new DagConnection(terminationCriterion, singleRootJoiner,
ExecutionMode.PIPELINED);
singleRootJoiner.setInputs(this.rootConnection, this.terminationCriterionRootConnection);
this.singleRoot = singleRootJoiner;
// add connection to terminationCriterion for interesting properties visitor
terminationCriterion.addOutgoingConnection(terminationCriterionRootConnection);
}
nextPartialSolution.addOutgoingConnection(rootConnection);
} | java | public void setNextPartialSolution(OptimizerNode nextPartialSolution, OptimizerNode terminationCriterion) {
// check if the root of the step function has the same parallelism as the iteration
// or if the step function has any operator at all
if (nextPartialSolution.getParallelism() != getParallelism() ||
nextPartialSolution == partialSolution || nextPartialSolution instanceof BinaryUnionNode)
{
// add a no-op to the root to express the re-partitioning
NoOpNode noop = new NoOpNode();
noop.setParallelism(getParallelism());
DagConnection noOpConn = new DagConnection(nextPartialSolution, noop, ExecutionMode.PIPELINED);
noop.setIncomingConnection(noOpConn);
nextPartialSolution.addOutgoingConnection(noOpConn);
nextPartialSolution = noop;
}
this.nextPartialSolution = nextPartialSolution;
this.terminationCriterion = terminationCriterion;
if (terminationCriterion == null) {
this.singleRoot = nextPartialSolution;
this.rootConnection = new DagConnection(nextPartialSolution, ExecutionMode.PIPELINED);
}
else {
// we have a termination criterion
SingleRootJoiner singleRootJoiner = new SingleRootJoiner();
this.rootConnection = new DagConnection(nextPartialSolution, singleRootJoiner, ExecutionMode.PIPELINED);
this.terminationCriterionRootConnection = new DagConnection(terminationCriterion, singleRootJoiner,
ExecutionMode.PIPELINED);
singleRootJoiner.setInputs(this.rootConnection, this.terminationCriterionRootConnection);
this.singleRoot = singleRootJoiner;
// add connection to terminationCriterion for interesting properties visitor
terminationCriterion.addOutgoingConnection(terminationCriterionRootConnection);
}
nextPartialSolution.addOutgoingConnection(rootConnection);
} | [
"public",
"void",
"setNextPartialSolution",
"(",
"OptimizerNode",
"nextPartialSolution",
",",
"OptimizerNode",
"terminationCriterion",
")",
"{",
"// check if the root of the step function has the same parallelism as the iteration",
"// or if the step function has any operator at all",
"if"... | Sets the nextPartialSolution for this BulkIterationNode.
@param nextPartialSolution The nextPartialSolution to set. | [
"Sets",
"the",
"nextPartialSolution",
"for",
"this",
"BulkIterationNode",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-optimizer/src/main/java/org/apache/flink/optimizer/dag/BulkIterationNode.java#L132-L174 |
katharsis-project/katharsis-framework | katharsis-core/src/main/java/io/katharsis/core/internal/utils/PropertyUtils.java | PropertyUtils.getPropertyClass | public static Class<?> getPropertyClass(Class<?> beanClass, String field) {
try {
return INSTANCE.findPropertyClass(beanClass, field);
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
throw handleReflectionException(beanClass, field, e);
}
} | java | public static Class<?> getPropertyClass(Class<?> beanClass, String field) {
try {
return INSTANCE.findPropertyClass(beanClass, field);
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
throw handleReflectionException(beanClass, field, e);
}
} | [
"public",
"static",
"Class",
"<",
"?",
">",
"getPropertyClass",
"(",
"Class",
"<",
"?",
">",
"beanClass",
",",
"String",
"field",
")",
"{",
"try",
"{",
"return",
"INSTANCE",
".",
"findPropertyClass",
"(",
"beanClass",
",",
"field",
")",
";",
"}",
"catch"... | Similar to {@link PropertyUtils#getPropertyClass(Class,List)} but returns the property class.
@param beanClass bean to be accessed
@param field bean's fieldName
@return bean's property class | [
"Similar",
"to",
"{",
"@link",
"PropertyUtils#getPropertyClass",
"(",
"Class",
"List",
")",
"}",
"but",
"returns",
"the",
"property",
"class",
"."
] | train | https://github.com/katharsis-project/katharsis-framework/blob/73d1a8763c49c5cf4643d43e2dbfedb647630c46/katharsis-core/src/main/java/io/katharsis/core/internal/utils/PropertyUtils.java#L63-L69 |
baidubce/bce-sdk-java | src/main/java/com/baidubce/services/lss/LssClient.java | LssClient.insertCuePoint | public InsertCuePointResponse insertCuePoint(String sessionId, String callback, Map<String, String> arguments) {
InsertCuePointRequest request = new InsertCuePointRequest()
.withSessionId(sessionId).withCallback(callback).withArguments(arguments);
return insertCuePoint(request);
} | java | public InsertCuePointResponse insertCuePoint(String sessionId, String callback, Map<String, String> arguments) {
InsertCuePointRequest request = new InsertCuePointRequest()
.withSessionId(sessionId).withCallback(callback).withArguments(arguments);
return insertCuePoint(request);
} | [
"public",
"InsertCuePointResponse",
"insertCuePoint",
"(",
"String",
"sessionId",
",",
"String",
"callback",
",",
"Map",
"<",
"String",
",",
"String",
">",
"arguments",
")",
"{",
"InsertCuePointRequest",
"request",
"=",
"new",
"InsertCuePointRequest",
"(",
")",
".... | Insert a cue point into your live session by live session id.
@param sessionId Live session id.
@param callback Call back method name.
@param arguments Call back method arguments.
@return the response | [
"Insert",
"a",
"cue",
"point",
"into",
"your",
"live",
"session",
"by",
"live",
"session",
"id",
"."
] | train | https://github.com/baidubce/bce-sdk-java/blob/f7140f28dd82121515c88ded7bfe769a37d0ec4a/src/main/java/com/baidubce/services/lss/LssClient.java#L1092-L1096 |
ben-manes/caffeine | simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/climbing/HillClimberWindowTinyLfuPolicy.java | HillClimberWindowTinyLfuPolicy.policies | public static Set<Policy> policies(Config config) {
HillClimberWindowTinyLfuSettings settings = new HillClimberWindowTinyLfuSettings(config);
Set<Policy> policies = new HashSet<>();
for (HillClimberType climber : settings.strategy()) {
for (double percentMain : settings.percentMain()) {
policies.add(new HillClimberWindowTinyLfuPolicy(climber, percentMain, settings));
}
}
return policies;
} | java | public static Set<Policy> policies(Config config) {
HillClimberWindowTinyLfuSettings settings = new HillClimberWindowTinyLfuSettings(config);
Set<Policy> policies = new HashSet<>();
for (HillClimberType climber : settings.strategy()) {
for (double percentMain : settings.percentMain()) {
policies.add(new HillClimberWindowTinyLfuPolicy(climber, percentMain, settings));
}
}
return policies;
} | [
"public",
"static",
"Set",
"<",
"Policy",
">",
"policies",
"(",
"Config",
"config",
")",
"{",
"HillClimberWindowTinyLfuSettings",
"settings",
"=",
"new",
"HillClimberWindowTinyLfuSettings",
"(",
"config",
")",
";",
"Set",
"<",
"Policy",
">",
"policies",
"=",
"ne... | Returns all variations of this policy based on the configuration parameters. | [
"Returns",
"all",
"variations",
"of",
"this",
"policy",
"based",
"on",
"the",
"configuration",
"parameters",
"."
] | train | https://github.com/ben-manes/caffeine/blob/4cf6d6e6a18ea2e8088f166261e5949343b0f2eb/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/climbing/HillClimberWindowTinyLfuPolicy.java#L103-L112 |
fcrepo3/fcrepo | fcrepo-server/src/main/java/org/fcrepo/server/access/WSDLServlet.java | WSDLServlet.doGet | @Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
String api = request.getParameter("api");
if (api == null || api.length() == 0) {
response.setContentType("text/html; charset=UTF-8");
getIndex(response.getWriter());
} else {
response.setContentType("text/xml; charset=UTF-8");
getWSDL(api.toUpperCase(), request.getRequestURL()
.toString(), response.getWriter());
}
response.flushBuffer();
} | java | @Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
String api = request.getParameter("api");
if (api == null || api.length() == 0) {
response.setContentType("text/html; charset=UTF-8");
getIndex(response.getWriter());
} else {
response.setContentType("text/xml; charset=UTF-8");
getWSDL(api.toUpperCase(), request.getRequestURL()
.toString(), response.getWriter());
}
response.flushBuffer();
} | [
"@",
"Override",
"public",
"void",
"doGet",
"(",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
")",
"throws",
"IOException",
",",
"ServletException",
"{",
"String",
"api",
"=",
"request",
".",
"getParameter",
"(",
"\"api\"",
")",
";",
... | Respond to an HTTP GET request. The single parameter, "api", indicates
which WSDL file to provide. If no parameters are given, a simple HTML
index is given instead. | [
"Respond",
"to",
"an",
"HTTP",
"GET",
"request",
".",
"The",
"single",
"parameter",
"api",
"indicates",
"which",
"WSDL",
"file",
"to",
"provide",
".",
"If",
"no",
"parameters",
"are",
"given",
"a",
"simple",
"HTML",
"index",
"is",
"given",
"instead",
"."
] | train | https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/access/WSDLServlet.java#L75-L91 |
mgormley/pacaya | src/main/java/edu/jhu/pacaya/parse/cky/intdata/IntNaryTree.java | IntNaryTree.readTreeInPtbFormat | public static IntNaryTree readTreeInPtbFormat(IntObjectBimap<String> lexAlphabet, IntObjectBimap<String> ntAlphabet, Reader reader) throws IOException {
QFiles.readUntilCharacter(reader, '(');
IntNaryTree root = IntNaryTree.readSubtreeInPtbFormat(lexAlphabet, ntAlphabet, reader);
QFiles.readUntilCharacter(reader, ')');
if (root == null) {
return null;
}
root.updateStartEnd();
return root;
} | java | public static IntNaryTree readTreeInPtbFormat(IntObjectBimap<String> lexAlphabet, IntObjectBimap<String> ntAlphabet, Reader reader) throws IOException {
QFiles.readUntilCharacter(reader, '(');
IntNaryTree root = IntNaryTree.readSubtreeInPtbFormat(lexAlphabet, ntAlphabet, reader);
QFiles.readUntilCharacter(reader, ')');
if (root == null) {
return null;
}
root.updateStartEnd();
return root;
} | [
"public",
"static",
"IntNaryTree",
"readTreeInPtbFormat",
"(",
"IntObjectBimap",
"<",
"String",
">",
"lexAlphabet",
",",
"IntObjectBimap",
"<",
"String",
">",
"ntAlphabet",
",",
"Reader",
"reader",
")",
"throws",
"IOException",
"{",
"QFiles",
".",
"readUntilCharacte... | Reads a full tree in Penn Treebank format. Such a tree should include an
outer set of parentheses. The returned tree will have initialized the
start/end fields. | [
"Reads",
"a",
"full",
"tree",
"in",
"Penn",
"Treebank",
"format",
".",
"Such",
"a",
"tree",
"should",
"include",
"an",
"outer",
"set",
"of",
"parentheses",
".",
"The",
"returned",
"tree",
"will",
"have",
"initialized",
"the",
"start",
"/",
"end",
"fields",... | train | https://github.com/mgormley/pacaya/blob/786294cbac7cc65dbc32210c10acc32ed0c69233/src/main/java/edu/jhu/pacaya/parse/cky/intdata/IntNaryTree.java#L133-L142 |
UrielCh/ovh-java-sdk | ovh-java-sdk-cloud/src/main/java/net/minidev/ovh/api/ApiOvhCloud.java | ApiOvhCloud.serviceName_pca_pcaServiceName_sessions_sessionId_restore_POST | public OvhTask serviceName_pca_pcaServiceName_sessions_sessionId_restore_POST(String serviceName, String pcaServiceName, String sessionId) throws IOException {
String qPath = "/cloud/{serviceName}/pca/{pcaServiceName}/sessions/{sessionId}/restore";
StringBuilder sb = path(qPath, serviceName, pcaServiceName, sessionId);
String resp = exec(qPath, "POST", sb.toString(), null);
return convertTo(resp, OvhTask.class);
} | java | public OvhTask serviceName_pca_pcaServiceName_sessions_sessionId_restore_POST(String serviceName, String pcaServiceName, String sessionId) throws IOException {
String qPath = "/cloud/{serviceName}/pca/{pcaServiceName}/sessions/{sessionId}/restore";
StringBuilder sb = path(qPath, serviceName, pcaServiceName, sessionId);
String resp = exec(qPath, "POST", sb.toString(), null);
return convertTo(resp, OvhTask.class);
} | [
"public",
"OvhTask",
"serviceName_pca_pcaServiceName_sessions_sessionId_restore_POST",
"(",
"String",
"serviceName",
",",
"String",
"pcaServiceName",
",",
"String",
"sessionId",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/cloud/{serviceName}/pca/{pcaServiceNa... | Create a restore task for session
REST: POST /cloud/{serviceName}/pca/{pcaServiceName}/sessions/{sessionId}/restore
@param serviceName [required] The internal name of your public cloud passport
@param pcaServiceName [required] The internal name of your PCA offer
@param sessionId [required] Session ID
@deprecated | [
"Create",
"a",
"restore",
"task",
"for",
"session"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-cloud/src/main/java/net/minidev/ovh/api/ApiOvhCloud.java#L2450-L2455 |
mabe02/lanterna | src/main/java/com/googlecode/lanterna/TerminalTextUtils.java | TerminalTextUtils.fitString | public static String fitString(String string, int fromColumn, int availableColumnSpace) {
if(availableColumnSpace <= 0) {
return "";
}
StringBuilder bob = new StringBuilder();
int column = 0;
int index = 0;
while(index < string.length() && column < fromColumn) {
char c = string.charAt(index++);
column += TerminalTextUtils.isCharCJK(c) ? 2 : 1;
}
if(column > fromColumn) {
bob.append(" ");
availableColumnSpace--;
}
while(availableColumnSpace > 0 && index < string.length()) {
char c = string.charAt(index++);
availableColumnSpace -= TerminalTextUtils.isCharCJK(c) ? 2 : 1;
if(availableColumnSpace < 0) {
bob.append(' ');
}
else {
bob.append(c);
}
}
return bob.toString();
} | java | public static String fitString(String string, int fromColumn, int availableColumnSpace) {
if(availableColumnSpace <= 0) {
return "";
}
StringBuilder bob = new StringBuilder();
int column = 0;
int index = 0;
while(index < string.length() && column < fromColumn) {
char c = string.charAt(index++);
column += TerminalTextUtils.isCharCJK(c) ? 2 : 1;
}
if(column > fromColumn) {
bob.append(" ");
availableColumnSpace--;
}
while(availableColumnSpace > 0 && index < string.length()) {
char c = string.charAt(index++);
availableColumnSpace -= TerminalTextUtils.isCharCJK(c) ? 2 : 1;
if(availableColumnSpace < 0) {
bob.append(' ');
}
else {
bob.append(c);
}
}
return bob.toString();
} | [
"public",
"static",
"String",
"fitString",
"(",
"String",
"string",
",",
"int",
"fromColumn",
",",
"int",
"availableColumnSpace",
")",
"{",
"if",
"(",
"availableColumnSpace",
"<=",
"0",
")",
"{",
"return",
"\"\"",
";",
"}",
"StringBuilder",
"bob",
"=",
"new"... | Given a string that may or may not contain CJK characters, returns the substring which will fit inside
<code>availableColumnSpace</code> columns. This method does not handle special cases like tab or new-line.
<p>
This overload has a {@code fromColumn} parameter that specified where inside the string to start fitting. Please
notice that {@code fromColumn} is not a character index inside the string, but a column index as if the string
has been printed from the left-most side of the terminal. So if the string is "日本語", fromColumn set to 1 will
not starting counting from the second character ("本") in the string but from the CJK filler character belonging
to "日". If you want to count from a particular character index inside the string, please pass in a substring
and use fromColumn set to 0.
@param string The string to fit inside the availableColumnSpace
@param fromColumn From what column of the input string to start fitting (see description above!)
@param availableColumnSpace Number of columns to fit the string inside
@return The whole or part of the input string which will fit inside the supplied availableColumnSpace | [
"Given",
"a",
"string",
"that",
"may",
"or",
"may",
"not",
"contain",
"CJK",
"characters",
"returns",
"the",
"substring",
"which",
"will",
"fit",
"inside",
"<code",
">",
"availableColumnSpace<",
"/",
"code",
">",
"columns",
".",
"This",
"method",
"does",
"no... | train | https://github.com/mabe02/lanterna/blob/8dfd62206ff46ab10223b2ef2dbb0a2c51850954/src/main/java/com/googlecode/lanterna/TerminalTextUtils.java#L269-L297 |
morimekta/utils | io-util/src/main/java/net/morimekta/util/FileWatcher.java | FileWatcher.removeWatcher | public boolean removeWatcher(Listener watcher) {
if (watcher == null) {
throw new IllegalArgumentException("Null watcher removed");
}
synchronized (mutex) {
AtomicBoolean removed = new AtomicBoolean(removeFromListeners(watchers, watcher));
watchedFiles.forEach((path, suppliers) -> {
if (removeFromListeners(suppliers, watcher)) {
removed.set(true);
}
});
return removed.get();
}
} | java | public boolean removeWatcher(Listener watcher) {
if (watcher == null) {
throw new IllegalArgumentException("Null watcher removed");
}
synchronized (mutex) {
AtomicBoolean removed = new AtomicBoolean(removeFromListeners(watchers, watcher));
watchedFiles.forEach((path, suppliers) -> {
if (removeFromListeners(suppliers, watcher)) {
removed.set(true);
}
});
return removed.get();
}
} | [
"public",
"boolean",
"removeWatcher",
"(",
"Listener",
"watcher",
")",
"{",
"if",
"(",
"watcher",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Null watcher removed\"",
")",
";",
"}",
"synchronized",
"(",
"mutex",
")",
"{",
"Atomi... | Remove a watcher from the list of listeners.
@param watcher The watcher to be removed.
@return True if the watcher was removed from the list. | [
"Remove",
"a",
"watcher",
"from",
"the",
"list",
"of",
"listeners",
"."
] | train | https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/FileWatcher.java#L344-L358 |
neo4j/neo4j-java-driver | driver/src/main/java/org/neo4j/driver/internal/util/CertificateTool.java | CertificateTool.saveX509Cert | public static void saveX509Cert( Certificate cert, File certFile ) throws GeneralSecurityException, IOException
{
saveX509Cert( new Certificate[]{cert}, certFile );
} | java | public static void saveX509Cert( Certificate cert, File certFile ) throws GeneralSecurityException, IOException
{
saveX509Cert( new Certificate[]{cert}, certFile );
} | [
"public",
"static",
"void",
"saveX509Cert",
"(",
"Certificate",
"cert",
",",
"File",
"certFile",
")",
"throws",
"GeneralSecurityException",
",",
"IOException",
"{",
"saveX509Cert",
"(",
"new",
"Certificate",
"[",
"]",
"{",
"cert",
"}",
",",
"certFile",
")",
";... | Save a certificate to a file. Remove all the content in the file if there is any before.
@param cert
@param certFile
@throws GeneralSecurityException
@throws IOException | [
"Save",
"a",
"certificate",
"to",
"a",
"file",
".",
"Remove",
"all",
"the",
"content",
"in",
"the",
"file",
"if",
"there",
"is",
"any",
"before",
"."
] | train | https://github.com/neo4j/neo4j-java-driver/blob/8dad6c48251fa1ab7017e72d9998a24fa2337a22/driver/src/main/java/org/neo4j/driver/internal/util/CertificateTool.java#L72-L75 |
couchbase/couchbase-lite-java-core | src/main/java/com/couchbase/lite/auth/AuthenticatorFactory.java | AuthenticatorFactory.createFacebookAuthenticator | public static Authenticator createFacebookAuthenticator(String token) {
Map<String, String> params = new HashMap<String, String>();
params.put("access_token", token);
return new TokenAuthenticator("_facebook", params);
} | java | public static Authenticator createFacebookAuthenticator(String token) {
Map<String, String> params = new HashMap<String, String>();
params.put("access_token", token);
return new TokenAuthenticator("_facebook", params);
} | [
"public",
"static",
"Authenticator",
"createFacebookAuthenticator",
"(",
"String",
"token",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"params",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"params",
".",
"put",
"(",
... | /*
Creates an Authenticator that knows how to do Facebook authentication.
@param token Facebook access token | [
"/",
"*",
"Creates",
"an",
"Authenticator",
"that",
"knows",
"how",
"to",
"do",
"Facebook",
"authentication",
"."
] | train | https://github.com/couchbase/couchbase-lite-java-core/blob/3b275642e2d2f231fd155ad9def9c5e9eff3118e/src/main/java/com/couchbase/lite/auth/AuthenticatorFactory.java#L39-L43 |
lecousin/java-framework-core | net.lecousin.core/src/main/java/net/lecousin/framework/math/RangeLong.java | RangeLong.removeIntersect | public Pair<RangeLong,RangeLong> removeIntersect(RangeLong o) {
if (o.max < min || o.min > max) // o is outside: no intersection
return new Pair<>(copy(), null);
if (o.min <= min) {
// nothing before
if (o.max >= max)
return new Pair<>(null, null); // o is fully overlapping this
return new Pair<>(null, new RangeLong(o.max + 1, max));
}
if (o.max >= max) {
// nothing after
return new Pair<>(new RangeLong(min, o.min - 1), null);
}
// in the middle
return new Pair<>(new RangeLong(min, o.min - 1), new RangeLong(o.max + 1, max));
} | java | public Pair<RangeLong,RangeLong> removeIntersect(RangeLong o) {
if (o.max < min || o.min > max) // o is outside: no intersection
return new Pair<>(copy(), null);
if (o.min <= min) {
// nothing before
if (o.max >= max)
return new Pair<>(null, null); // o is fully overlapping this
return new Pair<>(null, new RangeLong(o.max + 1, max));
}
if (o.max >= max) {
// nothing after
return new Pair<>(new RangeLong(min, o.min - 1), null);
}
// in the middle
return new Pair<>(new RangeLong(min, o.min - 1), new RangeLong(o.max + 1, max));
} | [
"public",
"Pair",
"<",
"RangeLong",
",",
"RangeLong",
">",
"removeIntersect",
"(",
"RangeLong",
"o",
")",
"{",
"if",
"(",
"o",
".",
"max",
"<",
"min",
"||",
"o",
".",
"min",
">",
"max",
")",
"// o is outside: no intersection\r",
"return",
"new",
"Pair",
... | Remove the intersection between this range and the given range, and return the range before and the range after the intersection. | [
"Remove",
"the",
"intersection",
"between",
"this",
"range",
"and",
"the",
"given",
"range",
"and",
"return",
"the",
"range",
"before",
"and",
"the",
"range",
"after",
"the",
"intersection",
"."
] | train | https://github.com/lecousin/java-framework-core/blob/b0c893b44bfde2c03f90ea846a49ef5749d598f3/net.lecousin.core/src/main/java/net/lecousin/framework/math/RangeLong.java#L87-L102 |
sd4324530/fastweixin | src/main/java/com/github/sd4324530/fastweixin/api/DataCubeAPI.java | DataCubeAPI.getUserRead | public GetUserReadResponse getUserRead(Date beginDate, Date endDate) {
BeanUtil.requireNonNull(beginDate, "beginDate is null");
BeanUtil.requireNonNull(endDate, "endDate is null");
GetUserReadResponse response = null;
String url = BASE_API_URL + "datacube/getuserread?access_token=#";
Map<String, String> param = new HashMap<String, String>();
param.put("begin_date", DATE_FORMAT.format(beginDate));
param.put("end_date", DATE_FORMAT.format(endDate));
String json = JSONUtil.toJson(param);
BaseResponse r = executePost(url, json);
String resultJson = isSuccess(r.getErrcode()) ? r.getErrmsg() : r.toJsonString();
response = JSONUtil.toBean(resultJson, GetUserReadResponse.class);
return response;
} | java | public GetUserReadResponse getUserRead(Date beginDate, Date endDate) {
BeanUtil.requireNonNull(beginDate, "beginDate is null");
BeanUtil.requireNonNull(endDate, "endDate is null");
GetUserReadResponse response = null;
String url = BASE_API_URL + "datacube/getuserread?access_token=#";
Map<String, String> param = new HashMap<String, String>();
param.put("begin_date", DATE_FORMAT.format(beginDate));
param.put("end_date", DATE_FORMAT.format(endDate));
String json = JSONUtil.toJson(param);
BaseResponse r = executePost(url, json);
String resultJson = isSuccess(r.getErrcode()) ? r.getErrmsg() : r.toJsonString();
response = JSONUtil.toBean(resultJson, GetUserReadResponse.class);
return response;
} | [
"public",
"GetUserReadResponse",
"getUserRead",
"(",
"Date",
"beginDate",
",",
"Date",
"endDate",
")",
"{",
"BeanUtil",
".",
"requireNonNull",
"(",
"beginDate",
",",
"\"beginDate is null\"",
")",
";",
"BeanUtil",
".",
"requireNonNull",
"(",
"endDate",
",",
"\"endD... | 获取图文统计数据,最大跨度为3天
@param beginDate 开始时间
@param endDate 结束时间
@return 图文统计数据 | [
"获取图文统计数据,最大跨度为3天"
] | train | https://github.com/sd4324530/fastweixin/blob/6bc0a7abfa23aad0dbad4c3123a47a7fb53f3447/src/main/java/com/github/sd4324530/fastweixin/api/DataCubeAPI.java#L122-L135 |
Bedework/bw-util | bw-util-directory/src/main/java/org/bedework/util/directory/common/Directory.java | Directory.searchOne | public boolean searchOne(String base, String filter) throws NamingException {
return search(base, filter, scopeOne);
} | java | public boolean searchOne(String base, String filter) throws NamingException {
return search(base, filter, scopeOne);
} | [
"public",
"boolean",
"searchOne",
"(",
"String",
"base",
",",
"String",
"filter",
")",
"throws",
"NamingException",
"{",
"return",
"search",
"(",
"base",
",",
"filter",
",",
"scopeOne",
")",
";",
"}"
] | Carry out a one level search
@param base
@param filter
@return DirSearchResult
@throws NamingException | [
"Carry",
"out",
"a",
"one",
"level",
"search"
] | train | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-directory/src/main/java/org/bedework/util/directory/common/Directory.java#L107-L109 |
anotheria/configureme | src/main/java/org/configureme/repository/Artefact.java | Artefact.addAttributeValue | public void addAttributeValue(final String attributeName, final Value attributeValue, Environment in) {
if (in == null)
in = GlobalEnvironment.INSTANCE;
Attribute attr = attributes.get(attributeName);
if (attr == null) {
attr = new Attribute(attributeName);
attributes.put(attr.getName(), attr);
}
attr.addValue(attributeValue, in);
Map<String, Object> valueMap = contentMap.get(in);
if(valueMap == null)
valueMap = new HashMap<>();
valueMap.put(attributeName, attributeValue.getRaw());
contentMap.put(in, valueMap);
//TODO check for loops and process such situation
if (attributeValue instanceof IncludeValue)
externalConfigurations.add(((IncludeValue) attributeValue).getConfigName());
} | java | public void addAttributeValue(final String attributeName, final Value attributeValue, Environment in) {
if (in == null)
in = GlobalEnvironment.INSTANCE;
Attribute attr = attributes.get(attributeName);
if (attr == null) {
attr = new Attribute(attributeName);
attributes.put(attr.getName(), attr);
}
attr.addValue(attributeValue, in);
Map<String, Object> valueMap = contentMap.get(in);
if(valueMap == null)
valueMap = new HashMap<>();
valueMap.put(attributeName, attributeValue.getRaw());
contentMap.put(in, valueMap);
//TODO check for loops and process such situation
if (attributeValue instanceof IncludeValue)
externalConfigurations.add(((IncludeValue) attributeValue).getConfigName());
} | [
"public",
"void",
"addAttributeValue",
"(",
"final",
"String",
"attributeName",
",",
"final",
"Value",
"attributeValue",
",",
"Environment",
"in",
")",
"{",
"if",
"(",
"in",
"==",
"null",
")",
"in",
"=",
"GlobalEnvironment",
".",
"INSTANCE",
";",
"Attribute",
... | Adds an attribute value. If the attribute doesn't exist it will be created.
@param attributeName the name of the attribute.
@param attributeValue the value of the attribute in the given environment.
@param in the environment in which the attribute value applies | [
"Adds",
"an",
"attribute",
"value",
".",
"If",
"the",
"attribute",
"doesn",
"t",
"exist",
"it",
"will",
"be",
"created",
"."
] | train | https://github.com/anotheria/configureme/blob/1f52dd9109349623190586bdf5a592de8016e1fa/src/main/java/org/configureme/repository/Artefact.java#L91-L109 |
lucee/Lucee | core/src/main/java/lucee/commons/io/res/util/ResourceUtil.java | ResourceUtil.checkMoveToOK | public static void checkMoveToOK(Resource source, Resource target) throws IOException {
if (!source.exists()) {
throw new IOException("can't move [" + source.getPath() + "] to [" + target.getPath() + "], source file does not exist");
}
if (source.isDirectory() && target.isFile()) throw new IOException("can't move [" + source.getPath() + "] directory to [" + target.getPath() + "], target is a file");
if (source.isFile() && target.isDirectory()) throw new IOException("can't move [" + source.getPath() + "] file to [" + target.getPath() + "], target is a directory");
} | java | public static void checkMoveToOK(Resource source, Resource target) throws IOException {
if (!source.exists()) {
throw new IOException("can't move [" + source.getPath() + "] to [" + target.getPath() + "], source file does not exist");
}
if (source.isDirectory() && target.isFile()) throw new IOException("can't move [" + source.getPath() + "] directory to [" + target.getPath() + "], target is a file");
if (source.isFile() && target.isDirectory()) throw new IOException("can't move [" + source.getPath() + "] file to [" + target.getPath() + "], target is a directory");
} | [
"public",
"static",
"void",
"checkMoveToOK",
"(",
"Resource",
"source",
",",
"Resource",
"target",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"source",
".",
"exists",
"(",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"can't move [\"",
"+",
... | check if moveing a file is ok with the rules for the Resource interface, to not change this
rules.
@param source
@param target
@throws IOException | [
"check",
"if",
"moveing",
"a",
"file",
"is",
"ok",
"with",
"the",
"rules",
"for",
"the",
"Resource",
"interface",
"to",
"not",
"change",
"this",
"rules",
"."
] | train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/commons/io/res/util/ResourceUtil.java#L1340-L1346 |
hdbeukel/james-core | src/main/java/org/jamesframework/core/search/LocalSearch.java | LocalSearch.updateCurrentAndBestSolution | protected boolean updateCurrentAndBestSolution(SolutionType solution){
return updateCurrentAndBestSolution(solution, getProblem().evaluate(solution), getProblem().validate(solution));
} | java | protected boolean updateCurrentAndBestSolution(SolutionType solution){
return updateCurrentAndBestSolution(solution, getProblem().evaluate(solution), getProblem().validate(solution));
} | [
"protected",
"boolean",
"updateCurrentAndBestSolution",
"(",
"SolutionType",
"solution",
")",
"{",
"return",
"updateCurrentAndBestSolution",
"(",
"solution",
",",
"getProblem",
"(",
")",
".",
"evaluate",
"(",
"solution",
")",
",",
"getProblem",
"(",
")",
".",
"val... | Update the current and best solution during search. The given solution is evaluated and validated,
followed by an update of the current solution (also if it is invalid). Conversely, the best solution
is only updated if the given solution is valid and improves over the best solution found so far.
@param solution new current solution
@return <code>true</code> if the best solution has been updated | [
"Update",
"the",
"current",
"and",
"best",
"solution",
"during",
"search",
".",
"The",
"given",
"solution",
"is",
"evaluated",
"and",
"validated",
"followed",
"by",
"an",
"update",
"of",
"the",
"current",
"solution",
"(",
"also",
"if",
"it",
"is",
"invalid",... | train | https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/search/LocalSearch.java#L263-L265 |
jglobus/JGlobus | gram/src/main/java/org/globus/rsl/Binding.java | Binding.toRSL | public void toRSL(StringBuffer buf, boolean explicitConcat) {
buf.append("(");
buf.append( getName() );
buf.append(" ");
getValue().toRSL(buf, explicitConcat);
buf.append(")");
} | java | public void toRSL(StringBuffer buf, boolean explicitConcat) {
buf.append("(");
buf.append( getName() );
buf.append(" ");
getValue().toRSL(buf, explicitConcat);
buf.append(")");
} | [
"public",
"void",
"toRSL",
"(",
"StringBuffer",
"buf",
",",
"boolean",
"explicitConcat",
")",
"{",
"buf",
".",
"append",
"(",
"\"(\"",
")",
";",
"buf",
".",
"append",
"(",
"getName",
"(",
")",
")",
";",
"buf",
".",
"append",
"(",
"\" \"",
")",
";",
... | Produces a RSL representation of this variable definition.
@param buf buffer to add the RSL representation to.
@param explicitConcat if true explicit concatination will
be used in RSL strings. | [
"Produces",
"a",
"RSL",
"representation",
"of",
"this",
"variable",
"definition",
"."
] | train | https://github.com/jglobus/JGlobus/blob/e14f6f6636544fd84298f9cec749d626ea971930/gram/src/main/java/org/globus/rsl/Binding.java#L93-L99 |
graphhopper/graphhopper | core/src/main/java/com/graphhopper/reader/ReaderElement.java | ReaderElement.hasTag | public boolean hasTag(String key, String... values) {
Object value = properties.get(key);
if (value == null)
return false;
// tag present, no values given: success
if (values.length == 0)
return true;
for (String val : values) {
if (val.equals(value))
return true;
}
return false;
} | java | public boolean hasTag(String key, String... values) {
Object value = properties.get(key);
if (value == null)
return false;
// tag present, no values given: success
if (values.length == 0)
return true;
for (String val : values) {
if (val.equals(value))
return true;
}
return false;
} | [
"public",
"boolean",
"hasTag",
"(",
"String",
"key",
",",
"String",
"...",
"values",
")",
"{",
"Object",
"value",
"=",
"properties",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"return",
"false",
";",
"// tag present, no valu... | Check that a given tag has one of the specified values. If no values are given, just checks
for presence of the tag | [
"Check",
"that",
"a",
"given",
"tag",
"has",
"one",
"of",
"the",
"specified",
"values",
".",
"If",
"no",
"values",
"are",
"given",
"just",
"checks",
"for",
"presence",
"of",
"the",
"tag"
] | train | https://github.com/graphhopper/graphhopper/blob/c235e306e6e823043cadcc41ead0e685bdebf737/core/src/main/java/com/graphhopper/reader/ReaderElement.java#L113-L127 |
Stratio/stratio-cassandra | src/java/org/apache/cassandra/cli/CliClient.java | CliClient.showColumnMeta | private void showColumnMeta(PrintStream output, CfDef cfDef, ColumnDef colDef)
{
output.append(NEWLINE + TAB + TAB + "{");
final AbstractType<?> comparator = getFormatType(cfDef.column_type.equals("Super")
? cfDef.subcomparator_type
: cfDef.comparator_type);
output.append("column_name : '" + CliUtils.escapeSQLString(comparator.getString(colDef.name)) + "'," + NEWLINE);
String validationClass = normaliseType(colDef.validation_class, "org.apache.cassandra.db.marshal");
output.append(TAB + TAB + "validation_class : " + CliUtils.escapeSQLString(validationClass));
if (colDef.isSetIndex_name())
{
output.append(",").append(NEWLINE)
.append(TAB + TAB + "index_name : '" + CliUtils.escapeSQLString(colDef.index_name) + "'," + NEWLINE)
.append(TAB + TAB + "index_type : " + CliUtils.escapeSQLString(Integer.toString(colDef.index_type.getValue())));
if (colDef.index_options != null && !colDef.index_options.isEmpty())
{
output.append(",").append(NEWLINE);
output.append(TAB + TAB + "index_options : {" + NEWLINE);
int numOpts = colDef.index_options.size();
for (Map.Entry<String, String> entry : colDef.index_options.entrySet())
{
String option = CliUtils.escapeSQLString(entry.getKey());
String optionValue = CliUtils.escapeSQLString(entry.getValue());
output.append(TAB + TAB + TAB)
.append("'" + option + "' : '")
.append(optionValue)
.append("'");
if (--numOpts > 0)
output.append(",").append(NEWLINE);
}
output.append("}");
}
}
output.append("}");
} | java | private void showColumnMeta(PrintStream output, CfDef cfDef, ColumnDef colDef)
{
output.append(NEWLINE + TAB + TAB + "{");
final AbstractType<?> comparator = getFormatType(cfDef.column_type.equals("Super")
? cfDef.subcomparator_type
: cfDef.comparator_type);
output.append("column_name : '" + CliUtils.escapeSQLString(comparator.getString(colDef.name)) + "'," + NEWLINE);
String validationClass = normaliseType(colDef.validation_class, "org.apache.cassandra.db.marshal");
output.append(TAB + TAB + "validation_class : " + CliUtils.escapeSQLString(validationClass));
if (colDef.isSetIndex_name())
{
output.append(",").append(NEWLINE)
.append(TAB + TAB + "index_name : '" + CliUtils.escapeSQLString(colDef.index_name) + "'," + NEWLINE)
.append(TAB + TAB + "index_type : " + CliUtils.escapeSQLString(Integer.toString(colDef.index_type.getValue())));
if (colDef.index_options != null && !colDef.index_options.isEmpty())
{
output.append(",").append(NEWLINE);
output.append(TAB + TAB + "index_options : {" + NEWLINE);
int numOpts = colDef.index_options.size();
for (Map.Entry<String, String> entry : colDef.index_options.entrySet())
{
String option = CliUtils.escapeSQLString(entry.getKey());
String optionValue = CliUtils.escapeSQLString(entry.getValue());
output.append(TAB + TAB + TAB)
.append("'" + option + "' : '")
.append(optionValue)
.append("'");
if (--numOpts > 0)
output.append(",").append(NEWLINE);
}
output.append("}");
}
}
output.append("}");
} | [
"private",
"void",
"showColumnMeta",
"(",
"PrintStream",
"output",
",",
"CfDef",
"cfDef",
",",
"ColumnDef",
"colDef",
")",
"{",
"output",
".",
"append",
"(",
"NEWLINE",
"+",
"TAB",
"+",
"TAB",
"+",
"\"{\"",
")",
";",
"final",
"AbstractType",
"<",
"?",
">... | Writes the supplied ColumnDef to the StringBuilder as a cli script.
@param output The File to write to.
@param cfDef The CfDef as a source for comparator/validator
@param colDef The Column Definition to export | [
"Writes",
"the",
"supplied",
"ColumnDef",
"to",
"the",
"StringBuilder",
"as",
"a",
"cli",
"script",
"."
] | train | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/cli/CliClient.java#L1917-L1955 |
GeoLatte/geolatte-common | src/main/java/org/geolatte/common/dataformats/json/jackson/MultiPointSerializer.java | MultiPointSerializer.writeShapeSpecificSerialization | @Override
public void writeShapeSpecificSerialization(MultiPoint value, JsonGenerator jgen, SerializerProvider provider)
throws IOException {
jgen.writeFieldName( "type");
jgen.writeString( "MultiPoint");
jgen.writeArrayFieldStart( "coordinates");
// set beanproperty to null since we are not serializing a real property
JsonSerializer<Object> ser = provider.findValueSerializer(Float.class, null);
for (int i = 0; i < value.getNumGeometries(); i++) {
Point pnt = value.getGeometryN(i);
jgen.writeStartArray();
ser.serialize( (float) pnt.getX(), jgen, provider);
ser.serialize( (float) pnt.getY(), jgen, provider);
jgen.writeEndArray();
}
jgen.writeEndArray();
} | java | @Override
public void writeShapeSpecificSerialization(MultiPoint value, JsonGenerator jgen, SerializerProvider provider)
throws IOException {
jgen.writeFieldName( "type");
jgen.writeString( "MultiPoint");
jgen.writeArrayFieldStart( "coordinates");
// set beanproperty to null since we are not serializing a real property
JsonSerializer<Object> ser = provider.findValueSerializer(Float.class, null);
for (int i = 0; i < value.getNumGeometries(); i++) {
Point pnt = value.getGeometryN(i);
jgen.writeStartArray();
ser.serialize( (float) pnt.getX(), jgen, provider);
ser.serialize( (float) pnt.getY(), jgen, provider);
jgen.writeEndArray();
}
jgen.writeEndArray();
} | [
"@",
"Override",
"public",
"void",
"writeShapeSpecificSerialization",
"(",
"MultiPoint",
"value",
",",
"JsonGenerator",
"jgen",
",",
"SerializerProvider",
"provider",
")",
"throws",
"IOException",
"{",
"jgen",
".",
"writeFieldName",
"(",
"\"type\"",
")",
";",
"jgen"... | Method that can be called to ask implementation to serialize values of type this serializer handles.
@param value Value to serialize; can not be null.
@param jgen Generator used to output resulting Json content
@param provider Provider that can be used to get serializers for serializing Objects value contains, if any.
@throws java.io.IOException If serialization failed. | [
"Method",
"that",
"can",
"be",
"called",
"to",
"ask",
"implementation",
"to",
"serialize",
"values",
"of",
"type",
"this",
"serializer",
"handles",
"."
] | train | https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/dataformats/json/jackson/MultiPointSerializer.java#L59-L75 |
google/closure-compiler | src/com/google/javascript/jscomp/TypeInference.java | TypeInference.backwardsInferenceFromCallSite | private void backwardsInferenceFromCallSite(Node n, FunctionType fnType, FlowScope scope) {
boolean updatedFnType = inferTemplatedTypesForCall(n, fnType, scope);
if (updatedFnType) {
fnType = n.getFirstChild().getJSType().toMaybeFunctionType();
}
updateTypeOfArguments(n, fnType);
updateBind(n);
} | java | private void backwardsInferenceFromCallSite(Node n, FunctionType fnType, FlowScope scope) {
boolean updatedFnType = inferTemplatedTypesForCall(n, fnType, scope);
if (updatedFnType) {
fnType = n.getFirstChild().getJSType().toMaybeFunctionType();
}
updateTypeOfArguments(n, fnType);
updateBind(n);
} | [
"private",
"void",
"backwardsInferenceFromCallSite",
"(",
"Node",
"n",
",",
"FunctionType",
"fnType",
",",
"FlowScope",
"scope",
")",
"{",
"boolean",
"updatedFnType",
"=",
"inferTemplatedTypesForCall",
"(",
"n",
",",
"fnType",
",",
"scope",
")",
";",
"if",
"(",
... | We only do forward type inference. We do not do full backwards type inference.
In other words, if we have,
<code>
var x = f();
g(x);
</code>
a forward type-inference engine would try to figure out the type
of "x" from the return type of "f". A backwards type-inference engine
would try to figure out the type of "x" from the parameter type of "g".
<p>However, there are a few special syntactic forms where we do some some half-assed backwards
type-inference, because programmers expect it in this day and age. To take an example from
Java,
<code>
List<String> x = Lists.newArrayList();
</code>
The Java compiler will be able to infer the generic type of the List returned by
newArrayList().
<p>In much the same way, we do some special-case backwards inference for JS. Those cases are
enumerated here. | [
"We",
"only",
"do",
"forward",
"type",
"inference",
".",
"We",
"do",
"not",
"do",
"full",
"backwards",
"type",
"inference",
"."
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/TypeInference.java#L1617-L1624 |
SvenEwald/xmlbeam | src/main/java/org/xmlbeam/util/intern/ReflectionHelper.java | ReflectionHelper.getCallableFactoryForParams | public static Method getCallableFactoryForParams(final Class<?> type, final Class<?>... params) {
for (Method m : type.getMethods()) {
if ((m.getModifiers() & PUBLIC_STATIC_MODIFIER) != PUBLIC_STATIC_MODIFIER) {
continue;
}
if (!type.isAssignableFrom(m.getReturnType())) {
continue;
}
if (!Arrays.equals(m.getParameterTypes(), params)) {
continue;
}
if (!VALID_FACTORY_METHOD_NAMES.matcher(m.getName()).matches()) {
continue;
}
return m;
}
return null;
} | java | public static Method getCallableFactoryForParams(final Class<?> type, final Class<?>... params) {
for (Method m : type.getMethods()) {
if ((m.getModifiers() & PUBLIC_STATIC_MODIFIER) != PUBLIC_STATIC_MODIFIER) {
continue;
}
if (!type.isAssignableFrom(m.getReturnType())) {
continue;
}
if (!Arrays.equals(m.getParameterTypes(), params)) {
continue;
}
if (!VALID_FACTORY_METHOD_NAMES.matcher(m.getName()).matches()) {
continue;
}
return m;
}
return null;
} | [
"public",
"static",
"Method",
"getCallableFactoryForParams",
"(",
"final",
"Class",
"<",
"?",
">",
"type",
",",
"final",
"Class",
"<",
"?",
">",
"...",
"params",
")",
"{",
"for",
"(",
"Method",
"m",
":",
"type",
".",
"getMethods",
"(",
")",
")",
"{",
... | Search for a static factory method returning the target type.
@param type
@param params
@return factory method or null if it is not found. | [
"Search",
"for",
"a",
"static",
"factory",
"method",
"returning",
"the",
"target",
"type",
"."
] | train | https://github.com/SvenEwald/xmlbeam/blob/acaac1b8fa28d246f17187f5e3c6696458a0b447/src/main/java/org/xmlbeam/util/intern/ReflectionHelper.java#L330-L347 |
drewwills/cernunnos | cernunnos-core/src/main/java/org/danann/cernunnos/sql/UpsertTask.java | UpsertTask.doUpdate | protected int doUpdate(JdbcTemplate jdbcTemplate, TaskRequest req, TaskResponse res) {
//Setup the update parameters and setter
final List<Phrase> parametersInUse = update_parameters != null ? update_parameters : parameters;
final PreparedStatementSetter preparedStatementSetter = new PhraseParameterPreparedStatementSetter(parametersInUse, req, res);
//Get the update sql and execute the update.
final String fUpdateSql = (String) update_sql.evaluate(req, res);
return jdbcTemplate.update(fUpdateSql, preparedStatementSetter);
} | java | protected int doUpdate(JdbcTemplate jdbcTemplate, TaskRequest req, TaskResponse res) {
//Setup the update parameters and setter
final List<Phrase> parametersInUse = update_parameters != null ? update_parameters : parameters;
final PreparedStatementSetter preparedStatementSetter = new PhraseParameterPreparedStatementSetter(parametersInUse, req, res);
//Get the update sql and execute the update.
final String fUpdateSql = (String) update_sql.evaluate(req, res);
return jdbcTemplate.update(fUpdateSql, preparedStatementSetter);
} | [
"protected",
"int",
"doUpdate",
"(",
"JdbcTemplate",
"jdbcTemplate",
",",
"TaskRequest",
"req",
",",
"TaskResponse",
"res",
")",
"{",
"//Setup the update parameters and setter",
"final",
"List",
"<",
"Phrase",
">",
"parametersInUse",
"=",
"update_parameters",
"!=",
"n... | Executes the update and returns the affected row count
Moved to its own method to reduce possibility for variable name confusion | [
"Executes",
"the",
"update",
"and",
"returns",
"the",
"affected",
"row",
"count"
] | train | https://github.com/drewwills/cernunnos/blob/dc6848e0253775e22b6c869fd06506d4ddb6d728/cernunnos-core/src/main/java/org/danann/cernunnos/sql/UpsertTask.java#L158-L166 |
timewalker74/ffmq | core/src/main/java/net/timewalker/ffmq4/storage/data/impl/BlockBasedDataStoreTools.java | BlockBasedDataStoreTools.findJournalFiles | public static File[] findJournalFiles( String baseName , File dataFolder )
{
final String journalBase = baseName+JournalFile.SUFFIX;
File[] journalFiles = dataFolder.listFiles(new FileFilter() {
/*
* (non-Javadoc)
* @see java.io.FileFilter#accept(java.io.File)
*/
@Override
public boolean accept(File pathname)
{
if (!pathname.isFile())
return false;
return pathname.getName().startsWith(journalBase) &&
!pathname.getName().endsWith(JournalFile.RECYCLED_SUFFIX);
}
});
// Sort them in ascending order
Arrays.sort(journalFiles, new Comparator<File>() {
@Override
public int compare(File f1, File f2)
{
return f1.getName().compareTo(f2.getName());
}
});
return journalFiles;
} | java | public static File[] findJournalFiles( String baseName , File dataFolder )
{
final String journalBase = baseName+JournalFile.SUFFIX;
File[] journalFiles = dataFolder.listFiles(new FileFilter() {
/*
* (non-Javadoc)
* @see java.io.FileFilter#accept(java.io.File)
*/
@Override
public boolean accept(File pathname)
{
if (!pathname.isFile())
return false;
return pathname.getName().startsWith(journalBase) &&
!pathname.getName().endsWith(JournalFile.RECYCLED_SUFFIX);
}
});
// Sort them in ascending order
Arrays.sort(journalFiles, new Comparator<File>() {
@Override
public int compare(File f1, File f2)
{
return f1.getName().compareTo(f2.getName());
}
});
return journalFiles;
} | [
"public",
"static",
"File",
"[",
"]",
"findJournalFiles",
"(",
"String",
"baseName",
",",
"File",
"dataFolder",
")",
"{",
"final",
"String",
"journalBase",
"=",
"baseName",
"+",
"JournalFile",
".",
"SUFFIX",
";",
"File",
"[",
"]",
"journalFiles",
"=",
"dataF... | Find existing journal files for a given base name
@param baseName
@param dataFolder
@return an array of journal files | [
"Find",
"existing",
"journal",
"files",
"for",
"a",
"given",
"base",
"name"
] | train | https://github.com/timewalker74/ffmq/blob/638773ee29a4a5f9c6119ed74ad14ac9c46382b3/core/src/main/java/net/timewalker/ffmq4/storage/data/impl/BlockBasedDataStoreTools.java#L163-L192 |
headius/invokebinder | src/main/java/com/headius/invokebinder/SmartBinder.java | SmartBinder.foldStatic | public SmartBinder foldStatic(String newName, Lookup lookup, Class<?> target, String method) {
Binder newBinder = binder.foldStatic(lookup, target, method);
return new SmartBinder(this, signature().prependArg(newName, newBinder.type().parameterType(0)), binder);
} | java | public SmartBinder foldStatic(String newName, Lookup lookup, Class<?> target, String method) {
Binder newBinder = binder.foldStatic(lookup, target, method);
return new SmartBinder(this, signature().prependArg(newName, newBinder.type().parameterType(0)), binder);
} | [
"public",
"SmartBinder",
"foldStatic",
"(",
"String",
"newName",
",",
"Lookup",
"lookup",
",",
"Class",
"<",
"?",
">",
"target",
",",
"String",
"method",
")",
"{",
"Binder",
"newBinder",
"=",
"binder",
".",
"foldStatic",
"(",
"lookup",
",",
"target",
",",
... | Acquire a static folding function from the given target class, using the
given name and Lookup. Pass all arguments to that function and insert
the resulting value as newName into the argument list.
@param newName the name of the new first argument where the fold
function's result will be passed
@param lookup the Lookup to use for acquiring a folding function
@param target the class on which to find the folding function
@param method the name of the method to become a folding function
@return a new SmartBinder with the fold applied | [
"Acquire",
"a",
"static",
"folding",
"function",
"from",
"the",
"given",
"target",
"class",
"using",
"the",
"given",
"name",
"and",
"Lookup",
".",
"Pass",
"all",
"arguments",
"to",
"that",
"function",
"and",
"insert",
"the",
"resulting",
"value",
"as",
"newN... | train | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/SmartBinder.java#L230-L233 |
apereo/cas | support/cas-server-support-openid/src/main/java/org/apereo/cas/support/openid/authentication/principal/OpenIdServiceResponseBuilder.java | OpenIdServiceResponseBuilder.build | @Override
public Response build(final WebApplicationService webApplicationService, final String ticketId, final Authentication authentication) {
val service = (OpenIdService) webApplicationService;
val parameterList = new ParameterList(HttpRequestUtils.getHttpServletRequestFromRequestAttributes().getParameterMap());
val parameters = new HashMap<String, String>();
if (StringUtils.isBlank(ticketId)) {
parameters.put(OpenIdProtocolConstants.OPENID_MODE, OpenIdProtocolConstants.CANCEL);
return buildRedirect(service, parameters);
}
val association = getAssociation(serverManager, parameterList);
val associated = association != null;
val associationValid = isAssociationValid(association);
var successFullAuthentication = true;
var assertion = (Assertion) null;
try {
if (associated && associationValid) {
assertion = centralAuthenticationService.validateServiceTicket(ticketId, service);
LOGGER.debug("Validated openid ticket [{}] for [{}]", ticketId, service);
} else if (!associated) {
LOGGER.debug("Responding to non-associated mode. Service ticket [{}] must be validated by the RP", ticketId);
} else {
LOGGER.warn("Association does not exist or is not valid");
successFullAuthentication = false;
}
} catch (final AbstractTicketException e) {
LOGGER.error("Could not validate ticket : [{}]", e.getMessage(), e);
successFullAuthentication = false;
}
val id = determineIdentity(service, assertion);
return buildAuthenticationResponse(service, parameters, successFullAuthentication, id, parameterList);
} | java | @Override
public Response build(final WebApplicationService webApplicationService, final String ticketId, final Authentication authentication) {
val service = (OpenIdService) webApplicationService;
val parameterList = new ParameterList(HttpRequestUtils.getHttpServletRequestFromRequestAttributes().getParameterMap());
val parameters = new HashMap<String, String>();
if (StringUtils.isBlank(ticketId)) {
parameters.put(OpenIdProtocolConstants.OPENID_MODE, OpenIdProtocolConstants.CANCEL);
return buildRedirect(service, parameters);
}
val association = getAssociation(serverManager, parameterList);
val associated = association != null;
val associationValid = isAssociationValid(association);
var successFullAuthentication = true;
var assertion = (Assertion) null;
try {
if (associated && associationValid) {
assertion = centralAuthenticationService.validateServiceTicket(ticketId, service);
LOGGER.debug("Validated openid ticket [{}] for [{}]", ticketId, service);
} else if (!associated) {
LOGGER.debug("Responding to non-associated mode. Service ticket [{}] must be validated by the RP", ticketId);
} else {
LOGGER.warn("Association does not exist or is not valid");
successFullAuthentication = false;
}
} catch (final AbstractTicketException e) {
LOGGER.error("Could not validate ticket : [{}]", e.getMessage(), e);
successFullAuthentication = false;
}
val id = determineIdentity(service, assertion);
return buildAuthenticationResponse(service, parameters, successFullAuthentication, id, parameterList);
} | [
"@",
"Override",
"public",
"Response",
"build",
"(",
"final",
"WebApplicationService",
"webApplicationService",
",",
"final",
"String",
"ticketId",
",",
"final",
"Authentication",
"authentication",
")",
"{",
"val",
"service",
"=",
"(",
"OpenIdService",
")",
"webAppl... | Generates an Openid response.
If no ticketId is found, response is negative.
If we have a ticket id, then we check if we have an association.
If so, we ask OpenId server manager to generate the answer according with the existing association.
If not, we send back an answer with the ticket id as association handle.
This will force the consumer to ask a verification, which will validate the service ticket.
@param ticketId the service ticket to provide to the service.
@param webApplicationService the service requesting an openid response
@return the generated authentication answer | [
"Generates",
"an",
"Openid",
"response",
".",
"If",
"no",
"ticketId",
"is",
"found",
"response",
"is",
"negative",
".",
"If",
"we",
"have",
"a",
"ticket",
"id",
"then",
"we",
"check",
"if",
"we",
"have",
"an",
"association",
".",
"If",
"so",
"we",
"ask... | train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/support/cas-server-support-openid/src/main/java/org/apereo/cas/support/openid/authentication/principal/OpenIdServiceResponseBuilder.java#L64-L99 |
alkacon/opencms-core | src/org/opencms/ui/contextmenu/CmsContextMenu.java | CmsContextMenu.addItem | public ContextMenuItem addItem(String caption) {
ContextMenuItemState itemState = getState().addChild(caption, getNextId());
ContextMenuItem item = new ContextMenuItem(null, itemState);
m_items.put(itemState.getId(), item);
return item;
} | java | public ContextMenuItem addItem(String caption) {
ContextMenuItemState itemState = getState().addChild(caption, getNextId());
ContextMenuItem item = new ContextMenuItem(null, itemState);
m_items.put(itemState.getId(), item);
return item;
} | [
"public",
"ContextMenuItem",
"addItem",
"(",
"String",
"caption",
")",
"{",
"ContextMenuItemState",
"itemState",
"=",
"getState",
"(",
")",
".",
"addChild",
"(",
"caption",
",",
"getNextId",
"(",
")",
")",
";",
"ContextMenuItem",
"item",
"=",
"new",
"ContextMe... | Adds new item to context menu root with given caption.<p>
@param caption the caption
@return reference to newly added item | [
"Adds",
"new",
"item",
"to",
"context",
"menu",
"root",
"with",
"given",
"caption",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/contextmenu/CmsContextMenu.java#L1024-L1032 |
nohana/Amalgam | amalgam/src/main/java/com/amalgam/app/DialogFragmentUtils.java | DialogFragmentUtils.showOnLoaderCallback | @TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static void showOnLoaderCallback(Handler handler, final android.app.FragmentManager manager, final android.app.DialogFragment fragment, final String tag) {
handler.post(new Runnable() {
@Override
public void run() {
fragment.show(manager, tag);
}
});
} | java | @TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static void showOnLoaderCallback(Handler handler, final android.app.FragmentManager manager, final android.app.DialogFragment fragment, final String tag) {
handler.post(new Runnable() {
@Override
public void run() {
fragment.show(manager, tag);
}
});
} | [
"@",
"TargetApi",
"(",
"Build",
".",
"VERSION_CODES",
".",
"HONEYCOMB",
")",
"public",
"static",
"void",
"showOnLoaderCallback",
"(",
"Handler",
"handler",
",",
"final",
"android",
".",
"app",
".",
"FragmentManager",
"manager",
",",
"final",
"android",
".",
"a... | Show {@link android.app.DialogFragment} with the specified tag on the loader callbacks.
@param handler the handler, in most case, this handler is the main handler.
@param manager the manager.
@param fragment the fragment.
@param tag the tag string that is related to the {@link android.app.DialogFragment}. | [
"Show",
"{"
] | train | https://github.com/nohana/Amalgam/blob/57809ddbfe7897e979cf507982ce0b3aa5e0ed8a/amalgam/src/main/java/com/amalgam/app/DialogFragmentUtils.java#L134-L142 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/PatternsImpl.java | PatternsImpl.getIntentPatternsWithServiceResponseAsync | public Observable<ServiceResponse<List<PatternRuleInfo>>> getIntentPatternsWithServiceResponseAsync(UUID appId, String versionId, UUID intentId, GetIntentPatternsOptionalParameter getIntentPatternsOptionalParameter) {
if (this.client.endpoint() == null) {
throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null.");
}
if (appId == null) {
throw new IllegalArgumentException("Parameter appId is required and cannot be null.");
}
if (versionId == null) {
throw new IllegalArgumentException("Parameter versionId is required and cannot be null.");
}
if (intentId == null) {
throw new IllegalArgumentException("Parameter intentId is required and cannot be null.");
}
final Integer skip = getIntentPatternsOptionalParameter != null ? getIntentPatternsOptionalParameter.skip() : null;
final Integer take = getIntentPatternsOptionalParameter != null ? getIntentPatternsOptionalParameter.take() : null;
return getIntentPatternsWithServiceResponseAsync(appId, versionId, intentId, skip, take);
} | java | public Observable<ServiceResponse<List<PatternRuleInfo>>> getIntentPatternsWithServiceResponseAsync(UUID appId, String versionId, UUID intentId, GetIntentPatternsOptionalParameter getIntentPatternsOptionalParameter) {
if (this.client.endpoint() == null) {
throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null.");
}
if (appId == null) {
throw new IllegalArgumentException("Parameter appId is required and cannot be null.");
}
if (versionId == null) {
throw new IllegalArgumentException("Parameter versionId is required and cannot be null.");
}
if (intentId == null) {
throw new IllegalArgumentException("Parameter intentId is required and cannot be null.");
}
final Integer skip = getIntentPatternsOptionalParameter != null ? getIntentPatternsOptionalParameter.skip() : null;
final Integer take = getIntentPatternsOptionalParameter != null ? getIntentPatternsOptionalParameter.take() : null;
return getIntentPatternsWithServiceResponseAsync(appId, versionId, intentId, skip, take);
} | [
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"List",
"<",
"PatternRuleInfo",
">",
">",
">",
"getIntentPatternsWithServiceResponseAsync",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"UUID",
"intentId",
",",
"GetIntentPatternsOptionalParameter",
"getInt... | Returns patterns to be retrieved for the specific intent.
@param appId The application ID.
@param versionId The version ID.
@param intentId The intent classifier ID.
@param getIntentPatternsOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<PatternRuleInfo> object | [
"Returns",
"patterns",
"to",
"be",
"retrieved",
"for",
"the",
"specific",
"intent",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/PatternsImpl.java#L900-L917 |
liferay/com-liferay-commerce | commerce-price-list-service/src/main/java/com/liferay/commerce/price/list/service/persistence/impl/CommercePriceListAccountRelPersistenceImpl.java | CommercePriceListAccountRelPersistenceImpl.removeByUuid_C | @Override
public void removeByUuid_C(String uuid, long companyId) {
for (CommercePriceListAccountRel commercePriceListAccountRel : findByUuid_C(
uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(commercePriceListAccountRel);
}
} | java | @Override
public void removeByUuid_C(String uuid, long companyId) {
for (CommercePriceListAccountRel commercePriceListAccountRel : findByUuid_C(
uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(commercePriceListAccountRel);
}
} | [
"@",
"Override",
"public",
"void",
"removeByUuid_C",
"(",
"String",
"uuid",
",",
"long",
"companyId",
")",
"{",
"for",
"(",
"CommercePriceListAccountRel",
"commercePriceListAccountRel",
":",
"findByUuid_C",
"(",
"uuid",
",",
"companyId",
",",
"QueryUtil",
".",
"AL... | Removes all the commerce price list account rels where uuid = ? and companyId = ? from the database.
@param uuid the uuid
@param companyId the company ID | [
"Removes",
"all",
"the",
"commerce",
"price",
"list",
"account",
"rels",
"where",
"uuid",
"=",
"?",
";",
"and",
"companyId",
"=",
"?",
";",
"from",
"the",
"database",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-price-list-service/src/main/java/com/liferay/commerce/price/list/service/persistence/impl/CommercePriceListAccountRelPersistenceImpl.java#L1428-L1434 |
aboutsip/pkts | pkts-streams/src/main/java/io/pkts/streams/impl/SimpleCallStateMachine.java | SimpleCallStateMachine.handleInCancellingState | private void handleInCancellingState(final SipPacket msg) throws SipPacketParseException {
// we don't move over to cancelled state even if
// we receive a 200 OK to the cancel request.
// therefore, not even checking it...
if (msg.isCancel()) {
transition(CallState.CANCELLING, msg);
return;
}
if (msg.isRequest()) {
} else {
final SipResponsePacket response = msg.toResponse();
if (response.isInvite()) {
if (response.getStatus() == 487) {
transition(CallState.CANCELLED, msg);
} else if (response.isSuccess()) {
// the cancel didn't make it over in time
// so we never cancelled, hence we move
// to in call
transition(CallState.IN_CALL, msg);
}
}
}
} | java | private void handleInCancellingState(final SipPacket msg) throws SipPacketParseException {
// we don't move over to cancelled state even if
// we receive a 200 OK to the cancel request.
// therefore, not even checking it...
if (msg.isCancel()) {
transition(CallState.CANCELLING, msg);
return;
}
if (msg.isRequest()) {
} else {
final SipResponsePacket response = msg.toResponse();
if (response.isInvite()) {
if (response.getStatus() == 487) {
transition(CallState.CANCELLED, msg);
} else if (response.isSuccess()) {
// the cancel didn't make it over in time
// so we never cancelled, hence we move
// to in call
transition(CallState.IN_CALL, msg);
}
}
}
} | [
"private",
"void",
"handleInCancellingState",
"(",
"final",
"SipPacket",
"msg",
")",
"throws",
"SipPacketParseException",
"{",
"// we don't move over to cancelled state even if",
"// we receive a 200 OK to the cancel request.",
"// therefore, not even checking it...",
"if",
"(",
"msg... | When in the cancelling state, we may actually end up going back to
IN_CALL in case we see a 2xx to the invite so pay attention for that.
@param msg
@throws SipPacketParseException | [
"When",
"in",
"the",
"cancelling",
"state",
"we",
"may",
"actually",
"end",
"up",
"going",
"back",
"to",
"IN_CALL",
"in",
"case",
"we",
"see",
"a",
"2xx",
"to",
"the",
"invite",
"so",
"pay",
"attention",
"for",
"that",
"."
] | train | https://github.com/aboutsip/pkts/blob/0f06bb0dac76c812187829f580a8d476ca99a1a1/pkts-streams/src/main/java/io/pkts/streams/impl/SimpleCallStateMachine.java#L219-L246 |
mongodb/stitch-android-sdk | core/sdk/src/main/java/com/mongodb/stitch/core/internal/common/StitchObjectMapper.java | StitchObjectMapper.withCodecRegistry | public StitchObjectMapper withCodecRegistry(final CodecRegistry codecRegistry) {
// We can't detect if their codecRegistry has any duplicate providers. There's also a chance
// that putting ours first may prevent decoding of some of their classes if for example they
// have their own way of decoding an Integer.
final CodecRegistry newReg =
CodecRegistries.fromRegistries(BsonUtils.DEFAULT_CODEC_REGISTRY, codecRegistry);
return new StitchObjectMapper(this, newReg);
} | java | public StitchObjectMapper withCodecRegistry(final CodecRegistry codecRegistry) {
// We can't detect if their codecRegistry has any duplicate providers. There's also a chance
// that putting ours first may prevent decoding of some of their classes if for example they
// have their own way of decoding an Integer.
final CodecRegistry newReg =
CodecRegistries.fromRegistries(BsonUtils.DEFAULT_CODEC_REGISTRY, codecRegistry);
return new StitchObjectMapper(this, newReg);
} | [
"public",
"StitchObjectMapper",
"withCodecRegistry",
"(",
"final",
"CodecRegistry",
"codecRegistry",
")",
"{",
"// We can't detect if their codecRegistry has any duplicate providers. There's also a chance",
"// that putting ours first may prevent decoding of some of their classes if for example ... | Applies the given codec registry to be used alongside the default codec registry.
@param codecRegistry the codec registry to merge in.
@return an {@link StitchObjectMapper} with the merged codec registries. | [
"Applies",
"the",
"given",
"codec",
"registry",
"to",
"be",
"used",
"alongside",
"the",
"default",
"codec",
"registry",
"."
] | train | https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/core/sdk/src/main/java/com/mongodb/stitch/core/internal/common/StitchObjectMapper.java#L107-L114 |
Hygieia/Hygieia | api/src/main/java/com/capitalone/dashboard/service/DashboardServiceImpl.java | DashboardServiceImpl.getAllDashboardsByTitleCount | @Override
public Integer getAllDashboardsByTitleCount(String title, String type) {
List<Dashboard> dashboards = null;
if ((type != null) && (!type.isEmpty()) && (!UNDEFINED.equalsIgnoreCase(type))) {
dashboards = dashboardRepository.findAllByTypeContainingIgnoreCaseAndTitleContainingIgnoreCase(type, title);
} else {
dashboards = dashboardRepository.findAllByTitleContainingIgnoreCase(title);
}
return dashboards != null ? dashboards.size() : 0;
} | java | @Override
public Integer getAllDashboardsByTitleCount(String title, String type) {
List<Dashboard> dashboards = null;
if ((type != null) && (!type.isEmpty()) && (!UNDEFINED.equalsIgnoreCase(type))) {
dashboards = dashboardRepository.findAllByTypeContainingIgnoreCaseAndTitleContainingIgnoreCase(type, title);
} else {
dashboards = dashboardRepository.findAllByTitleContainingIgnoreCase(title);
}
return dashboards != null ? dashboards.size() : 0;
} | [
"@",
"Override",
"public",
"Integer",
"getAllDashboardsByTitleCount",
"(",
"String",
"title",
",",
"String",
"type",
")",
"{",
"List",
"<",
"Dashboard",
">",
"dashboards",
"=",
"null",
";",
"if",
"(",
"(",
"type",
"!=",
"null",
")",
"&&",
"(",
"!",
"type... | Get count of all dashboards filtered by title
@param title
@return Integer | [
"Get",
"count",
"of",
"all",
"dashboards",
"filtered",
"by",
"title"
] | train | https://github.com/Hygieia/Hygieia/blob/d8b67a590da2744acf59bcd99d9b34ef1bb84890/api/src/main/java/com/capitalone/dashboard/service/DashboardServiceImpl.java#L726-L735 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java | ModelsImpl.addCustomPrebuiltEntityAsync | public Observable<UUID> addCustomPrebuiltEntityAsync(UUID appId, String versionId, PrebuiltDomainModelCreateObject prebuiltDomainModelCreateObject) {
return addCustomPrebuiltEntityWithServiceResponseAsync(appId, versionId, prebuiltDomainModelCreateObject).map(new Func1<ServiceResponse<UUID>, UUID>() {
@Override
public UUID call(ServiceResponse<UUID> response) {
return response.body();
}
});
} | java | public Observable<UUID> addCustomPrebuiltEntityAsync(UUID appId, String versionId, PrebuiltDomainModelCreateObject prebuiltDomainModelCreateObject) {
return addCustomPrebuiltEntityWithServiceResponseAsync(appId, versionId, prebuiltDomainModelCreateObject).map(new Func1<ServiceResponse<UUID>, UUID>() {
@Override
public UUID call(ServiceResponse<UUID> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"UUID",
">",
"addCustomPrebuiltEntityAsync",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"PrebuiltDomainModelCreateObject",
"prebuiltDomainModelCreateObject",
")",
"{",
"return",
"addCustomPrebuiltEntityWithServiceResponseAsync",
"(",
"... | Adds a custom prebuilt entity model to the application.
@param appId The application ID.
@param versionId The version ID.
@param prebuiltDomainModelCreateObject A model object containing the name of the custom prebuilt entity and the name of the domain to which this model belongs.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the UUID object | [
"Adds",
"a",
"custom",
"prebuilt",
"entity",
"model",
"to",
"the",
"application",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java#L5916-L5923 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/ArrayUtil.java | ArrayUtil.indexOf | public static <T> int indexOf(T[] array, Object value) {
if (null != array) {
for (int i = 0; i < array.length; i++) {
if (ObjectUtil.equal(value, array[i])) {
return i;
}
}
}
return INDEX_NOT_FOUND;
} | java | public static <T> int indexOf(T[] array, Object value) {
if (null != array) {
for (int i = 0; i < array.length; i++) {
if (ObjectUtil.equal(value, array[i])) {
return i;
}
}
}
return INDEX_NOT_FOUND;
} | [
"public",
"static",
"<",
"T",
">",
"int",
"indexOf",
"(",
"T",
"[",
"]",
"array",
",",
"Object",
"value",
")",
"{",
"if",
"(",
"null",
"!=",
"array",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"array",
".",
"length",
";",
"i",... | 返回数组中指定元素所在位置,未找到返回{@link #INDEX_NOT_FOUND}
@param <T> 数组类型
@param array 数组
@param value 被检查的元素
@return 数组中指定元素所在位置,未找到返回{@link #INDEX_NOT_FOUND}
@since 3.0.7 | [
"返回数组中指定元素所在位置,未找到返回",
"{",
"@link",
"#INDEX_NOT_FOUND",
"}"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/ArrayUtil.java#L897-L906 |
ModeShape/modeshape | modeshape-common/src/main/java/org/modeshape/common/util/Reflection.java | Reflection.getInstance | @SuppressWarnings( "unchecked" )
public static <T> T getInstance(String classname, ClassLoader cl) {
if (classname == null) throw new IllegalArgumentException("Cannot load null class!");
Class<T> clazz = null;
try {
clazz = (Class<T>)Class.forName(classname, true, cl);
// first look for a getInstance() constructor
T instance = null;
try {
Method factoryMethod = getFactoryMethod(clazz);
if (factoryMethod != null) instance = (T) factoryMethod.invoke(null);
}
catch (Exception e) {
// no factory method or factory method failed. Try a constructor.
instance = null;
}
if (instance == null) {
instance = clazz.newInstance();
}
return instance;
} catch (Exception e) {
throw new RuntimeException(e);
}
} | java | @SuppressWarnings( "unchecked" )
public static <T> T getInstance(String classname, ClassLoader cl) {
if (classname == null) throw new IllegalArgumentException("Cannot load null class!");
Class<T> clazz = null;
try {
clazz = (Class<T>)Class.forName(classname, true, cl);
// first look for a getInstance() constructor
T instance = null;
try {
Method factoryMethod = getFactoryMethod(clazz);
if (factoryMethod != null) instance = (T) factoryMethod.invoke(null);
}
catch (Exception e) {
// no factory method or factory method failed. Try a constructor.
instance = null;
}
if (instance == null) {
instance = clazz.newInstance();
}
return instance;
} catch (Exception e) {
throw new RuntimeException(e);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"T",
">",
"T",
"getInstance",
"(",
"String",
"classname",
",",
"ClassLoader",
"cl",
")",
"{",
"if",
"(",
"classname",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
... | Instantiates a class based on the class name provided. Instantiation is attempted via an appropriate, static
factory method named <tt>getInstance()</tt> first, and failing the existence of an appropriate factory, falls
back to an empty constructor.
<p />
@param classname class to instantiate
@return an instance of classname | [
"Instantiates",
"a",
"class",
"based",
"on",
"the",
"class",
"name",
"provided",
".",
"Instantiation",
"is",
"attempted",
"via",
"an",
"appropriate",
"static",
"factory",
"method",
"named",
"<tt",
">",
"getInstance",
"()",
"<",
"/",
"tt",
">",
"first",
"and"... | train | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-common/src/main/java/org/modeshape/common/util/Reflection.java#L286-L309 |
aNNiMON/Lightweight-Stream-API | stream/src/main/java/com/annimon/stream/Objects.java | Objects.deepEquals | @Contract(pure = true)
public static boolean deepEquals(@Nullable Object a, @Nullable Object b) {
return (a == b)
|| (a != null && b != null)
&& Arrays.deepEquals(new Object[] { a }, new Object[] { b });
} | java | @Contract(pure = true)
public static boolean deepEquals(@Nullable Object a, @Nullable Object b) {
return (a == b)
|| (a != null && b != null)
&& Arrays.deepEquals(new Object[] { a }, new Object[] { b });
} | [
"@",
"Contract",
"(",
"pure",
"=",
"true",
")",
"public",
"static",
"boolean",
"deepEquals",
"(",
"@",
"Nullable",
"Object",
"a",
",",
"@",
"Nullable",
"Object",
"b",
")",
"{",
"return",
"(",
"a",
"==",
"b",
")",
"||",
"(",
"a",
"!=",
"null",
"&&",... | Checks deep equality of two objects.
@param a an object
@param b an object
@return {@code true} if objects are deeply equals, {@code false} otherwise
@see Arrays#deepEquals(Object[], Object[])
@see Objects#equals(Object, Object)
@since 1.2.0 | [
"Checks",
"deep",
"equality",
"of",
"two",
"objects",
"."
] | train | https://github.com/aNNiMON/Lightweight-Stream-API/blob/f29fd57208c20252a4549b084d55ed082c3e58f0/stream/src/main/java/com/annimon/stream/Objects.java#L42-L47 |
seedstack/i18n-addon | rest/src/it/java/org/seedstack/i18n/shared/AbstractI18nRestIT.java | AbstractI18nRestIT.httpPost | protected Response httpPost(String path, String body, int status) {
return httpRequest(status, null).body(body).post(baseURL + PATH_PREFIX + path);
} | java | protected Response httpPost(String path, String body, int status) {
return httpRequest(status, null).body(body).post(baseURL + PATH_PREFIX + path);
} | [
"protected",
"Response",
"httpPost",
"(",
"String",
"path",
",",
"String",
"body",
",",
"int",
"status",
")",
"{",
"return",
"httpRequest",
"(",
"status",
",",
"null",
")",
".",
"body",
"(",
"body",
")",
".",
"post",
"(",
"baseURL",
"+",
"PATH_PREFIX",
... | Posts the body to the given path and expect a 200 status code.
@param path the resource URI
@param body the resource representation
@return the http response | [
"Posts",
"the",
"body",
"to",
"the",
"given",
"path",
"and",
"expect",
"a",
"200",
"status",
"code",
"."
] | train | https://github.com/seedstack/i18n-addon/blob/1e65101d8554623f09bda2497b0151fd10a16615/rest/src/it/java/org/seedstack/i18n/shared/AbstractI18nRestIT.java#L70-L72 |
ManfredTremmel/gwt-commons-lang3 | src/main/java/org/apache/commons/lang3/text/StrBuilder.java | StrBuilder.leftString | public String leftString(final int length) {
if (length <= 0) {
return StringUtils.EMPTY;
} else if (length >= size) {
return new String(buffer, 0, size);
} else {
return new String(buffer, 0, length);
}
} | java | public String leftString(final int length) {
if (length <= 0) {
return StringUtils.EMPTY;
} else if (length >= size) {
return new String(buffer, 0, size);
} else {
return new String(buffer, 0, length);
}
} | [
"public",
"String",
"leftString",
"(",
"final",
"int",
"length",
")",
"{",
"if",
"(",
"length",
"<=",
"0",
")",
"{",
"return",
"StringUtils",
".",
"EMPTY",
";",
"}",
"else",
"if",
"(",
"length",
">=",
"size",
")",
"{",
"return",
"new",
"String",
"(",... | Extracts the leftmost characters from the string builder without
throwing an exception.
<p>
This method extracts the left <code>length</code> characters from
the builder. If this many characters are not available, the whole
builder is returned. Thus the returned string may be shorter than the
length requested.
@param length the number of characters to extract, negative returns empty string
@return the new string | [
"Extracts",
"the",
"leftmost",
"characters",
"from",
"the",
"string",
"builder",
"without",
"throwing",
"an",
"exception",
".",
"<p",
">",
"This",
"method",
"extracts",
"the",
"left",
"<code",
">",
"length<",
"/",
"code",
">",
"characters",
"from",
"the",
"b... | train | https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/text/StrBuilder.java#L2296-L2304 |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/shapes/ellipse/BinaryEllipseDetectorPixel.java | BinaryEllipseDetectorPixel.isApproximatelyElliptical | boolean isApproximatelyElliptical(EllipseRotated_F64 ellipse , List<Point2D_F64> points , int maxSamples ) {
closestPoint.setEllipse(ellipse);
double maxDistance2 = maxDistanceFromEllipse*maxDistanceFromEllipse;
if( points.size() <= maxSamples ) {
for( int i = 0; i < points.size(); i++ ) {
Point2D_F64 p = points.get(i);
closestPoint.process(p);
double d = closestPoint.getClosest().distance2(p);
if( d > maxDistance2 ) {
return false;
}
}
} else {
for (int i = 0; i < maxSamples; i++) {
Point2D_F64 p = points.get( i*points.size()/maxSamples );
closestPoint.process(p);
double d = closestPoint.getClosest().distance2(p);
if( d > maxDistance2 ) {
return false;
}
}
}
return true;
} | java | boolean isApproximatelyElliptical(EllipseRotated_F64 ellipse , List<Point2D_F64> points , int maxSamples ) {
closestPoint.setEllipse(ellipse);
double maxDistance2 = maxDistanceFromEllipse*maxDistanceFromEllipse;
if( points.size() <= maxSamples ) {
for( int i = 0; i < points.size(); i++ ) {
Point2D_F64 p = points.get(i);
closestPoint.process(p);
double d = closestPoint.getClosest().distance2(p);
if( d > maxDistance2 ) {
return false;
}
}
} else {
for (int i = 0; i < maxSamples; i++) {
Point2D_F64 p = points.get( i*points.size()/maxSamples );
closestPoint.process(p);
double d = closestPoint.getClosest().distance2(p);
if( d > maxDistance2 ) {
return false;
}
}
}
return true;
} | [
"boolean",
"isApproximatelyElliptical",
"(",
"EllipseRotated_F64",
"ellipse",
",",
"List",
"<",
"Point2D_F64",
">",
"points",
",",
"int",
"maxSamples",
")",
"{",
"closestPoint",
".",
"setEllipse",
"(",
"ellipse",
")",
";",
"double",
"maxDistance2",
"=",
"maxDistan... | Look at the maximum distance contour points are from the ellipse and see if they exceed a maximum threshold | [
"Look",
"at",
"the",
"maximum",
"distance",
"contour",
"points",
"are",
"from",
"the",
"ellipse",
"and",
"see",
"if",
"they",
"exceed",
"a",
"maximum",
"threshold"
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/ellipse/BinaryEllipseDetectorPixel.java#L255-L283 |
JDBDT/jdbdt | src/main/java/org/jdbdt/Log.java | Log.writeSQL | void writeSQL(CallInfo callInfo, String sql) {
Element rootNode = root(callInfo);
writeSQL(rootNode, sql);
flush(rootNode);
} | java | void writeSQL(CallInfo callInfo, String sql) {
Element rootNode = root(callInfo);
writeSQL(rootNode, sql);
flush(rootNode);
} | [
"void",
"writeSQL",
"(",
"CallInfo",
"callInfo",
",",
"String",
"sql",
")",
"{",
"Element",
"rootNode",
"=",
"root",
"(",
"callInfo",
")",
";",
"writeSQL",
"(",
"rootNode",
",",
"sql",
")",
";",
"flush",
"(",
"rootNode",
")",
";",
"}"
] | Log SQL code.
@param callInfo Call info.
@param sql SQL code. | [
"Log",
"SQL",
"code",
"."
] | train | https://github.com/JDBDT/jdbdt/blob/7e32845ad41dfbc5d6fd0fd561e3613697186df4/src/main/java/org/jdbdt/Log.java#L236-L240 |
jpush/jmessage-api-java-client | src/main/java/cn/jmessage/api/crossapp/CrossAppClient.java | CrossAppClient.addCrossFriends | public ResponseWrapper addCrossFriends(String username, CrossFriendPayload payload)
throws APIConnectionException, APIRequestException {
StringUtils.checkUsername(username);
Preconditions.checkArgument(null != payload, "CrossFriendPayload should not be null");
return _httpClient.sendPost(_baseUrl + crossUserPath + "/" + username + "/friends", payload.toString());
} | java | public ResponseWrapper addCrossFriends(String username, CrossFriendPayload payload)
throws APIConnectionException, APIRequestException {
StringUtils.checkUsername(username);
Preconditions.checkArgument(null != payload, "CrossFriendPayload should not be null");
return _httpClient.sendPost(_baseUrl + crossUserPath + "/" + username + "/friends", payload.toString());
} | [
"public",
"ResponseWrapper",
"addCrossFriends",
"(",
"String",
"username",
",",
"CrossFriendPayload",
"payload",
")",
"throws",
"APIConnectionException",
",",
"APIRequestException",
"{",
"StringUtils",
".",
"checkUsername",
"(",
"username",
")",
";",
"Preconditions",
".... | Add users from cross app.
@param username Necessary
@param payload CrossFriendPayload
@return No content
@throws APIConnectionException connect exception
@throws APIRequestException request exception | [
"Add",
"users",
"from",
"cross",
"app",
"."
] | train | https://github.com/jpush/jmessage-api-java-client/blob/767f5fb15e9fe5a546c00f6e68b64f6dd53c617c/src/main/java/cn/jmessage/api/crossapp/CrossAppClient.java#L149-L154 |
dkpro/dkpro-argumentation | dkpro-argumentation-types/src/main/java/org/dkpro/argumentation/types/ArgumentUnitUtils.java | ArgumentUnitUtils.setProperties | public static void setProperties(ArgumentUnit argumentUnit, Properties properties)
throws IllegalArgumentException
{
if (argumentUnit == null) {
throw new IllegalArgumentException("argumentUnit is null");
}
if (properties == null) {
throw new IllegalArgumentException("properties is null");
}
argumentUnit.setProperties(propertiesToString(properties));
} | java | public static void setProperties(ArgumentUnit argumentUnit, Properties properties)
throws IllegalArgumentException
{
if (argumentUnit == null) {
throw new IllegalArgumentException("argumentUnit is null");
}
if (properties == null) {
throw new IllegalArgumentException("properties is null");
}
argumentUnit.setProperties(propertiesToString(properties));
} | [
"public",
"static",
"void",
"setProperties",
"(",
"ArgumentUnit",
"argumentUnit",
",",
"Properties",
"properties",
")",
"throws",
"IllegalArgumentException",
"{",
"if",
"(",
"argumentUnit",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"... | Sets the given properties to the argumentUnit (into the {@code properties} field).
@param argumentUnit argumentUnit
@param properties properties
@throws IllegalArgumentException if params are null | [
"Sets",
"the",
"given",
"properties",
"to",
"the",
"argumentUnit",
"(",
"into",
"the",
"{",
"@code",
"properties",
"}",
"field",
")",
"."
] | train | https://github.com/dkpro/dkpro-argumentation/blob/57ce6f5e73d8075b7088aeeebb107c85b3d4bbcb/dkpro-argumentation-types/src/main/java/org/dkpro/argumentation/types/ArgumentUnitUtils.java#L112-L124 |
OpenLiberty/open-liberty | dev/com.ibm.ws.jmx.connector.server.rest/src/com/ibm/ws/jmx/connector/server/rest/notification/NotificationManager.java | NotificationManager.deleteRegisteredListeners | public void deleteRegisteredListeners(RESTRequest request, int clientID, ObjectName source_objName, JSONConverter converter) {
//Get the client area
ClientNotificationArea clientArea = getInboxIfAvailable(clientID, null);
clientArea.removeAllListeners(request, source_objName, converter);
} | java | public void deleteRegisteredListeners(RESTRequest request, int clientID, ObjectName source_objName, JSONConverter converter) {
//Get the client area
ClientNotificationArea clientArea = getInboxIfAvailable(clientID, null);
clientArea.removeAllListeners(request, source_objName, converter);
} | [
"public",
"void",
"deleteRegisteredListeners",
"(",
"RESTRequest",
"request",
",",
"int",
"clientID",
",",
"ObjectName",
"source_objName",
",",
"JSONConverter",
"converter",
")",
"{",
"//Get the client area",
"ClientNotificationArea",
"clientArea",
"=",
"getInboxIfAvailable... | Delete all registered server-side notifications for the given object name.
This can only be called from HTTP-direct clients | [
"Delete",
"all",
"registered",
"server",
"-",
"side",
"notifications",
"for",
"the",
"given",
"object",
"name",
".",
"This",
"can",
"only",
"be",
"called",
"from",
"HTTP",
"-",
"direct",
"clients"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jmx.connector.server.rest/src/com/ibm/ws/jmx/connector/server/rest/notification/NotificationManager.java#L303-L308 |
ihaolin/wepay | wepay-core/src/main/java/me/hao0/wepay/core/Bills.java | Bills.query | public String query(String deviceInfo, String date, BillType type){
checkNotNullAndEmpty(date, "date");
checkNotNull(type, "bill type can't be null");
Map<String, String> downloadParams = buildDownloadParams(deviceInfo, date, type);
String billData = Http.post(DOWNLOAD).body(Maps.toXml(downloadParams)).request();
if (billData.startsWith("<xml>")){
XmlReaders readers = XmlReaders.create(billData);
throw new WepayException(
readers.getNodeStr(WepayField.RETURN_CODE),
readers.getNodeStr(WepayField.RETURN_MSG));
}
return billData;
} | java | public String query(String deviceInfo, String date, BillType type){
checkNotNullAndEmpty(date, "date");
checkNotNull(type, "bill type can't be null");
Map<String, String> downloadParams = buildDownloadParams(deviceInfo, date, type);
String billData = Http.post(DOWNLOAD).body(Maps.toXml(downloadParams)).request();
if (billData.startsWith("<xml>")){
XmlReaders readers = XmlReaders.create(billData);
throw new WepayException(
readers.getNodeStr(WepayField.RETURN_CODE),
readers.getNodeStr(WepayField.RETURN_MSG));
}
return billData;
} | [
"public",
"String",
"query",
"(",
"String",
"deviceInfo",
",",
"String",
"date",
",",
"BillType",
"type",
")",
"{",
"checkNotNullAndEmpty",
"(",
"date",
",",
"\"date\"",
")",
";",
"checkNotNull",
"(",
"type",
",",
"\"bill type can't be null\"",
")",
";",
"Map"... | 查询账单
@param deviceInfo 微信支付分配的终端设备号,填写此字段,只下载该设备号的对账单
@param date 账单的日期
@param type 账单类型
@see me.hao0.wepay.model.enums.BillType
@return 账单数据 | [
"查询账单"
] | train | https://github.com/ihaolin/wepay/blob/3360b6a57493d879d5a19def833db36fb455f859/wepay-core/src/main/java/me/hao0/wepay/core/Bills.java#L127-L139 |
spotbugs/spotbugs | eclipsePlugin/src/de/tobject/findbugs/reporter/JdtUtils.java | JdtUtils.getAnonCompilePriority50 | private static int getAnonCompilePriority50(IJavaElement javaElement, IJavaElement firstAncestor, IJavaElement topAncestor) {
// search for initializer block
IJavaElement initBlock = getLastAncestor(javaElement, IJavaElement.INITIALIZER);
// test is for anon. classes from initializer blocks
if (initBlock != null) {
return 10; // from inner from class init
}
// test for anon. classes from "regular" code
return 5;
} | java | private static int getAnonCompilePriority50(IJavaElement javaElement, IJavaElement firstAncestor, IJavaElement topAncestor) {
// search for initializer block
IJavaElement initBlock = getLastAncestor(javaElement, IJavaElement.INITIALIZER);
// test is for anon. classes from initializer blocks
if (initBlock != null) {
return 10; // from inner from class init
}
// test for anon. classes from "regular" code
return 5;
} | [
"private",
"static",
"int",
"getAnonCompilePriority50",
"(",
"IJavaElement",
"javaElement",
",",
"IJavaElement",
"firstAncestor",
",",
"IJavaElement",
"topAncestor",
")",
"{",
"// search for initializer block",
"IJavaElement",
"initBlock",
"=",
"getLastAncestor",
"(",
"java... | 1) from instance init 2) from deepest inner from instance init (deepest
first) 3) from static init 4) from deepest inner from static init
(deepest first) 5) from deepest inner (deepest first) 6) regular anon
classes from main class
<br>
Note, that nested inner anon. classes which do not have different
non-anon. inner class ancestors, are compiled in they nesting order,
opposite to rule 2)
@param javaElement
@return priority - lesser mean wil be compiled later, a value > 0 | [
"1",
")",
"from",
"instance",
"init",
"2",
")",
"from",
"deepest",
"inner",
"from",
"instance",
"init",
"(",
"deepest",
"first",
")",
"3",
")",
"from",
"static",
"init",
"4",
")",
"from",
"deepest",
"inner",
"from",
"static",
"init",
"(",
"deepest",
"f... | train | https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/eclipsePlugin/src/de/tobject/findbugs/reporter/JdtUtils.java#L424-L435 |
looly/hutool | hutool-db/src/main/java/cn/hutool/db/SqlConnRunner.java | SqlConnRunner.insertForGeneratedKey | public Long insertForGeneratedKey(Connection conn, Entity record) throws SQLException {
checkConn(conn);
if(CollectionUtil.isEmpty(record)){
throw new SQLException("Empty entity provided!");
}
PreparedStatement ps = null;
try {
ps = dialect.psForInsert(conn, record);
ps.executeUpdate();
return StatementUtil.getGeneratedKeyOfLong(ps);
} catch (SQLException e) {
throw e;
} finally {
DbUtil.close(ps);
}
} | java | public Long insertForGeneratedKey(Connection conn, Entity record) throws SQLException {
checkConn(conn);
if(CollectionUtil.isEmpty(record)){
throw new SQLException("Empty entity provided!");
}
PreparedStatement ps = null;
try {
ps = dialect.psForInsert(conn, record);
ps.executeUpdate();
return StatementUtil.getGeneratedKeyOfLong(ps);
} catch (SQLException e) {
throw e;
} finally {
DbUtil.close(ps);
}
} | [
"public",
"Long",
"insertForGeneratedKey",
"(",
"Connection",
"conn",
",",
"Entity",
"record",
")",
"throws",
"SQLException",
"{",
"checkConn",
"(",
"conn",
")",
";",
"if",
"(",
"CollectionUtil",
".",
"isEmpty",
"(",
"record",
")",
")",
"{",
"throw",
"new",
... | 插入数据<br>
此方法不会关闭Connection
@param conn 数据库连接
@param record 记录
@return 自增主键
@throws SQLException SQL执行异常 | [
"插入数据<br",
">",
"此方法不会关闭Connection"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-db/src/main/java/cn/hutool/db/SqlConnRunner.java#L209-L225 |
webmetrics/browsermob-proxy | src/main/java/org/browsermob/proxy/jetty/http/HttpMessage.java | HttpMessage.getFieldValues | public Enumeration getFieldValues(String name,String separators)
{
return _header.getValues(name,separators);
} | java | public Enumeration getFieldValues(String name,String separators)
{
return _header.getValues(name,separators);
} | [
"public",
"Enumeration",
"getFieldValues",
"(",
"String",
"name",
",",
"String",
"separators",
")",
"{",
"return",
"_header",
".",
"getValues",
"(",
"name",
",",
"separators",
")",
";",
"}"
] | Get a multi valued message field.
Get a field from a message header.
@param name The field name
@param separators String of separators.
@return Enumeration of field values or null | [
"Get",
"a",
"multi",
"valued",
"message",
"field",
".",
"Get",
"a",
"field",
"from",
"a",
"message",
"header",
"."
] | train | https://github.com/webmetrics/browsermob-proxy/blob/a9252e62246ac33d55d51b993ba1159404e7d389/src/main/java/org/browsermob/proxy/jetty/http/HttpMessage.java#L252-L255 |
apereo/cas | core/cas-server-core-webflow-api/src/main/java/org/apereo/cas/web/flow/configurer/AbstractCasWebflowConfigurer.java | AbstractCasWebflowConfigurer.containsFlowState | public boolean containsFlowState(final Flow flow, final String stateId) {
if (flow == null) {
LOGGER.error("Flow is not configured correctly and cannot be null.");
return false;
}
return flow.containsState(stateId);
} | java | public boolean containsFlowState(final Flow flow, final String stateId) {
if (flow == null) {
LOGGER.error("Flow is not configured correctly and cannot be null.");
return false;
}
return flow.containsState(stateId);
} | [
"public",
"boolean",
"containsFlowState",
"(",
"final",
"Flow",
"flow",
",",
"final",
"String",
"stateId",
")",
"{",
"if",
"(",
"flow",
"==",
"null",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"Flow is not configured correctly and cannot be null.\"",
")",
";",
"re... | Contains flow state?
@param flow the flow
@param stateId the state id
@return true if flow contains the state. | [
"Contains",
"flow",
"state?"
] | train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/core/cas-server-core-webflow-api/src/main/java/org/apereo/cas/web/flow/configurer/AbstractCasWebflowConfigurer.java#L546-L552 |
couchbase/couchbase-java-client | src/main/java/com/couchbase/client/java/bucket/api/Utils.java | Utils.addDetails | @InterfaceAudience.Private
@InterfaceStability.Uncommitted
public static <X extends CouchbaseException, R extends CouchbaseResponse> X addDetails(X ex, R r) {
if (r.statusDetails() != null) {
ex.details(r.statusDetails());
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("{} returned with enhanced error details {}", r, ex);
}
}
return ex;
} | java | @InterfaceAudience.Private
@InterfaceStability.Uncommitted
public static <X extends CouchbaseException, R extends CouchbaseResponse> X addDetails(X ex, R r) {
if (r.statusDetails() != null) {
ex.details(r.statusDetails());
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("{} returned with enhanced error details {}", r, ex);
}
}
return ex;
} | [
"@",
"InterfaceAudience",
".",
"Private",
"@",
"InterfaceStability",
".",
"Uncommitted",
"public",
"static",
"<",
"X",
"extends",
"CouchbaseException",
",",
"R",
"extends",
"CouchbaseResponse",
">",
"X",
"addDetails",
"(",
"X",
"ex",
",",
"R",
"r",
")",
"{",
... | Helper method to encapsulate the logic of enriching the exception with detailed status info. | [
"Helper",
"method",
"to",
"encapsulate",
"the",
"logic",
"of",
"enriching",
"the",
"exception",
"with",
"detailed",
"status",
"info",
"."
] | train | https://github.com/couchbase/couchbase-java-client/blob/f36a0ee0c66923bdde47838ca543e50cbaa99e14/src/main/java/com/couchbase/client/java/bucket/api/Utils.java#L54-L64 |
mapbox/mapbox-navigation-android | libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/utils/MathUtils.java | MathUtils.differenceBetweenAngles | public static double differenceBetweenAngles(double alpha, double beta) {
double phi = Math.abs(beta - alpha) % 360;
return phi > 180 ? 360 - phi : phi;
} | java | public static double differenceBetweenAngles(double alpha, double beta) {
double phi = Math.abs(beta - alpha) % 360;
return phi > 180 ? 360 - phi : phi;
} | [
"public",
"static",
"double",
"differenceBetweenAngles",
"(",
"double",
"alpha",
",",
"double",
"beta",
")",
"{",
"double",
"phi",
"=",
"Math",
".",
"abs",
"(",
"beta",
"-",
"alpha",
")",
"%",
"360",
";",
"return",
"phi",
">",
"180",
"?",
"360",
"-",
... | Returns the smallest angle between two angles.
@param alpha First angle in degrees
@param beta Second angle in degrees
@return Smallest angle between two angles. | [
"Returns",
"the",
"smallest",
"angle",
"between",
"two",
"angles",
"."
] | train | https://github.com/mapbox/mapbox-navigation-android/blob/375a89c017d360b9defc2c90d0c03468165162ec/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/utils/MathUtils.java#L76-L79 |
Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/jassimp/Jassimp.java | Jassimp.importFile | public static AiScene importFile(String filename) throws IOException {
return importFile(filename, EnumSet.noneOf(AiPostProcessSteps.class));
} | java | public static AiScene importFile(String filename) throws IOException {
return importFile(filename, EnumSet.noneOf(AiPostProcessSteps.class));
} | [
"public",
"static",
"AiScene",
"importFile",
"(",
"String",
"filename",
")",
"throws",
"IOException",
"{",
"return",
"importFile",
"(",
"filename",
",",
"EnumSet",
".",
"noneOf",
"(",
"AiPostProcessSteps",
".",
"class",
")",
")",
";",
"}"
] | Imports a file via assimp without post processing.
@param filename the file to import
@return the loaded scene
@throws IOException if an error occurs | [
"Imports",
"a",
"file",
"via",
"assimp",
"without",
"post",
"processing",
"."
] | train | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/jassimp/Jassimp.java#L77-L80 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_07_01/src/main/java/com/microsoft/azure/management/network/v2018_07_01/implementation/PublicIPAddressesInner.java | PublicIPAddressesInner.updateTags | public PublicIPAddressInner updateTags(String resourceGroupName, String publicIpAddressName, Map<String, String> tags) {
return updateTagsWithServiceResponseAsync(resourceGroupName, publicIpAddressName, tags).toBlocking().last().body();
} | java | public PublicIPAddressInner updateTags(String resourceGroupName, String publicIpAddressName, Map<String, String> tags) {
return updateTagsWithServiceResponseAsync(resourceGroupName, publicIpAddressName, tags).toBlocking().last().body();
} | [
"public",
"PublicIPAddressInner",
"updateTags",
"(",
"String",
"resourceGroupName",
",",
"String",
"publicIpAddressName",
",",
"Map",
"<",
"String",
",",
"String",
">",
"tags",
")",
"{",
"return",
"updateTagsWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"p... | Updates public IP address tags.
@param resourceGroupName The name of the resource group.
@param publicIpAddressName The name of the public IP address.
@param tags Resource tags.
@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 PublicIPAddressInner object if successful. | [
"Updates",
"public",
"IP",
"address",
"tags",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_07_01/src/main/java/com/microsoft/azure/management/network/v2018_07_01/implementation/PublicIPAddressesInner.java#L701-L703 |
tencentyun/cos-java-sdk | src/main/java/com/qcloud/cos/common_utils/CommonFileUtils.java | CommonFileUtils.getFileContent | public static String getFileContent(String filePath, long offset, int length) throws Exception {
FileInputStream fileInputStream = null;
try {
fileInputStream = getFileInputStream(filePath);
return getFileContent(fileInputStream, offset, length);
} finally {
closeFileStream(fileInputStream, filePath);
}
} | java | public static String getFileContent(String filePath, long offset, int length) throws Exception {
FileInputStream fileInputStream = null;
try {
fileInputStream = getFileInputStream(filePath);
return getFileContent(fileInputStream, offset, length);
} finally {
closeFileStream(fileInputStream, filePath);
}
} | [
"public",
"static",
"String",
"getFileContent",
"(",
"String",
"filePath",
",",
"long",
"offset",
",",
"int",
"length",
")",
"throws",
"Exception",
"{",
"FileInputStream",
"fileInputStream",
"=",
"null",
";",
"try",
"{",
"fileInputStream",
"=",
"getFileInputStream... | 获取文件指定块的内容
@param filePath 文件路径
@param offset 偏移量,即从哪里开始读取,单位为字节
@param length 读取的长度,单位为字节
@return 返回读取的内容,实际读取的长度小于等于length
@throws Exception | [
"获取文件指定块的内容"
] | train | https://github.com/tencentyun/cos-java-sdk/blob/6709a48f67c1ea7b82a7215f5037d6ccf218b630/src/main/java/com/qcloud/cos/common_utils/CommonFileUtils.java#L96-L104 |
alkacon/opencms-core | src/org/opencms/flex/CmsFlexCacheEntry.java | CmsFlexCacheEntry.addHeaders | public void addHeaders(Map<String, List<String>> headers) {
if (m_completed) {
return;
}
m_headers = headers;
Iterator<String> allHeaders = m_headers.keySet().iterator();
while (allHeaders.hasNext()) {
m_byteSize += CmsMemoryMonitor.getMemorySize(allHeaders.next());
}
} | java | public void addHeaders(Map<String, List<String>> headers) {
if (m_completed) {
return;
}
m_headers = headers;
Iterator<String> allHeaders = m_headers.keySet().iterator();
while (allHeaders.hasNext()) {
m_byteSize += CmsMemoryMonitor.getMemorySize(allHeaders.next());
}
} | [
"public",
"void",
"addHeaders",
"(",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"headers",
")",
"{",
"if",
"(",
"m_completed",
")",
"{",
"return",
";",
"}",
"m_headers",
"=",
"headers",
";",
"Iterator",
"<",
"String",
">",
"allHeaders"... | Add a map of headers to this cache entry,
which are usually collected in the class CmsFlexResponse first.<p>
@param headers the map of headers to add to the entry | [
"Add",
"a",
"map",
"of",
"headers",
"to",
"this",
"cache",
"entry",
"which",
"are",
"usually",
"collected",
"in",
"the",
"class",
"CmsFlexResponse",
"first",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/flex/CmsFlexCacheEntry.java#L195-L206 |
joniles/mpxj | src/main/java/net/sf/mpxj/fasttrack/FastTrackData.java | FastTrackData.logBlock | private void logBlock(int blockIndex, int startIndex, int blockLength)
{
if (m_log != null)
{
m_log.println("Block Index: " + blockIndex);
m_log.println("Length: " + blockLength + " (" + Integer.toHexString(blockLength) + ")");
m_log.println();
m_log.println(FastTrackUtility.hexdump(m_buffer, startIndex, blockLength, true, 16, ""));
m_log.flush();
}
} | java | private void logBlock(int blockIndex, int startIndex, int blockLength)
{
if (m_log != null)
{
m_log.println("Block Index: " + blockIndex);
m_log.println("Length: " + blockLength + " (" + Integer.toHexString(blockLength) + ")");
m_log.println();
m_log.println(FastTrackUtility.hexdump(m_buffer, startIndex, blockLength, true, 16, ""));
m_log.flush();
}
} | [
"private",
"void",
"logBlock",
"(",
"int",
"blockIndex",
",",
"int",
"startIndex",
",",
"int",
"blockLength",
")",
"{",
"if",
"(",
"m_log",
"!=",
"null",
")",
"{",
"m_log",
".",
"println",
"(",
"\"Block Index: \"",
"+",
"blockIndex",
")",
";",
"m_log",
"... | Log block data.
@param blockIndex current block index
@param startIndex start index
@param blockLength length | [
"Log",
"block",
"data",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/fasttrack/FastTrackData.java#L436-L446 |
alkacon/opencms-core | src-setup/org/opencms/setup/CmsSetupBean.java | CmsSetupBean.setDbProperty | public void setDbProperty(String key, String value) {
// extract the database key out of the entire key
String databaseKey = key.substring(0, key.indexOf('.'));
Properties databaseProperties = getDatabaseProperties().get(databaseKey);
databaseProperties.put(key, value);
} | java | public void setDbProperty(String key, String value) {
// extract the database key out of the entire key
String databaseKey = key.substring(0, key.indexOf('.'));
Properties databaseProperties = getDatabaseProperties().get(databaseKey);
databaseProperties.put(key, value);
} | [
"public",
"void",
"setDbProperty",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"// extract the database key out of the entire key",
"String",
"databaseKey",
"=",
"key",
".",
"substring",
"(",
"0",
",",
"key",
".",
"indexOf",
"(",
"'",
"'",
")",
")"... | This method sets the value for a given key in the database properties.<p>
@param key The key of the property
@param value The value of the property | [
"This",
"method",
"sets",
"the",
"value",
"for",
"a",
"given",
"key",
"in",
"the",
"database",
"properties",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-setup/org/opencms/setup/CmsSetupBean.java#L2119-L2125 |
VoltDB/voltdb | src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java | ArrayUtil.containsAt | public static boolean containsAt(byte[] arra, int start, byte[] arrb) {
return countSameElements(arra, start, arrb) == arrb.length;
} | java | public static boolean containsAt(byte[] arra, int start, byte[] arrb) {
return countSameElements(arra, start, arrb) == arrb.length;
} | [
"public",
"static",
"boolean",
"containsAt",
"(",
"byte",
"[",
"]",
"arra",
",",
"int",
"start",
",",
"byte",
"[",
"]",
"arrb",
")",
"{",
"return",
"countSameElements",
"(",
"arra",
",",
"start",
",",
"arrb",
")",
"==",
"arrb",
".",
"length",
";",
"}... | Returns true if arra from position start contains all elements of arrb
in sequential order. | [
"Returns",
"true",
"if",
"arra",
"from",
"position",
"start",
"contains",
"all",
"elements",
"of",
"arrb",
"in",
"sequential",
"order",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/ArrayUtil.java#L746-L748 |
mlhartme/mork | src/main/java/net/oneandone/mork/scanner/FA.java | FA.append | private int append(FA add) {
int relocation;
int idx;
relocation = used;
ensureCapacity(used + add.used);
for (idx = 0; idx < add.used; idx++) {
states[relocation + idx] =
new State(add.states[idx], relocation);
}
used += add.used;
return relocation;
} | java | private int append(FA add) {
int relocation;
int idx;
relocation = used;
ensureCapacity(used + add.used);
for (idx = 0; idx < add.used; idx++) {
states[relocation + idx] =
new State(add.states[idx], relocation);
}
used += add.used;
return relocation;
} | [
"private",
"int",
"append",
"(",
"FA",
"add",
")",
"{",
"int",
"relocation",
";",
"int",
"idx",
";",
"relocation",
"=",
"used",
";",
"ensureCapacity",
"(",
"used",
"+",
"add",
".",
"used",
")",
";",
"for",
"(",
"idx",
"=",
"0",
";",
"idx",
"<",
"... | Adds a copy of all states and transitions from the automaton
specified. No transition is added between old and new states.
States and transitions are relocated with the offsets specified. | [
"Adds",
"a",
"copy",
"of",
"all",
"states",
"and",
"transitions",
"from",
"the",
"automaton",
"specified",
".",
"No",
"transition",
"is",
"added",
"between",
"old",
"and",
"new",
"states",
".",
"States",
"and",
"transitions",
"are",
"relocated",
"with",
"the... | train | https://github.com/mlhartme/mork/blob/a069b087750c4133bfeebaf1f599c3bc96762113/src/main/java/net/oneandone/mork/scanner/FA.java#L271-L283 |
liyiorg/weixin-popular | src/main/java/weixin/popular/api/ScanAPI.java | ScanAPI.productClear | public static BaseResult productClear(String accessToken, ProductGet productGet) {
return productClear(accessToken, JsonUtil.toJSONString(productGet));
} | java | public static BaseResult productClear(String accessToken, ProductGet productGet) {
return productClear(accessToken, JsonUtil.toJSONString(productGet));
} | [
"public",
"static",
"BaseResult",
"productClear",
"(",
"String",
"accessToken",
",",
"ProductGet",
"productGet",
")",
"{",
"return",
"productClear",
"(",
"accessToken",
",",
"JsonUtil",
".",
"toJSONString",
"(",
"productGet",
")",
")",
";",
"}"
] | 清除商品信息
@param accessToken accessToken
@param productGet productGet
@return BaseResult | [
"清除商品信息"
] | train | https://github.com/liyiorg/weixin-popular/blob/c64255292d41463bdb671938feaabf42a335d82c/src/main/java/weixin/popular/api/ScanAPI.java#L249-L251 |
OnyxDevTools/onyx-database-parent | onyx-database-examples/spring-example/src/main/java/com/onyxdevtools/spring/MeetingController.java | MeetingController.findBoringMeetings | @SuppressWarnings({"unchecked", "SpellCheckingInspection"})
List<Meeting> findBoringMeetings()
{
Query query = new Query(Meeting.class, new QueryCriteria("notes", QueryCriteriaOperator.CONTAINS, "Boring"));
List<Meeting> boringMeetings = null;
try {
boringMeetings = persistenceManager.executeQuery(query);
} catch (OnyxException e) {
// Log an error
}
return boringMeetings;
} | java | @SuppressWarnings({"unchecked", "SpellCheckingInspection"})
List<Meeting> findBoringMeetings()
{
Query query = new Query(Meeting.class, new QueryCriteria("notes", QueryCriteriaOperator.CONTAINS, "Boring"));
List<Meeting> boringMeetings = null;
try {
boringMeetings = persistenceManager.executeQuery(query);
} catch (OnyxException e) {
// Log an error
}
return boringMeetings;
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unchecked\"",
",",
"\"SpellCheckingInspection\"",
"}",
")",
"List",
"<",
"Meeting",
">",
"findBoringMeetings",
"(",
")",
"{",
"Query",
"query",
"=",
"new",
"Query",
"(",
"Meeting",
".",
"class",
",",
"new",
"QueryCriteria"... | Method used to stream all meetings at work that are
snoozers and are really hard to stay awake but, you still have
to pay attention because someone is going to call on you and ask
you a dumb question.
@return A list of really boring meetings | [
"Method",
"used",
"to",
"stream",
"all",
"meetings",
"at",
"work",
"that",
"are",
"snoozers",
"and",
"are",
"really",
"hard",
"to",
"stay",
"awake",
"but",
"you",
"still",
"have",
"to",
"pay",
"attention",
"because",
"someone",
"is",
"going",
"to",
"call",... | train | https://github.com/OnyxDevTools/onyx-database-parent/blob/474dfc273a094dbc2ca08fcc08a2858cd538c920/onyx-database-examples/spring-example/src/main/java/com/onyxdevtools/spring/MeetingController.java#L43-L54 |
jasminb/jsonapi-converter | src/main/java/com/github/jasminb/jsonapi/ErrorUtils.java | ErrorUtils.parseErrorResponse | public static <T extends Errors> T parseErrorResponse(ObjectMapper mapper, ResponseBody errorResponse, Class<T> cls) throws IOException {
return mapper.readValue(errorResponse.bytes(), cls);
} | java | public static <T extends Errors> T parseErrorResponse(ObjectMapper mapper, ResponseBody errorResponse, Class<T> cls) throws IOException {
return mapper.readValue(errorResponse.bytes(), cls);
} | [
"public",
"static",
"<",
"T",
"extends",
"Errors",
">",
"T",
"parseErrorResponse",
"(",
"ObjectMapper",
"mapper",
",",
"ResponseBody",
"errorResponse",
",",
"Class",
"<",
"T",
">",
"cls",
")",
"throws",
"IOException",
"{",
"return",
"mapper",
".",
"readValue",... | Parses provided ResponseBody and returns it as T.
@param mapper Jackson Object mapper instance
@param errorResponse error response body
@return T collection
@throws IOException | [
"Parses",
"provided",
"ResponseBody",
"and",
"returns",
"it",
"as",
"T",
"."
] | train | https://github.com/jasminb/jsonapi-converter/blob/73b41c3b9274e70e62b3425071ca8afdc7bddaf6/src/main/java/com/github/jasminb/jsonapi/ErrorUtils.java#L32-L34 |
languagetool-org/languagetool | languagetool-core/src/main/java/org/languagetool/tools/StringTools.java | StringTools.addSpace | public static String addSpace(String word, Language language) {
String space = " ";
if (word.length() == 1) {
char c = word.charAt(0);
if ("fr".equals(language.getShortCode())) {
if (c == '.' || c == ',') {
space = "";
}
} else {
if (c == '.' || c == ',' || c == ';' || c == ':' || c == '?' || c == '!') {
space = "";
}
}
}
return space;
} | java | public static String addSpace(String word, Language language) {
String space = " ";
if (word.length() == 1) {
char c = word.charAt(0);
if ("fr".equals(language.getShortCode())) {
if (c == '.' || c == ',') {
space = "";
}
} else {
if (c == '.' || c == ',' || c == ';' || c == ':' || c == '?' || c == '!') {
space = "";
}
}
}
return space;
} | [
"public",
"static",
"String",
"addSpace",
"(",
"String",
"word",
",",
"Language",
"language",
")",
"{",
"String",
"space",
"=",
"\" \"",
";",
"if",
"(",
"word",
".",
"length",
"(",
")",
"==",
"1",
")",
"{",
"char",
"c",
"=",
"word",
".",
"charAt",
... | Adds spaces before words that are not punctuation.
@param word Word to add the preceding space.
@param language
Language of the word (to check typography conventions). Currently
French convention of not adding spaces only before '.' and ',' is
implemented; other languages assume that before ,.;:!? no spaces
should be added.
@return String containing a space or an empty string. | [
"Adds",
"spaces",
"before",
"words",
"that",
"are",
"not",
"punctuation",
"."
] | train | https://github.com/languagetool-org/languagetool/blob/b7a3d63883d242fb2525877c6382681c57a0a142/languagetool-core/src/main/java/org/languagetool/tools/StringTools.java#L372-L387 |
terrestris/shogun-core | src/shogun-core-main/src/main/java/de/terrestris/shoguncore/service/UserService.java | UserService.findByAccountName | @PostAuthorize("hasRole(@configHolder.getSuperAdminRoleName()) or hasPermission(#accountName, 'READ')")
@Transactional(readOnly = true)
public E findByAccountName(String accountName) {
return dao.findByAccountName(accountName);
} | java | @PostAuthorize("hasRole(@configHolder.getSuperAdminRoleName()) or hasPermission(#accountName, 'READ')")
@Transactional(readOnly = true)
public E findByAccountName(String accountName) {
return dao.findByAccountName(accountName);
} | [
"@",
"PostAuthorize",
"(",
"\"hasRole(@configHolder.getSuperAdminRoleName()) or hasPermission(#accountName, 'READ')\"",
")",
"@",
"Transactional",
"(",
"readOnly",
"=",
"true",
")",
"public",
"E",
"findByAccountName",
"(",
"String",
"accountName",
")",
"{",
"return",
"dao",... | Returns the user for the given (unique) account name.
If no user was found, null will be returned.
@param accountName A unique account name.
@return The unique user for the account name or null. | [
"Returns",
"the",
"user",
"for",
"the",
"given",
"(",
"unique",
")",
"account",
"name",
".",
"If",
"no",
"user",
"was",
"found",
"null",
"will",
"be",
"returned",
"."
] | train | https://github.com/terrestris/shogun-core/blob/3dbabda35ae63235265913c865dba389b050b6e6/src/shogun-core-main/src/main/java/de/terrestris/shoguncore/service/UserService.java#L98-L102 |
OpenLiberty/open-liberty | dev/com.ibm.ws.classloading/src/com/ibm/ws/classloading/java2sec/PermissionManager.java | PermissionManager.getEffectivePermissions | public ArrayList<Permission> getEffectivePermissions(String codeBase) {
List<Permission> emptyPermissions = Collections.emptyList();
return getEffectivePermissions(emptyPermissions, codeBase);
} | java | public ArrayList<Permission> getEffectivePermissions(String codeBase) {
List<Permission> emptyPermissions = Collections.emptyList();
return getEffectivePermissions(emptyPermissions, codeBase);
} | [
"public",
"ArrayList",
"<",
"Permission",
">",
"getEffectivePermissions",
"(",
"String",
"codeBase",
")",
"{",
"List",
"<",
"Permission",
">",
"emptyPermissions",
"=",
"Collections",
".",
"emptyList",
"(",
")",
";",
"return",
"getEffectivePermissions",
"(",
"empty... | Return the effective granted permissions.
@param codeBase - The code base of the code to obtain the effective permissions for.
@return the effective granted permissions. | [
"Return",
"the",
"effective",
"granted",
"permissions",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.classloading/src/com/ibm/ws/classloading/java2sec/PermissionManager.java#L530-L533 |
rwl/CSparseJ | src/main/java/edu/emory/mathcs/csparsej/tdouble/Dcs_utsolve.java | Dcs_utsolve.cs_utsolve | public static boolean cs_utsolve(Dcs U, double[] x) {
int p, j, n, Up[], Ui[];
double Ux[];
if (!Dcs_util.CS_CSC(U) || x == null)
return (false); /* check inputs */
n = U.n;
Up = U.p;
Ui = U.i;
Ux = U.x;
for (j = 0; j < n; j++) {
for (p = Up[j]; p < Up[j + 1] - 1; p++) {
x[j] -= Ux[p] * x[Ui[p]];
}
x[j] /= Ux[Up[j + 1] - 1];
}
return (true);
} | java | public static boolean cs_utsolve(Dcs U, double[] x) {
int p, j, n, Up[], Ui[];
double Ux[];
if (!Dcs_util.CS_CSC(U) || x == null)
return (false); /* check inputs */
n = U.n;
Up = U.p;
Ui = U.i;
Ux = U.x;
for (j = 0; j < n; j++) {
for (p = Up[j]; p < Up[j + 1] - 1; p++) {
x[j] -= Ux[p] * x[Ui[p]];
}
x[j] /= Ux[Up[j + 1] - 1];
}
return (true);
} | [
"public",
"static",
"boolean",
"cs_utsolve",
"(",
"Dcs",
"U",
",",
"double",
"[",
"]",
"x",
")",
"{",
"int",
"p",
",",
"j",
",",
"n",
",",
"Up",
"[",
"]",
",",
"Ui",
"[",
"]",
";",
"double",
"Ux",
"[",
"]",
";",
"if",
"(",
"!",
"Dcs_util",
... | Solves a lower triangular system U'x=b, where x and b are dense vectors.
The diagonal of U must be the last entry of each column.
@param U
upper triangular matrix in column-compressed form
@param x
size n, right hand side on input, solution on output
@return true if successful, false on error | [
"Solves",
"a",
"lower",
"triangular",
"system",
"U",
"x",
"=",
"b",
"where",
"x",
"and",
"b",
"are",
"dense",
"vectors",
".",
"The",
"diagonal",
"of",
"U",
"must",
"be",
"the",
"last",
"entry",
"of",
"each",
"column",
"."
] | train | https://github.com/rwl/CSparseJ/blob/6a6f66bccce1558156a961494358952603b0ac84/src/main/java/edu/emory/mathcs/csparsej/tdouble/Dcs_utsolve.java#L47-L63 |
EsotericSoftware/kryo | src/com/esotericsoftware/kryo/Kryo.java | Kryo.addDefaultSerializer | public void addDefaultSerializer (Class type, Serializer serializer) {
if (type == null) throw new IllegalArgumentException("type cannot be null.");
if (serializer == null) throw new IllegalArgumentException("serializer cannot be null.");
insertDefaultSerializer(type, new SingletonSerializerFactory(serializer));
} | java | public void addDefaultSerializer (Class type, Serializer serializer) {
if (type == null) throw new IllegalArgumentException("type cannot be null.");
if (serializer == null) throw new IllegalArgumentException("serializer cannot be null.");
insertDefaultSerializer(type, new SingletonSerializerFactory(serializer));
} | [
"public",
"void",
"addDefaultSerializer",
"(",
"Class",
"type",
",",
"Serializer",
"serializer",
")",
"{",
"if",
"(",
"type",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"type cannot be null.\"",
")",
";",
"if",
"(",
"serializer",
"==",... | Instances of the specified class will use the specified serializer when {@link #register(Class)} or
{@link #register(Class, int)} are called.
@see #setDefaultSerializer(Class) | [
"Instances",
"of",
"the",
"specified",
"class",
"will",
"use",
"the",
"specified",
"serializer",
"when",
"{"
] | train | https://github.com/EsotericSoftware/kryo/blob/a8be1ab26f347f299a3c3f7171d6447dd5390845/src/com/esotericsoftware/kryo/Kryo.java#L260-L264 |
alkacon/opencms-core | src/org/opencms/db/CmsDriverManager.java | CmsDriverManager.deleteRelationsWithSiblings | protected void deleteRelationsWithSiblings(CmsDbContext dbc, CmsResource resource) throws CmsException {
// get all siblings
List<CmsResource> siblings;
if (resource.getSiblingCount() > 1) {
siblings = readSiblings(dbc, resource, CmsResourceFilter.ALL);
} else {
siblings = new ArrayList<CmsResource>();
siblings.add(resource);
}
// clean the relations in content for all siblings
I_CmsVfsDriver vfsDriver = getVfsDriver(dbc);
Iterator<CmsResource> it = siblings.iterator();
while (it.hasNext()) {
CmsResource sibling = it.next();
// clean the relation information for this sibling
vfsDriver.deleteRelations(
dbc,
dbc.currentProject().getUuid(),
sibling,
CmsRelationFilter.TARGETS.filterDefinedInContent());
}
} | java | protected void deleteRelationsWithSiblings(CmsDbContext dbc, CmsResource resource) throws CmsException {
// get all siblings
List<CmsResource> siblings;
if (resource.getSiblingCount() > 1) {
siblings = readSiblings(dbc, resource, CmsResourceFilter.ALL);
} else {
siblings = new ArrayList<CmsResource>();
siblings.add(resource);
}
// clean the relations in content for all siblings
I_CmsVfsDriver vfsDriver = getVfsDriver(dbc);
Iterator<CmsResource> it = siblings.iterator();
while (it.hasNext()) {
CmsResource sibling = it.next();
// clean the relation information for this sibling
vfsDriver.deleteRelations(
dbc,
dbc.currentProject().getUuid(),
sibling,
CmsRelationFilter.TARGETS.filterDefinedInContent());
}
} | [
"protected",
"void",
"deleteRelationsWithSiblings",
"(",
"CmsDbContext",
"dbc",
",",
"CmsResource",
"resource",
")",
"throws",
"CmsException",
"{",
"// get all siblings",
"List",
"<",
"CmsResource",
">",
"siblings",
";",
"if",
"(",
"resource",
".",
"getSiblingCount",
... | Deletes all relations for the given resource and all its siblings.<p>
@param dbc the current database context
@param resource the resource to delete the resource for
@throws CmsException if something goes wrong | [
"Deletes",
"all",
"relations",
"for",
"the",
"given",
"resource",
"and",
"all",
"its",
"siblings",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/db/CmsDriverManager.java#L10352-L10374 |
javagl/Common | src/main/java/de/javagl/common/collections/Maps.java | Maps.getCount | public static <K> Integer getCount(Map<K, Integer> map, K k)
{
Integer count = map.get(k);
if (count == null)
{
count = 0;
map.put(k, count);
}
return count;
} | java | public static <K> Integer getCount(Map<K, Integer> map, K k)
{
Integer count = map.get(k);
if (count == null)
{
count = 0;
map.put(k, count);
}
return count;
} | [
"public",
"static",
"<",
"K",
">",
"Integer",
"getCount",
"(",
"Map",
"<",
"K",
",",
"Integer",
">",
"map",
",",
"K",
"k",
")",
"{",
"Integer",
"count",
"=",
"map",
".",
"get",
"(",
"k",
")",
";",
"if",
"(",
"count",
"==",
"null",
")",
"{",
"... | Returns the value that is stored for the given key in the given map.
If there is no value stored, then 0 will be inserted into the map
and returned
@param <K> The key type
@param map The map
@param k The key
@return The value | [
"Returns",
"the",
"value",
"that",
"is",
"stored",
"for",
"the",
"given",
"key",
"in",
"the",
"given",
"map",
".",
"If",
"there",
"is",
"no",
"value",
"stored",
"then",
"0",
"will",
"be",
"inserted",
"into",
"the",
"map",
"and",
"returned"
] | train | https://github.com/javagl/Common/blob/5a4876b48c3a2dc61d21324733cf37512d721c33/src/main/java/de/javagl/common/collections/Maps.java#L67-L76 |
elki-project/elki | elki-core-distance/src/main/java/de/lmu/ifi/dbs/elki/distance/similarityfunction/kernel/KernelMatrix.java | KernelMatrix.centerMatrix | public static double[][] centerMatrix(final double[][] matrix) {
// FIXME: implement more efficiently. Maybe in matrix class itself?
final double[][] normalizingMatrix = new double[matrix.length][matrix[0].length];
for(double[] row : normalizingMatrix) {
Arrays.fill(row, 1.0 / matrix[0].length);
}
return times(plusEquals(minusEquals(minus(matrix, times(normalizingMatrix, matrix)), times(matrix, normalizingMatrix)), times(normalizingMatrix, matrix)), normalizingMatrix);
} | java | public static double[][] centerMatrix(final double[][] matrix) {
// FIXME: implement more efficiently. Maybe in matrix class itself?
final double[][] normalizingMatrix = new double[matrix.length][matrix[0].length];
for(double[] row : normalizingMatrix) {
Arrays.fill(row, 1.0 / matrix[0].length);
}
return times(plusEquals(minusEquals(minus(matrix, times(normalizingMatrix, matrix)), times(matrix, normalizingMatrix)), times(normalizingMatrix, matrix)), normalizingMatrix);
} | [
"public",
"static",
"double",
"[",
"]",
"[",
"]",
"centerMatrix",
"(",
"final",
"double",
"[",
"]",
"[",
"]",
"matrix",
")",
"{",
"// FIXME: implement more efficiently. Maybe in matrix class itself?",
"final",
"double",
"[",
"]",
"[",
"]",
"normalizingMatrix",
"="... | Centers the matrix in feature space according to Smola et Schoelkopf,
Learning with Kernels p. 431 Alters the input matrix. If you still need the
original matrix, use
<code>centeredMatrix = centerKernelMatrix(uncenteredMatrix.copy()) {</code>
@param matrix the matrix to be centered
@return centered matrix (for convenience) | [
"Centers",
"the",
"matrix",
"in",
"feature",
"space",
"according",
"to",
"Smola",
"et",
"Schoelkopf",
"Learning",
"with",
"Kernels",
"p",
".",
"431",
"Alters",
"the",
"input",
"matrix",
".",
"If",
"you",
"still",
"need",
"the",
"original",
"matrix",
"use",
... | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-distance/src/main/java/de/lmu/ifi/dbs/elki/distance/similarityfunction/kernel/KernelMatrix.java#L243-L250 |
UrielCh/ovh-java-sdk | ovh-java-sdk-emaildomain/src/main/java/net/minidev/ovh/api/ApiOvhEmaildomain.java | ApiOvhEmaildomain.delegatedAccount_email_GET | public OvhAccountDelegated delegatedAccount_email_GET(String email) throws IOException {
String qPath = "/email/domain/delegatedAccount/{email}";
StringBuilder sb = path(qPath, email);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhAccountDelegated.class);
} | java | public OvhAccountDelegated delegatedAccount_email_GET(String email) throws IOException {
String qPath = "/email/domain/delegatedAccount/{email}";
StringBuilder sb = path(qPath, email);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhAccountDelegated.class);
} | [
"public",
"OvhAccountDelegated",
"delegatedAccount_email_GET",
"(",
"String",
"email",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/email/domain/delegatedAccount/{email}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"email",
")",
";... | Get this object properties
REST: GET /email/domain/delegatedAccount/{email}
@param email [required] Email | [
"Get",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-emaildomain/src/main/java/net/minidev/ovh/api/ApiOvhEmaildomain.java#L271-L276 |
xcesco/kripton | kripton-processor/src/main/java/com/abubusoft/kripton/processor/sqlite/grammars/jql/JQLBuilder.java | JQLBuilder.forEachFields | private static String forEachFields(final Set<String> fields, OnFieldListener listener) {
StringBuilder builder = new StringBuilder();
{
String comma = "";
for (String item : fields) {
builder.append(comma + listener.onField(item));
comma = ", ";
}
}
return builder.toString();
} | java | private static String forEachFields(final Set<String> fields, OnFieldListener listener) {
StringBuilder builder = new StringBuilder();
{
String comma = "";
for (String item : fields) {
builder.append(comma + listener.onField(item));
comma = ", ";
}
}
return builder.toString();
} | [
"private",
"static",
"String",
"forEachFields",
"(",
"final",
"Set",
"<",
"String",
">",
"fields",
",",
"OnFieldListener",
"listener",
")",
"{",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"{",
"String",
"comma",
"=",
"\"\"",
";",... | For each fields.
@param fields
the fields
@param listener
the listener
@return the string | [
"For",
"each",
"fields",
"."
] | train | https://github.com/xcesco/kripton/blob/90de2c0523d39b99e81b8d38aa996898762f594a/kripton-processor/src/main/java/com/abubusoft/kripton/processor/sqlite/grammars/jql/JQLBuilder.java#L1071-L1082 |
haraldk/TwelveMonkeys | imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/QuickDrawContext.java | QuickDrawContext.paintRoundRect | public void paintRoundRect(final Rectangle2D pRectangle, int pArcW, int pArcH) {
paintShape(toRoundRect(pRectangle, pArcW, pArcH));
} | java | public void paintRoundRect(final Rectangle2D pRectangle, int pArcW, int pArcH) {
paintShape(toRoundRect(pRectangle, pArcW, pArcH));
} | [
"public",
"void",
"paintRoundRect",
"(",
"final",
"Rectangle2D",
"pRectangle",
",",
"int",
"pArcW",
",",
"int",
"pArcH",
")",
"{",
"paintShape",
"(",
"toRoundRect",
"(",
"pRectangle",
",",
"pArcW",
",",
"pArcH",
")",
")",
";",
"}"
] | PaintRooundRect(r,int,int) // fills a rectangle's interior with the pattern of the
graphics pen, using the pattern mode of the graphics pen.
@param pRectangle the rectangle to paint
@param pArcW width of the oval defining the rounded corner.
@param pArcH height of the oval defining the rounded corner. | [
"PaintRooundRect",
"(",
"r",
"int",
"int",
")",
"//",
"fills",
"a",
"rectangle",
"s",
"interior",
"with",
"the",
"pattern",
"of",
"the",
"graphics",
"pen",
"using",
"the",
"pattern",
"mode",
"of",
"the",
"graphics",
"pen",
"."
] | train | https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/QuickDrawContext.java#L606-L608 |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.utils/src/com/ibm/ws/sib/utils/ras/SibTr.java | SibTr.formatSliceToSB | private static void formatSliceToSB(StringBuilder sb, DataSlice slice, int max)
{
if (slice != null)
{
if (slice.getBytes() != null)
{
formatBytesToSB(sb, slice.getBytes(), slice.getOffset(), slice.getLength(), true, max);
}
else
{
sb.append("empty slice"+ls);
}
}
else
{
sb.append("slice is null"+ls);
}
} | java | private static void formatSliceToSB(StringBuilder sb, DataSlice slice, int max)
{
if (slice != null)
{
if (slice.getBytes() != null)
{
formatBytesToSB(sb, slice.getBytes(), slice.getOffset(), slice.getLength(), true, max);
}
else
{
sb.append("empty slice"+ls);
}
}
else
{
sb.append("slice is null"+ls);
}
} | [
"private",
"static",
"void",
"formatSliceToSB",
"(",
"StringBuilder",
"sb",
",",
"DataSlice",
"slice",
",",
"int",
"max",
")",
"{",
"if",
"(",
"slice",
"!=",
"null",
")",
"{",
"if",
"(",
"slice",
".",
"getBytes",
"(",
")",
"!=",
"null",
")",
"{",
"fo... | Produce a formatted view of a DataSlice. Duplicate output lines are
suppressed to save space.
<p>
@param sb the StringBuilder to the end of which the slice will be formatted
@param slice The DataSlice to be formatted
@param max The maximum amount of data to format for the slice
@return the formatted data slice | [
"Produce",
"a",
"formatted",
"view",
"of",
"a",
"DataSlice",
".",
"Duplicate",
"output",
"lines",
"are",
"suppressed",
"to",
"save",
"space",
".",
"<p",
">"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.utils/src/com/ibm/ws/sib/utils/ras/SibTr.java#L1327-L1344 |
ironjacamar/ironjacamar | common/src/main/java/org/ironjacamar/common/metadata/common/AbstractParser.java | AbstractParser.attributeAsBoolean | protected Boolean attributeAsBoolean(XMLStreamReader reader, String attributeName, Boolean defaultValue,
Map<String, String> expressions)
throws XMLStreamException, ParserException
{
String attributeString = rawAttributeText(reader, attributeName);
if (attributeName != null && expressions != null && attributeString != null &&
attributeString.indexOf("${") != -1)
expressions.put(attributeName, attributeString);
String stringValue = getSubstitutionValue(attributeString);
if (StringUtils.isEmpty(stringValue) || stringValue.trim().equalsIgnoreCase("true") ||
stringValue.trim().equalsIgnoreCase("false"))
{
return StringUtils.isEmpty(stringValue) ? defaultValue : Boolean.valueOf(stringValue.trim());
}
else
{
throw new ParserException(bundle.attributeAsBoolean(attributeString, reader.getLocalName()));
}
} | java | protected Boolean attributeAsBoolean(XMLStreamReader reader, String attributeName, Boolean defaultValue,
Map<String, String> expressions)
throws XMLStreamException, ParserException
{
String attributeString = rawAttributeText(reader, attributeName);
if (attributeName != null && expressions != null && attributeString != null &&
attributeString.indexOf("${") != -1)
expressions.put(attributeName, attributeString);
String stringValue = getSubstitutionValue(attributeString);
if (StringUtils.isEmpty(stringValue) || stringValue.trim().equalsIgnoreCase("true") ||
stringValue.trim().equalsIgnoreCase("false"))
{
return StringUtils.isEmpty(stringValue) ? defaultValue : Boolean.valueOf(stringValue.trim());
}
else
{
throw new ParserException(bundle.attributeAsBoolean(attributeString, reader.getLocalName()));
}
} | [
"protected",
"Boolean",
"attributeAsBoolean",
"(",
"XMLStreamReader",
"reader",
",",
"String",
"attributeName",
",",
"Boolean",
"defaultValue",
",",
"Map",
"<",
"String",
",",
"String",
">",
"expressions",
")",
"throws",
"XMLStreamException",
",",
"ParserException",
... | convert an xml attribute in boolean value. Empty elements results in default value
@param reader the StAX reader
@param attributeName the name of the attribute
@param defaultValue defaultValue
@param expressions The expressions
@return the boolean representing element
@throws XMLStreamException StAX exception
@throws ParserException in case of not valid boolean for given attribute | [
"convert",
"an",
"xml",
"attribute",
"in",
"boolean",
"value",
".",
"Empty",
"elements",
"results",
"in",
"default",
"value"
] | train | https://github.com/ironjacamar/ironjacamar/blob/f0389ee7e62aa8b40ba09b251edad76d220ea796/common/src/main/java/org/ironjacamar/common/metadata/common/AbstractParser.java#L128-L148 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.