repository_name stringlengths 7 58 | func_path_in_repository stringlengths 11 218 | func_name stringlengths 4 140 | whole_func_string stringlengths 153 5.32k | language stringclasses 1
value | func_code_string stringlengths 72 4k | func_code_tokens listlengths 20 832 | func_documentation_string stringlengths 61 2k | func_documentation_tokens listlengths 1 647 | split_name stringclasses 1
value | func_code_url stringlengths 102 339 |
|---|---|---|---|---|---|---|---|---|---|---|
Azure/azure-sdk-for-java | cognitiveservices/data-plane/language/luis/runtime/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/runtime/LuisRuntimeManager.java | LuisRuntimeManager.authenticate | public static LuisRuntimeAPI authenticate(String baseUrl, ServiceClientCredentials credentials) {
"""
Initializes an instance of Language Understanding (LUIS) Runtime API client.
@param baseUrl the base URL of the service
@param credentials the management credentials for Azure
@return the Language Understanding (LUIS) Runtime API client
"""
String endpointAPI = null;
try {
URI uri = new URI(baseUrl);
endpointAPI = uri.getHost();
} catch (Exception e) {
endpointAPI = EndpointAPI.US_WEST.toString();
}
return new LuisRuntimeAPIImpl(baseUrl, credentials)
.withEndpoint(endpointAPI);
} | java | public static LuisRuntimeAPI authenticate(String baseUrl, ServiceClientCredentials credentials) {
String endpointAPI = null;
try {
URI uri = new URI(baseUrl);
endpointAPI = uri.getHost();
} catch (Exception e) {
endpointAPI = EndpointAPI.US_WEST.toString();
}
return new LuisRuntimeAPIImpl(baseUrl, credentials)
.withEndpoint(endpointAPI);
} | [
"public",
"static",
"LuisRuntimeAPI",
"authenticate",
"(",
"String",
"baseUrl",
",",
"ServiceClientCredentials",
"credentials",
")",
"{",
"String",
"endpointAPI",
"=",
"null",
";",
"try",
"{",
"URI",
"uri",
"=",
"new",
"URI",
"(",
"baseUrl",
")",
";",
"endpoin... | Initializes an instance of Language Understanding (LUIS) Runtime API client.
@param baseUrl the base URL of the service
@param credentials the management credentials for Azure
@return the Language Understanding (LUIS) Runtime API client | [
"Initializes",
"an",
"instance",
"of",
"Language",
"Understanding",
"(",
"LUIS",
")",
"Runtime",
"API",
"client",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/runtime/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/runtime/LuisRuntimeManager.java#L92-L102 |
code4everything/util | src/main/java/com/zhazhapan/util/FileExecutor.java | FileExecutor.copyFiles | public static void copyFiles(String[] files, String storageFolder) throws IOException {
"""
批量复制文件,使用原文件名
@param files 文件路径数组
@param storageFolder 存储目录
@throws IOException 异常
"""
copyFiles(getFiles(files), storageFolder);
} | java | public static void copyFiles(String[] files, String storageFolder) throws IOException {
copyFiles(getFiles(files), storageFolder);
} | [
"public",
"static",
"void",
"copyFiles",
"(",
"String",
"[",
"]",
"files",
",",
"String",
"storageFolder",
")",
"throws",
"IOException",
"{",
"copyFiles",
"(",
"getFiles",
"(",
"files",
")",
",",
"storageFolder",
")",
";",
"}"
] | 批量复制文件,使用原文件名
@param files 文件路径数组
@param storageFolder 存储目录
@throws IOException 异常 | [
"批量复制文件,使用原文件名"
] | train | https://github.com/code4everything/util/blob/1fc9f0ead1108f4d7208ba7c000df4244f708418/src/main/java/com/zhazhapan/util/FileExecutor.java#L436-L438 |
liferay/com-liferay-commerce | commerce-product-api/src/main/java/com/liferay/commerce/product/service/persistence/CPOptionUtil.java | CPOptionUtil.findByUUID_G | public static CPOption findByUUID_G(String uuid, long groupId)
throws com.liferay.commerce.product.exception.NoSuchCPOptionException {
"""
Returns the cp option where uuid = ? and groupId = ? or throws a {@link NoSuchCPOptionException} if it could not be found.
@param uuid the uuid
@param groupId the group ID
@return the matching cp option
@throws NoSuchCPOptionException if a matching cp option could not be found
"""
return getPersistence().findByUUID_G(uuid, groupId);
} | java | public static CPOption findByUUID_G(String uuid, long groupId)
throws com.liferay.commerce.product.exception.NoSuchCPOptionException {
return getPersistence().findByUUID_G(uuid, groupId);
} | [
"public",
"static",
"CPOption",
"findByUUID_G",
"(",
"String",
"uuid",
",",
"long",
"groupId",
")",
"throws",
"com",
".",
"liferay",
".",
"commerce",
".",
"product",
".",
"exception",
".",
"NoSuchCPOptionException",
"{",
"return",
"getPersistence",
"(",
")",
"... | Returns the cp option where uuid = ? and groupId = ? or throws a {@link NoSuchCPOptionException} if it could not be found.
@param uuid the uuid
@param groupId the group ID
@return the matching cp option
@throws NoSuchCPOptionException if a matching cp option could not be found | [
"Returns",
"the",
"cp",
"option",
"where",
"uuid",
"=",
"?",
";",
"and",
"groupId",
"=",
"?",
";",
"or",
"throws",
"a",
"{",
"@link",
"NoSuchCPOptionException",
"}",
"if",
"it",
"could",
"not",
"be",
"found",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-product-api/src/main/java/com/liferay/commerce/product/service/persistence/CPOptionUtil.java#L274-L277 |
wcm-io/wcm-io-tooling | maven/plugins/json-dialog-conversion-plugin/src/main/java/io/wcm/maven/plugins/jsondlgcnv/DialogConverter.java | DialogConverter.rewriteProperty | private void rewriteProperty(JSONObject node, String key, JSONArray rewriteProperty) throws JSONException {
"""
Applies a string rewrite to a property.
@param node Node
@param key the property name to rewrite
@param rewriteProperty the property that defines the string rewrite
@throws JSONException
"""
if (node.get(cleanup(key)) instanceof String) {
if (rewriteProperty.length() == 2) {
if (rewriteProperty.get(0) instanceof String && rewriteProperty.get(1) instanceof String) {
String pattern = rewriteProperty.getString(0);
String replacement = rewriteProperty.getString(1);
Pattern compiledPattern = Pattern.compile(pattern);
Matcher matcher = compiledPattern.matcher(node.getString(cleanup(key)));
node.put(cleanup(key), matcher.replaceAll(replacement));
}
}
}
} | java | private void rewriteProperty(JSONObject node, String key, JSONArray rewriteProperty) throws JSONException {
if (node.get(cleanup(key)) instanceof String) {
if (rewriteProperty.length() == 2) {
if (rewriteProperty.get(0) instanceof String && rewriteProperty.get(1) instanceof String) {
String pattern = rewriteProperty.getString(0);
String replacement = rewriteProperty.getString(1);
Pattern compiledPattern = Pattern.compile(pattern);
Matcher matcher = compiledPattern.matcher(node.getString(cleanup(key)));
node.put(cleanup(key), matcher.replaceAll(replacement));
}
}
}
} | [
"private",
"void",
"rewriteProperty",
"(",
"JSONObject",
"node",
",",
"String",
"key",
",",
"JSONArray",
"rewriteProperty",
")",
"throws",
"JSONException",
"{",
"if",
"(",
"node",
".",
"get",
"(",
"cleanup",
"(",
"key",
")",
")",
"instanceof",
"String",
")",... | Applies a string rewrite to a property.
@param node Node
@param key the property name to rewrite
@param rewriteProperty the property that defines the string rewrite
@throws JSONException | [
"Applies",
"a",
"string",
"rewrite",
"to",
"a",
"property",
"."
] | train | https://github.com/wcm-io/wcm-io-tooling/blob/1abcd01dd3ad4cc248f03b431f929573d84fa9b4/maven/plugins/json-dialog-conversion-plugin/src/main/java/io/wcm/maven/plugins/jsondlgcnv/DialogConverter.java#L349-L362 |
BotMill/fb-botmill | src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/ReplyFactory.java | ReplyFactory.addAirlineFlightUpdateTemplate | public static AirlineFlightUpdateTemplateBuilder addAirlineFlightUpdateTemplate(
String introMessage, String locale, String pnrNumber,
UpdateType updateType) {
"""
Adds an Airline Flight Update Template to the response.
@param introMessage
the message to send before the template. It can't be empty.
@param locale
the current locale. It can't be empty and must be in format
[a-z]{2}_[A-Z]{2}. Locale must be in format [a-z]{2}_[A-Z]{2}.
For more information see<a href=
"https://developers.facebook.com/docs/internationalization#locales"
> Facebook's locale support</a>.
@param pnrNumber
the Passenger Name Record number (Booking Number). It can't be
empty.
@param updateType
an {@link UpdateType} object that represents the kind of
status update of the flight. It can't be null.
@return a builder for the response.
@see <a href=
"https://developers.facebook.com/docs/messenger-platform/send-api-reference/airline-update-template"
> Facebook's Messenger Platform Airline Flight Update Template
Documentation</a>
"""
return new AirlineFlightUpdateTemplateBuilder(introMessage, locale,
pnrNumber, updateType);
} | java | public static AirlineFlightUpdateTemplateBuilder addAirlineFlightUpdateTemplate(
String introMessage, String locale, String pnrNumber,
UpdateType updateType) {
return new AirlineFlightUpdateTemplateBuilder(introMessage, locale,
pnrNumber, updateType);
} | [
"public",
"static",
"AirlineFlightUpdateTemplateBuilder",
"addAirlineFlightUpdateTemplate",
"(",
"String",
"introMessage",
",",
"String",
"locale",
",",
"String",
"pnrNumber",
",",
"UpdateType",
"updateType",
")",
"{",
"return",
"new",
"AirlineFlightUpdateTemplateBuilder",
... | Adds an Airline Flight Update Template to the response.
@param introMessage
the message to send before the template. It can't be empty.
@param locale
the current locale. It can't be empty and must be in format
[a-z]{2}_[A-Z]{2}. Locale must be in format [a-z]{2}_[A-Z]{2}.
For more information see<a href=
"https://developers.facebook.com/docs/internationalization#locales"
> Facebook's locale support</a>.
@param pnrNumber
the Passenger Name Record number (Booking Number). It can't be
empty.
@param updateType
an {@link UpdateType} object that represents the kind of
status update of the flight. It can't be null.
@return a builder for the response.
@see <a href=
"https://developers.facebook.com/docs/messenger-platform/send-api-reference/airline-update-template"
> Facebook's Messenger Platform Airline Flight Update Template
Documentation</a> | [
"Adds",
"an",
"Airline",
"Flight",
"Update",
"Template",
"to",
"the",
"response",
"."
] | train | https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/ReplyFactory.java#L375-L380 |
rjstanford/protea-http | src/main/java/cc/protea/util/http/Request.java | Request.addQueryParameter | public Request addQueryParameter(final String name, final String value) {
"""
Adds a Query Parameter to a list. The list is converted to a String and appended to the URL when the Request is submitted.
@param name
The Query Parameter's name
@param value
The Query Parameter's value
@return this Request, to support chained method calls
"""
this.query.put(name, value);
return this;
} | java | public Request addQueryParameter(final String name, final String value) {
this.query.put(name, value);
return this;
} | [
"public",
"Request",
"addQueryParameter",
"(",
"final",
"String",
"name",
",",
"final",
"String",
"value",
")",
"{",
"this",
".",
"query",
".",
"put",
"(",
"name",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] | Adds a Query Parameter to a list. The list is converted to a String and appended to the URL when the Request is submitted.
@param name
The Query Parameter's name
@param value
The Query Parameter's value
@return this Request, to support chained method calls | [
"Adds",
"a",
"Query",
"Parameter",
"to",
"a",
"list",
".",
"The",
"list",
"is",
"converted",
"to",
"a",
"String",
"and",
"appended",
"to",
"the",
"URL",
"when",
"the",
"Request",
"is",
"submitted",
"."
] | train | https://github.com/rjstanford/protea-http/blob/4d4a18805639181a738faff199e39d58337169ea/src/main/java/cc/protea/util/http/Request.java#L78-L81 |
alkacon/opencms-core | src-gwt/org/opencms/acacia/client/CmsUndoRedoHandler.java | CmsUndoRedoHandler.addChange | public void addChange(String valuePath, String attributeName, int valueIndex, ChangeType changeType) {
"""
Adds a change to the undo stack.<p>
@param valuePath the entity value path
@param attributeName the attribute name
@param valueIndex the value index
@param changeType the change type
"""
if (ChangeType.value.equals(changeType)) {
if (m_changeTimer != null) {
if (!m_changeTimer.matches(valuePath, attributeName, valueIndex)) {
// only in case the change properties of the timer do not match the current change,
// add the last change and start a new timer
m_changeTimer.cancel();
m_changeTimer.run();
m_changeTimer = new ChangeTimer(valuePath, attributeName, valueIndex, changeType);
m_changeTimer.schedule(CHANGE_TIMER_DELAY);
}
} else {
m_changeTimer = new ChangeTimer(valuePath, attributeName, valueIndex, changeType);
m_changeTimer.schedule(CHANGE_TIMER_DELAY);
}
} else {
if (m_changeTimer != null) {
m_changeTimer.cancel();
m_changeTimer.run();
}
internalAddChange(valuePath, attributeName, valueIndex, changeType);
}
} | java | public void addChange(String valuePath, String attributeName, int valueIndex, ChangeType changeType) {
if (ChangeType.value.equals(changeType)) {
if (m_changeTimer != null) {
if (!m_changeTimer.matches(valuePath, attributeName, valueIndex)) {
// only in case the change properties of the timer do not match the current change,
// add the last change and start a new timer
m_changeTimer.cancel();
m_changeTimer.run();
m_changeTimer = new ChangeTimer(valuePath, attributeName, valueIndex, changeType);
m_changeTimer.schedule(CHANGE_TIMER_DELAY);
}
} else {
m_changeTimer = new ChangeTimer(valuePath, attributeName, valueIndex, changeType);
m_changeTimer.schedule(CHANGE_TIMER_DELAY);
}
} else {
if (m_changeTimer != null) {
m_changeTimer.cancel();
m_changeTimer.run();
}
internalAddChange(valuePath, attributeName, valueIndex, changeType);
}
} | [
"public",
"void",
"addChange",
"(",
"String",
"valuePath",
",",
"String",
"attributeName",
",",
"int",
"valueIndex",
",",
"ChangeType",
"changeType",
")",
"{",
"if",
"(",
"ChangeType",
".",
"value",
".",
"equals",
"(",
"changeType",
")",
")",
"{",
"if",
"(... | Adds a change to the undo stack.<p>
@param valuePath the entity value path
@param attributeName the attribute name
@param valueIndex the value index
@param changeType the change type | [
"Adds",
"a",
"change",
"to",
"the",
"undo",
"stack",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/acacia/client/CmsUndoRedoHandler.java#L317-L340 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/string/StringHelper.java | StringHelper.getNotNull | @Nullable
public static String getNotNull (@Nullable final String s, final String sDefaultIfNull) {
"""
Get the passed string but never return <code>null</code>. If the passed
parameter is <code>null</code> the second parameter is returned.
@param s
The parameter to be not <code>null</code>.
@param sDefaultIfNull
The value to be used of the first parameter is <code>null</code>. May
be <code>null</code> but in this case the call to this method is
obsolete.
@return The passed default value if the string is <code>null</code>,
otherwise the input string.
"""
return s == null ? sDefaultIfNull : s;
} | java | @Nullable
public static String getNotNull (@Nullable final String s, final String sDefaultIfNull)
{
return s == null ? sDefaultIfNull : s;
} | [
"@",
"Nullable",
"public",
"static",
"String",
"getNotNull",
"(",
"@",
"Nullable",
"final",
"String",
"s",
",",
"final",
"String",
"sDefaultIfNull",
")",
"{",
"return",
"s",
"==",
"null",
"?",
"sDefaultIfNull",
":",
"s",
";",
"}"
] | Get the passed string but never return <code>null</code>. If the passed
parameter is <code>null</code> the second parameter is returned.
@param s
The parameter to be not <code>null</code>.
@param sDefaultIfNull
The value to be used of the first parameter is <code>null</code>. May
be <code>null</code> but in this case the call to this method is
obsolete.
@return The passed default value if the string is <code>null</code>,
otherwise the input string. | [
"Get",
"the",
"passed",
"string",
"but",
"never",
"return",
"<code",
">",
"null<",
"/",
"code",
">",
".",
"If",
"the",
"passed",
"parameter",
"is",
"<code",
">",
"null<",
"/",
"code",
">",
"the",
"second",
"parameter",
"is",
"returned",
"."
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/string/StringHelper.java#L4528-L4532 |
antlrjavaparser/antlr-java-parser | src/main/java/com/github/antlrjavaparser/ASTHelper.java | ASTHelper.createFieldDeclaration | public static FieldDeclaration createFieldDeclaration(int modifiers, Type type, String name) {
"""
Creates a {@link FieldDeclaration}.
@param modifiers
modifiers
@param type
type
@param name
field name
@return instance of {@link FieldDeclaration}
"""
VariableDeclaratorId id = new VariableDeclaratorId(name);
VariableDeclarator variable = new VariableDeclarator(id);
return createFieldDeclaration(modifiers, type, variable);
} | java | public static FieldDeclaration createFieldDeclaration(int modifiers, Type type, String name) {
VariableDeclaratorId id = new VariableDeclaratorId(name);
VariableDeclarator variable = new VariableDeclarator(id);
return createFieldDeclaration(modifiers, type, variable);
} | [
"public",
"static",
"FieldDeclaration",
"createFieldDeclaration",
"(",
"int",
"modifiers",
",",
"Type",
"type",
",",
"String",
"name",
")",
"{",
"VariableDeclaratorId",
"id",
"=",
"new",
"VariableDeclaratorId",
"(",
"name",
")",
";",
"VariableDeclarator",
"variable"... | Creates a {@link FieldDeclaration}.
@param modifiers
modifiers
@param type
type
@param name
field name
@return instance of {@link FieldDeclaration} | [
"Creates",
"a",
"{",
"@link",
"FieldDeclaration",
"}",
"."
] | train | https://github.com/antlrjavaparser/antlr-java-parser/blob/077160deb44d952c40c442800abd91af7e6fe006/src/main/java/com/github/antlrjavaparser/ASTHelper.java#L136-L140 |
ManfredTremmel/gwt-commons-lang3 | src/main/java/org/apache/commons/lang3/StringUtils.java | StringUtils.indexOfAnyBut | public static int indexOfAnyBut(final CharSequence seq, final CharSequence searchChars) {
"""
<p>Search a CharSequence to find the first index of any
character not in the given set of characters.</p>
<p>A {@code null} CharSequence will return {@code -1}.
A {@code null} or empty search string will return {@code -1}.</p>
<pre>
StringUtils.indexOfAnyBut(null, *) = -1
StringUtils.indexOfAnyBut("", *) = -1
StringUtils.indexOfAnyBut(*, null) = -1
StringUtils.indexOfAnyBut(*, "") = -1
StringUtils.indexOfAnyBut("zzabyycdxx", "za") = 3
StringUtils.indexOfAnyBut("zzabyycdxx", "") = -1
StringUtils.indexOfAnyBut("aba","ab") = -1
</pre>
@param seq the CharSequence to check, may be null
@param searchChars the chars to search for, may be null
@return the index of any of the chars, -1 if no match or null input
@since 2.0
@since 3.0 Changed signature from indexOfAnyBut(String, String) to indexOfAnyBut(CharSequence, CharSequence)
"""
if (isEmpty(seq) || isEmpty(searchChars)) {
return INDEX_NOT_FOUND;
}
final int strLen = seq.length();
for (int i = 0; i < strLen; i++) {
final char ch = seq.charAt(i);
final boolean chFound = CharSequenceUtils.indexOf(searchChars, ch, 0) >= 0;
if (i + 1 < strLen && Character.isHighSurrogate(ch)) {
final char ch2 = seq.charAt(i + 1);
if (chFound && CharSequenceUtils.indexOf(searchChars, ch2, 0) < 0) {
return i;
}
} else {
if (!chFound) {
return i;
}
}
}
return INDEX_NOT_FOUND;
} | java | public static int indexOfAnyBut(final CharSequence seq, final CharSequence searchChars) {
if (isEmpty(seq) || isEmpty(searchChars)) {
return INDEX_NOT_FOUND;
}
final int strLen = seq.length();
for (int i = 0; i < strLen; i++) {
final char ch = seq.charAt(i);
final boolean chFound = CharSequenceUtils.indexOf(searchChars, ch, 0) >= 0;
if (i + 1 < strLen && Character.isHighSurrogate(ch)) {
final char ch2 = seq.charAt(i + 1);
if (chFound && CharSequenceUtils.indexOf(searchChars, ch2, 0) < 0) {
return i;
}
} else {
if (!chFound) {
return i;
}
}
}
return INDEX_NOT_FOUND;
} | [
"public",
"static",
"int",
"indexOfAnyBut",
"(",
"final",
"CharSequence",
"seq",
",",
"final",
"CharSequence",
"searchChars",
")",
"{",
"if",
"(",
"isEmpty",
"(",
"seq",
")",
"||",
"isEmpty",
"(",
"searchChars",
")",
")",
"{",
"return",
"INDEX_NOT_FOUND",
";... | <p>Search a CharSequence to find the first index of any
character not in the given set of characters.</p>
<p>A {@code null} CharSequence will return {@code -1}.
A {@code null} or empty search string will return {@code -1}.</p>
<pre>
StringUtils.indexOfAnyBut(null, *) = -1
StringUtils.indexOfAnyBut("", *) = -1
StringUtils.indexOfAnyBut(*, null) = -1
StringUtils.indexOfAnyBut(*, "") = -1
StringUtils.indexOfAnyBut("zzabyycdxx", "za") = 3
StringUtils.indexOfAnyBut("zzabyycdxx", "") = -1
StringUtils.indexOfAnyBut("aba","ab") = -1
</pre>
@param seq the CharSequence to check, may be null
@param searchChars the chars to search for, may be null
@return the index of any of the chars, -1 if no match or null input
@since 2.0
@since 3.0 Changed signature from indexOfAnyBut(String, String) to indexOfAnyBut(CharSequence, CharSequence) | [
"<p",
">",
"Search",
"a",
"CharSequence",
"to",
"find",
"the",
"first",
"index",
"of",
"any",
"character",
"not",
"in",
"the",
"given",
"set",
"of",
"characters",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/StringUtils.java#L2337-L2357 |
wildfly/wildfly-core | patching/src/main/java/org/jboss/as/patching/IoUtils.java | IoUtils.newFile | public static File newFile(File baseDir, String... segments) {
"""
Return a new File object based on the baseDir and the segments.
This method does not perform any operation on the file system.
"""
File f = baseDir;
for (String segment : segments) {
f = new File(f, segment);
}
return f;
} | java | public static File newFile(File baseDir, String... segments) {
File f = baseDir;
for (String segment : segments) {
f = new File(f, segment);
}
return f;
} | [
"public",
"static",
"File",
"newFile",
"(",
"File",
"baseDir",
",",
"String",
"...",
"segments",
")",
"{",
"File",
"f",
"=",
"baseDir",
";",
"for",
"(",
"String",
"segment",
":",
"segments",
")",
"{",
"f",
"=",
"new",
"File",
"(",
"f",
",",
"segment"... | Return a new File object based on the baseDir and the segments.
This method does not perform any operation on the file system. | [
"Return",
"a",
"new",
"File",
"object",
"based",
"on",
"the",
"baseDir",
"and",
"the",
"segments",
"."
] | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/patching/src/main/java/org/jboss/as/patching/IoUtils.java#L208-L214 |
JakeWharton/ActionBarSherlock | actionbarsherlock/src/com/actionbarsherlock/widget/SuggestionsAdapter.java | SuggestionsAdapter.getView | @Override
public View getView(int position, View convertView, ViewGroup parent) {
"""
This method is overridden purely to provide a bit of protection against
flaky content providers.
@see android.widget.ListAdapter#getView(int, View, ViewGroup)
"""
try {
return super.getView(position, convertView, parent);
} catch (RuntimeException e) {
Log.w(LOG_TAG, "Search suggestions cursor threw exception.", e);
// Put exception string in item title
View v = newView(mContext, mCursor, parent);
if (v != null) {
ChildViewCache views = (ChildViewCache) v.getTag();
TextView tv = views.mText1;
tv.setText(e.toString());
}
return v;
}
} | java | @Override
public View getView(int position, View convertView, ViewGroup parent) {
try {
return super.getView(position, convertView, parent);
} catch (RuntimeException e) {
Log.w(LOG_TAG, "Search suggestions cursor threw exception.", e);
// Put exception string in item title
View v = newView(mContext, mCursor, parent);
if (v != null) {
ChildViewCache views = (ChildViewCache) v.getTag();
TextView tv = views.mText1;
tv.setText(e.toString());
}
return v;
}
} | [
"@",
"Override",
"public",
"View",
"getView",
"(",
"int",
"position",
",",
"View",
"convertView",
",",
"ViewGroup",
"parent",
")",
"{",
"try",
"{",
"return",
"super",
".",
"getView",
"(",
"position",
",",
"convertView",
",",
"parent",
")",
";",
"}",
"cat... | This method is overridden purely to provide a bit of protection against
flaky content providers.
@see android.widget.ListAdapter#getView(int, View, ViewGroup) | [
"This",
"method",
"is",
"overridden",
"purely",
"to",
"provide",
"a",
"bit",
"of",
"protection",
"against",
"flaky",
"content",
"providers",
"."
] | train | https://github.com/JakeWharton/ActionBarSherlock/blob/2c71339e756bcc0b1424c4525680549ba3a2dc97/actionbarsherlock/src/com/actionbarsherlock/widget/SuggestionsAdapter.java#L508-L523 |
fcrepo3/fcrepo | fcrepo-server/src/main/java/org/fcrepo/server/rest/param/AbstractParam.java | AbstractParam.onError | protected Response onError(String param, Throwable e) {
"""
Generates an HTTP 400 (Bad Request)
@param param the original parameter
@param e the original error
@return HTTP 400 Bad Request
"""
return Response.status(Status.BAD_REQUEST)
.entity(getErrorMessage(param, e)).build();
} | java | protected Response onError(String param, Throwable e) {
return Response.status(Status.BAD_REQUEST)
.entity(getErrorMessage(param, e)).build();
} | [
"protected",
"Response",
"onError",
"(",
"String",
"param",
",",
"Throwable",
"e",
")",
"{",
"return",
"Response",
".",
"status",
"(",
"Status",
".",
"BAD_REQUEST",
")",
".",
"entity",
"(",
"getErrorMessage",
"(",
"param",
",",
"e",
")",
")",
".",
"build... | Generates an HTTP 400 (Bad Request)
@param param the original parameter
@param e the original error
@return HTTP 400 Bad Request | [
"Generates",
"an",
"HTTP",
"400",
"(",
"Bad",
"Request",
")"
] | train | https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/rest/param/AbstractParam.java#L73-L76 |
khuxtable/seaglass | src/main/java/com/seaglasslookandfeel/SeaGlassSynthPainterImpl.java | SeaGlassSynthPainterImpl.paintSliderThumbBackground | public void paintSliderThumbBackground(SynthContext context, Graphics g, int x, int y, int w, int h, int orientation) {
"""
Paints the background of the thumb of a slider.
@param context SynthContext identifying the <code>JComponent</code>
and <code>Region</code> to paint to
@param g <code>Graphics</code> to paint to
@param x X coordinate of the area to paint to
@param y Y coordinate of the area to paint to
@param w Width of the area to paint to
@param h Height of the area to paint to
@param orientation One of <code>JSlider.HORIZONTAL</code> or <code>
JSlider.VERTICAL</code>
"""
if (context.getComponent().getClientProperty("Slider.paintThumbArrowShape") == Boolean.TRUE) {
if (orientation == JSlider.HORIZONTAL) {
orientation = JSlider.VERTICAL;
} else {
orientation = JSlider.HORIZONTAL;
}
paintBackground(context, g, x, y, w, h, orientation);
} else {
paintBackground(context, g, x, y, w, h, orientation);
}
} | java | public void paintSliderThumbBackground(SynthContext context, Graphics g, int x, int y, int w, int h, int orientation) {
if (context.getComponent().getClientProperty("Slider.paintThumbArrowShape") == Boolean.TRUE) {
if (orientation == JSlider.HORIZONTAL) {
orientation = JSlider.VERTICAL;
} else {
orientation = JSlider.HORIZONTAL;
}
paintBackground(context, g, x, y, w, h, orientation);
} else {
paintBackground(context, g, x, y, w, h, orientation);
}
} | [
"public",
"void",
"paintSliderThumbBackground",
"(",
"SynthContext",
"context",
",",
"Graphics",
"g",
",",
"int",
"x",
",",
"int",
"y",
",",
"int",
"w",
",",
"int",
"h",
",",
"int",
"orientation",
")",
"{",
"if",
"(",
"context",
".",
"getComponent",
"(",... | Paints the background of the thumb of a slider.
@param context SynthContext identifying the <code>JComponent</code>
and <code>Region</code> to paint to
@param g <code>Graphics</code> to paint to
@param x X coordinate of the area to paint to
@param y Y coordinate of the area to paint to
@param w Width of the area to paint to
@param h Height of the area to paint to
@param orientation One of <code>JSlider.HORIZONTAL</code> or <code>
JSlider.VERTICAL</code> | [
"Paints",
"the",
"background",
"of",
"the",
"thumb",
"of",
"a",
"slider",
"."
] | train | https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/SeaGlassSynthPainterImpl.java#L1681-L1694 |
tvesalainen/util | util/src/main/java/org/vesalainen/lang/Primitives.java | Primitives.parseShort | public static final short parseShort(CharSequence cs) {
"""
Equal to calling parseShort(cs, 10).
@param cs
@return
@throws java.lang.NumberFormatException if input cannot be parsed to proper
short.
@see java.lang.Short#parseShort(java.lang.String, int)
@see java.lang.Character#digit(int, int)
"""
if (CharSequences.startsWith(cs, "0b"))
{
return parseShort(cs, 2, 2, cs.length());
}
if (CharSequences.startsWith(cs, "0x"))
{
return parseShort(cs, 16, 2, cs.length());
}
return parseShort(cs, 10);
} | java | public static final short parseShort(CharSequence cs)
{
if (CharSequences.startsWith(cs, "0b"))
{
return parseShort(cs, 2, 2, cs.length());
}
if (CharSequences.startsWith(cs, "0x"))
{
return parseShort(cs, 16, 2, cs.length());
}
return parseShort(cs, 10);
} | [
"public",
"static",
"final",
"short",
"parseShort",
"(",
"CharSequence",
"cs",
")",
"{",
"if",
"(",
"CharSequences",
".",
"startsWith",
"(",
"cs",
",",
"\"0b\"",
")",
")",
"{",
"return",
"parseShort",
"(",
"cs",
",",
"2",
",",
"2",
",",
"cs",
".",
"l... | Equal to calling parseShort(cs, 10).
@param cs
@return
@throws java.lang.NumberFormatException if input cannot be parsed to proper
short.
@see java.lang.Short#parseShort(java.lang.String, int)
@see java.lang.Character#digit(int, int) | [
"Equal",
"to",
"calling",
"parseShort",
"(",
"cs",
"10",
")",
"."
] | train | https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/lang/Primitives.java#L1169-L1180 |
lightblueseas/swing-components | src/main/java/de/alpharogroup/swing/base/BaseDesktopMenu.java | BaseDesktopMenu.newLookAndFeelMenu | protected JMenu newLookAndFeelMenu(final ActionListener listener) {
"""
Creates the look and feel menu.
@param listener
the listener
@return the j menu
"""
final JMenu menuLookAndFeel = new JMenu("Look and Feel");
menuLookAndFeel.setMnemonic('L');
// Look and Feel JMenuItems
// GTK
JMenuItem jmiPlafGTK;
jmiPlafGTK = new JMenuItem("GTK", 'g'); //$NON-NLS-1$
MenuExtensions.setCtrlAccelerator(jmiPlafGTK, 'G');
jmiPlafGTK.addActionListener(new LookAndFeelGTKAction("GTK", this.applicationFrame));
menuLookAndFeel.add(jmiPlafGTK);
// Metal default Metal theme
JMenuItem jmiPlafMetal;
jmiPlafMetal = new JMenuItem("Metal", 'm'); //$NON-NLS-1$
MenuExtensions.setCtrlAccelerator(jmiPlafMetal, 'M');
jmiPlafMetal.addActionListener(new LookAndFeelMetalAction("Metal", this.applicationFrame));
menuLookAndFeel.add(jmiPlafMetal);
// Metal Ocean theme
JMenuItem jmiPlafOcean;
jmiPlafOcean = new JMenuItem("Ocean", 'o'); //$NON-NLS-1$
MenuExtensions.setCtrlAccelerator(jmiPlafOcean, 'O');
jmiPlafOcean.addActionListener(new LookAndFeelMetalAction("Ocean", this.applicationFrame));
menuLookAndFeel.add(jmiPlafOcean);
// Motif
JMenuItem jmiPlafMotiv;
jmiPlafMotiv = new JMenuItem("Motif", 't'); //$NON-NLS-1$
MenuExtensions.setCtrlAccelerator(jmiPlafMotiv, 'T');
jmiPlafMotiv.addActionListener(new LookAndFeelMotifAction("Motif", this.applicationFrame));
menuLookAndFeel.add(jmiPlafMotiv);
// Nimbus
JMenuItem jmiPlafNimbus;
jmiPlafNimbus = new JMenuItem("Nimbus", 'n'); //$NON-NLS-1$
MenuExtensions.setCtrlAccelerator(jmiPlafNimbus, 'N');
jmiPlafNimbus
.addActionListener(new LookAndFeelNimbusAction("Nimbus", this.applicationFrame));
menuLookAndFeel.add(jmiPlafNimbus);
// Windows
JMenuItem jmiPlafSystem;
jmiPlafSystem = new JMenuItem("System", 'd'); //$NON-NLS-1$
MenuExtensions.setCtrlAccelerator(jmiPlafSystem, 'W');
jmiPlafSystem
.addActionListener(new LookAndFeelSystemAction("System", this.applicationFrame));
menuLookAndFeel.add(jmiPlafSystem);
return menuLookAndFeel;
} | java | protected JMenu newLookAndFeelMenu(final ActionListener listener)
{
final JMenu menuLookAndFeel = new JMenu("Look and Feel");
menuLookAndFeel.setMnemonic('L');
// Look and Feel JMenuItems
// GTK
JMenuItem jmiPlafGTK;
jmiPlafGTK = new JMenuItem("GTK", 'g'); //$NON-NLS-1$
MenuExtensions.setCtrlAccelerator(jmiPlafGTK, 'G');
jmiPlafGTK.addActionListener(new LookAndFeelGTKAction("GTK", this.applicationFrame));
menuLookAndFeel.add(jmiPlafGTK);
// Metal default Metal theme
JMenuItem jmiPlafMetal;
jmiPlafMetal = new JMenuItem("Metal", 'm'); //$NON-NLS-1$
MenuExtensions.setCtrlAccelerator(jmiPlafMetal, 'M');
jmiPlafMetal.addActionListener(new LookAndFeelMetalAction("Metal", this.applicationFrame));
menuLookAndFeel.add(jmiPlafMetal);
// Metal Ocean theme
JMenuItem jmiPlafOcean;
jmiPlafOcean = new JMenuItem("Ocean", 'o'); //$NON-NLS-1$
MenuExtensions.setCtrlAccelerator(jmiPlafOcean, 'O');
jmiPlafOcean.addActionListener(new LookAndFeelMetalAction("Ocean", this.applicationFrame));
menuLookAndFeel.add(jmiPlafOcean);
// Motif
JMenuItem jmiPlafMotiv;
jmiPlafMotiv = new JMenuItem("Motif", 't'); //$NON-NLS-1$
MenuExtensions.setCtrlAccelerator(jmiPlafMotiv, 'T');
jmiPlafMotiv.addActionListener(new LookAndFeelMotifAction("Motif", this.applicationFrame));
menuLookAndFeel.add(jmiPlafMotiv);
// Nimbus
JMenuItem jmiPlafNimbus;
jmiPlafNimbus = new JMenuItem("Nimbus", 'n'); //$NON-NLS-1$
MenuExtensions.setCtrlAccelerator(jmiPlafNimbus, 'N');
jmiPlafNimbus
.addActionListener(new LookAndFeelNimbusAction("Nimbus", this.applicationFrame));
menuLookAndFeel.add(jmiPlafNimbus);
// Windows
JMenuItem jmiPlafSystem;
jmiPlafSystem = new JMenuItem("System", 'd'); //$NON-NLS-1$
MenuExtensions.setCtrlAccelerator(jmiPlafSystem, 'W');
jmiPlafSystem
.addActionListener(new LookAndFeelSystemAction("System", this.applicationFrame));
menuLookAndFeel.add(jmiPlafSystem);
return menuLookAndFeel;
} | [
"protected",
"JMenu",
"newLookAndFeelMenu",
"(",
"final",
"ActionListener",
"listener",
")",
"{",
"final",
"JMenu",
"menuLookAndFeel",
"=",
"new",
"JMenu",
"(",
"\"Look and Feel\"",
")",
";",
"menuLookAndFeel",
".",
"setMnemonic",
"(",
"'",
"'",
")",
";",
"// Lo... | Creates the look and feel menu.
@param listener
the listener
@return the j menu | [
"Creates",
"the",
"look",
"and",
"feel",
"menu",
"."
] | train | https://github.com/lightblueseas/swing-components/blob/4045e85cabd8f0ce985cbfff134c3c9873930c79/src/main/java/de/alpharogroup/swing/base/BaseDesktopMenu.java#L357-L405 |
actorapp/actor-platform | actor-sdk/sdk-core/core/core-shared/src/main/java/im/actor/core/Messenger.java | Messenger.sendDocument | @ObjectiveCName("sendDocumentWithPeer:withName:withMime:withDescriptor:")
public void sendDocument(Peer peer, String fileName, String mimeType, String descriptor) {
"""
Send document without preview
@param peer destination peer
@param fileName File name (without path)
@param mimeType mimetype of document
@param descriptor File Descriptor
"""
sendDocument(peer, fileName, mimeType, null, descriptor);
} | java | @ObjectiveCName("sendDocumentWithPeer:withName:withMime:withDescriptor:")
public void sendDocument(Peer peer, String fileName, String mimeType, String descriptor) {
sendDocument(peer, fileName, mimeType, null, descriptor);
} | [
"@",
"ObjectiveCName",
"(",
"\"sendDocumentWithPeer:withName:withMime:withDescriptor:\"",
")",
"public",
"void",
"sendDocument",
"(",
"Peer",
"peer",
",",
"String",
"fileName",
",",
"String",
"mimeType",
",",
"String",
"descriptor",
")",
"{",
"sendDocument",
"(",
"pee... | Send document without preview
@param peer destination peer
@param fileName File name (without path)
@param mimeType mimetype of document
@param descriptor File Descriptor | [
"Send",
"document",
"without",
"preview"
] | train | https://github.com/actorapp/actor-platform/blob/5123c1584757c6eeea0ed2a0e7e043629871a0c6/actor-sdk/sdk-core/core/core-shared/src/main/java/im/actor/core/Messenger.java#L943-L946 |
aol/cyclops | cyclops/src/main/java/cyclops/companion/Functions.java | Functions.limitLongs | public static Function<? super ReactiveSeq<Long>, ? extends ReactiveSeq<Long>> limitLongs(long maxSize) {
"""
/*
Fluent limit operation using primitive types
e.g.
<pre>
{@code
import static cyclops.ReactiveSeq.limitLongs;
ReactiveSeq.ofLongs(1,2,3)
.to(limitLongs(1));
//[1]
}
</pre>
"""
return a->a.longs(i->i,s->s.limit(maxSize));
} | java | public static Function<? super ReactiveSeq<Long>, ? extends ReactiveSeq<Long>> limitLongs(long maxSize){
return a->a.longs(i->i,s->s.limit(maxSize));
} | [
"public",
"static",
"Function",
"<",
"?",
"super",
"ReactiveSeq",
"<",
"Long",
">",
",",
"?",
"extends",
"ReactiveSeq",
"<",
"Long",
">",
">",
"limitLongs",
"(",
"long",
"maxSize",
")",
"{",
"return",
"a",
"->",
"a",
".",
"longs",
"(",
"i",
"->",
"i"... | /*
Fluent limit operation using primitive types
e.g.
<pre>
{@code
import static cyclops.ReactiveSeq.limitLongs;
ReactiveSeq.ofLongs(1,2,3)
.to(limitLongs(1));
//[1]
}
</pre> | [
"/",
"*",
"Fluent",
"limit",
"operation",
"using",
"primitive",
"types",
"e",
".",
"g",
".",
"<pre",
">",
"{",
"@code",
"import",
"static",
"cyclops",
".",
"ReactiveSeq",
".",
"limitLongs",
";"
] | train | https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/Functions.java#L338-L341 |
hibernate/hibernate-ogm | neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/dialect/impl/BaseNeo4jAssociationQueries.java | BaseNeo4jAssociationQueries.findRelationship | public Relationship findRelationship(GraphDatabaseService executionEngine, AssociationKey associationKey, RowKey rowKey) {
"""
Returns the relationship corresponding to the {@link AssociationKey} and {@link RowKey}.
@param executionEngine the {@link GraphDatabaseService} used to run the query
@param associationKey represents the association
@param rowKey represents a row in an association
@return the corresponding relationship
"""
Object[] relationshipValues = relationshipValues( associationKey, rowKey );
Object[] queryValues = ArrayHelper.concat( associationKey.getEntityKey().getColumnValues(), relationshipValues );
Result result = executionEngine.execute( findRelationshipQuery, params( queryValues ) );
return singleResult( result );
} | java | public Relationship findRelationship(GraphDatabaseService executionEngine, AssociationKey associationKey, RowKey rowKey) {
Object[] relationshipValues = relationshipValues( associationKey, rowKey );
Object[] queryValues = ArrayHelper.concat( associationKey.getEntityKey().getColumnValues(), relationshipValues );
Result result = executionEngine.execute( findRelationshipQuery, params( queryValues ) );
return singleResult( result );
} | [
"public",
"Relationship",
"findRelationship",
"(",
"GraphDatabaseService",
"executionEngine",
",",
"AssociationKey",
"associationKey",
",",
"RowKey",
"rowKey",
")",
"{",
"Object",
"[",
"]",
"relationshipValues",
"=",
"relationshipValues",
"(",
"associationKey",
",",
"ro... | Returns the relationship corresponding to the {@link AssociationKey} and {@link RowKey}.
@param executionEngine the {@link GraphDatabaseService} used to run the query
@param associationKey represents the association
@param rowKey represents a row in an association
@return the corresponding relationship | [
"Returns",
"the",
"relationship",
"corresponding",
"to",
"the",
"{",
"@link",
"AssociationKey",
"}",
"and",
"{",
"@link",
"RowKey",
"}",
"."
] | train | https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/dialect/impl/BaseNeo4jAssociationQueries.java#L241-L246 |
aws/aws-sdk-java | aws-java-sdk-dynamodb/src/main/java/com/amazonaws/services/dynamodbv2/document/utils/ValueMap.java | ValueMap.withStringSet | public ValueMap withStringSet(String key, Set<String> val) {
"""
Sets the value of the specified key in the current ValueMap to the
given value.
"""
super.put(key, val);
return this;
} | java | public ValueMap withStringSet(String key, Set<String> val) {
super.put(key, val);
return this;
} | [
"public",
"ValueMap",
"withStringSet",
"(",
"String",
"key",
",",
"Set",
"<",
"String",
">",
"val",
")",
"{",
"super",
".",
"put",
"(",
"key",
",",
"val",
")",
";",
"return",
"this",
";",
"}"
] | Sets the value of the specified key in the current ValueMap to the
given value. | [
"Sets",
"the",
"value",
"of",
"the",
"specified",
"key",
"in",
"the",
"current",
"ValueMap",
"to",
"the",
"given",
"value",
"."
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-dynamodb/src/main/java/com/amazonaws/services/dynamodbv2/document/utils/ValueMap.java#L94-L97 |
Azure/azure-sdk-for-java | sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/DataMaskingRulesInner.java | DataMaskingRulesInner.createOrUpdate | public DataMaskingRuleInner createOrUpdate(String resourceGroupName, String serverName, String databaseName, String dataMaskingRuleName, DataMaskingRuleInner parameters) {
"""
Creates or updates a database data masking rule.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param databaseName The name of the database.
@param dataMaskingRuleName The name of the data masking rule.
@param parameters The required parameters for creating or updating a data masking rule.
@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 DataMaskingRuleInner object if successful.
"""
return createOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, databaseName, dataMaskingRuleName, parameters).toBlocking().single().body();
} | java | public DataMaskingRuleInner createOrUpdate(String resourceGroupName, String serverName, String databaseName, String dataMaskingRuleName, DataMaskingRuleInner parameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, databaseName, dataMaskingRuleName, parameters).toBlocking().single().body();
} | [
"public",
"DataMaskingRuleInner",
"createOrUpdate",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"String",
"databaseName",
",",
"String",
"dataMaskingRuleName",
",",
"DataMaskingRuleInner",
"parameters",
")",
"{",
"return",
"createOrUpdateWithServic... | Creates or updates a database data masking rule.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param databaseName The name of the database.
@param dataMaskingRuleName The name of the data masking rule.
@param parameters The required parameters for creating or updating a data masking rule.
@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 DataMaskingRuleInner object if successful. | [
"Creates",
"or",
"updates",
"a",
"database",
"data",
"masking",
"rule",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/DataMaskingRulesInner.java#L81-L83 |
GCRC/nunaliit | nunaliit2-couch-client/src/main/java/ca/carleton/gcrc/couch/client/impl/ConnectionUtils.java | ConnectionUtils.captureReponseErrors | static public void captureReponseErrors(Object response, String errorMessage) throws Exception {
"""
Analyze a CouchDb response and raises an exception if an error was returned
in the response.
@param response JSON response sent by server
@param errorMessage Message of top exception
@throws Exception If error is returned in response
"""
if( null == response ) {
throw new Exception("Capturing errors from null response");
}
if( false == (response instanceof JSONObject) ) {
// Not an error
return;
}
JSONObject obj = (JSONObject)response;
if( JSONSupport.containsKey(obj,"error") ) {
String serverMessage;
try {
serverMessage = obj.getString("error");
} catch (Exception e) {
serverMessage = "Unable to parse error response";
}
if( null == errorMessage ) {
errorMessage = "Error returned by database: ";
}
throw new Exception(errorMessage+serverMessage);
}
} | java | static public void captureReponseErrors(Object response, String errorMessage) throws Exception {
if( null == response ) {
throw new Exception("Capturing errors from null response");
}
if( false == (response instanceof JSONObject) ) {
// Not an error
return;
}
JSONObject obj = (JSONObject)response;
if( JSONSupport.containsKey(obj,"error") ) {
String serverMessage;
try {
serverMessage = obj.getString("error");
} catch (Exception e) {
serverMessage = "Unable to parse error response";
}
if( null == errorMessage ) {
errorMessage = "Error returned by database: ";
}
throw new Exception(errorMessage+serverMessage);
}
} | [
"static",
"public",
"void",
"captureReponseErrors",
"(",
"Object",
"response",
",",
"String",
"errorMessage",
")",
"throws",
"Exception",
"{",
"if",
"(",
"null",
"==",
"response",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Capturing errors from null response\"",... | Analyze a CouchDb response and raises an exception if an error was returned
in the response.
@param response JSON response sent by server
@param errorMessage Message of top exception
@throws Exception If error is returned in response | [
"Analyze",
"a",
"CouchDb",
"response",
"and",
"raises",
"an",
"exception",
"if",
"an",
"error",
"was",
"returned",
"in",
"the",
"response",
"."
] | train | https://github.com/GCRC/nunaliit/blob/0b4abfc64eef2eb8b94f852ce697de2e851d8e67/nunaliit2-couch-client/src/main/java/ca/carleton/gcrc/couch/client/impl/ConnectionUtils.java#L427-L449 |
alkacon/opencms-core | src/org/opencms/jsp/jsonpart/CmsJsonPart.java | CmsJsonPart.parseJsonParts | public static List<CmsJsonPart> parseJsonParts(String text) {
"""
Parses the encoded JSON parts from the given string and puts them in a list.<p>
@param text the text containing the encoded JSON parts
@return the decoded JSON parts
"""
List<CmsJsonPart> result = Lists.newArrayList();
Matcher matcher = FORMAT_PATTERN.matcher(text);
while (matcher.find()) {
String key = matcher.group(1);
String value = matcher.group(2);
CmsJsonPart part = new CmsJsonPart(key, value);
result.add(part);
}
return result;
} | java | public static List<CmsJsonPart> parseJsonParts(String text) {
List<CmsJsonPart> result = Lists.newArrayList();
Matcher matcher = FORMAT_PATTERN.matcher(text);
while (matcher.find()) {
String key = matcher.group(1);
String value = matcher.group(2);
CmsJsonPart part = new CmsJsonPart(key, value);
result.add(part);
}
return result;
} | [
"public",
"static",
"List",
"<",
"CmsJsonPart",
">",
"parseJsonParts",
"(",
"String",
"text",
")",
"{",
"List",
"<",
"CmsJsonPart",
">",
"result",
"=",
"Lists",
".",
"newArrayList",
"(",
")",
";",
"Matcher",
"matcher",
"=",
"FORMAT_PATTERN",
".",
"matcher",
... | Parses the encoded JSON parts from the given string and puts them in a list.<p>
@param text the text containing the encoded JSON parts
@return the decoded JSON parts | [
"Parses",
"the",
"encoded",
"JSON",
"parts",
"from",
"the",
"given",
"string",
"and",
"puts",
"them",
"in",
"a",
"list",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/jsonpart/CmsJsonPart.java#L85-L96 |
azkaban/azkaban | azkaban-common/src/main/java/azkaban/utils/StringUtils.java | StringUtils.join2 | public static String join2(final Collection<String> list, final String delimiter) {
"""
Don't bother to add delimiter for last element
@return String - elements in the list separated by delimiter
"""
final StringBuffer buffer = new StringBuffer();
boolean first = true;
for (final String str : list) {
if (!first) {
buffer.append(delimiter);
}
buffer.append(str);
first = false;
}
return buffer.toString();
} | java | public static String join2(final Collection<String> list, final String delimiter) {
final StringBuffer buffer = new StringBuffer();
boolean first = true;
for (final String str : list) {
if (!first) {
buffer.append(delimiter);
}
buffer.append(str);
first = false;
}
return buffer.toString();
} | [
"public",
"static",
"String",
"join2",
"(",
"final",
"Collection",
"<",
"String",
">",
"list",
",",
"final",
"String",
"delimiter",
")",
"{",
"final",
"StringBuffer",
"buffer",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"boolean",
"first",
"=",
"true",
";"... | Don't bother to add delimiter for last element
@return String - elements in the list separated by delimiter | [
"Don",
"t",
"bother",
"to",
"add",
"delimiter",
"for",
"last",
"element"
] | train | https://github.com/azkaban/azkaban/blob/d258ea7d6e66807c6eff79c5325d6d3443618dff/azkaban-common/src/main/java/azkaban/utils/StringUtils.java#L75-L88 |
OpenLiberty/open-liberty | dev/com.ibm.ws.concurrent.mp.1.0/src/com/ibm/ws/concurrent/mp/ManagedCompletableFuture.java | ManagedCompletableFuture.failedStage | @Trivial
public static <U> CompletionStage<U> failedStage(Throwable x) {
"""
Because CompletableFuture.failedStage is static, this is not a true override.
It will be difficult for the user to invoke this method because they would need to get the class
of the CompletableFuture implementation and locate the static failedStage method on that.
@throws UnsupportedOperationException directing the user to use the ManagedExecutor spec interface instead.
"""
throw new UnsupportedOperationException(Tr.formatMessage(tc, "CWWKC1156.not.supported", "ManagedExecutor.failedStage"));
} | java | @Trivial
public static <U> CompletionStage<U> failedStage(Throwable x) {
throw new UnsupportedOperationException(Tr.formatMessage(tc, "CWWKC1156.not.supported", "ManagedExecutor.failedStage"));
} | [
"@",
"Trivial",
"public",
"static",
"<",
"U",
">",
"CompletionStage",
"<",
"U",
">",
"failedStage",
"(",
"Throwable",
"x",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"Tr",
".",
"formatMessage",
"(",
"tc",
",",
"\"CWWKC1156.not.supported\"",
... | Because CompletableFuture.failedStage is static, this is not a true override.
It will be difficult for the user to invoke this method because they would need to get the class
of the CompletableFuture implementation and locate the static failedStage method on that.
@throws UnsupportedOperationException directing the user to use the ManagedExecutor spec interface instead. | [
"Because",
"CompletableFuture",
".",
"failedStage",
"is",
"static",
"this",
"is",
"not",
"a",
"true",
"override",
".",
"It",
"will",
"be",
"difficult",
"for",
"the",
"user",
"to",
"invoke",
"this",
"method",
"because",
"they",
"would",
"need",
"to",
"get",
... | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.concurrent.mp.1.0/src/com/ibm/ws/concurrent/mp/ManagedCompletableFuture.java#L387-L390 |
Erudika/para | para-core/src/main/java/com/erudika/para/utils/Utils.java | Utils.arrayJoin | public static String arrayJoin(List<String> arr, String separator) {
"""
Joins a list of strings to String using a separator.
@param arr a list of strings
@param separator a separator string
@return a string
"""
return (arr == null || separator == null) ? "" : StringUtils.join(arr, separator);
} | java | public static String arrayJoin(List<String> arr, String separator) {
return (arr == null || separator == null) ? "" : StringUtils.join(arr, separator);
} | [
"public",
"static",
"String",
"arrayJoin",
"(",
"List",
"<",
"String",
">",
"arr",
",",
"String",
"separator",
")",
"{",
"return",
"(",
"arr",
"==",
"null",
"||",
"separator",
"==",
"null",
")",
"?",
"\"\"",
":",
"StringUtils",
".",
"join",
"(",
"arr",... | Joins a list of strings to String using a separator.
@param arr a list of strings
@param separator a separator string
@return a string | [
"Joins",
"a",
"list",
"of",
"strings",
"to",
"String",
"using",
"a",
"separator",
"."
] | train | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/utils/Utils.java#L317-L319 |
Whiley/WhileyCompiler | src/main/java/wyc/io/WhileyFileParser.java | WhileyFileParser.parseFunctionOrMethodDeclaration | private Decl.FunctionOrMethod parseFunctionOrMethodDeclaration(Tuple<Modifier> modifiers,
boolean isFunction) {
"""
Parse a <i>function declaration</i> or <i>method declaration</i>, which
have the form:
<pre>
FunctionDeclaration ::= "function" TypePattern "->" TypePattern (FunctionMethodClause)* ':' NewLine Block
MethodDeclaration ::= "method" TypePattern "->" TypePattern (FunctionMethodClause)* ':' NewLine Block
FunctionMethodClause ::= "requires" Expr | "ensures" Expr
</pre>
Here, the first type pattern (i.e. before "->") is referred to as the
"parameter", whilst the second is referred to as the "return". There are
two kinds of option clause:
<ul>
<li><b>Requires clause</b>. This defines a constraint on the permissible
values of the parameters on entry to the function or method, and is often
referred to as the "precondition". This expression may refer to any
variables declared within the parameter type pattern. Multiple clauses
may be given, and these are taken together as a conjunction. Furthermore,
the convention is to specify the requires clause(s) before any ensure(s)
clauses.</li>
<li><b>Ensures clause</b>. This defines a constraint on the permissible
values of the the function or method's return value, and is often
referred to as the "postcondition". This expression may refer to any
variables declared within either the parameter or return type pattern.
Multiple clauses may be given, and these are taken together as a
conjunction. Furthermore, the convention is to specify the requires
clause(s) after the others.</li>
</ul>
<p>
The following function declaration provides a small example to
illustrate:
</p>
<pre>
function max(int x, int y) -> (int z)
// return must be greater than either parameter
ensures x <= z && y <= z
// return must equal one of the parmaeters
ensures x == z || y == z:
...
</pre>
<p>
Here, we see the specification for the well-known <code>max()</code>
function which returns the largest of its parameters. This does not throw
any exceptions, and does not enforce any preconditions on its parameters.
</p>
"""
int start = index;
// Create appropriate enclosing scope
EnclosingScope scope = new EnclosingScope();
//
if (isFunction) {
match(Function);
} else {
match(Method);
}
Identifier name = parseIdentifier();
// Parse template parameters
Tuple<Template.Variable> template = parseOptionalTemplate(scope);
// Parse function or method parameters
Tuple<Decl.Variable> parameters = parseParameters(scope,RightBrace);
// Parse (optional) return type
Tuple<Decl.Variable> returns;
//
if (tryAndMatch(true, MinusGreater) != null) {
// Explicit return type is given, so parse it! We first clone the
// environent and create a special one only for use within ensures
// clauses, since these are the only expressions which may refer to
// variables declared in the return type.
returns = parseOptionalParameters(scope);
} else {
// No returns provided
returns = new Tuple<>();
}
// Parse optional requires/ensures clauses
Tuple<Expr> requires = parseInvariant(scope,Requires);
Tuple<Expr> ensures = parseInvariant(scope,Ensures);
// Parse function or method body (if not native)
Stmt.Block body;
int end;
if(modifiers.match(Modifier.Native.class) == null) {
// Not native function or method
match(Colon);
end = index;
matchEndLine();
scope.declareThisLifetime();
body = parseBlock(scope, false);
} else {
end = index;
matchEndLine();
// FIXME: having empty block seems wasteful
body = new Stmt.Block();
}
//
WyilFile.Decl.FunctionOrMethod declaration;
if (isFunction) {
declaration = new Decl.Function(modifiers, name, template, parameters, returns, requires, ensures,
body);
} else {
declaration = new Decl.Method(modifiers, name, template, parameters, returns, requires, ensures, body);
}
return annotateSourceLocation(declaration,start,end-1);
} | java | private Decl.FunctionOrMethod parseFunctionOrMethodDeclaration(Tuple<Modifier> modifiers,
boolean isFunction) {
int start = index;
// Create appropriate enclosing scope
EnclosingScope scope = new EnclosingScope();
//
if (isFunction) {
match(Function);
} else {
match(Method);
}
Identifier name = parseIdentifier();
// Parse template parameters
Tuple<Template.Variable> template = parseOptionalTemplate(scope);
// Parse function or method parameters
Tuple<Decl.Variable> parameters = parseParameters(scope,RightBrace);
// Parse (optional) return type
Tuple<Decl.Variable> returns;
//
if (tryAndMatch(true, MinusGreater) != null) {
// Explicit return type is given, so parse it! We first clone the
// environent and create a special one only for use within ensures
// clauses, since these are the only expressions which may refer to
// variables declared in the return type.
returns = parseOptionalParameters(scope);
} else {
// No returns provided
returns = new Tuple<>();
}
// Parse optional requires/ensures clauses
Tuple<Expr> requires = parseInvariant(scope,Requires);
Tuple<Expr> ensures = parseInvariant(scope,Ensures);
// Parse function or method body (if not native)
Stmt.Block body;
int end;
if(modifiers.match(Modifier.Native.class) == null) {
// Not native function or method
match(Colon);
end = index;
matchEndLine();
scope.declareThisLifetime();
body = parseBlock(scope, false);
} else {
end = index;
matchEndLine();
// FIXME: having empty block seems wasteful
body = new Stmt.Block();
}
//
WyilFile.Decl.FunctionOrMethod declaration;
if (isFunction) {
declaration = new Decl.Function(modifiers, name, template, parameters, returns, requires, ensures,
body);
} else {
declaration = new Decl.Method(modifiers, name, template, parameters, returns, requires, ensures, body);
}
return annotateSourceLocation(declaration,start,end-1);
} | [
"private",
"Decl",
".",
"FunctionOrMethod",
"parseFunctionOrMethodDeclaration",
"(",
"Tuple",
"<",
"Modifier",
">",
"modifiers",
",",
"boolean",
"isFunction",
")",
"{",
"int",
"start",
"=",
"index",
";",
"// Create appropriate enclosing scope",
"EnclosingScope",
"scope"... | Parse a <i>function declaration</i> or <i>method declaration</i>, which
have the form:
<pre>
FunctionDeclaration ::= "function" TypePattern "->" TypePattern (FunctionMethodClause)* ':' NewLine Block
MethodDeclaration ::= "method" TypePattern "->" TypePattern (FunctionMethodClause)* ':' NewLine Block
FunctionMethodClause ::= "requires" Expr | "ensures" Expr
</pre>
Here, the first type pattern (i.e. before "->") is referred to as the
"parameter", whilst the second is referred to as the "return". There are
two kinds of option clause:
<ul>
<li><b>Requires clause</b>. This defines a constraint on the permissible
values of the parameters on entry to the function or method, and is often
referred to as the "precondition". This expression may refer to any
variables declared within the parameter type pattern. Multiple clauses
may be given, and these are taken together as a conjunction. Furthermore,
the convention is to specify the requires clause(s) before any ensure(s)
clauses.</li>
<li><b>Ensures clause</b>. This defines a constraint on the permissible
values of the the function or method's return value, and is often
referred to as the "postcondition". This expression may refer to any
variables declared within either the parameter or return type pattern.
Multiple clauses may be given, and these are taken together as a
conjunction. Furthermore, the convention is to specify the requires
clause(s) after the others.</li>
</ul>
<p>
The following function declaration provides a small example to
illustrate:
</p>
<pre>
function max(int x, int y) -> (int z)
// return must be greater than either parameter
ensures x <= z && y <= z
// return must equal one of the parmaeters
ensures x == z || y == z:
...
</pre>
<p>
Here, we see the specification for the well-known <code>max()</code>
function which returns the largest of its parameters. This does not throw
any exceptions, and does not enforce any preconditions on its parameters.
</p> | [
"Parse",
"a",
"<i",
">",
"function",
"declaration<",
"/",
"i",
">",
"or",
"<i",
">",
"method",
"declaration<",
"/",
"i",
">",
"which",
"have",
"the",
"form",
":"
] | train | https://github.com/Whiley/WhileyCompiler/blob/680f8a657d3fc286f8cc422755988b6d74ab3f4c/src/main/java/wyc/io/WhileyFileParser.java#L292-L349 |
citrusframework/citrus | modules/citrus-jdbc/src/main/java/com/consol/citrus/jdbc/server/JdbcEndpointAdapterController.java | JdbcEndpointAdapterController.checkSuccess | private void checkSuccess(Message response) throws JdbcServerException {
"""
Check that response is not having an exception message.
@param response The response message to check
@throws JdbcServerException In case the message contains a error.
"""
OperationResult operationResult = null;
if (response instanceof JdbcMessage || response.getPayload() instanceof OperationResult) {
operationResult = response.getPayload(OperationResult.class);
} else if (response.getPayload() != null && StringUtils.hasText(response.getPayload(String.class))) {
operationResult = (OperationResult) endpointConfiguration.getMarshaller().unmarshal(new StringSource(response.getPayload(String.class)));
}
if (!success(response, operationResult)) {
throw new JdbcServerException(getExceptionMessage(response, operationResult));
}
} | java | private void checkSuccess(Message response) throws JdbcServerException {
OperationResult operationResult = null;
if (response instanceof JdbcMessage || response.getPayload() instanceof OperationResult) {
operationResult = response.getPayload(OperationResult.class);
} else if (response.getPayload() != null && StringUtils.hasText(response.getPayload(String.class))) {
operationResult = (OperationResult) endpointConfiguration.getMarshaller().unmarshal(new StringSource(response.getPayload(String.class)));
}
if (!success(response, operationResult)) {
throw new JdbcServerException(getExceptionMessage(response, operationResult));
}
} | [
"private",
"void",
"checkSuccess",
"(",
"Message",
"response",
")",
"throws",
"JdbcServerException",
"{",
"OperationResult",
"operationResult",
"=",
"null",
";",
"if",
"(",
"response",
"instanceof",
"JdbcMessage",
"||",
"response",
".",
"getPayload",
"(",
")",
"in... | Check that response is not having an exception message.
@param response The response message to check
@throws JdbcServerException In case the message contains a error. | [
"Check",
"that",
"response",
"is",
"not",
"having",
"an",
"exception",
"message",
"."
] | train | https://github.com/citrusframework/citrus/blob/55c58ef74c01d511615e43646ca25c1b2301c56d/modules/citrus-jdbc/src/main/java/com/consol/citrus/jdbc/server/JdbcEndpointAdapterController.java#L360-L371 |
pgjdbc/pgjdbc | pgjdbc/src/main/java/org/postgresql/jdbc/EscapedFunctions2.java | EscapedFunctions2.sqlminute | public static void sqlminute(StringBuilder buf, List<? extends CharSequence> parsedArgs) throws SQLException {
"""
minute translation
@param buf The buffer to append into
@param parsedArgs arguments
@throws SQLException if something wrong happens
"""
singleArgumentFunctionCall(buf, "extract(minute from ", "minute", parsedArgs);
} | java | public static void sqlminute(StringBuilder buf, List<? extends CharSequence> parsedArgs) throws SQLException {
singleArgumentFunctionCall(buf, "extract(minute from ", "minute", parsedArgs);
} | [
"public",
"static",
"void",
"sqlminute",
"(",
"StringBuilder",
"buf",
",",
"List",
"<",
"?",
"extends",
"CharSequence",
">",
"parsedArgs",
")",
"throws",
"SQLException",
"{",
"singleArgumentFunctionCall",
"(",
"buf",
",",
"\"extract(minute from \"",
",",
"\"minute\"... | minute translation
@param buf The buffer to append into
@param parsedArgs arguments
@throws SQLException if something wrong happens | [
"minute",
"translation"
] | train | https://github.com/pgjdbc/pgjdbc/blob/95ba7b261e39754674c5817695ae5ebf9a341fae/pgjdbc/src/main/java/org/postgresql/jdbc/EscapedFunctions2.java#L416-L418 |
windup/windup | rules-java-ee/addon/src/main/java/org/jboss/windup/rules/apps/javaee/service/DataSourceService.java | DataSourceService.createUnique | public synchronized DataSourceModel createUnique(Set<ProjectModel> applications, String dataSourceName, String jndiName) {
"""
Create unique; if existing convert an existing {@link DataSourceModel} if one exists.
"""
JNDIResourceModel jndiResourceModel = new JNDIResourceService(getGraphContext()).createUnique(applications, jndiName);
final DataSourceModel dataSourceModel;
if (jndiResourceModel instanceof DataSourceModel)
{
dataSourceModel = (DataSourceModel) jndiResourceModel;
}
else
{
dataSourceModel = addTypeToModel(jndiResourceModel);
}
dataSourceModel.setName(dataSourceName);
return dataSourceModel;
} | java | public synchronized DataSourceModel createUnique(Set<ProjectModel> applications, String dataSourceName, String jndiName)
{
JNDIResourceModel jndiResourceModel = new JNDIResourceService(getGraphContext()).createUnique(applications, jndiName);
final DataSourceModel dataSourceModel;
if (jndiResourceModel instanceof DataSourceModel)
{
dataSourceModel = (DataSourceModel) jndiResourceModel;
}
else
{
dataSourceModel = addTypeToModel(jndiResourceModel);
}
dataSourceModel.setName(dataSourceName);
return dataSourceModel;
} | [
"public",
"synchronized",
"DataSourceModel",
"createUnique",
"(",
"Set",
"<",
"ProjectModel",
">",
"applications",
",",
"String",
"dataSourceName",
",",
"String",
"jndiName",
")",
"{",
"JNDIResourceModel",
"jndiResourceModel",
"=",
"new",
"JNDIResourceService",
"(",
"... | Create unique; if existing convert an existing {@link DataSourceModel} if one exists. | [
"Create",
"unique",
";",
"if",
"existing",
"convert",
"an",
"existing",
"{"
] | train | https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/rules-java-ee/addon/src/main/java/org/jboss/windup/rules/apps/javaee/service/DataSourceService.java#L27-L41 |
alkacon/opencms-core | src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java | CmsJSONSearchConfigurationParser.parseOptionalBooleanValue | protected static Boolean parseOptionalBooleanValue(JSONObject json, String key) {
"""
Helper for reading an optional Boolean value - returning <code>null</code> if parsing fails.
@param json The JSON object where the value should be read from.
@param key The key of the value to read.
@return The value from the JSON, or <code>null</code> if the value does not exist, or is no Boolean.
"""
try {
return Boolean.valueOf(json.getBoolean(key));
} catch (JSONException e) {
LOG.info(Messages.get().getBundle().key(Messages.LOG_OPTIONAL_BOOLEAN_MISSING_1, key), e);
return null;
}
} | java | protected static Boolean parseOptionalBooleanValue(JSONObject json, String key) {
try {
return Boolean.valueOf(json.getBoolean(key));
} catch (JSONException e) {
LOG.info(Messages.get().getBundle().key(Messages.LOG_OPTIONAL_BOOLEAN_MISSING_1, key), e);
return null;
}
} | [
"protected",
"static",
"Boolean",
"parseOptionalBooleanValue",
"(",
"JSONObject",
"json",
",",
"String",
"key",
")",
"{",
"try",
"{",
"return",
"Boolean",
".",
"valueOf",
"(",
"json",
".",
"getBoolean",
"(",
"key",
")",
")",
";",
"}",
"catch",
"(",
"JSONEx... | Helper for reading an optional Boolean value - returning <code>null</code> if parsing fails.
@param json The JSON object where the value should be read from.
@param key The key of the value to read.
@return The value from the JSON, or <code>null</code> if the value does not exist, or is no Boolean. | [
"Helper",
"for",
"reading",
"an",
"optional",
"Boolean",
"value",
"-",
"returning",
"<code",
">",
"null<",
"/",
"code",
">",
"if",
"parsing",
"fails",
"."
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/search/config/parser/CmsJSONSearchConfigurationParser.java#L269-L277 |
UrielCh/ovh-java-sdk | ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java | ApiOvhTelephony.billingAccount_miniPabx_serviceName_hunting_PUT | public void billingAccount_miniPabx_serviceName_hunting_PUT(String billingAccount, String serviceName, OvhMiniPabxHunting body) throws IOException {
"""
Alter this object properties
REST: PUT /telephony/{billingAccount}/miniPabx/{serviceName}/hunting
@param body [required] New object properties
@param billingAccount [required] The name of your billingAccount
@param serviceName [required]
"""
String qPath = "/telephony/{billingAccount}/miniPabx/{serviceName}/hunting";
StringBuilder sb = path(qPath, billingAccount, serviceName);
exec(qPath, "PUT", sb.toString(), body);
} | java | public void billingAccount_miniPabx_serviceName_hunting_PUT(String billingAccount, String serviceName, OvhMiniPabxHunting body) throws IOException {
String qPath = "/telephony/{billingAccount}/miniPabx/{serviceName}/hunting";
StringBuilder sb = path(qPath, billingAccount, serviceName);
exec(qPath, "PUT", sb.toString(), body);
} | [
"public",
"void",
"billingAccount_miniPabx_serviceName_hunting_PUT",
"(",
"String",
"billingAccount",
",",
"String",
"serviceName",
",",
"OvhMiniPabxHunting",
"body",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/telephony/{billingAccount}/miniPabx/{serviceName... | Alter this object properties
REST: PUT /telephony/{billingAccount}/miniPabx/{serviceName}/hunting
@param body [required] New object properties
@param billingAccount [required] The name of your billingAccount
@param serviceName [required] | [
"Alter",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L5188-L5192 |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/alg/misc/PixelMath.java | PixelMath.boundImage | public static void boundImage( GrayU16 img , int min , int max ) {
"""
Bounds image pixels to be between these two values
@param img Image
@param min minimum value.
@param max maximum value.
"""
ImplPixelMath.boundImage(img,min,max);
} | java | public static void boundImage( GrayU16 img , int min , int max ) {
ImplPixelMath.boundImage(img,min,max);
} | [
"public",
"static",
"void",
"boundImage",
"(",
"GrayU16",
"img",
",",
"int",
"min",
",",
"int",
"max",
")",
"{",
"ImplPixelMath",
".",
"boundImage",
"(",
"img",
",",
"min",
",",
"max",
")",
";",
"}"
] | Bounds image pixels to be between these two values
@param img Image
@param min minimum value.
@param max maximum value. | [
"Bounds",
"image",
"pixels",
"to",
"be",
"between",
"these",
"two",
"values"
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/misc/PixelMath.java#L4360-L4362 |
i-net-software/jlessc | src/com/inet/lib/less/LessParser.java | LessParser.readQuote | private void readQuote( char quote, StringBuilder builder ) {
"""
Read a quoted string and append it to the builder.
@param quote the quote character.
@param builder the target
"""
builder.append( quote );
boolean isBackslash = false;
for( ;; ) {
char ch = read();
builder.append( ch );
if( ch == quote && !isBackslash ) {
return;
}
isBackslash = ch == '\\';
}
} | java | private void readQuote( char quote, StringBuilder builder ) {
builder.append( quote );
boolean isBackslash = false;
for( ;; ) {
char ch = read();
builder.append( ch );
if( ch == quote && !isBackslash ) {
return;
}
isBackslash = ch == '\\';
}
} | [
"private",
"void",
"readQuote",
"(",
"char",
"quote",
",",
"StringBuilder",
"builder",
")",
"{",
"builder",
".",
"append",
"(",
"quote",
")",
";",
"boolean",
"isBackslash",
"=",
"false",
";",
"for",
"(",
";",
";",
")",
"{",
"char",
"ch",
"=",
"read",
... | Read a quoted string and append it to the builder.
@param quote the quote character.
@param builder the target | [
"Read",
"a",
"quoted",
"string",
"and",
"append",
"it",
"to",
"the",
"builder",
"."
] | train | https://github.com/i-net-software/jlessc/blob/15b13e1637f6cc2e4d72df021e23ee0ca8d5e629/src/com/inet/lib/less/LessParser.java#L1062-L1073 |
litsec/eidas-opensaml | opensaml3/src/main/java/se/litsec/eidas/opensaml/ext/RequestedAttributeTemplates.java | RequestedAttributeTemplates.GENDER | public static RequestedAttribute GENDER(Boolean isRequired, boolean includeFriendlyName) {
"""
Creates a {@code RequestedAttribute} object for the Gender attribute.
@param isRequired
flag to tell whether the attribute is required
@param includeFriendlyName
flag that tells whether the friendly name should be included
@return a {@code RequestedAttribute} object representing the Gender attribute
"""
return create(AttributeConstants.EIDAS_GENDER_ATTRIBUTE_NAME,
includeFriendlyName ? AttributeConstants.EIDAS_GENDER_ATTRIBUTE_FRIENDLY_NAME : null,
Attribute.URI_REFERENCE, isRequired);
} | java | public static RequestedAttribute GENDER(Boolean isRequired, boolean includeFriendlyName) {
return create(AttributeConstants.EIDAS_GENDER_ATTRIBUTE_NAME,
includeFriendlyName ? AttributeConstants.EIDAS_GENDER_ATTRIBUTE_FRIENDLY_NAME : null,
Attribute.URI_REFERENCE, isRequired);
} | [
"public",
"static",
"RequestedAttribute",
"GENDER",
"(",
"Boolean",
"isRequired",
",",
"boolean",
"includeFriendlyName",
")",
"{",
"return",
"create",
"(",
"AttributeConstants",
".",
"EIDAS_GENDER_ATTRIBUTE_NAME",
",",
"includeFriendlyName",
"?",
"AttributeConstants",
"."... | Creates a {@code RequestedAttribute} object for the Gender attribute.
@param isRequired
flag to tell whether the attribute is required
@param includeFriendlyName
flag that tells whether the friendly name should be included
@return a {@code RequestedAttribute} object representing the Gender attribute | [
"Creates",
"a",
"{",
"@code",
"RequestedAttribute",
"}",
"object",
"for",
"the",
"Gender",
"attribute",
"."
] | train | https://github.com/litsec/eidas-opensaml/blob/522ba6dba433a9524cb8a02464cc3b087b47a2b7/opensaml3/src/main/java/se/litsec/eidas/opensaml/ext/RequestedAttributeTemplates.java#L101-L105 |
RobotiumTech/robotium | robotium-solo/src/main/java/com/robotium/solo/Waiter.java | Waiter.waitForViews | public <T extends View> boolean waitForViews(boolean scrollMethod, Class<? extends T>... classes) {
"""
Waits for two views to be shown.
@param scrollMethod {@code true} if it's a method used for scrolling
@param classes the classes to wait for
@return {@code true} if any of the views are shown and {@code false} if none of the views are shown before the timeout
"""
final long endTime = SystemClock.uptimeMillis() + Timeout.getSmallTimeout();
while (SystemClock.uptimeMillis() < endTime) {
for (Class<? extends T> classToWaitFor : classes) {
if (waitForView(classToWaitFor, 0, false, false)) {
return true;
}
}
if(scrollMethod){
scroller.scroll(Scroller.DOWN);
}
else {
scroller.scrollDown();
}
sleeper.sleep();
}
return false;
} | java | public <T extends View> boolean waitForViews(boolean scrollMethod, Class<? extends T>... classes) {
final long endTime = SystemClock.uptimeMillis() + Timeout.getSmallTimeout();
while (SystemClock.uptimeMillis() < endTime) {
for (Class<? extends T> classToWaitFor : classes) {
if (waitForView(classToWaitFor, 0, false, false)) {
return true;
}
}
if(scrollMethod){
scroller.scroll(Scroller.DOWN);
}
else {
scroller.scrollDown();
}
sleeper.sleep();
}
return false;
} | [
"public",
"<",
"T",
"extends",
"View",
">",
"boolean",
"waitForViews",
"(",
"boolean",
"scrollMethod",
",",
"Class",
"<",
"?",
"extends",
"T",
">",
"...",
"classes",
")",
"{",
"final",
"long",
"endTime",
"=",
"SystemClock",
".",
"uptimeMillis",
"(",
")",
... | Waits for two views to be shown.
@param scrollMethod {@code true} if it's a method used for scrolling
@param classes the classes to wait for
@return {@code true} if any of the views are shown and {@code false} if none of the views are shown before the timeout | [
"Waits",
"for",
"two",
"views",
"to",
"be",
"shown",
"."
] | train | https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Waiter.java#L273-L292 |
knightliao/disconf | disconf-client/src/main/java/com/baidu/disconf/client/support/utils/StringUtil.java | StringUtil.bytesToString | public static String bytesToString(byte[] bytes, boolean noCase) {
"""
将一个byte数组转换成62进制的字符串。
@param bytes 二进制数组
@param noCase 区分大小写
@return 62进制的字符串
"""
char[] digits = noCase ? DIGITS_NOCASE : DIGITS;
int digitsLength = digits.length;
if (ArrayUtils.isEmpty(bytes)) {
return String.valueOf(digits[0]);
}
StringBuilder strValue = new StringBuilder();
int value = 0;
int limit = Integer.MAX_VALUE >>> 8;
int i = 0;
do {
while (i < bytes.length && value < limit) {
value = (value << 8) + (0xFF & bytes[i++]);
}
while (value >= digitsLength) {
strValue.append(digits[value % digitsLength]);
value = value / digitsLength;
}
} while (i < bytes.length);
if (value != 0 || strValue.length() == 0) {
strValue.append(digits[value]);
}
return strValue.toString();
} | java | public static String bytesToString(byte[] bytes, boolean noCase) {
char[] digits = noCase ? DIGITS_NOCASE : DIGITS;
int digitsLength = digits.length;
if (ArrayUtils.isEmpty(bytes)) {
return String.valueOf(digits[0]);
}
StringBuilder strValue = new StringBuilder();
int value = 0;
int limit = Integer.MAX_VALUE >>> 8;
int i = 0;
do {
while (i < bytes.length && value < limit) {
value = (value << 8) + (0xFF & bytes[i++]);
}
while (value >= digitsLength) {
strValue.append(digits[value % digitsLength]);
value = value / digitsLength;
}
} while (i < bytes.length);
if (value != 0 || strValue.length() == 0) {
strValue.append(digits[value]);
}
return strValue.toString();
} | [
"public",
"static",
"String",
"bytesToString",
"(",
"byte",
"[",
"]",
"bytes",
",",
"boolean",
"noCase",
")",
"{",
"char",
"[",
"]",
"digits",
"=",
"noCase",
"?",
"DIGITS_NOCASE",
":",
"DIGITS",
";",
"int",
"digitsLength",
"=",
"digits",
".",
"length",
"... | 将一个byte数组转换成62进制的字符串。
@param bytes 二进制数组
@param noCase 区分大小写
@return 62进制的字符串 | [
"将一个byte数组转换成62进制的字符串。"
] | train | https://github.com/knightliao/disconf/blob/d413cbce9334fe38a5a24982ce4db3a6ed8e98ea/disconf-client/src/main/java/com/baidu/disconf/client/support/utils/StringUtil.java#L487-L516 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/sun/misc/FDBigInteger.java | FDBigInteger.multAddMe | private /*@ helper @*/ void multAddMe(int iv, int addend) {
"""
/*@
@ requires this.value()*UNSIGNED(iv) + UNSIGNED(addend) < ((\bigint)1) << ((this.data.length + this.offset)*32);
@ assignable this.data[*];
@ ensures this.value() == \old(this.value()*UNSIGNED(iv) + UNSIGNED(addend));
@
"""
long v = iv & LONG_MASK;
// unroll 0th iteration, doing addition.
long p = v * (data[0] & LONG_MASK) + (addend & LONG_MASK);
data[0] = (int) p;
p >>>= 32;
for (int i = 1; i < nWords; i++) {
p += v * (data[i] & LONG_MASK);
data[i] = (int) p;
p >>>= 32;
}
if (p != 0L) {
data[nWords++] = (int) p; // will fail noisily if illegal!
}
} | java | private /*@ helper @*/ void multAddMe(int iv, int addend) {
long v = iv & LONG_MASK;
// unroll 0th iteration, doing addition.
long p = v * (data[0] & LONG_MASK) + (addend & LONG_MASK);
data[0] = (int) p;
p >>>= 32;
for (int i = 1; i < nWords; i++) {
p += v * (data[i] & LONG_MASK);
data[i] = (int) p;
p >>>= 32;
}
if (p != 0L) {
data[nWords++] = (int) p; // will fail noisily if illegal!
}
} | [
"private",
"/*@ helper @*/",
"void",
"multAddMe",
"(",
"int",
"iv",
",",
"int",
"addend",
")",
"{",
"long",
"v",
"=",
"iv",
"&",
"LONG_MASK",
";",
"// unroll 0th iteration, doing addition.",
"long",
"p",
"=",
"v",
"*",
"(",
"data",
"[",
"0",
"]",
"&",
"L... | /*@
@ requires this.value()*UNSIGNED(iv) + UNSIGNED(addend) < ((\bigint)1) << ((this.data.length + this.offset)*32);
@ assignable this.data[*];
@ ensures this.value() == \old(this.value()*UNSIGNED(iv) + UNSIGNED(addend));
@ | [
"/",
"*"
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/misc/FDBigInteger.java#L1233-L1247 |
korpling/ANNIS | annis-service/src/main/java/annis/service/internal/QueryServiceImpl.java | QueryServiceImpl.getExampleQueries | @GET
@Path("corpora/example-queries/")
@Produces(MediaType.APPLICATION_XML)
public List<ExampleQuery> getExampleQueries(
@QueryParam("corpora") String rawCorpusNames) throws WebApplicationException {
"""
Fetches the example queries for a specific corpus.
@param rawCorpusNames specifies the corpora the examples are fetched from.
"""
Subject user = SecurityUtils.getSubject();
try
{
String[] corpusNames;
if (rawCorpusNames != null)
{
corpusNames = rawCorpusNames.split(",");
}
else
{
List<AnnisCorpus> allCorpora = queryDao.listCorpora();
corpusNames = new String[allCorpora.size()];
for (int i = 0; i < corpusNames.length; i++)
{
corpusNames[i] = allCorpora.get(i).getName();
}
}
List<String> allowedCorpora = new ArrayList<>();
// filter by which corpora the user is allowed to access
for (String c : corpusNames)
{
if (user.isPermitted("query:*:" + c))
{
allowedCorpora.add(c);
}
}
List<Long> corpusIDs = queryDao.mapCorpusNamesToIds(allowedCorpora);
return queryDao.getExampleQueries(corpusIDs);
}
catch (Exception ex)
{
log.error("Problem accessing example queries", ex);
throw new WebApplicationException(ex, 500);
}
} | java | @GET
@Path("corpora/example-queries/")
@Produces(MediaType.APPLICATION_XML)
public List<ExampleQuery> getExampleQueries(
@QueryParam("corpora") String rawCorpusNames) throws WebApplicationException
{
Subject user = SecurityUtils.getSubject();
try
{
String[] corpusNames;
if (rawCorpusNames != null)
{
corpusNames = rawCorpusNames.split(",");
}
else
{
List<AnnisCorpus> allCorpora = queryDao.listCorpora();
corpusNames = new String[allCorpora.size()];
for (int i = 0; i < corpusNames.length; i++)
{
corpusNames[i] = allCorpora.get(i).getName();
}
}
List<String> allowedCorpora = new ArrayList<>();
// filter by which corpora the user is allowed to access
for (String c : corpusNames)
{
if (user.isPermitted("query:*:" + c))
{
allowedCorpora.add(c);
}
}
List<Long> corpusIDs = queryDao.mapCorpusNamesToIds(allowedCorpora);
return queryDao.getExampleQueries(corpusIDs);
}
catch (Exception ex)
{
log.error("Problem accessing example queries", ex);
throw new WebApplicationException(ex, 500);
}
} | [
"@",
"GET",
"@",
"Path",
"(",
"\"corpora/example-queries/\"",
")",
"@",
"Produces",
"(",
"MediaType",
".",
"APPLICATION_XML",
")",
"public",
"List",
"<",
"ExampleQuery",
">",
"getExampleQueries",
"(",
"@",
"QueryParam",
"(",
"\"corpora\"",
")",
"String",
"rawCor... | Fetches the example queries for a specific corpus.
@param rawCorpusNames specifies the corpora the examples are fetched from. | [
"Fetches",
"the",
"example",
"queries",
"for",
"a",
"specific",
"corpus",
"."
] | train | https://github.com/korpling/ANNIS/blob/152a2e34832e015f73ac8ce8a7d4c32641641324/annis-service/src/main/java/annis/service/internal/QueryServiceImpl.java#L905-L950 |
vznet/mongo-jackson-mapper | src/main/java/net/vz/mongodb/jackson/JacksonDBCollection.java | JacksonDBCollection.mapReduce | @Deprecated
public com.mongodb.MapReduceOutput mapReduce(String map, String reduce, String outputTarget, DBObject query) throws MongoException {
"""
performs a map reduce operation
Runs the command in REPLACE output mode (saves to named collection)
@param map map function in javascript code
@param outputTarget optional - leave null if want to use temp collection
@param reduce reduce function in javascript code
@param query to match
@return The output
@throws MongoException If an error occurred
"""
return mapReduce(new MapReduceCommand(dbCollection, map, reduce, outputTarget, MapReduceCommand.OutputType.REPLACE, serializeFields(query)));
} | java | @Deprecated
public com.mongodb.MapReduceOutput mapReduce(String map, String reduce, String outputTarget, DBObject query) throws MongoException {
return mapReduce(new MapReduceCommand(dbCollection, map, reduce, outputTarget, MapReduceCommand.OutputType.REPLACE, serializeFields(query)));
} | [
"@",
"Deprecated",
"public",
"com",
".",
"mongodb",
".",
"MapReduceOutput",
"mapReduce",
"(",
"String",
"map",
",",
"String",
"reduce",
",",
"String",
"outputTarget",
",",
"DBObject",
"query",
")",
"throws",
"MongoException",
"{",
"return",
"mapReduce",
"(",
"... | performs a map reduce operation
Runs the command in REPLACE output mode (saves to named collection)
@param map map function in javascript code
@param outputTarget optional - leave null if want to use temp collection
@param reduce reduce function in javascript code
@param query to match
@return The output
@throws MongoException If an error occurred | [
"performs",
"a",
"map",
"reduce",
"operation",
"Runs",
"the",
"command",
"in",
"REPLACE",
"output",
"mode",
"(",
"saves",
"to",
"named",
"collection",
")"
] | train | https://github.com/vznet/mongo-jackson-mapper/blob/ecd189aefa89636cddf70fb383f5d676be347976/src/main/java/net/vz/mongodb/jackson/JacksonDBCollection.java#L1254-L1257 |
primefaces-extensions/core | src/main/java/org/primefaces/extensions/component/sheet/SheetRenderer.java | SheetRenderer.encodeSortVar | protected void encodeSortVar(final FacesContext context, final Sheet sheet, final WidgetBuilder wb)
throws IOException {
"""
Encodes a javascript sort var that informs the col header event of the column's sorting options. The var is an array of boolean indicating whether or not
the column is sortable.
@param context
@param sheet
@param wb
@throws IOException
"""
final JavascriptVarBuilder vb = new JavascriptVarBuilder(null, false);
for (final SheetColumn column : sheet.getColumns()) {
if (!column.isRendered()) {
continue;
}
if (column.getValueExpression("sortBy") == null) {
vb.appendArrayValue("false", false);
}
else {
vb.appendArrayValue("true", false);
}
}
wb.nativeAttr("sortable", vb.closeVar().toString());
} | java | protected void encodeSortVar(final FacesContext context, final Sheet sheet, final WidgetBuilder wb)
throws IOException {
final JavascriptVarBuilder vb = new JavascriptVarBuilder(null, false);
for (final SheetColumn column : sheet.getColumns()) {
if (!column.isRendered()) {
continue;
}
if (column.getValueExpression("sortBy") == null) {
vb.appendArrayValue("false", false);
}
else {
vb.appendArrayValue("true", false);
}
}
wb.nativeAttr("sortable", vb.closeVar().toString());
} | [
"protected",
"void",
"encodeSortVar",
"(",
"final",
"FacesContext",
"context",
",",
"final",
"Sheet",
"sheet",
",",
"final",
"WidgetBuilder",
"wb",
")",
"throws",
"IOException",
"{",
"final",
"JavascriptVarBuilder",
"vb",
"=",
"new",
"JavascriptVarBuilder",
"(",
"... | Encodes a javascript sort var that informs the col header event of the column's sorting options. The var is an array of boolean indicating whether or not
the column is sortable.
@param context
@param sheet
@param wb
@throws IOException | [
"Encodes",
"a",
"javascript",
"sort",
"var",
"that",
"informs",
"the",
"col",
"header",
"event",
"of",
"the",
"column",
"s",
"sorting",
"options",
".",
"The",
"var",
"is",
"an",
"array",
"of",
"boolean",
"indicating",
"whether",
"or",
"not",
"the",
"column... | train | https://github.com/primefaces-extensions/core/blob/afdbca591f60f47898e3517e1e939bc2f63d5355/src/main/java/org/primefaces/extensions/component/sheet/SheetRenderer.java#L780-L797 |
mongodb/stitch-android-sdk | server/services/aws-s3/src/main/java/com/mongodb/stitch/server/services/aws/s3/internal/AwsS3ServiceClientImpl.java | AwsS3ServiceClientImpl.signPolicy | public AwsS3SignPolicyResult signPolicy(
@Nonnull final String bucket,
@Nonnull final String key,
@Nonnull final String acl,
@Nonnull final String contentType
) {
"""
Signs an AWS S3 security policy for a future put object request. This future request would
be made outside of the Stitch SDK. This is typically used for large requests that are better
sent directly to AWS.
@see <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-post-example.html">Uploading a File to Amazon S3 Using HTTP POST</a>
@param bucket the bucket to put the future object in.
@param key the key (or name) of the future object.
@param acl the ACL to apply to the future object (e.g. private).
@param contentType the content type of the object (e.g. application/json).
@return the signed policy details.
"""
return proxy.signPolicy(bucket, key, acl, contentType);
} | java | public AwsS3SignPolicyResult signPolicy(
@Nonnull final String bucket,
@Nonnull final String key,
@Nonnull final String acl,
@Nonnull final String contentType
) {
return proxy.signPolicy(bucket, key, acl, contentType);
} | [
"public",
"AwsS3SignPolicyResult",
"signPolicy",
"(",
"@",
"Nonnull",
"final",
"String",
"bucket",
",",
"@",
"Nonnull",
"final",
"String",
"key",
",",
"@",
"Nonnull",
"final",
"String",
"acl",
",",
"@",
"Nonnull",
"final",
"String",
"contentType",
")",
"{",
... | Signs an AWS S3 security policy for a future put object request. This future request would
be made outside of the Stitch SDK. This is typically used for large requests that are better
sent directly to AWS.
@see <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-post-example.html">Uploading a File to Amazon S3 Using HTTP POST</a>
@param bucket the bucket to put the future object in.
@param key the key (or name) of the future object.
@param acl the ACL to apply to the future object (e.g. private).
@param contentType the content type of the object (e.g. application/json).
@return the signed policy details. | [
"Signs",
"an",
"AWS",
"S3",
"security",
"policy",
"for",
"a",
"future",
"put",
"object",
"request",
".",
"This",
"future",
"request",
"would",
"be",
"made",
"outside",
"of",
"the",
"Stitch",
"SDK",
".",
"This",
"is",
"typically",
"used",
"for",
"large",
... | train | https://github.com/mongodb/stitch-android-sdk/blob/159b9334b1f1a827285544be5ee20cdf7b04e4cc/server/services/aws-s3/src/main/java/com/mongodb/stitch/server/services/aws/s3/internal/AwsS3ServiceClientImpl.java#L128-L135 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/AppsImpl.java | AppsImpl.updateSettingsWithServiceResponseAsync | public Observable<ServiceResponse<OperationStatus>> updateSettingsWithServiceResponseAsync(UUID appId, UpdateSettingsOptionalParameter updateSettingsOptionalParameter) {
"""
Updates the application settings.
@param appId The application ID.
@param updateSettingsOptionalParameter 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 OperationStatus object
"""
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.");
}
final boolean publicParameter = updateSettingsOptionalParameter != null ? updateSettingsOptionalParameter.publicParameter() : false;
return updateSettingsWithServiceResponseAsync(appId, publicParameter);
} | java | public Observable<ServiceResponse<OperationStatus>> updateSettingsWithServiceResponseAsync(UUID appId, UpdateSettingsOptionalParameter updateSettingsOptionalParameter) {
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.");
}
final boolean publicParameter = updateSettingsOptionalParameter != null ? updateSettingsOptionalParameter.publicParameter() : false;
return updateSettingsWithServiceResponseAsync(appId, publicParameter);
} | [
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"OperationStatus",
">",
">",
"updateSettingsWithServiceResponseAsync",
"(",
"UUID",
"appId",
",",
"UpdateSettingsOptionalParameter",
"updateSettingsOptionalParameter",
")",
"{",
"if",
"(",
"this",
".",
"client",
".",
... | Updates the application settings.
@param appId The application ID.
@param updateSettingsOptionalParameter 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 OperationStatus object | [
"Updates",
"the",
"application",
"settings",
"."
] | 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/AppsImpl.java#L1352-L1362 |
OpenLiberty/open-liberty | dev/com.ibm.websphere.javaee.jsf.2.2/src/javax/faces/component/_ComponentAttributesMap.java | _ComponentAttributesMap.setComponentProperty | private void setComponentProperty(_PropertyDescriptorHolder propertyDescriptor, Object value) {
"""
Execute the setter method of the specified property on the underlying
component.
@param propertyDescriptor specifies which property to write.
@throws IllegalArgumentException if the property is not writable.
@throws FacesException if any other problem occurs while invoking
the getter method.
"""
Method writeMethod = propertyDescriptor.getWriteMethod();
if (writeMethod == null)
{
throw new IllegalArgumentException("Component property " + propertyDescriptor.getName()
+ " is not writable");
}
try
{
writeMethod.invoke(_component, new Object[]{value});
}
catch (Exception e)
{
FacesContext facesContext = _component.getFacesContext();
throw new FacesException("Could not set property " + propertyDescriptor.getName() +
" of component " + _component.getClientId(facesContext) + " to value : " + value + " with type : " +
(value == null ? "null" : value.getClass().getName()), e);
}
} | java | private void setComponentProperty(_PropertyDescriptorHolder propertyDescriptor, Object value)
{
Method writeMethod = propertyDescriptor.getWriteMethod();
if (writeMethod == null)
{
throw new IllegalArgumentException("Component property " + propertyDescriptor.getName()
+ " is not writable");
}
try
{
writeMethod.invoke(_component, new Object[]{value});
}
catch (Exception e)
{
FacesContext facesContext = _component.getFacesContext();
throw new FacesException("Could not set property " + propertyDescriptor.getName() +
" of component " + _component.getClientId(facesContext) + " to value : " + value + " with type : " +
(value == null ? "null" : value.getClass().getName()), e);
}
} | [
"private",
"void",
"setComponentProperty",
"(",
"_PropertyDescriptorHolder",
"propertyDescriptor",
",",
"Object",
"value",
")",
"{",
"Method",
"writeMethod",
"=",
"propertyDescriptor",
".",
"getWriteMethod",
"(",
")",
";",
"if",
"(",
"writeMethod",
"==",
"null",
")"... | Execute the setter method of the specified property on the underlying
component.
@param propertyDescriptor specifies which property to write.
@throws IllegalArgumentException if the property is not writable.
@throws FacesException if any other problem occurs while invoking
the getter method. | [
"Execute",
"the",
"setter",
"method",
"of",
"the",
"specified",
"property",
"on",
"the",
"underlying",
"component",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.websphere.javaee.jsf.2.2/src/javax/faces/component/_ComponentAttributesMap.java#L705-L724 |
jmurty/java-xmlbuilder | src/main/java/com/jamesmurty/utils/NamespaceContextImpl.java | NamespaceContextImpl.addNamespace | public void addNamespace(String prefix, String namespaceURI) {
"""
Add a custom mapping from prefix to a namespace. This mapping will
override any mappings present in this class's XML Element (if provided).
@param prefix
the namespace's prefix. Use an empty string for the
default prefix.
@param namespaceURI
the namespace URI to map.
"""
this.prefixToNsUriMap.put(prefix, namespaceURI);
if (this.nsUriToPrefixesMap.get(namespaceURI) == null) {
this.nsUriToPrefixesMap.put(namespaceURI, new HashSet<String>());
}
this.nsUriToPrefixesMap.get(namespaceURI).add(prefix);
} | java | public void addNamespace(String prefix, String namespaceURI) {
this.prefixToNsUriMap.put(prefix, namespaceURI);
if (this.nsUriToPrefixesMap.get(namespaceURI) == null) {
this.nsUriToPrefixesMap.put(namespaceURI, new HashSet<String>());
}
this.nsUriToPrefixesMap.get(namespaceURI).add(prefix);
} | [
"public",
"void",
"addNamespace",
"(",
"String",
"prefix",
",",
"String",
"namespaceURI",
")",
"{",
"this",
".",
"prefixToNsUriMap",
".",
"put",
"(",
"prefix",
",",
"namespaceURI",
")",
";",
"if",
"(",
"this",
".",
"nsUriToPrefixesMap",
".",
"get",
"(",
"n... | Add a custom mapping from prefix to a namespace. This mapping will
override any mappings present in this class's XML Element (if provided).
@param prefix
the namespace's prefix. Use an empty string for the
default prefix.
@param namespaceURI
the namespace URI to map. | [
"Add",
"a",
"custom",
"mapping",
"from",
"prefix",
"to",
"a",
"namespace",
".",
"This",
"mapping",
"will",
"override",
"any",
"mappings",
"present",
"in",
"this",
"class",
"s",
"XML",
"Element",
"(",
"if",
"provided",
")",
"."
] | train | https://github.com/jmurty/java-xmlbuilder/blob/7c224b8e8ed79808509322cb141dab5a88dd3cec/src/main/java/com/jamesmurty/utils/NamespaceContextImpl.java#L52-L58 |
jbundle/jbundle | thin/base/screen/util/src/main/java/org/jbundle/thin/base/screen/util/JBlinkLabel.java | JBlinkLabel.addIcon | public void addIcon(Object icon, int iIndex) {
"""
Add this icon to the list of icons alternating for this label.
@param icon The icon to add.
@param iIndex The index for this icon.
"""
if (m_rgIcons == null)
{
m_rgIcons = new ImageIcon[MAX_ICONS];
m_timer = new javax.swing.Timer(500, this); // Remind me to change graphics every 1/2 second
m_timer.start();
}
if (iIndex < MAX_ICONS)
if (icon instanceof ImageIcon) // Always
m_rgIcons[iIndex] = (ImageIcon)icon;
} | java | public void addIcon(Object icon, int iIndex)
{
if (m_rgIcons == null)
{
m_rgIcons = new ImageIcon[MAX_ICONS];
m_timer = new javax.swing.Timer(500, this); // Remind me to change graphics every 1/2 second
m_timer.start();
}
if (iIndex < MAX_ICONS)
if (icon instanceof ImageIcon) // Always
m_rgIcons[iIndex] = (ImageIcon)icon;
} | [
"public",
"void",
"addIcon",
"(",
"Object",
"icon",
",",
"int",
"iIndex",
")",
"{",
"if",
"(",
"m_rgIcons",
"==",
"null",
")",
"{",
"m_rgIcons",
"=",
"new",
"ImageIcon",
"[",
"MAX_ICONS",
"]",
";",
"m_timer",
"=",
"new",
"javax",
".",
"swing",
".",
"... | Add this icon to the list of icons alternating for this label.
@param icon The icon to add.
@param iIndex The index for this icon. | [
"Add",
"this",
"icon",
"to",
"the",
"list",
"of",
"icons",
"alternating",
"for",
"this",
"label",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/util/src/main/java/org/jbundle/thin/base/screen/util/JBlinkLabel.java#L208-L219 |
inferred/FreeBuilder | src/main/java/org/inferred/freebuilder/processor/source/FunctionalType.java | FunctionalType.unboxedUnaryOperator | public static FunctionalType unboxedUnaryOperator(TypeMirror type, Types types) {
"""
Returns a unary operator that will accept {@code type}, without autoboxing if possible.
"""
switch (type.getKind()) {
case INT:
case LONG:
case DOUBLE:
return primitiveUnaryOperator((PrimitiveType) type);
case BOOLEAN:
case BYTE:
case CHAR:
case SHORT:
case FLOAT:
return unaryOperator(types.boxedClass((PrimitiveType) type).asType());
default:
return unaryOperator(type);
}
} | java | public static FunctionalType unboxedUnaryOperator(TypeMirror type, Types types) {
switch (type.getKind()) {
case INT:
case LONG:
case DOUBLE:
return primitiveUnaryOperator((PrimitiveType) type);
case BOOLEAN:
case BYTE:
case CHAR:
case SHORT:
case FLOAT:
return unaryOperator(types.boxedClass((PrimitiveType) type).asType());
default:
return unaryOperator(type);
}
} | [
"public",
"static",
"FunctionalType",
"unboxedUnaryOperator",
"(",
"TypeMirror",
"type",
",",
"Types",
"types",
")",
"{",
"switch",
"(",
"type",
".",
"getKind",
"(",
")",
")",
"{",
"case",
"INT",
":",
"case",
"LONG",
":",
"case",
"DOUBLE",
":",
"return",
... | Returns a unary operator that will accept {@code type}, without autoboxing if possible. | [
"Returns",
"a",
"unary",
"operator",
"that",
"will",
"accept",
"{"
] | train | https://github.com/inferred/FreeBuilder/blob/d5a222f90648aece135da4b971c55a60afe8649c/src/main/java/org/inferred/freebuilder/processor/source/FunctionalType.java#L109-L126 |
iipc/webarchive-commons | src/main/java/org/archive/util/zip/GZIPMembersInputStream.java | GZIPMembersInputStream.countingStream | protected static InputStream countingStream(InputStream in, int lookback) throws IOException {
"""
A CountingInputStream is inserted to read compressed-offsets.
@param in stream to wrap
@param lookback tolerance of initial mark
@return original stream wrapped in CountingInputStream
@throws IOException
"""
CountingInputStream cin = new CountingInputStream(in);
cin.mark(lookback);
return cin;
} | java | protected static InputStream countingStream(InputStream in, int lookback) throws IOException {
CountingInputStream cin = new CountingInputStream(in);
cin.mark(lookback);
return cin;
} | [
"protected",
"static",
"InputStream",
"countingStream",
"(",
"InputStream",
"in",
",",
"int",
"lookback",
")",
"throws",
"IOException",
"{",
"CountingInputStream",
"cin",
"=",
"new",
"CountingInputStream",
"(",
"in",
")",
";",
"cin",
".",
"mark",
"(",
"lookback"... | A CountingInputStream is inserted to read compressed-offsets.
@param in stream to wrap
@param lookback tolerance of initial mark
@return original stream wrapped in CountingInputStream
@throws IOException | [
"A",
"CountingInputStream",
"is",
"inserted",
"to",
"read",
"compressed",
"-",
"offsets",
"."
] | train | https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/zip/GZIPMembersInputStream.java#L91-L95 |
NessComputing/components-ness-lifecycle | src/main/java/com/nesscomputing/lifecycle/guice/AbstractLifecycleProvider.java | AbstractLifecycleProvider.addAction | @Override
public void addAction(final LifecycleStage stage, final LifecycleAction<T> action) {
"""
Add a lifecycle Action to this provider. The action will called back when the lifecycle stage is
hit and contain an object that was created by the provider.
"""
stageEvents.add(new StageEvent(stage, action));
} | java | @Override
public void addAction(final LifecycleStage stage, final LifecycleAction<T> action)
{
stageEvents.add(new StageEvent(stage, action));
} | [
"@",
"Override",
"public",
"void",
"addAction",
"(",
"final",
"LifecycleStage",
"stage",
",",
"final",
"LifecycleAction",
"<",
"T",
">",
"action",
")",
"{",
"stageEvents",
".",
"add",
"(",
"new",
"StageEvent",
"(",
"stage",
",",
"action",
")",
")",
";",
... | Add a lifecycle Action to this provider. The action will called back when the lifecycle stage is
hit and contain an object that was created by the provider. | [
"Add",
"a",
"lifecycle",
"Action",
"to",
"this",
"provider",
".",
"The",
"action",
"will",
"called",
"back",
"when",
"the",
"lifecycle",
"stage",
"is",
"hit",
"and",
"contain",
"an",
"object",
"that",
"was",
"created",
"by",
"the",
"provider",
"."
] | train | https://github.com/NessComputing/components-ness-lifecycle/blob/6c8ae8ec8fdcd16b30383092ce9e70424a6760f1/src/main/java/com/nesscomputing/lifecycle/guice/AbstractLifecycleProvider.java#L46-L50 |
marklogic/java-client-api | marklogic-client-api/src/main/java/com/marklogic/client/query/StructuredQueryBuilder.java | StructuredQueryBuilder.geoAttributePair | public GeospatialIndex geoAttributePair(Element parent, Attribute lat, Attribute lon) {
"""
Identifies a parent element with child latitude and longitude attributes
to match with a geospatial query.
@param parent the parent of the element with the coordinates
@param lat the attribute with the latitude coordinate
@param lon the attribute with the longitude coordinate
@return the specification for the index on the geospatial coordinates
"""
return new GeoAttributePairImpl(parent, lat, lon);
} | java | public GeospatialIndex geoAttributePair(Element parent, Attribute lat, Attribute lon) {
return new GeoAttributePairImpl(parent, lat, lon);
} | [
"public",
"GeospatialIndex",
"geoAttributePair",
"(",
"Element",
"parent",
",",
"Attribute",
"lat",
",",
"Attribute",
"lon",
")",
"{",
"return",
"new",
"GeoAttributePairImpl",
"(",
"parent",
",",
"lat",
",",
"lon",
")",
";",
"}"
] | Identifies a parent element with child latitude and longitude attributes
to match with a geospatial query.
@param parent the parent of the element with the coordinates
@param lat the attribute with the latitude coordinate
@param lon the attribute with the longitude coordinate
@return the specification for the index on the geospatial coordinates | [
"Identifies",
"a",
"parent",
"element",
"with",
"child",
"latitude",
"and",
"longitude",
"attributes",
"to",
"match",
"with",
"a",
"geospatial",
"query",
"."
] | train | https://github.com/marklogic/java-client-api/blob/acf60229a928abd4a8cc4b21b641d56957467da7/marklogic-client-api/src/main/java/com/marklogic/client/query/StructuredQueryBuilder.java#L901-L903 |
Alluxio/alluxio | underfs/kodo/src/main/java/alluxio/underfs/kodo/KodoUnderFileSystem.java | KodoUnderFileSystem.getObjectStatus | @Nullable
@Override
protected ObjectStatus getObjectStatus(String key) {
"""
Gets metadata information about object. Implementations should process the key as is, which may
be a file or a directory key.
@param key ufs key to get metadata for
@return {@link ObjectStatus} if key exists and successful, otherwise null
"""
try {
FileInfo fileInfo = mKodoClinet.getFileInfo(key);
if (fileInfo == null) {
return null;
}
return new ObjectStatus(key, fileInfo.hash, fileInfo.fsize, fileInfo.putTime / 10000);
} catch (QiniuException e) {
LOG.warn("Failed to get Object {}, Msg: {}", key, e);
}
return null;
} | java | @Nullable
@Override
protected ObjectStatus getObjectStatus(String key) {
try {
FileInfo fileInfo = mKodoClinet.getFileInfo(key);
if (fileInfo == null) {
return null;
}
return new ObjectStatus(key, fileInfo.hash, fileInfo.fsize, fileInfo.putTime / 10000);
} catch (QiniuException e) {
LOG.warn("Failed to get Object {}, Msg: {}", key, e);
}
return null;
} | [
"@",
"Nullable",
"@",
"Override",
"protected",
"ObjectStatus",
"getObjectStatus",
"(",
"String",
"key",
")",
"{",
"try",
"{",
"FileInfo",
"fileInfo",
"=",
"mKodoClinet",
".",
"getFileInfo",
"(",
"key",
")",
";",
"if",
"(",
"fileInfo",
"==",
"null",
")",
"{... | Gets metadata information about object. Implementations should process the key as is, which may
be a file or a directory key.
@param key ufs key to get metadata for
@return {@link ObjectStatus} if key exists and successful, otherwise null | [
"Gets",
"metadata",
"information",
"about",
"object",
".",
"Implementations",
"should",
"process",
"the",
"key",
"as",
"is",
"which",
"may",
"be",
"a",
"file",
"or",
"a",
"directory",
"key",
"."
] | train | https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/underfs/kodo/src/main/java/alluxio/underfs/kodo/KodoUnderFileSystem.java#L186-L199 |
sriharshachilakapati/WebGL4J | webgl4j/src/main/java/com/shc/webgl4j/client/WebGL10.java | WebGL10.glBlendColor | public static void glBlendColor(float r, float g, float b, float a) {
"""
The {@link #GL_BLEND_COLOR} may be used to calculate the source and destination blending factors. The color
components are clamped to the range {@code [0,1]} before being stored. See {@link #glBlendFunc(int, int)} for a
complete description of the blending operations. Initially the {@link #GL_BLEND_COLOR} is set to {@code (0, 0, 0,
0)}.
@param r Specifies the red component of {@link #GL_BLEND_COLOR}.
@param g Specifies the green component of {@link #GL_BLEND_COLOR}.
@param b Specifies the blue component of {@link #GL_BLEND_COLOR}.
@param a Specifies the alpha component of {@link #GL_BLEND_COLOR}.
"""
checkContextCompatibility();
nglBlendColor(r, g, b, a);
} | java | public static void glBlendColor(float r, float g, float b, float a)
{
checkContextCompatibility();
nglBlendColor(r, g, b, a);
} | [
"public",
"static",
"void",
"glBlendColor",
"(",
"float",
"r",
",",
"float",
"g",
",",
"float",
"b",
",",
"float",
"a",
")",
"{",
"checkContextCompatibility",
"(",
")",
";",
"nglBlendColor",
"(",
"r",
",",
"g",
",",
"b",
",",
"a",
")",
";",
"}"
] | The {@link #GL_BLEND_COLOR} may be used to calculate the source and destination blending factors. The color
components are clamped to the range {@code [0,1]} before being stored. See {@link #glBlendFunc(int, int)} for a
complete description of the blending operations. Initially the {@link #GL_BLEND_COLOR} is set to {@code (0, 0, 0,
0)}.
@param r Specifies the red component of {@link #GL_BLEND_COLOR}.
@param g Specifies the green component of {@link #GL_BLEND_COLOR}.
@param b Specifies the blue component of {@link #GL_BLEND_COLOR}.
@param a Specifies the alpha component of {@link #GL_BLEND_COLOR}. | [
"The",
"{",
"@link",
"#GL_BLEND_COLOR",
"}",
"may",
"be",
"used",
"to",
"calculate",
"the",
"source",
"and",
"destination",
"blending",
"factors",
".",
"The",
"color",
"components",
"are",
"clamped",
"to",
"the",
"range",
"{",
"@code",
"[",
"0",
"1",
"]",
... | train | https://github.com/sriharshachilakapati/WebGL4J/blob/7daa425300b08b338b50cef2935289849c92d415/webgl4j/src/main/java/com/shc/webgl4j/client/WebGL10.java#L659-L663 |
citrusframework/citrus | modules/citrus-jmx/src/main/java/com/consol/citrus/jmx/client/JmxClient.java | JmxClient.addNotificationListener | private void addNotificationListener(ObjectName objectName, final String correlationKey, MBeanServerConnection serverConnection) {
"""
Add notification listener for response messages.
@param objectName
@param correlationKey
@param serverConnection
"""
try {
notificationListener = new NotificationListener() {
@Override
public void handleNotification(Notification notification, Object handback) {
correlationManager.store(correlationKey, new DefaultMessage(notification.getMessage()));
}
};
serverConnection.addNotificationListener(objectName, notificationListener, getEndpointConfiguration().getNotificationFilter(), getEndpointConfiguration().getNotificationHandback());
} catch (InstanceNotFoundException e) {
throw new CitrusRuntimeException("Failed to find object name instance", e);
} catch (IOException e) {
throw new CitrusRuntimeException("Failed to add notification listener", e);
}
} | java | private void addNotificationListener(ObjectName objectName, final String correlationKey, MBeanServerConnection serverConnection) {
try {
notificationListener = new NotificationListener() {
@Override
public void handleNotification(Notification notification, Object handback) {
correlationManager.store(correlationKey, new DefaultMessage(notification.getMessage()));
}
};
serverConnection.addNotificationListener(objectName, notificationListener, getEndpointConfiguration().getNotificationFilter(), getEndpointConfiguration().getNotificationHandback());
} catch (InstanceNotFoundException e) {
throw new CitrusRuntimeException("Failed to find object name instance", e);
} catch (IOException e) {
throw new CitrusRuntimeException("Failed to add notification listener", e);
}
} | [
"private",
"void",
"addNotificationListener",
"(",
"ObjectName",
"objectName",
",",
"final",
"String",
"correlationKey",
",",
"MBeanServerConnection",
"serverConnection",
")",
"{",
"try",
"{",
"notificationListener",
"=",
"new",
"NotificationListener",
"(",
")",
"{",
... | Add notification listener for response messages.
@param objectName
@param correlationKey
@param serverConnection | [
"Add",
"notification",
"listener",
"for",
"response",
"messages",
"."
] | train | https://github.com/citrusframework/citrus/blob/55c58ef74c01d511615e43646ca25c1b2301c56d/modules/citrus-jmx/src/main/java/com/consol/citrus/jmx/client/JmxClient.java#L261-L276 |
JodaOrg/joda-convert | src/main/java/org/joda/convert/StringConvert.java | StringConvert.convertFromString | public <T> T convertFromString(Class<T> cls, String str) {
"""
Converts the specified object from a {@code String}.
<p>
This uses {@link #findConverter} to provide the converter.
@param <T> the type to convert to
@param cls the class to convert to, not null
@param str the string to convert, null returns null
@return the converted object, may be null
@throws RuntimeException (or subclass) if unable to convert
"""
if (str == null) {
return null;
}
StringConverter<T> conv = findConverter(cls);
return conv.convertFromString(cls, str);
} | java | public <T> T convertFromString(Class<T> cls, String str) {
if (str == null) {
return null;
}
StringConverter<T> conv = findConverter(cls);
return conv.convertFromString(cls, str);
} | [
"public",
"<",
"T",
">",
"T",
"convertFromString",
"(",
"Class",
"<",
"T",
">",
"cls",
",",
"String",
"str",
")",
"{",
"if",
"(",
"str",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"StringConverter",
"<",
"T",
">",
"conv",
"=",
"findConvert... | Converts the specified object from a {@code String}.
<p>
This uses {@link #findConverter} to provide the converter.
@param <T> the type to convert to
@param cls the class to convert to, not null
@param str the string to convert, null returns null
@return the converted object, may be null
@throws RuntimeException (or subclass) if unable to convert | [
"Converts",
"the",
"specified",
"object",
"from",
"a",
"{",
"@code",
"String",
"}",
".",
"<p",
">",
"This",
"uses",
"{",
"@link",
"#findConverter",
"}",
"to",
"provide",
"the",
"converter",
"."
] | train | https://github.com/JodaOrg/joda-convert/blob/266bd825f4550590d5dafdf4225c548559e0633b/src/main/java/org/joda/convert/StringConvert.java#L441-L447 |
Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/animation/GVRPoseMapper.java | GVRPoseMapper.animate | public void animate(GVRHybridObject target, float time) {
"""
/*
Updates the color and depth map textures from the Kinect cameras.
If a Skeleton is our target or a child, we update the joint angles
for the user associated with it.
"""
if ((mSourceSkeleton == null) || !mSourceSkeleton.isEnabled())
{
return;
}
mapLocalToTarget();
mDestSkeleton.poseToBones();
mDestSkeleton.updateBonePose();
mDestSkeleton.updateSkinPose();
} | java | public void animate(GVRHybridObject target, float time)
{
if ((mSourceSkeleton == null) || !mSourceSkeleton.isEnabled())
{
return;
}
mapLocalToTarget();
mDestSkeleton.poseToBones();
mDestSkeleton.updateBonePose();
mDestSkeleton.updateSkinPose();
} | [
"public",
"void",
"animate",
"(",
"GVRHybridObject",
"target",
",",
"float",
"time",
")",
"{",
"if",
"(",
"(",
"mSourceSkeleton",
"==",
"null",
")",
"||",
"!",
"mSourceSkeleton",
".",
"isEnabled",
"(",
")",
")",
"{",
"return",
";",
"}",
"mapLocalToTarget",... | /*
Updates the color and depth map textures from the Kinect cameras.
If a Skeleton is our target or a child, we update the joint angles
for the user associated with it. | [
"/",
"*",
"Updates",
"the",
"color",
"and",
"depth",
"map",
"textures",
"from",
"the",
"Kinect",
"cameras",
".",
"If",
"a",
"Skeleton",
"is",
"our",
"target",
"or",
"a",
"child",
"we",
"update",
"the",
"joint",
"angles",
"for",
"the",
"user",
"associated... | train | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/animation/GVRPoseMapper.java#L219-L229 |
sebastiangraf/jSCSI | bundles/initiator/src/main/java/org/jscsi/initiator/LinkFactory.java | LinkFactory.getConnection | public final Connection getConnection (final Session session, final Configuration initConfiguration, final InetSocketAddress inetAddress, final short initConnectionID) {
"""
Method to create and return a new, empty <code>Connection</code> object with the configured layer of threading.
@param session Reference to the <code>AbsSession</code> object, which contains this connection.
@param initConfiguration The configuration to use within this connection.
@param inetAddress The <code>InetSocketAddress</code> to which this connection should established.
@param initConnectionID The ID of this connection.
@return AbsConnection The Connection Object.
"""
try {
final Connection newConnection = new Connection(session, initConfiguration, inetAddress, initConnectionID);
return newConnection;
} catch (Exception e) {
LOGGER.error("This exception is thrown: " + e);
e.printStackTrace();
return null;
}
} | java | public final Connection getConnection (final Session session, final Configuration initConfiguration, final InetSocketAddress inetAddress, final short initConnectionID) {
try {
final Connection newConnection = new Connection(session, initConfiguration, inetAddress, initConnectionID);
return newConnection;
} catch (Exception e) {
LOGGER.error("This exception is thrown: " + e);
e.printStackTrace();
return null;
}
} | [
"public",
"final",
"Connection",
"getConnection",
"(",
"final",
"Session",
"session",
",",
"final",
"Configuration",
"initConfiguration",
",",
"final",
"InetSocketAddress",
"inetAddress",
",",
"final",
"short",
"initConnectionID",
")",
"{",
"try",
"{",
"final",
"Con... | Method to create and return a new, empty <code>Connection</code> object with the configured layer of threading.
@param session Reference to the <code>AbsSession</code> object, which contains this connection.
@param initConfiguration The configuration to use within this connection.
@param inetAddress The <code>InetSocketAddress</code> to which this connection should established.
@param initConnectionID The ID of this connection.
@return AbsConnection The Connection Object. | [
"Method",
"to",
"create",
"and",
"return",
"a",
"new",
"empty",
"<code",
">",
"Connection<",
"/",
"code",
">",
"object",
"with",
"the",
"configured",
"layer",
"of",
"threading",
"."
] | train | https://github.com/sebastiangraf/jSCSI/blob/6169bfe73f0b15de7d6485453555389e782ae888/bundles/initiator/src/main/java/org/jscsi/initiator/LinkFactory.java#L97-L107 |
OpenLiberty/open-liberty | dev/com.ibm.ws.product.utility/src/com/ibm/ws/product/utility/extension/IFixUtils.java | IFixUtils.equalsHashes | private static boolean equalsHashes(File fileToHash, String hashToCompare) throws IOException {
"""
This method calculates a hash of the required file and compares it against the supplied hash. It then returns
true if both hashes are equals.
@param fileToHash - The file to calculate the hash for.
@param hashToCompare - The hash to compare.
@return - A boolean indicating whether the hashes are equal.
"""
boolean result = false;
// Now calculate the new hash and compare the 2. If they are NOT the same the ifix needs to be re-applied.
String fileHash = MD5Utils.getFileMD5String(fileToHash);
if (fileHash.equals(hashToCompare))
result = true;
return result;
} | java | private static boolean equalsHashes(File fileToHash, String hashToCompare) throws IOException {
boolean result = false;
// Now calculate the new hash and compare the 2. If they are NOT the same the ifix needs to be re-applied.
String fileHash = MD5Utils.getFileMD5String(fileToHash);
if (fileHash.equals(hashToCompare))
result = true;
return result;
} | [
"private",
"static",
"boolean",
"equalsHashes",
"(",
"File",
"fileToHash",
",",
"String",
"hashToCompare",
")",
"throws",
"IOException",
"{",
"boolean",
"result",
"=",
"false",
";",
"// Now calculate the new hash and compare the 2. If they are NOT the same the ifix needs to be ... | This method calculates a hash of the required file and compares it against the supplied hash. It then returns
true if both hashes are equals.
@param fileToHash - The file to calculate the hash for.
@param hashToCompare - The hash to compare.
@return - A boolean indicating whether the hashes are equal. | [
"This",
"method",
"calculates",
"a",
"hash",
"of",
"the",
"required",
"file",
"and",
"compares",
"it",
"against",
"the",
"supplied",
"hash",
".",
"It",
"then",
"returns",
"true",
"if",
"both",
"hashes",
"are",
"equals",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.product.utility/src/com/ibm/ws/product/utility/extension/IFixUtils.java#L305-L314 |
UrielCh/ovh-java-sdk | ovh-java-sdk-packxdsl/src/main/java/net/minidev/ovh/api/ApiOvhPackxdsl.java | ApiOvhPackxdsl.packName_voipLine_options_shippingAddresses_GET | public ArrayList<OvhShippingAddress> packName_voipLine_options_shippingAddresses_GET(String packName) throws IOException {
"""
Get available shipping addresses
REST: GET /pack/xdsl/{packName}/voipLine/options/shippingAddresses
@param packName [required] The internal name of your pack
"""
String qPath = "/pack/xdsl/{packName}/voipLine/options/shippingAddresses";
StringBuilder sb = path(qPath, packName);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t4);
} | java | public ArrayList<OvhShippingAddress> packName_voipLine_options_shippingAddresses_GET(String packName) throws IOException {
String qPath = "/pack/xdsl/{packName}/voipLine/options/shippingAddresses";
StringBuilder sb = path(qPath, packName);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t4);
} | [
"public",
"ArrayList",
"<",
"OvhShippingAddress",
">",
"packName_voipLine_options_shippingAddresses_GET",
"(",
"String",
"packName",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/pack/xdsl/{packName}/voipLine/options/shippingAddresses\"",
";",
"StringBuilder",
... | Get available shipping addresses
REST: GET /pack/xdsl/{packName}/voipLine/options/shippingAddresses
@param packName [required] The internal name of your pack | [
"Get",
"available",
"shipping",
"addresses"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-packxdsl/src/main/java/net/minidev/ovh/api/ApiOvhPackxdsl.java#L287-L292 |
litsec/eidas-opensaml | opensaml3/src/main/java/se/litsec/eidas/opensaml/ext/attributes/AttributeUtils.java | AttributeUtils.addAttributeValue | public static <T extends XMLObject> void addAttributeValue(Attribute attribute, T value) {
"""
Utility method that adds an XML object as a value to an {@code Attribute}.
<p>
Example:
</p>
<pre>{@code
Attribute attr =
AttributeUtils.createAttribute("http://eidas.europa.eu/attributes/naturalperson/CurrentFamilyName", "FamilyName");
CurrentFamilyNameType value = AttributeUtils.createAttributeValueObject(CurrentFamilyNameType.class);
value.setValue("Lindström");
AttributeUtils.addAttributeValue(attr, value);}
</pre>
@param <T>
the type
@param attribute
the attribute to update
@param value
the value to add
"""
attribute.getAttributeValues().add(value);
} | java | public static <T extends XMLObject> void addAttributeValue(Attribute attribute, T value) {
attribute.getAttributeValues().add(value);
} | [
"public",
"static",
"<",
"T",
"extends",
"XMLObject",
">",
"void",
"addAttributeValue",
"(",
"Attribute",
"attribute",
",",
"T",
"value",
")",
"{",
"attribute",
".",
"getAttributeValues",
"(",
")",
".",
"add",
"(",
"value",
")",
";",
"}"
] | Utility method that adds an XML object as a value to an {@code Attribute}.
<p>
Example:
</p>
<pre>{@code
Attribute attr =
AttributeUtils.createAttribute("http://eidas.europa.eu/attributes/naturalperson/CurrentFamilyName", "FamilyName");
CurrentFamilyNameType value = AttributeUtils.createAttributeValueObject(CurrentFamilyNameType.class);
value.setValue("Lindström");
AttributeUtils.addAttributeValue(attr, value);}
</pre>
@param <T>
the type
@param attribute
the attribute to update
@param value
the value to add | [
"Utility",
"method",
"that",
"adds",
"an",
"XML",
"object",
"as",
"a",
"value",
"to",
"an",
"{",
"@code",
"Attribute",
"}",
".",
"<p",
">",
"Example",
":",
"<",
"/",
"p",
">",
"<pre",
">",
"{",
"@code",
"Attribute",
"attr",
"=",
"AttributeUtils",
"."... | train | https://github.com/litsec/eidas-opensaml/blob/522ba6dba433a9524cb8a02464cc3b087b47a2b7/opensaml3/src/main/java/se/litsec/eidas/opensaml/ext/attributes/AttributeUtils.java#L143-L145 |
tomgibara/bits | src/main/java/com/tomgibara/bits/Bits.java | Bits.asStore | public static BitStore asStore(boolean[] bits, int offset, int length) {
"""
Exposes a sub-range of a boolean array as a {@link BitStore}. The
returned bit store is a live view over the booleans; changes made to the
array are reflected in bit store and vice versa. The size of the returned
bit vector equals the length of the range with the least-significant bit
of the {@link BitStore} taking its value from the lowest-indexed value in
the range.
@param bits
an array of bit values
@param offset
the index of the first boolean value in the {@link BitStore}
@param length
the number of boolean values covered by the {@link BitStore}
@return a {@link BitStore} over the boolean array
"""
if (bits == null) throw new IllegalArgumentException("null bits");
int size = bits.length;
if (offset < 0) throw new IllegalArgumentException("negative offset");
if (length < 0) throw new IllegalArgumentException("negative length");
int finish = offset + length;
if (finish < 0) throw new IllegalArgumentException("index overflow");
if (finish > size) throw new IllegalArgumentException("exceeds size");
return new BooleansBitStore(bits, offset, finish, true);
} | java | public static BitStore asStore(boolean[] bits, int offset, int length) {
if (bits == null) throw new IllegalArgumentException("null bits");
int size = bits.length;
if (offset < 0) throw new IllegalArgumentException("negative offset");
if (length < 0) throw new IllegalArgumentException("negative length");
int finish = offset + length;
if (finish < 0) throw new IllegalArgumentException("index overflow");
if (finish > size) throw new IllegalArgumentException("exceeds size");
return new BooleansBitStore(bits, offset, finish, true);
} | [
"public",
"static",
"BitStore",
"asStore",
"(",
"boolean",
"[",
"]",
"bits",
",",
"int",
"offset",
",",
"int",
"length",
")",
"{",
"if",
"(",
"bits",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"null bits\"",
")",
";",
"int",
"s... | Exposes a sub-range of a boolean array as a {@link BitStore}. The
returned bit store is a live view over the booleans; changes made to the
array are reflected in bit store and vice versa. The size of the returned
bit vector equals the length of the range with the least-significant bit
of the {@link BitStore} taking its value from the lowest-indexed value in
the range.
@param bits
an array of bit values
@param offset
the index of the first boolean value in the {@link BitStore}
@param length
the number of boolean values covered by the {@link BitStore}
@return a {@link BitStore} over the boolean array | [
"Exposes",
"a",
"sub",
"-",
"range",
"of",
"a",
"boolean",
"array",
"as",
"a",
"{",
"@link",
"BitStore",
"}",
".",
"The",
"returned",
"bit",
"store",
"is",
"a",
"live",
"view",
"over",
"the",
"booleans",
";",
"changes",
"made",
"to",
"the",
"array",
... | train | https://github.com/tomgibara/bits/blob/56c32c0a30efd3d7c4e7c6600a0ca39e51eecc97/src/main/java/com/tomgibara/bits/Bits.java#L580-L589 |
apereo/cas | support/cas-server-support-ldap/src/main/java/org/apereo/cas/authentication/LdapAuthenticationHandler.java | LdapAuthenticationHandler.getLdapPrincipalIdentifier | protected String getLdapPrincipalIdentifier(final String username, final LdapEntry ldapEntry) throws LoginException {
"""
Gets ldap principal identifier. If the principal id attribute is defined, it's retrieved.
If no attribute value is found, a warning is generated and the provided username is used instead.
If no attribute is defined, username is used instead.
@param username the username
@param ldapEntry the ldap entry
@return the ldap principal identifier
@throws LoginException in case the principal id cannot be determined.
"""
if (StringUtils.isNotBlank(this.principalIdAttribute)) {
val principalAttr = ldapEntry.getAttribute(this.principalIdAttribute);
if (principalAttr == null || principalAttr.size() == 0) {
if (this.allowMissingPrincipalAttributeValue) {
LOGGER.warn("The principal id attribute [{}] is not found. CAS cannot construct the final authenticated principal "
+ "if it's unable to locate the attribute that is designated as the principal id. "
+ "Attributes available on the LDAP entry are [{}]. Since principal id attribute is not available, CAS will "
+ "fall back to construct the principal based on the provided user id: [{}]",
this.principalIdAttribute, ldapEntry.getAttributes(), username);
return username;
}
LOGGER.error("The principal id attribute [{}] is not found. CAS is configured to disallow missing principal attributes",
this.principalIdAttribute);
throw new LoginException("Principal id attribute is not found for " + principalAttr);
}
val value = principalAttr.getStringValue();
if (principalAttr.size() > 1) {
if (!this.allowMultiplePrincipalAttributeValues) {
throw new LoginException("Multiple principal values are not allowed: " + principalAttr);
}
LOGGER.warn("Found multiple values for principal id attribute: [{}]. Using first value=[{}].", principalAttr, value);
}
LOGGER.debug("Retrieved principal id attribute [{}]", value);
return value;
}
LOGGER.debug("Principal id attribute is not defined. Using the default provided user id [{}]", username);
return username;
} | java | protected String getLdapPrincipalIdentifier(final String username, final LdapEntry ldapEntry) throws LoginException {
if (StringUtils.isNotBlank(this.principalIdAttribute)) {
val principalAttr = ldapEntry.getAttribute(this.principalIdAttribute);
if (principalAttr == null || principalAttr.size() == 0) {
if (this.allowMissingPrincipalAttributeValue) {
LOGGER.warn("The principal id attribute [{}] is not found. CAS cannot construct the final authenticated principal "
+ "if it's unable to locate the attribute that is designated as the principal id. "
+ "Attributes available on the LDAP entry are [{}]. Since principal id attribute is not available, CAS will "
+ "fall back to construct the principal based on the provided user id: [{}]",
this.principalIdAttribute, ldapEntry.getAttributes(), username);
return username;
}
LOGGER.error("The principal id attribute [{}] is not found. CAS is configured to disallow missing principal attributes",
this.principalIdAttribute);
throw new LoginException("Principal id attribute is not found for " + principalAttr);
}
val value = principalAttr.getStringValue();
if (principalAttr.size() > 1) {
if (!this.allowMultiplePrincipalAttributeValues) {
throw new LoginException("Multiple principal values are not allowed: " + principalAttr);
}
LOGGER.warn("Found multiple values for principal id attribute: [{}]. Using first value=[{}].", principalAttr, value);
}
LOGGER.debug("Retrieved principal id attribute [{}]", value);
return value;
}
LOGGER.debug("Principal id attribute is not defined. Using the default provided user id [{}]", username);
return username;
} | [
"protected",
"String",
"getLdapPrincipalIdentifier",
"(",
"final",
"String",
"username",
",",
"final",
"LdapEntry",
"ldapEntry",
")",
"throws",
"LoginException",
"{",
"if",
"(",
"StringUtils",
".",
"isNotBlank",
"(",
"this",
".",
"principalIdAttribute",
")",
")",
... | Gets ldap principal identifier. If the principal id attribute is defined, it's retrieved.
If no attribute value is found, a warning is generated and the provided username is used instead.
If no attribute is defined, username is used instead.
@param username the username
@param ldapEntry the ldap entry
@return the ldap principal identifier
@throws LoginException in case the principal id cannot be determined. | [
"Gets",
"ldap",
"principal",
"identifier",
".",
"If",
"the",
"principal",
"id",
"attribute",
"is",
"defined",
"it",
"s",
"retrieved",
".",
"If",
"no",
"attribute",
"value",
"is",
"found",
"a",
"warning",
"is",
"generated",
"and",
"the",
"provided",
"username... | train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/support/cas-server-support-ldap/src/main/java/org/apereo/cas/authentication/LdapAuthenticationHandler.java#L205-L233 |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/mfp/impl/JsMsgObject.java | JsMsgObject.encodeHeaderPartToSlice | private final DataSlice encodeHeaderPartToSlice(JsMsgPart jsPart) throws MessageEncodeFailedException {
"""
Encode the header, or only, a message part into a DataSlice for transmitting
over the wire, or flattening for persistence.
If the message part is already 'assembled' the contents are simply be
wrapped in a DataSlice by the JMFMessage & returned.
If the message part is not already assembled, the part is encoded into a
new byte array which is wrapped by a DataSlice.
@param jsPart The message part to be encoded.
@return DataSlice The DataSlice containing the encoded message part
@exception MessageEncodeFailedException is thrown if the message part failed to encode.
"""
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "encodeHeaderPartToSlice", jsPart);
// We hope that it is already encoded so we can just get it from JMF.....
DataSlice slice = ((JMFMessage)jsPart.jmfPart).getAssembledContent();
// ... if not, then we have to encode it now
if (slice == null) {
byte[] buff;
// We need to ensure noone updates any vital aspects of the message part
// between the calls to getEncodedLength() and toByteArray() d364050
synchronized (getPartLockArtefact(jsPart)) {
buff = encodePart(jsPart);
}
slice = new DataSlice(buff, 0, buff.length);
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "encodeHeaderPartToSlice", slice);
return slice;
} | java | private final DataSlice encodeHeaderPartToSlice(JsMsgPart jsPart) throws MessageEncodeFailedException {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "encodeHeaderPartToSlice", jsPart);
// We hope that it is already encoded so we can just get it from JMF.....
DataSlice slice = ((JMFMessage)jsPart.jmfPart).getAssembledContent();
// ... if not, then we have to encode it now
if (slice == null) {
byte[] buff;
// We need to ensure noone updates any vital aspects of the message part
// between the calls to getEncodedLength() and toByteArray() d364050
synchronized (getPartLockArtefact(jsPart)) {
buff = encodePart(jsPart);
}
slice = new DataSlice(buff, 0, buff.length);
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "encodeHeaderPartToSlice", slice);
return slice;
} | [
"private",
"final",
"DataSlice",
"encodeHeaderPartToSlice",
"(",
"JsMsgPart",
"jsPart",
")",
"throws",
"MessageEncodeFailedException",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
... | Encode the header, or only, a message part into a DataSlice for transmitting
over the wire, or flattening for persistence.
If the message part is already 'assembled' the contents are simply be
wrapped in a DataSlice by the JMFMessage & returned.
If the message part is not already assembled, the part is encoded into a
new byte array which is wrapped by a DataSlice.
@param jsPart The message part to be encoded.
@return DataSlice The DataSlice containing the encoded message part
@exception MessageEncodeFailedException is thrown if the message part failed to encode. | [
"Encode",
"the",
"header",
"or",
"only",
"a",
"message",
"part",
"into",
"a",
"DataSlice",
"for",
"transmitting",
"over",
"the",
"wire",
"or",
"flattening",
"for",
"persistence",
".",
"If",
"the",
"message",
"part",
"is",
"already",
"assembled",
"the",
"cont... | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/mfp/impl/JsMsgObject.java#L1146-L1166 |
igniterealtime/Smack | smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java | Roster.getEntriesAndAddListener | public void getEntriesAndAddListener(RosterListener rosterListener, RosterEntries rosterEntries) {
"""
Add a roster listener and invoke the roster entries with all entries of the roster.
<p>
The method guarantees that the listener is only invoked after
{@link RosterEntries#rosterEntries(Collection)} has been invoked, and that all roster events
that happen while <code>rosterEntries(Collection) </code> is called are queued until the
method returns.
</p>
<p>
This guarantee makes this the ideal method to e.g. populate a UI element with the roster while
installing a {@link RosterListener} to listen for subsequent roster events.
</p>
@param rosterListener the listener to install
@param rosterEntries the roster entries callback interface
@since 4.1
"""
Objects.requireNonNull(rosterListener, "listener must not be null");
Objects.requireNonNull(rosterEntries, "rosterEntries must not be null");
synchronized (rosterListenersAndEntriesLock) {
rosterEntries.rosterEntries(entries.values());
addRosterListener(rosterListener);
}
} | java | public void getEntriesAndAddListener(RosterListener rosterListener, RosterEntries rosterEntries) {
Objects.requireNonNull(rosterListener, "listener must not be null");
Objects.requireNonNull(rosterEntries, "rosterEntries must not be null");
synchronized (rosterListenersAndEntriesLock) {
rosterEntries.rosterEntries(entries.values());
addRosterListener(rosterListener);
}
} | [
"public",
"void",
"getEntriesAndAddListener",
"(",
"RosterListener",
"rosterListener",
",",
"RosterEntries",
"rosterEntries",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"rosterListener",
",",
"\"listener must not be null\"",
")",
";",
"Objects",
".",
"requireNonNull... | Add a roster listener and invoke the roster entries with all entries of the roster.
<p>
The method guarantees that the listener is only invoked after
{@link RosterEntries#rosterEntries(Collection)} has been invoked, and that all roster events
that happen while <code>rosterEntries(Collection) </code> is called are queued until the
method returns.
</p>
<p>
This guarantee makes this the ideal method to e.g. populate a UI element with the roster while
installing a {@link RosterListener} to listen for subsequent roster events.
</p>
@param rosterListener the listener to install
@param rosterEntries the roster entries callback interface
@since 4.1 | [
"Add",
"a",
"roster",
"listener",
"and",
"invoke",
"the",
"roster",
"entries",
"with",
"all",
"entries",
"of",
"the",
"roster",
".",
"<p",
">",
"The",
"method",
"guarantees",
"that",
"the",
"listener",
"is",
"only",
"invoked",
"after",
"{",
"@link",
"Roste... | train | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java#L867-L875 |
code4everything/util | src/main/java/com/zhazhapan/util/encryption/SimpleEncrypt.java | SimpleEncrypt.mix | public static String mix(String string, int key) {
"""
混合加密
@param string {@link String}
@param key {@link Integer}
@return {@link String}
"""
return ascii(JavaEncrypt.base64(xor(string, key)), key);
} | java | public static String mix(String string, int key) {
return ascii(JavaEncrypt.base64(xor(string, key)), key);
} | [
"public",
"static",
"String",
"mix",
"(",
"String",
"string",
",",
"int",
"key",
")",
"{",
"return",
"ascii",
"(",
"JavaEncrypt",
".",
"base64",
"(",
"xor",
"(",
"string",
",",
"key",
")",
")",
",",
"key",
")",
";",
"}"
] | 混合加密
@param string {@link String}
@param key {@link Integer}
@return {@link String} | [
"混合加密"
] | train | https://github.com/code4everything/util/blob/1fc9f0ead1108f4d7208ba7c000df4244f708418/src/main/java/com/zhazhapan/util/encryption/SimpleEncrypt.java#L20-L22 |
albfernandez/itext2 | src/main/java/com/lowagie/text/Rectangle.java | Rectangle.updateBorderBasedOnWidth | private void updateBorderBasedOnWidth(float width, int side) {
"""
Helper function updating the border flag for a side
based on the specified width.
A width of 0 will disable the border on that side.
Any other width enables it.
@param width width of border
@param side border side constant
"""
useVariableBorders = true;
if (width > 0)
enableBorderSide(side);
else
disableBorderSide(side);
} | java | private void updateBorderBasedOnWidth(float width, int side) {
useVariableBorders = true;
if (width > 0)
enableBorderSide(side);
else
disableBorderSide(side);
} | [
"private",
"void",
"updateBorderBasedOnWidth",
"(",
"float",
"width",
",",
"int",
"side",
")",
"{",
"useVariableBorders",
"=",
"true",
";",
"if",
"(",
"width",
">",
"0",
")",
"enableBorderSide",
"(",
"side",
")",
";",
"else",
"disableBorderSide",
"(",
"side"... | Helper function updating the border flag for a side
based on the specified width.
A width of 0 will disable the border on that side.
Any other width enables it.
@param width width of border
@param side border side constant | [
"Helper",
"function",
"updating",
"the",
"border",
"flag",
"for",
"a",
"side",
"based",
"on",
"the",
"specified",
"width",
".",
"A",
"width",
"of",
"0",
"will",
"disable",
"the",
"border",
"on",
"that",
"side",
".",
"Any",
"other",
"width",
"enables",
"i... | train | https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/Rectangle.java#L595-L601 |
OpenLiberty/open-liberty | dev/com.ibm.ws.logging.hpel/src/com/ibm/ws/logging/hpel/impl/LogRepositoryManagerImpl.java | LogRepositoryManagerImpl.calculateLogFile | private File calculateLogFile(long timestamp) {
"""
/*
Calculates location of the new file with provided timestamp.
It should be called with the instance lock taken.
"""
if (ivSubDirectory == null)
getControllingProcessDirectory(timestamp, svPid) ;
return getLogFile(ivSubDirectory, timestamp);
} | java | private File calculateLogFile(long timestamp) {
if (ivSubDirectory == null)
getControllingProcessDirectory(timestamp, svPid) ;
return getLogFile(ivSubDirectory, timestamp);
} | [
"private",
"File",
"calculateLogFile",
"(",
"long",
"timestamp",
")",
"{",
"if",
"(",
"ivSubDirectory",
"==",
"null",
")",
"getControllingProcessDirectory",
"(",
"timestamp",
",",
"svPid",
")",
";",
"return",
"getLogFile",
"(",
"ivSubDirectory",
",",
"timestamp",
... | /*
Calculates location of the new file with provided timestamp.
It should be called with the instance lock taken. | [
"/",
"*",
"Calculates",
"location",
"of",
"the",
"new",
"file",
"with",
"provided",
"timestamp",
".",
"It",
"should",
"be",
"called",
"with",
"the",
"instance",
"lock",
"taken",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.logging.hpel/src/com/ibm/ws/logging/hpel/impl/LogRepositoryManagerImpl.java#L520-L525 |
RobotiumTech/robotium | robotium-solo/src/main/java/com/robotium/solo/WebElementCreator.java | WebElementCreator.createWebElementAndSetLocation | private WebElement createWebElementAndSetLocation(String information, WebView webView) {
"""
Creates a {@code WebView} object
@param information the data of the web element
@param webView the web view the text is shown in
@return a {@code WebElement} object with a given text and location
"""
String[] data = information.split(";,");
String[] elements = null;
int x = 0;
int y = 0;
int width = 0;
int height = 0;
Hashtable<String, String> attributes = new Hashtable<String, String>();
try{
x = Math.round(Float.valueOf(data[5]));
y = Math.round(Float.valueOf(data[6]));
width = Math.round(Float.valueOf(data[7]));
height = Math.round(Float.valueOf(data[8]));
elements = data[9].split("\\#\\$");
}catch(Exception ignored){}
if(elements != null) {
for (int index = 0; index < elements.length; index++){
String[] element = elements[index].split("::");
if (element.length > 1) {
attributes.put(element[0], element[1]);
} else {
attributes.put(element[0], element[0]);
}
}
}
WebElement webElement = null;
try{
webElement = new WebElement(data[0], data[1], data[2], data[3], data[4], attributes);
setLocation(webElement, webView, x, y, width, height);
}catch(Exception ignored) {}
return webElement;
} | java | private WebElement createWebElementAndSetLocation(String information, WebView webView){
String[] data = information.split(";,");
String[] elements = null;
int x = 0;
int y = 0;
int width = 0;
int height = 0;
Hashtable<String, String> attributes = new Hashtable<String, String>();
try{
x = Math.round(Float.valueOf(data[5]));
y = Math.round(Float.valueOf(data[6]));
width = Math.round(Float.valueOf(data[7]));
height = Math.round(Float.valueOf(data[8]));
elements = data[9].split("\\#\\$");
}catch(Exception ignored){}
if(elements != null) {
for (int index = 0; index < elements.length; index++){
String[] element = elements[index].split("::");
if (element.length > 1) {
attributes.put(element[0], element[1]);
} else {
attributes.put(element[0], element[0]);
}
}
}
WebElement webElement = null;
try{
webElement = new WebElement(data[0], data[1], data[2], data[3], data[4], attributes);
setLocation(webElement, webView, x, y, width, height);
}catch(Exception ignored) {}
return webElement;
} | [
"private",
"WebElement",
"createWebElementAndSetLocation",
"(",
"String",
"information",
",",
"WebView",
"webView",
")",
"{",
"String",
"[",
"]",
"data",
"=",
"information",
".",
"split",
"(",
"\";,\"",
")",
";",
"String",
"[",
"]",
"elements",
"=",
"null",
... | Creates a {@code WebView} object
@param information the data of the web element
@param webView the web view the text is shown in
@return a {@code WebElement} object with a given text and location | [
"Creates",
"a",
"{",
"@code",
"WebView",
"}",
"object"
] | train | https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/WebElementCreator.java#L124-L159 |
openengsb/openengsb | components/edb/src/main/java/org/openengsb/core/edb/jpa/internal/Diff.java | Diff.addModifiedOrDeletedObjects | private void addModifiedOrDeletedObjects(List<EDBObject> tempList) {
"""
add all modified or deleted objects to the diff collection. As base to indicate if something changed the start
state and the list of elements from the end state is taken.
"""
for (EDBObject a : this.startState) {
String oid = a.getOID();
EDBObject b = removeIfExist(oid, tempList);
ObjectDiff odiff = new ObjectDiff(this.startCommit, this.endCommit, a, b);
if (odiff.getDifferenceCount() > 0) {
diff.put(oid, odiff);
}
}
} | java | private void addModifiedOrDeletedObjects(List<EDBObject> tempList) {
for (EDBObject a : this.startState) {
String oid = a.getOID();
EDBObject b = removeIfExist(oid, tempList);
ObjectDiff odiff = new ObjectDiff(this.startCommit, this.endCommit, a, b);
if (odiff.getDifferenceCount() > 0) {
diff.put(oid, odiff);
}
}
} | [
"private",
"void",
"addModifiedOrDeletedObjects",
"(",
"List",
"<",
"EDBObject",
">",
"tempList",
")",
"{",
"for",
"(",
"EDBObject",
"a",
":",
"this",
".",
"startState",
")",
"{",
"String",
"oid",
"=",
"a",
".",
"getOID",
"(",
")",
";",
"EDBObject",
"b",... | add all modified or deleted objects to the diff collection. As base to indicate if something changed the start
state and the list of elements from the end state is taken. | [
"add",
"all",
"modified",
"or",
"deleted",
"objects",
"to",
"the",
"diff",
"collection",
".",
"As",
"base",
"to",
"indicate",
"if",
"something",
"changed",
"the",
"start",
"state",
"and",
"the",
"list",
"of",
"elements",
"from",
"the",
"end",
"state",
"is"... | train | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/edb/src/main/java/org/openengsb/core/edb/jpa/internal/Diff.java#L78-L87 |
apache/groovy | src/main/java/org/codehaus/groovy/runtime/IOGroovyMethods.java | IOGroovyMethods.withFormatter | public static Appendable withFormatter(Appendable self, @ClosureParams(value=SimpleType.class, options="java.util.Formatter") Closure closure) {
"""
Invokes a Closure that uses a Formatter taking care of resource handling.
A Formatter is created and passed to the Closure as its argument.
After the Closure executes, the Formatter is flushed and closed releasing any
associated resources.
@param self an Appendable
@param closure a 1-arg Closure which will be called with a Formatter as its argument
@return the Appendable on which this operation was invoked
@since 2.1.0
"""
Formatter formatter = new Formatter(self);
callWithFormatter(closure, formatter);
return self;
} | java | public static Appendable withFormatter(Appendable self, @ClosureParams(value=SimpleType.class, options="java.util.Formatter") Closure closure) {
Formatter formatter = new Formatter(self);
callWithFormatter(closure, formatter);
return self;
} | [
"public",
"static",
"Appendable",
"withFormatter",
"(",
"Appendable",
"self",
",",
"@",
"ClosureParams",
"(",
"value",
"=",
"SimpleType",
".",
"class",
",",
"options",
"=",
"\"java.util.Formatter\"",
")",
"Closure",
"closure",
")",
"{",
"Formatter",
"formatter",
... | Invokes a Closure that uses a Formatter taking care of resource handling.
A Formatter is created and passed to the Closure as its argument.
After the Closure executes, the Formatter is flushed and closed releasing any
associated resources.
@param self an Appendable
@param closure a 1-arg Closure which will be called with a Formatter as its argument
@return the Appendable on which this operation was invoked
@since 2.1.0 | [
"Invokes",
"a",
"Closure",
"that",
"uses",
"a",
"Formatter",
"taking",
"care",
"of",
"resource",
"handling",
".",
"A",
"Formatter",
"is",
"created",
"and",
"passed",
"to",
"the",
"Closure",
"as",
"its",
"argument",
".",
"After",
"the",
"Closure",
"executes",... | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/IOGroovyMethods.java#L123-L127 |
box/box-android-sdk | box-content-sdk/src/main/java/com/box/androidsdk/content/BoxApiShare.java | BoxApiShare.getSharedLinkRequest | public BoxRequestsShare.GetSharedLink getSharedLinkRequest(String sharedLink, String password) {
"""
Returns a request to get a BoxItem from a shared link.
@param sharedLink shared link of the item to retrieve.
@param password password for shared link
@return request to get a BoxItem from a shared link.
"""
BoxSharedLinkSession session = null;
if (mSession instanceof BoxSharedLinkSession) {
session = (BoxSharedLinkSession)mSession;
} else {
session = new BoxSharedLinkSession(mSession);
}
session.setSharedLink(sharedLink);
session.setPassword(password);
BoxRequestsShare.GetSharedLink request = new BoxRequestsShare.GetSharedLink(getSharedItemsUrl(), session);
return request;
} | java | public BoxRequestsShare.GetSharedLink getSharedLinkRequest(String sharedLink, String password) {
BoxSharedLinkSession session = null;
if (mSession instanceof BoxSharedLinkSession) {
session = (BoxSharedLinkSession)mSession;
} else {
session = new BoxSharedLinkSession(mSession);
}
session.setSharedLink(sharedLink);
session.setPassword(password);
BoxRequestsShare.GetSharedLink request = new BoxRequestsShare.GetSharedLink(getSharedItemsUrl(), session);
return request;
} | [
"public",
"BoxRequestsShare",
".",
"GetSharedLink",
"getSharedLinkRequest",
"(",
"String",
"sharedLink",
",",
"String",
"password",
")",
"{",
"BoxSharedLinkSession",
"session",
"=",
"null",
";",
"if",
"(",
"mSession",
"instanceof",
"BoxSharedLinkSession",
")",
"{",
... | Returns a request to get a BoxItem from a shared link.
@param sharedLink shared link of the item to retrieve.
@param password password for shared link
@return request to get a BoxItem from a shared link. | [
"Returns",
"a",
"request",
"to",
"get",
"a",
"BoxItem",
"from",
"a",
"shared",
"link",
"."
] | train | https://github.com/box/box-android-sdk/blob/a621ad5ddebf23067fec27529130d72718fc0e88/box-content-sdk/src/main/java/com/box/androidsdk/content/BoxApiShare.java#L43-L55 |
geomajas/geomajas-project-client-gwt | plugin/editing/editing-javascript-api-gwt/src/main/java/org/geomajas/plugin/editing/jsapi/gwt/client/gfx/JsSnapService.java | JsSnapService.addNearestEdgeSnappingRule | public void addNearestEdgeSnappingRule(String snapLayer, double distance) {
"""
Add a new snapping rules to the list. Each new rule provides information on how snapping should occur.
The added rule will use algorithm {@link NearestVertexSnapAlgorithm}.
@param snapLayer
The layer id that will provide the target geometries where to snap.
@param distance
The maximum distance to bridge during snapping. unit=meters.
"""
SnapSourceProvider snapSourceProvider = new VectorLayerSourceProvider(editor.getMapWidget().getMapModel()
.getVectorLayer(snapLayer));
delegate.addSnappingRule(new SnappingRule(new NearestEdgeSnapAlgorithm(), snapSourceProvider, distance));
} | java | public void addNearestEdgeSnappingRule(String snapLayer, double distance) {
SnapSourceProvider snapSourceProvider = new VectorLayerSourceProvider(editor.getMapWidget().getMapModel()
.getVectorLayer(snapLayer));
delegate.addSnappingRule(new SnappingRule(new NearestEdgeSnapAlgorithm(), snapSourceProvider, distance));
} | [
"public",
"void",
"addNearestEdgeSnappingRule",
"(",
"String",
"snapLayer",
",",
"double",
"distance",
")",
"{",
"SnapSourceProvider",
"snapSourceProvider",
"=",
"new",
"VectorLayerSourceProvider",
"(",
"editor",
".",
"getMapWidget",
"(",
")",
".",
"getMapModel",
"(",... | Add a new snapping rules to the list. Each new rule provides information on how snapping should occur.
The added rule will use algorithm {@link NearestVertexSnapAlgorithm}.
@param snapLayer
The layer id that will provide the target geometries where to snap.
@param distance
The maximum distance to bridge during snapping. unit=meters. | [
"Add",
"a",
"new",
"snapping",
"rules",
"to",
"the",
"list",
".",
"Each",
"new",
"rule",
"provides",
"information",
"on",
"how",
"snapping",
"should",
"occur",
".",
"The",
"added",
"rule",
"will",
"use",
"algorithm",
"{",
"@link",
"NearestVertexSnapAlgorithm",... | train | https://github.com/geomajas/geomajas-project-client-gwt/blob/1c1adc48deb192ed825265eebcc74d70bbf45670/plugin/editing/editing-javascript-api-gwt/src/main/java/org/geomajas/plugin/editing/jsapi/gwt/client/gfx/JsSnapService.java#L81-L85 |
netscaler/nitro | src/main/java/com/citrix/netscaler/nitro/resource/config/appfw/appfwhtmlerrorpage.java | appfwhtmlerrorpage.get | public static appfwhtmlerrorpage get(nitro_service service, String name) throws Exception {
"""
Use this API to fetch appfwhtmlerrorpage resource of given name .
"""
appfwhtmlerrorpage obj = new appfwhtmlerrorpage();
obj.set_name(name);
appfwhtmlerrorpage response = (appfwhtmlerrorpage) obj.get_resource(service);
return response;
} | java | public static appfwhtmlerrorpage get(nitro_service service, String name) throws Exception{
appfwhtmlerrorpage obj = new appfwhtmlerrorpage();
obj.set_name(name);
appfwhtmlerrorpage response = (appfwhtmlerrorpage) obj.get_resource(service);
return response;
} | [
"public",
"static",
"appfwhtmlerrorpage",
"get",
"(",
"nitro_service",
"service",
",",
"String",
"name",
")",
"throws",
"Exception",
"{",
"appfwhtmlerrorpage",
"obj",
"=",
"new",
"appfwhtmlerrorpage",
"(",
")",
";",
"obj",
".",
"set_name",
"(",
"name",
")",
";... | Use this API to fetch appfwhtmlerrorpage resource of given name . | [
"Use",
"this",
"API",
"to",
"fetch",
"appfwhtmlerrorpage",
"resource",
"of",
"given",
"name",
"."
] | train | https://github.com/netscaler/nitro/blob/2a98692dcf4e4ec430c7d7baab8382e4ba5a35e4/src/main/java/com/citrix/netscaler/nitro/resource/config/appfw/appfwhtmlerrorpage.java#L134-L139 |
hankcs/HanLP | src/main/java/com/hankcs/hanlp/HanLP.java | HanLP.convertToPinyinFirstCharString | public static String convertToPinyinFirstCharString(String text, String separator, boolean remainNone) {
"""
转化为拼音(首字母)
@param text 文本
@param separator 分隔符
@param remainNone 有些字没有拼音(如标点),是否保留它们(用none表示)
@return 一个字符串,由[首字母][分隔符][首字母]构成
"""
List<Pinyin> pinyinList = PinyinDictionary.convertToPinyin(text, remainNone);
int length = pinyinList.size();
StringBuilder sb = new StringBuilder(length * (1 + separator.length()));
int i = 1;
for (Pinyin pinyin : pinyinList)
{
sb.append(pinyin.getFirstChar());
if (i < length)
{
sb.append(separator);
}
++i;
}
return sb.toString();
} | java | public static String convertToPinyinFirstCharString(String text, String separator, boolean remainNone)
{
List<Pinyin> pinyinList = PinyinDictionary.convertToPinyin(text, remainNone);
int length = pinyinList.size();
StringBuilder sb = new StringBuilder(length * (1 + separator.length()));
int i = 1;
for (Pinyin pinyin : pinyinList)
{
sb.append(pinyin.getFirstChar());
if (i < length)
{
sb.append(separator);
}
++i;
}
return sb.toString();
} | [
"public",
"static",
"String",
"convertToPinyinFirstCharString",
"(",
"String",
"text",
",",
"String",
"separator",
",",
"boolean",
"remainNone",
")",
"{",
"List",
"<",
"Pinyin",
">",
"pinyinList",
"=",
"PinyinDictionary",
".",
"convertToPinyin",
"(",
"text",
",",
... | 转化为拼音(首字母)
@param text 文本
@param separator 分隔符
@param remainNone 有些字没有拼音(如标点),是否保留它们(用none表示)
@return 一个字符串,由[首字母][分隔符][首字母]构成 | [
"转化为拼音(首字母)"
] | train | https://github.com/hankcs/HanLP/blob/a538d0722ab2e4980a9dcd9ea40324fc3ddba7ce/src/main/java/com/hankcs/hanlp/HanLP.java#L608-L624 |
deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/execution/input/Operands.java | Operands.addArgument | public Operands addArgument(@NonNull String id, @NonNull INDArray array) {
"""
This method allows to pass array to the node identified by its name
@param id
@param array
@return
"""
map.put(NodeDescriptor.builder().name(id).build(), array);
return this;
} | java | public Operands addArgument(@NonNull String id, @NonNull INDArray array) {
map.put(NodeDescriptor.builder().name(id).build(), array);
return this;
} | [
"public",
"Operands",
"addArgument",
"(",
"@",
"NonNull",
"String",
"id",
",",
"@",
"NonNull",
"INDArray",
"array",
")",
"{",
"map",
".",
"put",
"(",
"NodeDescriptor",
".",
"builder",
"(",
")",
".",
"name",
"(",
"id",
")",
".",
"build",
"(",
")",
","... | This method allows to pass array to the node identified by its name
@param id
@param array
@return | [
"This",
"method",
"allows",
"to",
"pass",
"array",
"to",
"the",
"node",
"identified",
"by",
"its",
"name"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/execution/input/Operands.java#L39-L42 |
jboss/jboss-jsf-api_spec | src/main/java/javax/faces/TypedCollections.java | TypedCollections.dynamicallyCastSet | @SuppressWarnings("unchecked")
static <E> Set<E> dynamicallyCastSet(Set<?> set,
Class<E> type) {
"""
Dynamically check that the members of the set are all instances of
the given type (or null).
@param <E>
the set's element type
@param set
the set to cast
@param type
the class of the set's element type.
@return the dynamically-type checked set.
@throws java.lang.ClassCastException
"""
return dynamicallyCastCollection(set, type, Set.class);
} | java | @SuppressWarnings("unchecked")
static <E> Set<E> dynamicallyCastSet(Set<?> set,
Class<E> type) {
return dynamicallyCastCollection(set, type, Set.class);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"static",
"<",
"E",
">",
"Set",
"<",
"E",
">",
"dynamicallyCastSet",
"(",
"Set",
"<",
"?",
">",
"set",
",",
"Class",
"<",
"E",
">",
"type",
")",
"{",
"return",
"dynamicallyCastCollection",
"(",
"set",
... | Dynamically check that the members of the set are all instances of
the given type (or null).
@param <E>
the set's element type
@param set
the set to cast
@param type
the class of the set's element type.
@return the dynamically-type checked set.
@throws java.lang.ClassCastException | [
"Dynamically",
"check",
"that",
"the",
"members",
"of",
"the",
"set",
"are",
"all",
"instances",
"of",
"the",
"given",
"type",
"(",
"or",
"null",
")",
"."
] | train | https://github.com/jboss/jboss-jsf-api_spec/blob/cb33d215acbab847f2db5cdf2c6fe4d99c0a01c3/src/main/java/javax/faces/TypedCollections.java#L122-L126 |
mikepenz/Materialize | library/src/main/java/com/mikepenz/materialize/util/UIUtils.java | UIUtils.setFlag | public static void setFlag(Activity activity, final int bits, boolean on) {
"""
helper method to activate or deactivate a specific flag
@param bits
@param on
"""
Window win = activity.getWindow();
WindowManager.LayoutParams winParams = win.getAttributes();
if (on) {
winParams.flags |= bits;
} else {
winParams.flags &= ~bits;
}
win.setAttributes(winParams);
} | java | public static void setFlag(Activity activity, final int bits, boolean on) {
Window win = activity.getWindow();
WindowManager.LayoutParams winParams = win.getAttributes();
if (on) {
winParams.flags |= bits;
} else {
winParams.flags &= ~bits;
}
win.setAttributes(winParams);
} | [
"public",
"static",
"void",
"setFlag",
"(",
"Activity",
"activity",
",",
"final",
"int",
"bits",
",",
"boolean",
"on",
")",
"{",
"Window",
"win",
"=",
"activity",
".",
"getWindow",
"(",
")",
";",
"WindowManager",
".",
"LayoutParams",
"winParams",
"=",
"win... | helper method to activate or deactivate a specific flag
@param bits
@param on | [
"helper",
"method",
"to",
"activate",
"or",
"deactivate",
"a",
"specific",
"flag"
] | train | https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/util/UIUtils.java#L223-L232 |
puniverse/galaxy | src/main/java/co/paralleluniverse/galaxy/Grid.java | Grid.getInstance | public static Grid getInstance(String configFile, String propertiesFile) throws InterruptedException {
"""
Retrieves the grid instance, as defined in the given configuration file.
@param configFile The name of the configuration file containing the grid definition.
@param propertiesFile The name of the properties file containing the grid's properties. You may, of course use Spring's {@code <context:property-placeholder location="classpath:com/foo/bar.properties"/>}
but this parameter is helpful when you want to use the same xml configuration with different properties for different
instances.
@return The grid instance.
"""
return getInstance(configFile == null ? null : new FileSystemResource(configFile), propertiesFile);
} | java | public static Grid getInstance(String configFile, String propertiesFile) throws InterruptedException {
return getInstance(configFile == null ? null : new FileSystemResource(configFile), propertiesFile);
} | [
"public",
"static",
"Grid",
"getInstance",
"(",
"String",
"configFile",
",",
"String",
"propertiesFile",
")",
"throws",
"InterruptedException",
"{",
"return",
"getInstance",
"(",
"configFile",
"==",
"null",
"?",
"null",
":",
"new",
"FileSystemResource",
"(",
"conf... | Retrieves the grid instance, as defined in the given configuration file.
@param configFile The name of the configuration file containing the grid definition.
@param propertiesFile The name of the properties file containing the grid's properties. You may, of course use Spring's {@code <context:property-placeholder location="classpath:com/foo/bar.properties"/>}
but this parameter is helpful when you want to use the same xml configuration with different properties for different
instances.
@return The grid instance. | [
"Retrieves",
"the",
"grid",
"instance",
"as",
"defined",
"in",
"the",
"given",
"configuration",
"file",
"."
] | train | https://github.com/puniverse/galaxy/blob/1d077532c4a5bcd6c52ff670770c31e98420ff63/src/main/java/co/paralleluniverse/galaxy/Grid.java#L59-L61 |
lucee/Lucee | core/src/main/java/lucee/runtime/interpreter/CFMLExpressionInterpreter.java | CFMLExpressionInterpreter.eqvOp | private Ref eqvOp() throws PageException {
"""
Transfomiert eine Equivalence (eqv) Operation. <br />
EBNF:<br />
<code>xorOp {"eqv" spaces xorOp};</code>
@return CFXD Element
@throws PageException
"""
Ref ref = xorOp();
while (cfml.forwardIfCurrent("eqv")) {
cfml.removeSpace();
ref = new EQV(ref, xorOp(), limited);
}
return ref;
} | java | private Ref eqvOp() throws PageException {
Ref ref = xorOp();
while (cfml.forwardIfCurrent("eqv")) {
cfml.removeSpace();
ref = new EQV(ref, xorOp(), limited);
}
return ref;
} | [
"private",
"Ref",
"eqvOp",
"(",
")",
"throws",
"PageException",
"{",
"Ref",
"ref",
"=",
"xorOp",
"(",
")",
";",
"while",
"(",
"cfml",
".",
"forwardIfCurrent",
"(",
"\"eqv\"",
")",
")",
"{",
"cfml",
".",
"removeSpace",
"(",
")",
";",
"ref",
"=",
"new"... | Transfomiert eine Equivalence (eqv) Operation. <br />
EBNF:<br />
<code>xorOp {"eqv" spaces xorOp};</code>
@return CFXD Element
@throws PageException | [
"Transfomiert",
"eine",
"Equivalence",
"(",
"eqv",
")",
"Operation",
".",
"<br",
"/",
">",
"EBNF",
":",
"<br",
"/",
">",
"<code",
">",
"xorOp",
"{",
"eqv",
"spaces",
"xorOp",
"}",
";",
"<",
"/",
"code",
">"
] | train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/runtime/interpreter/CFMLExpressionInterpreter.java#L363-L370 |
sgroschupf/zkclient | src/main/java/org/I0Itec/zkclient/ZkClient.java | ZkClient.createEphemeral | public void createEphemeral(final String path, final List<ACL> acl) throws ZkInterruptedException, IllegalArgumentException, ZkException, RuntimeException {
"""
Create an ephemeral node and set its ACL.
@param path
@param acl
@throws ZkInterruptedException
if operation was interrupted, or a required reconnection got interrupted
@throws IllegalArgumentException
if called from anything except the ZooKeeper event thread
@throws ZkException
if any ZooKeeper exception occurred
@throws RuntimeException
if any other exception occurs
"""
create(path, null, acl, CreateMode.EPHEMERAL);
} | java | public void createEphemeral(final String path, final List<ACL> acl) throws ZkInterruptedException, IllegalArgumentException, ZkException, RuntimeException {
create(path, null, acl, CreateMode.EPHEMERAL);
} | [
"public",
"void",
"createEphemeral",
"(",
"final",
"String",
"path",
",",
"final",
"List",
"<",
"ACL",
">",
"acl",
")",
"throws",
"ZkInterruptedException",
",",
"IllegalArgumentException",
",",
"ZkException",
",",
"RuntimeException",
"{",
"create",
"(",
"path",
... | Create an ephemeral node and set its ACL.
@param path
@param acl
@throws ZkInterruptedException
if operation was interrupted, or a required reconnection got interrupted
@throws IllegalArgumentException
if called from anything except the ZooKeeper event thread
@throws ZkException
if any ZooKeeper exception occurred
@throws RuntimeException
if any other exception occurs | [
"Create",
"an",
"ephemeral",
"node",
"and",
"set",
"its",
"ACL",
"."
] | train | https://github.com/sgroschupf/zkclient/blob/03ccf12c70aca2f771bfcd94d44dc7c4d4a1495e/src/main/java/org/I0Itec/zkclient/ZkClient.java#L478-L480 |
windup/windup | reporting/api/src/main/java/org/jboss/windup/reporting/service/ReportService.java | ReportService.getUniqueFilename | public String getUniqueFilename(String baseFileName, String extension, boolean cleanBaseFileName, String... ancestorFolders) {
"""
Returns a unique file name
@param baseFileName the requested base name for the file
@param extension the requested extension for the file
@param cleanBaseFileName specify if the <code>baseFileName</code> has to be cleaned before being used (i.e. 'jboss-web' should not be cleaned to avoid '-' to become '_')
@param ancestorFolders specify the ancestor folders for the file (if there's no ancestor folder, just pass 'null' value)
@return a String representing the unique file generated
"""
if (cleanBaseFileName)
{
baseFileName = PathUtil.cleanFileName(baseFileName);
}
if (ancestorFolders != null)
{
Path pathToFile = Paths.get("", Stream.of(ancestorFolders).map(ancestor -> PathUtil.cleanFileName(ancestor)).toArray(String[]::new)).resolve(baseFileName);
baseFileName = pathToFile.toString();
}
String filename = baseFileName + "." + extension;
// FIXME this looks nasty
while (usedFilenames.contains(filename))
{
filename = baseFileName + "." + index.getAndIncrement() + "." + extension;
}
usedFilenames.add(filename);
return filename;
} | java | public String getUniqueFilename(String baseFileName, String extension, boolean cleanBaseFileName, String... ancestorFolders)
{
if (cleanBaseFileName)
{
baseFileName = PathUtil.cleanFileName(baseFileName);
}
if (ancestorFolders != null)
{
Path pathToFile = Paths.get("", Stream.of(ancestorFolders).map(ancestor -> PathUtil.cleanFileName(ancestor)).toArray(String[]::new)).resolve(baseFileName);
baseFileName = pathToFile.toString();
}
String filename = baseFileName + "." + extension;
// FIXME this looks nasty
while (usedFilenames.contains(filename))
{
filename = baseFileName + "." + index.getAndIncrement() + "." + extension;
}
usedFilenames.add(filename);
return filename;
} | [
"public",
"String",
"getUniqueFilename",
"(",
"String",
"baseFileName",
",",
"String",
"extension",
",",
"boolean",
"cleanBaseFileName",
",",
"String",
"...",
"ancestorFolders",
")",
"{",
"if",
"(",
"cleanBaseFileName",
")",
"{",
"baseFileName",
"=",
"PathUtil",
"... | Returns a unique file name
@param baseFileName the requested base name for the file
@param extension the requested extension for the file
@param cleanBaseFileName specify if the <code>baseFileName</code> has to be cleaned before being used (i.e. 'jboss-web' should not be cleaned to avoid '-' to become '_')
@param ancestorFolders specify the ancestor folders for the file (if there's no ancestor folder, just pass 'null' value)
@return a String representing the unique file generated | [
"Returns",
"a",
"unique",
"file",
"name"
] | train | https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/reporting/api/src/main/java/org/jboss/windup/reporting/service/ReportService.java#L109-L131 |
Azure/azure-sdk-for-java | sql/resource-manager/v2017_03_01_preview/src/main/java/com/microsoft/azure/management/sql/v2017_03_01_preview/implementation/JobExecutionsInner.java | JobExecutionsInner.beginCreateAsync | public Observable<JobExecutionInner> beginCreateAsync(String resourceGroupName, String serverName, String jobAgentName, String jobName) {
"""
Starts an elastic job execution.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param jobAgentName The name of the job agent.
@param jobName The name of the job to get.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the JobExecutionInner object
"""
return beginCreateWithServiceResponseAsync(resourceGroupName, serverName, jobAgentName, jobName).map(new Func1<ServiceResponse<JobExecutionInner>, JobExecutionInner>() {
@Override
public JobExecutionInner call(ServiceResponse<JobExecutionInner> response) {
return response.body();
}
});
} | java | public Observable<JobExecutionInner> beginCreateAsync(String resourceGroupName, String serverName, String jobAgentName, String jobName) {
return beginCreateWithServiceResponseAsync(resourceGroupName, serverName, jobAgentName, jobName).map(new Func1<ServiceResponse<JobExecutionInner>, JobExecutionInner>() {
@Override
public JobExecutionInner call(ServiceResponse<JobExecutionInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"JobExecutionInner",
">",
"beginCreateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"String",
"jobAgentName",
",",
"String",
"jobName",
")",
"{",
"return",
"beginCreateWithServiceResponseAsync",
"(",
"resource... | Starts an elastic job execution.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param jobAgentName The name of the job agent.
@param jobName The name of the job to get.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the JobExecutionInner object | [
"Starts",
"an",
"elastic",
"job",
"execution",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2017_03_01_preview/src/main/java/com/microsoft/azure/management/sql/v2017_03_01_preview/implementation/JobExecutionsInner.java#L633-L640 |
apereo/cas | support/cas-server-support-saml-idp-metadata/src/main/java/org/apereo/cas/support/saml/services/idp/metadata/cache/resolver/UrlResourceMetadataResolver.java | UrlResourceMetadataResolver.getMetadataResolverFromResponse | protected AbstractMetadataResolver getMetadataResolverFromResponse(final HttpResponse response, final File backupFile) throws Exception {
"""
Gets metadata resolver from response.
@param response the response
@param backupFile the backup file
@return the metadata resolver from response
@throws Exception the exception
"""
val entity = response.getEntity();
val result = IOUtils.toString(entity.getContent(), StandardCharsets.UTF_8);
val path = backupFile.toPath();
LOGGER.trace("Writing metadata to file at [{}]", path);
try (val output = Files.newBufferedWriter(path, StandardCharsets.UTF_8)) {
IOUtils.write(result, output);
output.flush();
}
EntityUtils.consume(entity);
return new InMemoryResourceMetadataResolver(backupFile, configBean);
} | java | protected AbstractMetadataResolver getMetadataResolverFromResponse(final HttpResponse response, final File backupFile) throws Exception {
val entity = response.getEntity();
val result = IOUtils.toString(entity.getContent(), StandardCharsets.UTF_8);
val path = backupFile.toPath();
LOGGER.trace("Writing metadata to file at [{}]", path);
try (val output = Files.newBufferedWriter(path, StandardCharsets.UTF_8)) {
IOUtils.write(result, output);
output.flush();
}
EntityUtils.consume(entity);
return new InMemoryResourceMetadataResolver(backupFile, configBean);
} | [
"protected",
"AbstractMetadataResolver",
"getMetadataResolverFromResponse",
"(",
"final",
"HttpResponse",
"response",
",",
"final",
"File",
"backupFile",
")",
"throws",
"Exception",
"{",
"val",
"entity",
"=",
"response",
".",
"getEntity",
"(",
")",
";",
"val",
"resu... | Gets metadata resolver from response.
@param response the response
@param backupFile the backup file
@return the metadata resolver from response
@throws Exception the exception | [
"Gets",
"metadata",
"resolver",
"from",
"response",
"."
] | train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/support/cas-server-support-saml-idp-metadata/src/main/java/org/apereo/cas/support/saml/services/idp/metadata/cache/resolver/UrlResourceMetadataResolver.java#L126-L137 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UTF16.java | UTF16.countCodePoint | public static int countCodePoint(char source[], int start, int limit) {
"""
Number of codepoints in a UTF16 char array substring
@param source UTF16 char array
@param start Offset of the substring
@param limit Offset of the substring
@return number of codepoint in the substring
@exception IndexOutOfBoundsException If start and limit are not valid.
"""
if (source == null || source.length == 0) {
return 0;
}
return findCodePointOffset(source, start, limit, limit - start);
} | java | public static int countCodePoint(char source[], int start, int limit) {
if (source == null || source.length == 0) {
return 0;
}
return findCodePointOffset(source, start, limit, limit - start);
} | [
"public",
"static",
"int",
"countCodePoint",
"(",
"char",
"source",
"[",
"]",
",",
"int",
"start",
",",
"int",
"limit",
")",
"{",
"if",
"(",
"source",
"==",
"null",
"||",
"source",
".",
"length",
"==",
"0",
")",
"{",
"return",
"0",
";",
"}",
"retur... | Number of codepoints in a UTF16 char array substring
@param source UTF16 char array
@param start Offset of the substring
@param limit Offset of the substring
@return number of codepoint in the substring
@exception IndexOutOfBoundsException If start and limit are not valid. | [
"Number",
"of",
"codepoints",
"in",
"a",
"UTF16",
"char",
"array",
"substring"
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/UTF16.java#L1067-L1072 |
joniles/mpxj | src/main/java/net/sf/mpxj/Resource.java | Resource.setBaselineCost | public void setBaselineCost(int baselineNumber, Number value) {
"""
Set a baseline value.
@param baselineNumber baseline index (1-10)
@param value baseline value
"""
set(selectField(ResourceFieldLists.BASELINE_COSTS, baselineNumber), value);
} | java | public void setBaselineCost(int baselineNumber, Number value)
{
set(selectField(ResourceFieldLists.BASELINE_COSTS, baselineNumber), value);
} | [
"public",
"void",
"setBaselineCost",
"(",
"int",
"baselineNumber",
",",
"Number",
"value",
")",
"{",
"set",
"(",
"selectField",
"(",
"ResourceFieldLists",
".",
"BASELINE_COSTS",
",",
"baselineNumber",
")",
",",
"value",
")",
";",
"}"
] | Set a baseline value.
@param baselineNumber baseline index (1-10)
@param value baseline value | [
"Set",
"a",
"baseline",
"value",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Resource.java#L2194-L2197 |
ttddyy/datasource-proxy | src/main/java/net/ttddyy/dsproxy/proxy/StatementProxyLogic.java | StatementProxyLogic.invoke | public Object invoke(Method method, Object[] args) throws Throwable {
"""
set true if auto-generate keys is enabled at "Connection#prepareStatement()"
"""
return MethodExecutionListenerUtils.invoke(new MethodExecutionListenerUtils.MethodExecutionCallback() {
@Override
public Object execute(Object proxyTarget, Method method, Object[] args) throws Throwable {
return performQueryExecutionListener(method, args);
}
}, this.proxyConfig, this.statement, this.connectionInfo, method, args);
} | java | public Object invoke(Method method, Object[] args) throws Throwable {
return MethodExecutionListenerUtils.invoke(new MethodExecutionListenerUtils.MethodExecutionCallback() {
@Override
public Object execute(Object proxyTarget, Method method, Object[] args) throws Throwable {
return performQueryExecutionListener(method, args);
}
}, this.proxyConfig, this.statement, this.connectionInfo, method, args);
} | [
"public",
"Object",
"invoke",
"(",
"Method",
"method",
",",
"Object",
"[",
"]",
"args",
")",
"throws",
"Throwable",
"{",
"return",
"MethodExecutionListenerUtils",
".",
"invoke",
"(",
"new",
"MethodExecutionListenerUtils",
".",
"MethodExecutionCallback",
"(",
")",
... | set true if auto-generate keys is enabled at "Connection#prepareStatement()" | [
"set",
"true",
"if",
"auto",
"-",
"generate",
"keys",
"is",
"enabled",
"at",
"Connection#prepareStatement",
"()"
] | train | https://github.com/ttddyy/datasource-proxy/blob/62163ccf9a569a99aa3ad9f9151a32567447a62e/src/main/java/net/ttddyy/dsproxy/proxy/StatementProxyLogic.java#L118-L127 |
taimos/dvalin | jaxrs/src/main/java/de/taimos/dvalin/jaxrs/providers/AuthorizationProvider.java | AuthorizationProvider.createSC | protected static SecurityContext createSC(String user, String... roles) {
"""
Create a {@link SecurityContext} to return to the provider
@param user the user principal
@param roles the roles of the user
@return the {@link SecurityContext}
"""
final Subject subject = new Subject();
final Principal principal = new SimplePrincipal(user);
subject.getPrincipals().add(principal);
if (roles != null) {
for (final String role : roles) {
subject.getPrincipals().add(new SimplePrincipal(role));
}
}
return new DefaultSecurityContext(principal, subject);
} | java | protected static SecurityContext createSC(String user, String... roles) {
final Subject subject = new Subject();
final Principal principal = new SimplePrincipal(user);
subject.getPrincipals().add(principal);
if (roles != null) {
for (final String role : roles) {
subject.getPrincipals().add(new SimplePrincipal(role));
}
}
return new DefaultSecurityContext(principal, subject);
} | [
"protected",
"static",
"SecurityContext",
"createSC",
"(",
"String",
"user",
",",
"String",
"...",
"roles",
")",
"{",
"final",
"Subject",
"subject",
"=",
"new",
"Subject",
"(",
")",
";",
"final",
"Principal",
"principal",
"=",
"new",
"SimplePrincipal",
"(",
... | Create a {@link SecurityContext} to return to the provider
@param user the user principal
@param roles the roles of the user
@return the {@link SecurityContext} | [
"Create",
"a",
"{",
"@link",
"SecurityContext",
"}",
"to",
"return",
"to",
"the",
"provider"
] | train | https://github.com/taimos/dvalin/blob/ff8f1bf594e43d7e8ca8de0b4da9f923b66a1a47/jaxrs/src/main/java/de/taimos/dvalin/jaxrs/providers/AuthorizationProvider.java#L144-L156 |
banq/jdonframework | src/main/java/com/jdon/util/jdom/XMLProperties.java | XMLProperties.setProperty | public void setProperty(String name, String value) {
"""
Sets the value of the specified property. If the property doesn't
currently exist, it will be automatically created.
@param name
the name of the property to set.
@param value
the new value for the property.
"""
// Set cache correctly with prop name and value.
propertyCache.put(name, value);
String[] propName = parsePropertyName(name);
// Search for this property by traversing down the XML heirarchy.
Element element = doc.getRootElement();
for (int i = 0; i < propName.length; i++) {
// If we don't find this part of the property in the XML heirarchy
// we add it as a new node
if (element.getChild(propName[i]) == null) {
element.addContent(new Element(propName[i]));
}
element = element.getChild(propName[i]);
}
// Set the value of the property in this node.
element.setText(value);
} | java | public void setProperty(String name, String value) {
// Set cache correctly with prop name and value.
propertyCache.put(name, value);
String[] propName = parsePropertyName(name);
// Search for this property by traversing down the XML heirarchy.
Element element = doc.getRootElement();
for (int i = 0; i < propName.length; i++) {
// If we don't find this part of the property in the XML heirarchy
// we add it as a new node
if (element.getChild(propName[i]) == null) {
element.addContent(new Element(propName[i]));
}
element = element.getChild(propName[i]);
}
// Set the value of the property in this node.
element.setText(value);
} | [
"public",
"void",
"setProperty",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"// Set cache correctly with prop name and value.\r",
"propertyCache",
".",
"put",
"(",
"name",
",",
"value",
")",
";",
"String",
"[",
"]",
"propName",
"=",
"parsePropertyNam... | Sets the value of the specified property. If the property doesn't
currently exist, it will be automatically created.
@param name
the name of the property to set.
@param value
the new value for the property. | [
"Sets",
"the",
"value",
"of",
"the",
"specified",
"property",
".",
"If",
"the",
"property",
"doesn",
"t",
"currently",
"exist",
"it",
"will",
"be",
"automatically",
"created",
"."
] | train | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/util/jdom/XMLProperties.java#L188-L206 |
BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/UIContextImpl.java | UIContextImpl.setFocussed | @Override
public void setFocussed(final WComponent component, final UIContext uic) {
"""
Sets the component in this UIC which is to be the focus of the client browser cursor. The id of the component is
used to find the focussed element in the rendered html. Since id could be different in different contexts the
context of the component is also needed.
@param component - the component that sould be the cursor focus in the rendered UI.
@param uic - the context that the component exists in.
"""
this.focussed = component;
this.focussedUIC = uic;
} | java | @Override
public void setFocussed(final WComponent component, final UIContext uic) {
this.focussed = component;
this.focussedUIC = uic;
} | [
"@",
"Override",
"public",
"void",
"setFocussed",
"(",
"final",
"WComponent",
"component",
",",
"final",
"UIContext",
"uic",
")",
"{",
"this",
".",
"focussed",
"=",
"component",
";",
"this",
".",
"focussedUIC",
"=",
"uic",
";",
"}"
] | Sets the component in this UIC which is to be the focus of the client browser cursor. The id of the component is
used to find the focussed element in the rendered html. Since id could be different in different contexts the
context of the component is also needed.
@param component - the component that sould be the cursor focus in the rendered UI.
@param uic - the context that the component exists in. | [
"Sets",
"the",
"component",
"in",
"this",
"UIC",
"which",
"is",
"to",
"be",
"the",
"focus",
"of",
"the",
"client",
"browser",
"cursor",
".",
"The",
"id",
"of",
"the",
"component",
"is",
"used",
"to",
"find",
"the",
"focussed",
"element",
"in",
"the",
"... | train | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/UIContextImpl.java#L260-L264 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/utils/ObjectVector.java | ObjectVector.indexOf | public final int indexOf(Object elem, int index) {
"""
Searches for the first occurence of the given argument,
beginning the search at index, and testing for equality
using the equals method.
@param elem object to look for
@param index Index of where to begin search
@return the index of the first occurrence of the object
argument in this vector at position index or later in the
vector; returns -1 if the object is not found.
"""
for (int i = index; i < m_firstFree; i++)
{
if (m_map[i] == elem)
return i;
}
return java.lang.Integer.MIN_VALUE;
} | java | public final int indexOf(Object elem, int index)
{
for (int i = index; i < m_firstFree; i++)
{
if (m_map[i] == elem)
return i;
}
return java.lang.Integer.MIN_VALUE;
} | [
"public",
"final",
"int",
"indexOf",
"(",
"Object",
"elem",
",",
"int",
"index",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"index",
";",
"i",
"<",
"m_firstFree",
";",
"i",
"++",
")",
"{",
"if",
"(",
"m_map",
"[",
"i",
"]",
"==",
"elem",
")",
"retu... | Searches for the first occurence of the given argument,
beginning the search at index, and testing for equality
using the equals method.
@param elem object to look for
@param index Index of where to begin search
@return the index of the first occurrence of the object
argument in this vector at position index or later in the
vector; returns -1 if the object is not found. | [
"Searches",
"for",
"the",
"first",
"occurence",
"of",
"the",
"given",
"argument",
"beginning",
"the",
"search",
"at",
"index",
"and",
"testing",
"for",
"equality",
"using",
"the",
"equals",
"method",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/utils/ObjectVector.java#L349-L359 |
jenkinsci/artifactory-plugin | src/main/java/org/jfrog/hudson/release/gradle/BaseGradleReleaseAction.java | BaseGradleReleaseAction.initBuilderSpecific | @Override
protected void initBuilderSpecific() throws Exception {
"""
Initialize the version properties map from the gradle.properties file, and the additional properties from the
gradle.properties file.
"""
reset();
FilePath workspace = getModuleRoot(EnvVars.masterEnvVars);
FilePath gradlePropertiesPath = new FilePath(workspace, "gradle.properties");
if (releaseProps == null) {
releaseProps = PropertyUtils.getModulesPropertiesFromPropFile(gradlePropertiesPath, getReleaseProperties());
}
if (nextIntegProps == null) {
nextIntegProps =
PropertyUtils.getModulesPropertiesFromPropFile(gradlePropertiesPath, getNextIntegProperties());
}
} | java | @Override
protected void initBuilderSpecific() throws Exception {
reset();
FilePath workspace = getModuleRoot(EnvVars.masterEnvVars);
FilePath gradlePropertiesPath = new FilePath(workspace, "gradle.properties");
if (releaseProps == null) {
releaseProps = PropertyUtils.getModulesPropertiesFromPropFile(gradlePropertiesPath, getReleaseProperties());
}
if (nextIntegProps == null) {
nextIntegProps =
PropertyUtils.getModulesPropertiesFromPropFile(gradlePropertiesPath, getNextIntegProperties());
}
} | [
"@",
"Override",
"protected",
"void",
"initBuilderSpecific",
"(",
")",
"throws",
"Exception",
"{",
"reset",
"(",
")",
";",
"FilePath",
"workspace",
"=",
"getModuleRoot",
"(",
"EnvVars",
".",
"masterEnvVars",
")",
";",
"FilePath",
"gradlePropertiesPath",
"=",
"ne... | Initialize the version properties map from the gradle.properties file, and the additional properties from the
gradle.properties file. | [
"Initialize",
"the",
"version",
"properties",
"map",
"from",
"the",
"gradle",
".",
"properties",
"file",
"and",
"the",
"additional",
"properties",
"from",
"the",
"gradle",
".",
"properties",
"file",
"."
] | train | https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/release/gradle/BaseGradleReleaseAction.java#L76-L88 |
Berico-Technologies/CLAVIN | src/main/java/com/bericotech/clavin/resolver/ClavinLocationResolver.java | ClavinLocationResolver.resolveLocations | @SuppressWarnings("unchecked")
public List<ResolvedLocation> resolveLocations(final List<LocationOccurrence> locations, final int maxHitDepth,
final int maxContextWindow, final boolean fuzzy) throws ClavinException {
"""
Resolves the supplied list of location names into
{@link ResolvedLocation}s containing {@link com.bericotech.clavin.gazetteer.GeoName} objects.
Calls {@link Gazetteer#getClosestLocations} on
each location name to find all possible matches, then uses
heuristics to select the best match for each by calling
{@link ClavinLocationResolver#pickBestCandidates}.
@param locations list of location names to be resolved
@param maxHitDepth number of candidate matches to consider
@param maxContextWindow how much context to consider when resolving
@param fuzzy switch for turning on/off fuzzy matching
@return list of {@link ResolvedLocation} objects
@throws ClavinException if an error occurs parsing the search terms
"""
return resolveLocations(locations, maxHitDepth, maxContextWindow, fuzzy, DEFAULT_ANCESTRY_MODE);
} | java | @SuppressWarnings("unchecked")
public List<ResolvedLocation> resolveLocations(final List<LocationOccurrence> locations, final int maxHitDepth,
final int maxContextWindow, final boolean fuzzy) throws ClavinException {
return resolveLocations(locations, maxHitDepth, maxContextWindow, fuzzy, DEFAULT_ANCESTRY_MODE);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"List",
"<",
"ResolvedLocation",
">",
"resolveLocations",
"(",
"final",
"List",
"<",
"LocationOccurrence",
">",
"locations",
",",
"final",
"int",
"maxHitDepth",
",",
"final",
"int",
"maxContextWindow",
... | Resolves the supplied list of location names into
{@link ResolvedLocation}s containing {@link com.bericotech.clavin.gazetteer.GeoName} objects.
Calls {@link Gazetteer#getClosestLocations} on
each location name to find all possible matches, then uses
heuristics to select the best match for each by calling
{@link ClavinLocationResolver#pickBestCandidates}.
@param locations list of location names to be resolved
@param maxHitDepth number of candidate matches to consider
@param maxContextWindow how much context to consider when resolving
@param fuzzy switch for turning on/off fuzzy matching
@return list of {@link ResolvedLocation} objects
@throws ClavinException if an error occurs parsing the search terms | [
"Resolves",
"the",
"supplied",
"list",
"of",
"location",
"names",
"into",
"{",
"@link",
"ResolvedLocation",
"}",
"s",
"containing",
"{",
"@link",
"com",
".",
"bericotech",
".",
"clavin",
".",
"gazetteer",
".",
"GeoName",
"}",
"objects",
"."
] | train | https://github.com/Berico-Technologies/CLAVIN/blob/f73c741f33a01b91aa5b06e71860bc354ef3010d/src/main/java/com/bericotech/clavin/resolver/ClavinLocationResolver.java#L136-L140 |
spring-projects/spring-retry | src/main/java/org/springframework/retry/backoff/ExponentialBackOffPolicy.java | ExponentialBackOffPolicy.backOff | public void backOff(BackOffContext backOffContext)
throws BackOffInterruptedException {
"""
Pause for a length of time equal to ' <code>exp(backOffContext.expSeed)</code>'.
"""
ExponentialBackOffContext context = (ExponentialBackOffContext) backOffContext;
try {
long sleepTime = context.getSleepAndIncrement();
if (logger.isDebugEnabled()) {
logger.debug("Sleeping for " + sleepTime);
}
sleeper.sleep(sleepTime);
}
catch (InterruptedException e) {
throw new BackOffInterruptedException("Thread interrupted while sleeping", e);
}
} | java | public void backOff(BackOffContext backOffContext)
throws BackOffInterruptedException {
ExponentialBackOffContext context = (ExponentialBackOffContext) backOffContext;
try {
long sleepTime = context.getSleepAndIncrement();
if (logger.isDebugEnabled()) {
logger.debug("Sleeping for " + sleepTime);
}
sleeper.sleep(sleepTime);
}
catch (InterruptedException e) {
throw new BackOffInterruptedException("Thread interrupted while sleeping", e);
}
} | [
"public",
"void",
"backOff",
"(",
"BackOffContext",
"backOffContext",
")",
"throws",
"BackOffInterruptedException",
"{",
"ExponentialBackOffContext",
"context",
"=",
"(",
"ExponentialBackOffContext",
")",
"backOffContext",
";",
"try",
"{",
"long",
"sleepTime",
"=",
"con... | Pause for a length of time equal to ' <code>exp(backOffContext.expSeed)</code>'. | [
"Pause",
"for",
"a",
"length",
"of",
"time",
"equal",
"to",
"<code",
">",
"exp",
"(",
"backOffContext",
".",
"expSeed",
")",
"<",
"/",
"code",
">",
"."
] | train | https://github.com/spring-projects/spring-retry/blob/e2b0555f96594c2321990d0deeac45fc44d4f123/src/main/java/org/springframework/retry/backoff/ExponentialBackOffPolicy.java#L170-L183 |
alkacon/opencms-core | src/org/opencms/security/CmsRoleManager.java | CmsRoleManager.checkRole | public void checkRole(CmsObject cms, CmsRole role) throws CmsRoleViolationException {
"""
Checks if the user of this OpenCms context is a member of the given role
for the given organizational unit.<p>
The user must have the given role in at least one parent organizational unit.<p>
@param cms the opencms context
@param role the role to check
@throws CmsRoleViolationException if the user does not have the required role permissions
"""
m_securityManager.checkRole(cms.getRequestContext(), role);
} | java | public void checkRole(CmsObject cms, CmsRole role) throws CmsRoleViolationException {
m_securityManager.checkRole(cms.getRequestContext(), role);
} | [
"public",
"void",
"checkRole",
"(",
"CmsObject",
"cms",
",",
"CmsRole",
"role",
")",
"throws",
"CmsRoleViolationException",
"{",
"m_securityManager",
".",
"checkRole",
"(",
"cms",
".",
"getRequestContext",
"(",
")",
",",
"role",
")",
";",
"}"
] | Checks if the user of this OpenCms context is a member of the given role
for the given organizational unit.<p>
The user must have the given role in at least one parent organizational unit.<p>
@param cms the opencms context
@param role the role to check
@throws CmsRoleViolationException if the user does not have the required role permissions | [
"Checks",
"if",
"the",
"user",
"of",
"this",
"OpenCms",
"context",
"is",
"a",
"member",
"of",
"the",
"given",
"role",
"for",
"the",
"given",
"organizational",
"unit",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/security/CmsRoleManager.java#L91-L94 |
graphhopper/graphhopper | core/src/main/java/com/graphhopper/routing/Path.java | Path.calcDetails | public Map<String, List<PathDetail>> calcDetails(List<String> requestedPathDetails, PathDetailsBuilderFactory pathBuilderFactory, int previousIndex) {
"""
Calculates the PathDetails for this Path. This method will return fast, if there are no calculators.
@param pathBuilderFactory Generates the relevant PathBuilders
@return List of PathDetails for this Path
"""
if (!isFound() || requestedPathDetails.isEmpty())
return Collections.emptyMap();
List<PathDetailsBuilder> pathBuilders = pathBuilderFactory.createPathDetailsBuilders(requestedPathDetails, encoder, weighting);
if (pathBuilders.isEmpty())
return Collections.emptyMap();
forEveryEdge(new PathDetailsFromEdges(pathBuilders, previousIndex));
Map<String, List<PathDetail>> pathDetails = new HashMap<>(pathBuilders.size());
for (PathDetailsBuilder builder : pathBuilders) {
Map.Entry<String, List<PathDetail>> entry = builder.build();
List<PathDetail> existing = pathDetails.put(entry.getKey(), entry.getValue());
if (existing != null)
throw new IllegalStateException("Some PathDetailsBuilders use duplicate key: " + entry.getKey());
}
return pathDetails;
} | java | public Map<String, List<PathDetail>> calcDetails(List<String> requestedPathDetails, PathDetailsBuilderFactory pathBuilderFactory, int previousIndex) {
if (!isFound() || requestedPathDetails.isEmpty())
return Collections.emptyMap();
List<PathDetailsBuilder> pathBuilders = pathBuilderFactory.createPathDetailsBuilders(requestedPathDetails, encoder, weighting);
if (pathBuilders.isEmpty())
return Collections.emptyMap();
forEveryEdge(new PathDetailsFromEdges(pathBuilders, previousIndex));
Map<String, List<PathDetail>> pathDetails = new HashMap<>(pathBuilders.size());
for (PathDetailsBuilder builder : pathBuilders) {
Map.Entry<String, List<PathDetail>> entry = builder.build();
List<PathDetail> existing = pathDetails.put(entry.getKey(), entry.getValue());
if (existing != null)
throw new IllegalStateException("Some PathDetailsBuilders use duplicate key: " + entry.getKey());
}
return pathDetails;
} | [
"public",
"Map",
"<",
"String",
",",
"List",
"<",
"PathDetail",
">",
">",
"calcDetails",
"(",
"List",
"<",
"String",
">",
"requestedPathDetails",
",",
"PathDetailsBuilderFactory",
"pathBuilderFactory",
",",
"int",
"previousIndex",
")",
"{",
"if",
"(",
"!",
"is... | Calculates the PathDetails for this Path. This method will return fast, if there are no calculators.
@param pathBuilderFactory Generates the relevant PathBuilders
@return List of PathDetails for this Path | [
"Calculates",
"the",
"PathDetails",
"for",
"this",
"Path",
".",
"This",
"method",
"will",
"return",
"fast",
"if",
"there",
"are",
"no",
"calculators",
"."
] | train | https://github.com/graphhopper/graphhopper/blob/c235e306e6e823043cadcc41ead0e685bdebf737/core/src/main/java/com/graphhopper/routing/Path.java#L380-L398 |
foundation-runtime/service-directory | 2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/LookupManagerImpl.java | LookupManagerImpl.removeNotificationHandler | @Override
public void removeNotificationHandler(String serviceName, NotificationHandler handler) throws ServiceException {
"""
Remove the NotificationHandler from the Service.
@param serviceName
the service name.
@param handler
the NotificationHandler for the service.
"""
if(! isStarted){
ServiceDirectoryError error = new ServiceDirectoryError(ErrorCode.SERVICE_DIRECTORY_MANAGER_FACTORY_CLOSED);
throw new ServiceException(error);
}
if(handler == null || serviceName == null || serviceName.isEmpty()){
throw new IllegalArgumentException();
}
getLookupService().removeNotificationHandler(serviceName, handler);
} | java | @Override
public void removeNotificationHandler(String serviceName, NotificationHandler handler) throws ServiceException {
if(! isStarted){
ServiceDirectoryError error = new ServiceDirectoryError(ErrorCode.SERVICE_DIRECTORY_MANAGER_FACTORY_CLOSED);
throw new ServiceException(error);
}
if(handler == null || serviceName == null || serviceName.isEmpty()){
throw new IllegalArgumentException();
}
getLookupService().removeNotificationHandler(serviceName, handler);
} | [
"@",
"Override",
"public",
"void",
"removeNotificationHandler",
"(",
"String",
"serviceName",
",",
"NotificationHandler",
"handler",
")",
"throws",
"ServiceException",
"{",
"if",
"(",
"!",
"isStarted",
")",
"{",
"ServiceDirectoryError",
"error",
"=",
"new",
"Service... | Remove the NotificationHandler from the Service.
@param serviceName
the service name.
@param handler
the NotificationHandler for the service. | [
"Remove",
"the",
"NotificationHandler",
"from",
"the",
"Service",
"."
] | train | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/LookupManagerImpl.java#L447-L460 |
hazelcast/hazelcast | hazelcast/src/main/java/com/hazelcast/spi/impl/eventservice/impl/EventServiceImpl.java | EventServiceImpl.getSegment | public EventServiceSegment getSegment(String service, boolean forceCreate) {
"""
Returns the {@link EventServiceSegment} for the {@code service}. If the segment is {@code null} and
{@code forceCreate} is {@code true}, the segment is created and registered with the {@link MetricsRegistry}.
@param service the service of the segment
@param forceCreate whether the segment should be created in case there is no segment
@return the segment for the service or null if there is no segment and {@code forceCreate} is {@code false}
"""
EventServiceSegment segment = segments.get(service);
if (segment == null && forceCreate) {
// we can't make use of the ConcurrentUtil; we need to register the segment to the metricsRegistry in case of creation
EventServiceSegment newSegment = new EventServiceSegment(service, nodeEngine.getService(service));
EventServiceSegment existingSegment = segments.putIfAbsent(service, newSegment);
if (existingSegment == null) {
segment = newSegment;
nodeEngine.getMetricsRegistry().scanAndRegister(newSegment, "event.[" + service + "]");
} else {
segment = existingSegment;
}
}
return segment;
} | java | public EventServiceSegment getSegment(String service, boolean forceCreate) {
EventServiceSegment segment = segments.get(service);
if (segment == null && forceCreate) {
// we can't make use of the ConcurrentUtil; we need to register the segment to the metricsRegistry in case of creation
EventServiceSegment newSegment = new EventServiceSegment(service, nodeEngine.getService(service));
EventServiceSegment existingSegment = segments.putIfAbsent(service, newSegment);
if (existingSegment == null) {
segment = newSegment;
nodeEngine.getMetricsRegistry().scanAndRegister(newSegment, "event.[" + service + "]");
} else {
segment = existingSegment;
}
}
return segment;
} | [
"public",
"EventServiceSegment",
"getSegment",
"(",
"String",
"service",
",",
"boolean",
"forceCreate",
")",
"{",
"EventServiceSegment",
"segment",
"=",
"segments",
".",
"get",
"(",
"service",
")",
";",
"if",
"(",
"segment",
"==",
"null",
"&&",
"forceCreate",
... | Returns the {@link EventServiceSegment} for the {@code service}. If the segment is {@code null} and
{@code forceCreate} is {@code true}, the segment is created and registered with the {@link MetricsRegistry}.
@param service the service of the segment
@param forceCreate whether the segment should be created in case there is no segment
@return the segment for the service or null if there is no segment and {@code forceCreate} is {@code false} | [
"Returns",
"the",
"{",
"@link",
"EventServiceSegment",
"}",
"for",
"the",
"{",
"@code",
"service",
"}",
".",
"If",
"the",
"segment",
"is",
"{",
"@code",
"null",
"}",
"and",
"{",
"@code",
"forceCreate",
"}",
"is",
"{",
"@code",
"true",
"}",
"the",
"segm... | train | https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/spi/impl/eventservice/impl/EventServiceImpl.java#L539-L553 |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java | Apptentive.queryCanShowInteraction | public static synchronized void queryCanShowInteraction(final String event, BooleanCallback callback) {
"""
This method can be used to determine if a call to one of the <strong><code>engage()</code></strong> methods such as
{@link #engage(Context, String)} using the same event name will
result in the display of an Interaction. This is useful if you need to know whether an Interaction will be
displayed before you create a UI Button, etc.
@param event A unique String representing the line this method is called on. For instance, you may want to have
the ability to target interactions to run after the user uploads a file in your app. You may then
call <strong><code>engage(activity, "finished_upload");</code></strong>
"""
dispatchConversationTask(new ConversationDispatchTask(callback, DispatchQueue.mainQueue()) {
@Override
protected boolean execute(Conversation conversation) {
return canShowLocalAppInteraction(conversation, event);
}
}, "check if interaction can be shown");
} | java | public static synchronized void queryCanShowInteraction(final String event, BooleanCallback callback) {
dispatchConversationTask(new ConversationDispatchTask(callback, DispatchQueue.mainQueue()) {
@Override
protected boolean execute(Conversation conversation) {
return canShowLocalAppInteraction(conversation, event);
}
}, "check if interaction can be shown");
} | [
"public",
"static",
"synchronized",
"void",
"queryCanShowInteraction",
"(",
"final",
"String",
"event",
",",
"BooleanCallback",
"callback",
")",
"{",
"dispatchConversationTask",
"(",
"new",
"ConversationDispatchTask",
"(",
"callback",
",",
"DispatchQueue",
".",
"mainQue... | This method can be used to determine if a call to one of the <strong><code>engage()</code></strong> methods such as
{@link #engage(Context, String)} using the same event name will
result in the display of an Interaction. This is useful if you need to know whether an Interaction will be
displayed before you create a UI Button, etc.
@param event A unique String representing the line this method is called on. For instance, you may want to have
the ability to target interactions to run after the user uploads a file in your app. You may then
call <strong><code>engage(activity, "finished_upload");</code></strong> | [
"This",
"method",
"can",
"be",
"used",
"to",
"determine",
"if",
"a",
"call",
"to",
"one",
"of",
"the",
"<strong",
">",
"<code",
">",
"engage",
"()",
"<",
"/",
"code",
">",
"<",
"/",
"strong",
">",
"methods",
"such",
"as",
"{",
"@link",
"#engage",
"... | train | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java#L1378-L1385 |
derari/cthul | objects/src/main/java/org/cthul/objects/reflection/Signatures.java | Signatures.candidateConstructors | public static <T> Constructor<T>[] candidateConstructors(Constructor<T>[] constructors, Class<?>[] argTypes) {
"""
Selects the best equally-matching constructors for the given argument types.
@param <T>
@param constructors
@param argTypes
@return constructors
"""
return candidates(constructors, collectSignatures(constructors), collectVarArgs(constructors), argTypes);
} | java | public static <T> Constructor<T>[] candidateConstructors(Constructor<T>[] constructors, Class<?>[] argTypes) {
return candidates(constructors, collectSignatures(constructors), collectVarArgs(constructors), argTypes);
} | [
"public",
"static",
"<",
"T",
">",
"Constructor",
"<",
"T",
">",
"[",
"]",
"candidateConstructors",
"(",
"Constructor",
"<",
"T",
">",
"[",
"]",
"constructors",
",",
"Class",
"<",
"?",
">",
"[",
"]",
"argTypes",
")",
"{",
"return",
"candidates",
"(",
... | Selects the best equally-matching constructors for the given argument types.
@param <T>
@param constructors
@param argTypes
@return constructors | [
"Selects",
"the",
"best",
"equally",
"-",
"matching",
"constructors",
"for",
"the",
"given",
"argument",
"types",
"."
] | train | https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/objects/src/main/java/org/cthul/objects/reflection/Signatures.java#L115-L117 |
igniterealtime/Smack | smack-openpgp/src/main/java/org/jivesoftware/smackx/ox/util/OpenPgpPubSubUtil.java | OpenPgpPubSubUtil.fetchPubkey | public static PubkeyElement fetchPubkey(XMPPConnection connection, BareJid contact, OpenPgpV4Fingerprint v4_fingerprint)
throws InterruptedException, XMPPException.XMPPErrorException, PubSubException.NotAPubSubNodeException,
PubSubException.NotALeafNodeException, SmackException.NotConnectedException, SmackException.NoResponseException {
"""
Fetch the OpenPGP public key of a {@code contact}, identified by its OpenPGP {@code v4_fingerprint}.
@see <a href="https://xmpp.org/extensions/xep-0373.html#discover-pubkey">XEP-0373 §4.3</a>
@param connection XMPP connection
@param contact {@link BareJid} of the contact we want to fetch a key from.
@param v4_fingerprint upper case, hex encoded v4 fingerprint of the contacts key.
@return {@link PubkeyElement} containing the requested public key.
@throws InterruptedException if the thread gets interrupted.A
@throws XMPPException.XMPPErrorException in case of an XMPP protocol error.
@throws PubSubException.NotAPubSubNodeException in case the targeted entity is not a PubSub node.
@throws PubSubException.NotALeafNodeException in case the fetched node is not a {@link LeafNode}.
@throws SmackException.NotConnectedException in case we are not connected.
@throws SmackException.NoResponseException if the server doesn't respond.
"""
PubSubManager pm = PubSubManager.getInstanceFor(connection, contact);
String nodeName = PEP_NODE_PUBLIC_KEY(v4_fingerprint);
LeafNode node = getLeafNode(pm, nodeName);
List<PayloadItem<PubkeyElement>> list = node.getItems(1);
if (list.isEmpty()) {
return null;
}
return list.get(0).getPayload();
} | java | public static PubkeyElement fetchPubkey(XMPPConnection connection, BareJid contact, OpenPgpV4Fingerprint v4_fingerprint)
throws InterruptedException, XMPPException.XMPPErrorException, PubSubException.NotAPubSubNodeException,
PubSubException.NotALeafNodeException, SmackException.NotConnectedException, SmackException.NoResponseException {
PubSubManager pm = PubSubManager.getInstanceFor(connection, contact);
String nodeName = PEP_NODE_PUBLIC_KEY(v4_fingerprint);
LeafNode node = getLeafNode(pm, nodeName);
List<PayloadItem<PubkeyElement>> list = node.getItems(1);
if (list.isEmpty()) {
return null;
}
return list.get(0).getPayload();
} | [
"public",
"static",
"PubkeyElement",
"fetchPubkey",
"(",
"XMPPConnection",
"connection",
",",
"BareJid",
"contact",
",",
"OpenPgpV4Fingerprint",
"v4_fingerprint",
")",
"throws",
"InterruptedException",
",",
"XMPPException",
".",
"XMPPErrorException",
",",
"PubSubException",... | Fetch the OpenPGP public key of a {@code contact}, identified by its OpenPGP {@code v4_fingerprint}.
@see <a href="https://xmpp.org/extensions/xep-0373.html#discover-pubkey">XEP-0373 §4.3</a>
@param connection XMPP connection
@param contact {@link BareJid} of the contact we want to fetch a key from.
@param v4_fingerprint upper case, hex encoded v4 fingerprint of the contacts key.
@return {@link PubkeyElement} containing the requested public key.
@throws InterruptedException if the thread gets interrupted.A
@throws XMPPException.XMPPErrorException in case of an XMPP protocol error.
@throws PubSubException.NotAPubSubNodeException in case the targeted entity is not a PubSub node.
@throws PubSubException.NotALeafNodeException in case the fetched node is not a {@link LeafNode}.
@throws SmackException.NotConnectedException in case we are not connected.
@throws SmackException.NoResponseException if the server doesn't respond. | [
"Fetch",
"the",
"OpenPGP",
"public",
"key",
"of",
"a",
"{",
"@code",
"contact",
"}",
"identified",
"by",
"its",
"OpenPGP",
"{",
"@code",
"v4_fingerprint",
"}",
"."
] | train | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-openpgp/src/main/java/org/jivesoftware/smackx/ox/util/OpenPgpPubSubUtil.java#L274-L289 |
igniterealtime/Smack | smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/Form.java | Form.setAnswer | public void setAnswer(String variable, boolean value) {
"""
Sets a new boolean value to a given form's field. The field whose variable matches the
requested variable will be completed with the specified value. If no field could be found
for the specified variable then an exception will be raised.
@param variable the variable name that was completed.
@param value the boolean value that was answered.
@throws IllegalStateException if the form is not of type "submit".
@throws IllegalArgumentException if the form does not include the specified variable or
if the answer type does not correspond with the field type.
"""
FormField field = getField(variable);
if (field == null) {
throw new IllegalArgumentException("Field not found for the specified variable name.");
}
if (field.getType() != FormField.Type.bool) {
throw new IllegalArgumentException("This field is not of type boolean.");
}
setAnswer(field, Boolean.toString(value));
} | java | public void setAnswer(String variable, boolean value) {
FormField field = getField(variable);
if (field == null) {
throw new IllegalArgumentException("Field not found for the specified variable name.");
}
if (field.getType() != FormField.Type.bool) {
throw new IllegalArgumentException("This field is not of type boolean.");
}
setAnswer(field, Boolean.toString(value));
} | [
"public",
"void",
"setAnswer",
"(",
"String",
"variable",
",",
"boolean",
"value",
")",
"{",
"FormField",
"field",
"=",
"getField",
"(",
"variable",
")",
";",
"if",
"(",
"field",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"F... | Sets a new boolean value to a given form's field. The field whose variable matches the
requested variable will be completed with the specified value. If no field could be found
for the specified variable then an exception will be raised.
@param variable the variable name that was completed.
@param value the boolean value that was answered.
@throws IllegalStateException if the form is not of type "submit".
@throws IllegalArgumentException if the form does not include the specified variable or
if the answer type does not correspond with the field type. | [
"Sets",
"a",
"new",
"boolean",
"value",
"to",
"a",
"given",
"form",
"s",
"field",
".",
"The",
"field",
"whose",
"variable",
"matches",
"the",
"requested",
"variable",
"will",
"be",
"completed",
"with",
"the",
"specified",
"value",
".",
"If",
"no",
"field",... | train | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/Form.java#L230-L239 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.